public void UnregisterToFightingList(FoeController foe) { if (fightingFoes.Contains(foe)) { fightingFoes.Remove(foe); } }
public void RegisterToFightingList(FoeController foe) { if (!fightingFoes.Contains(foe)) { fightingFoes.Add(foe); } }
public void RegisterToQueue(FoeController foeController) { // Check if the requester is already in the queue if (pathAskedBy.Contains(foeController)) { return; } pathAskedBy.Enqueue(foeController); }
public void ReduceFightingFoesMoral(FoeController emitter, int amount) { if (gameManager.gameState != GameManager.GameState.INGAMEDAY) { return; } foreach (FoeController foe in fightingFoes) { // Check if not the emitter if (foe != emitter) { foe.morals -= amount; } } }
// Update is called once per frame void Update() { // Check if a path has been requested if (pathAskedBy.Count > 0) { // Get the first foe that has requested a path and remove it from the queue currentPathAskBy = pathAskedBy.Dequeue(); // Check if the requested path does not need the full path if (currentPathAskBy.state == FoeController.State.WANDERING || currentPathAskBy.state == FoeController.State.FLEE) { currentPathAskBy.path = pathFinder.GetAStarPathTo(gameManager.grid, currentPathAskBy.transform.position, currentPathAskBy.target.position, true); } else { currentPathAskBy.path = pathFinder.GetAStarPathTo(gameManager.grid, currentPathAskBy.transform.position, currentPathAskBy.target.position); } } }