void _SetCommand(CNewBattle battle, int nCmdNum, int targetIdx)
        {
            BattleCharacter PC = battle.GetPCs()[m_nCmdInputState]; //m_PCs[m_nCmdInputState];

            switch (nCmdNum)
            {
            case 0:
            {
                Attack tmpCmd = new Attack();
                tmpCmd.actor  = PC;
                tmpCmd.target = battle.GetAllCharacters()[targetIdx];         //m_AllChars[targetIdx];
                //m_CmdList[m_nCmdInputState] = tmpCmd;
                m_CmdList.Add(tmpCmd);
                break;
            }

            default:
            {
                Skill tmpCmd = new Skill();
                tmpCmd.actor   = PC;
                tmpCmd.target  = PC;
                tmpCmd.skillID = 0;         // 가만히 있기
                //m_CmdList[m_nCmdInputState] = tmpCmd;
                m_CmdList.Add(tmpCmd);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        public void OnStart(CNewBattle battle)
        {
            nFinishType = -1;
            battle.GetForm().CloseBattle(-1);

            IsBattleEnd      = false;
            m_CurrentCharIdx = 0;
            MakeEnemiesCommands(battle); // 적 커맨드 결정
            //MakeInitiList(battle.m_nCharNum);
            MakeInitiList(m_CmdList);    // 우선권 계산

            //OnTick(battle); // 실행 -> 타이머에서 호출!!
        }
        public void OnStart(CNewBattle battle)
        {
            m_nCmdInputState = -1;

            //m_CmdList = new Command[battle.m_nCharNum];
            m_CmdList = new List <Command>();

            BattleCharacter[] pcs = battle.GetPCs();

            Screen.Inst().UpdateCharacterParams();

            GetCmdOfNextPc(battle);
            //ToNextPC(battle);
            //battle.GetForm().InitSelectCmd(battle.GetPCs()[m_nCmdInputState].Name);
        }
Ejemplo n.º 4
0
 // 적군의 명령을 생성한다.
 void MakeEnemiesCommands(CNewBattle battle)
 {
     for (int i = 0; i < battle.m_nEnemyNum; ++i)
     {
         Skill tmpCmd = new Skill();
         tmpCmd.actor = battle.GetEnemies()[i]; //m_Enemys[i];
         if (tmpCmd.actor.IsAlive())
         {
             tmpCmd.target  = battle.GetPCs()[i]; //m_PCs[i];
             tmpCmd.skillID = 0;                  // 가만히 있기
             //m_CmdList[battle.m_nPCNum + i] = tmpCmd;
             m_CmdList.Add(tmpCmd);
         }
     }
 }
        void GetCmdOfNextPc(CNewBattle battle)
        {
            BattleCharacter[] pcs = battle.GetPCs();

            ++m_nCmdInputState;
            if (m_nCmdInputState >= battle.m_nPCNum)
            {
                //// 명령 수행 상태로.
                battle.GetStateMachine().ChangeState(new ExecCommandState(m_CmdList));
            }
            else
            {
                if (pcs[m_nCmdInputState].IsDead())
                {
                    //_SetCommand(battle, 0, 0);    // List 로 바꾸었기 때문에, 필요 없어짐.
                    GetCmdOfNextPc(battle);
                }
                else
                {
                    battle.GetForm().InitSelectCmd(battle.GetPCs()[m_nCmdInputState].Name);
                }
            }
        }
 public void SetCommand(CNewBattle battle, int nCmdNum, int targetIdx)
 {
     _SetCommand(battle, nCmdNum, targetIdx);
     GetCmdOfNextPc(battle);
 }
 public void OnEnd(CNewBattle battle)
 {
     //bGetCmdMode = false;
     battle.GetForm().EndSelectCmd();
 }
 public void OnTick(CNewBattle battle)
 {
     //ToNextPC(battle);
 }
Ejemplo n.º 9
0
 public StateMachine(CNewBattle owner)
 {
     m_Owner        = owner;
     m_CurrentState = new InitState();
 }
Ejemplo n.º 10
0
 private void btGUIStart_Click(object sender, EventArgs e)
 {
     timer1.Enabled = true;
     battle         = new CNewBattle(this);
     battle.Start();
 }
Ejemplo n.º 11
0
        int nFinishType;// = -1;
        public void OnTick(CNewBattle battle)
        {
            if (IsBattleEnd)
            {
                // 종료 처리
                battle.GetForm().CloseBattle(nFinishType);

                Screen.Inst().WriteLine("");
                switch (nFinishType)
                {
                case 0:     // 적 전멸
                    Screen.Inst().WriteLine("You defeated all enemies.\nBattle ends.");
                    break;

                case 1:     // 아군 전멸
                    Screen.Inst().WriteLine("You all died.\nBattle ends.");
                    break;

                case 2:     // 도망 성공
                    Screen.Inst().WriteLine("You escaped from battle.\nBattle ends.");
                    break;

                case 3:     // 이벤트
                    Screen.Inst().WriteLine("Battle ends by event.");
                    break;

                default:     // 에러
                    System.Diagnostics.Debug.Assert(false, "FinishType error.");
                    Screen.Inst().WriteLine("Battle ends. Finish Type error.");
                    break;
                }
                // 전투 종료. null state 로 이전.
                battle.GetStateMachine().ChangeState(new NullState());
                return;
            }
            else
            {
                if (m_CurrentCharIdx >= m_Initiativities.Count) // m_InitiList.Length)
                {
                    // 전투가 끝나지 않았다면 다시 커맨드를 입력받는다.
                    battle.GetStateMachine().ChangeState(new SelectCmdState());
                    return;
                }
            }

            bool bFinished = false;

            //foreach (int i in m_InitiList)  // 우선권에 따라 명령을 하나씩 수행
            //{
            Command cmd = m_Initiativities[m_CurrentCharIdx].Cmd;

            if (cmd.actor.IsAlive())
            {
                if (cmd.Run())      // cmd tick 이 끝나면 다음 cmd 로 이전.
                {
                    ++m_CurrentCharIdx;
                    bFinished = true;
                    battle.CheckBattleEnd(out nFinishType, out bFinished, cmd);
                }

                Screen.Inst().UpdateCharacterParams();

                //if (bFinished)
                //    break;
            }
            else
            {
                //Screen.Inst().WriteLine("");
                //Screen.Inst().WriteLine(String.Format("{0}은(는) 이미 죽어있다.", cmd.actor.Name));
                ++m_CurrentCharIdx;
                OnTick(battle);
                return;
            }
            //}

            if (bFinished)
            {
                IsBattleEnd = true;
            }
        }
Ejemplo n.º 12
0
 public void SetCommand(CNewBattle battle, int nCmdNum, int targetIdx)
 {
 }
Ejemplo n.º 13
0
 public void OnEnd(CNewBattle battle)
 {
 }
Ejemplo n.º 14
0
 public void OnTick(CNewBattle battle)
 {
 }
Ejemplo n.º 15
0
 public void OnStart(CNewBattle battle)
 {
 }
Ejemplo n.º 16
0
 public void OnStart(CNewBattle battle)
 {
     battle.InitBattle();
     battle.GetStateMachine().ChangeState(new SelectCmdState());
 }