예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_btree != null)
        {
            for (int i = 0; i < m_monstList.Count; i++)
            {
                NPC npc = m_monstList[i] as NPC;
                if (npc.IsDied)
                {
                    continue;
                }
                Input         input   = npc.CurrentInput;
                List <string> actions = m_btree.Run(input);
                for (int j = 0; j < actions.Count; j++)
                {
                    string action = actions[j];
                    switch (action)
                    {
                    case "escape":
                        npc.Escape();
                        break;

                    case "attack":
                        npc.Attack();
                        break;

                    case "patrol":
                        npc.Patrol();
                        break;
                    }
                }
            }
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (m_btree != null)
        {
            for (int i = 0; i < m_soldierList.Count; i++)
            {
                Soldier soldier = m_soldierList [i] as Soldier;
                if (soldier.IsDied)
                {
                    continue;
                }
                Input         input   = soldier.CurrentState;
                List <string> actions = m_btree.Run(input);
                for (int j = 0; j < actions.Count; j++)
                {
                    string action = actions [j];
                    switch (action)
                    {
                    case "escape":
                        soldier.Escape();
                        break;

                    case "attack":
                        soldier.Attack();
                        break;

                    case "patrol":
                        soldier.Patrol();
                        break;
                    }
                }
            }
        }

        if (recoverTime <= 0)
        {
            for (int i = 0; i < m_soldierList.Count; i++)
            {
                Soldier soldier = m_soldierList [i] as Soldier;
                if (soldier.IsDied)
                {
                    continue;
                }
                soldier.Recover(5);
            }
            recoverTime = 50;
        }
        recoverTime--;
    }