private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (lbLock) { return; } panel2.Visible = false; label2.Text = ""; //int targetIdx = listBox1.SelectedIndex; int targetIdx = ((lbData)listBox1.SelectedItem).Index; //listBox1.Items.Clear(); lbLock = true; battle.GetStateMachine().SetCommand(m_nSelectedCommand, targetIdx); //battle.GetStateMachine().OnTick(); }
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); } } }
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; } }
public void OnStart(CNewBattle battle) { battle.InitBattle(); battle.GetStateMachine().ChangeState(new SelectCmdState()); }