#pragma once #include "GameObject.h" #include "BonusObject.h" #include "NavigationGrid.h" #include "../CSC8503Common/GameWorld.h" #include "StateMachine.h" #include "State.h" #include "StateTransition.h" using namespace NCL; using namespace CSC8503; class AIOpponentObject : public GameObject { public: AIOpponentObject(string filePath); virtual ~AIOpponentObject() { delete grid, delete stateMachine; } void UpdatePosition(float dt); // position behind the player to teleport the AI void AddObstacles(vector<GameObject*>& objects) { obstacles = objects; } void StartMovingAIOpponentObject(float dt); void TeleportAIOpponentObject(float dt); void SetPlayer(PlayerObject* p) { player = p; } void SetAIOpponent(AIOpponentObject* p) { aiOpponent = p; } int PickUpItem(GameObject* object, int bonusValue); void AddScore(const unsigned int value) { score += value; } void SetScore(const unsigned int value) { score = value; } unsigned int GetScore() const { return score; } void AddPointsCollected(const unsigned int value) { pointsCollected += value; } void SetPointsCollected(const unsigned int value) { pointsCollected = value; } unsigned int GetPointsCollected() const { return pointsCollected; } unsigned int GetItems() { return pickedUpItems; } float& GetSpeedMultiplier() { return speedMultiplier; } void SetSpeedMultiplier(const float speed) { speedMultiplier = speed; } float& GetSprint() { return sprint; } const string& GetName() const { return name; } protected: NavigationGrid* grid; vector<Vector3> nodes; float speed = 500.0f; Vector3 targetPosition; StateMachine* stateMachine; PlayerObject* player = nullptr; float currentDT; bool stateSwitch; void initStateMachine(); //Raycasting vector<GameObject*> obstacles; void optimiseNodes(); bool raycast(Ray& r, RayCollision& closestCollision, bool object = false) const; void drawPath(); AIOpponentObject* aiOpponent = nullptr; bool stateRun; bool stateTeleport; string name; float speedMultiplier = 1.0f; float sprint = 0.0f; unsigned int pickedUpItems = 0; unsigned int pointsCollected = 0; unsigned int score = 0; float teleportationCounter = 0; Vector3 enemyPreviousPos; };