Пример #1
0
    /// <summary>
    /// 执行命令
    /// </summary>
    public void ExcuteCommand()
    {
        //如果队列中有命令
        if (CheckNextCommand())
        {//执行命令
            currentCommmandNum++;

            currentCommand.Excute();

            if (currentCommand != null && currentCommand.needAsync)
            {//只要当前是异步的,继续执行命令
                ExcuteCommand();
            }
        }
        else
        {     //如果队列中没有命令,先查看当前是否有命令执行
            if (currentCommmandNum == 0)
            { //如果当前没有命令执行, 通知玩家回到Idle状态
                currentCommand = null;

                MyEventSystem.Instance.TriggerChangeState(AIStateEnum.Idle);

                if (callBack != null)
                {
                    callBack();
                    //执行后清空
                    callBack = null;
                }

                Debug.Log("命令执行完毕");
            }
        }
    }