예제 #1
0
 public void UnregisterToFightingList(FoeController foe)
 {
     if (fightingFoes.Contains(foe))
     {
         fightingFoes.Remove(foe);
     }
 }
예제 #2
0
 public void RegisterToFightingList(FoeController foe)
 {
     if (!fightingFoes.Contains(foe))
     {
         fightingFoes.Add(foe);
     }
 }
예제 #3
0
    public void RegisterToQueue(FoeController foeController)
    {
        // Check if the requester is already in the queue
        if (pathAskedBy.Contains(foeController))
        {
            return;
        }

        pathAskedBy.Enqueue(foeController);
    }
예제 #4
0
    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;
            }
        }
    }
예제 #5
0
    // 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);
            }
        }
    }