public void AddCommand(BattleCommand cmd)
        {
            BattleMissionBase newMission = CreateMission(cmd);

            if (newMission == null)
            {
                return;
            }
            newMission.SetCommand(cmd);


            if (m_lastQueue != null)
            {
                if (cmd.Type == EBattleCommandType.CmdFireBallResponse || cmd.Type == EBattleCommandType.CmdExchangeBall)
                {
                    AddNewMissionList(cmd, newMission);
                }
                else
                {
                    m_lastQueue.Enqueue(newMission);
                }
            }
            else
            {
                AddNewMissionList(cmd, newMission);
            }

            m_isIdle = false;
        }
        public void Update(float fDeltaTime)
        {
            if (m_isIdle)
            {
                return;
            }

            List <Queue <BattleMissionBase> > rmQueueList = new List <Queue <BattleMissionBase> >();

            for (int i = 0; i < m_missionList.Count; ++i)
            {
                BattleMissionBase currMission = m_missionList[i].Peek();
                currMission.Update(fDeltaTime);
                if (currMission.IsOver)
                {
                    m_usableMissionDic[currMission.Type].Enqueue(currMission);
                    m_missionList[i].Dequeue();
                    if (m_missionList[i].Count <= 0)
                    {
                        rmQueueList.Add(m_missionList[i]);
                    }
                }
            }

            for (int i = 0; i < rmQueueList.Count; ++i)
            {
                m_missionList.Remove(rmQueueList[i]);
            }
            rmQueueList.Clear();

            if (m_missionList.Count == 0)
            {
                m_isIdle = true;
            }

            if (m_lastQueue != null && m_lastQueue.Count == 0)
            {
                m_lastQueue = null;
            }
        }
        private BattleMissionBase CreateMission(BattleCommand cmd)
        {
            BattleMissionBase newMission;

            if (m_usableMissionDic[cmd.Type].Count > 0)
            {
                newMission = m_usableMissionDic[cmd.Type].Dequeue();
            }
            else
            {
                newMission = BattleMissionBase.CreateBattleMission(cmd.Type, m_battleField);
                if (newMission == null)
                {
                    Debug.Log("Can't Create BattleMission type : " + cmd.Type);
                }
                if (newMission != null)
                {
                    newMission.Init();
                }
            }

            return(newMission);
        }
Exemple #4
0
        public static BattleMissionBase CreateBattleMission(EBattleCommandType type, BattleField battleField)
        {
            BattleMissionBase bm = null;

            switch (type)
            {
            case EBattleCommandType.CmdFireBallResponse:
                bm = new BMAddBall(type, battleField);
                break;

            case EBattleCommandType.CmdEraseBall:
                bm = new BMEraseBall(type, battleField);
                break;

            case EBattleCommandType.CmdFallBall:
                bm = new BMFallBall(type, battleField);
                break;

            case EBattleCommandType.CmdExchangeBall:
                bm = new BMExChangeBall(type, battleField);
                break;

            case EBattleCommandType.CmdBallQueue:
                bm = new BMBallQueue(type, battleField);
                break;

            case EBattleCommandType.CmdSceneTransform:
                bm = new BMFceneTransform(type, battleField);
                break;

            default:
                bm = null;
                break;
            }

            return(bm);
        }
 public void AddNewMissionList(BattleCommand cmd, BattleMissionBase newMission)
 {
     m_lastQueue = new Queue <BattleMissionBase>();
     m_lastQueue.Enqueue(newMission);
     m_missionList.Add(m_lastQueue);
 }