private void checkEndphase(Player _player, Computer _computer) { if (this.m_playerTurn == ePlayerId.PLAYER) { if (_player.Phase != ePhase.BATTLE) this.Step = eBattleStep.ENDPHASE; } else { if (_computer.Phase != ePhase.BATTLE) this.Step = eBattleStep.ENDPHASE; } }
public void End(Player _player, Computer _computer) { this.Step = eBattleStep.ENDPHASE; foreach (var card in _player.MonsterField.ListCard) { card.LeftClick -= new CardLeftClickEventHandle(player_card_LeftClick); } foreach (var card in _computer.MonsterField.ListCard) { card.LeftClick -= new CardLeftClickEventHandle(computer_card_LeftClick); } List_monsterATK.Clear(); }
public void Update(Player _player, Computer _computer) { if (this.Step == eBattleStep.ENDPHASE) return; this.checkEndphase(_player, _computer); #if DEBUG //System.Diagnostics.Debug.WriteLine(this.Step.ToString()); #endif switch (this.Step) { case eBattleStep.START_STEP: if (EffectManager.GetInstance().GetState(eSoundId.battle_turn) == SoundState.Playing) { return; // do nohing // just wait for sound end } // Active card effect this.MonsterATK = null; this.MonsterBeATK = null; this.LoseMonster = null; this.isdestroy[0] = false; this.isdestroy[1] = false; m_timer.ResetStopWatch(); this.Step = eBattleStep.BATTLE_STEP; break; case eBattleStep.BATTLE_STEP: if (this.m_playerTurn == ePlayerId.PLAYER) { //wait event click //... if (MonsterATK == null) break; battleSword.Update(_player); if (_computer.MonsterField.Count == 0) // Trường hợp đối thủ không có bài trên sân { battleSword.DirectAtk(_computer); this.Step = eBattleStep.START_DS; break; } if (MonsterBeATK != null) // Trường hợp chọn được lá bị tấn công { this.Step = eBattleStep.START_DS; break; } } else//com turn { if (MonsterATK == null) { //chọn lá tấn công cho computer _computer.SelectMonsterATK(this); } if (this.MonsterATK == null) { _computer.Phase = ePhase.END; this.Step = eBattleStep.ENDPHASE; break; } if (_player.MonsterField.Count == 0) // Trường hợp đối thủ không có bài trên sân { battleSword.DirectAtk(_player); } this.Step = eBattleStep.START_DS; break; } break; case eBattleStep.START_DS: if (battleSword.IsAction == false) { //Chạy một số animation battleSword.Status = STATUS.SWORD_HALF; EffectManager.GetInstance().Play(eSoundId.attack); //if (EffectManager.GetInstance().GetState(eSoundId.attack) == SoundState.Stopped) if (m_timer.StopWatch(EffectManager.GetInstance().GetDuration(eSoundId.attack))) { battleSword.Hide(); this.Step = eBattleStep.BEFORE_DS; } } // active card effect break; case eBattleStep.BEFORE_DS: // flip face down monster EffectManager.GetInstance().Play(eSoundId.card_open); if (this.MonsterBeATK != null) { if (this.MonsterBeATK.IsFaceUp == false) this.MonsterBeATK.IsFaceUp = true; } this.Step = eBattleStep.DURING_DS; break; case eBattleStep.DURING_DS: if (MonsterBeATK != null) { if (this.MonsterBeATK.BattlePosition == eBattlePosition.DEF) { if (MonsterATK.Atk > MonsterBeATK.Def) { this.isdestroy[1] = true; } if (MonsterATK.Atk < MonsterBeATK.Def) { this.LoseMonster = MonsterATK; this.DamageCalculate(_player, _computer, MonsterBeATK.Def - MonsterATK.Atk); this.LoseMonster = null; } } else { int dif = MonsterATK.Atk - MonsterBeATK.Atk; if (dif < 0) { this.isdestroy[0] = true; this.LoseMonster = MonsterATK; } if (dif > 0) { this.isdestroy[1] = true; this.LoseMonster = MonsterBeATK; } if (dif == 0) { this.isdestroy[0] = true; this.isdestroy[1] = true; } this.DamageCalculate(_player, _computer, dif); } } else { AtkDirectly(_player, _computer); } this.Step = eBattleStep.AFTER_DS; break; case eBattleStep.AFTER_DS: //active card effect this.Step = eBattleStep.END_DS; break; case eBattleStep.END_DS: for (int i = 0; i < 2; i++) { if (isdestroy[i] == true) { LoseMonster = monster[i]; } else continue; if (this.LoseMonster.IsAction == true) break; if (_player.MonsterField.ListCard.Contains(LoseMonster)) { this.LoseMonster.LeftClick -= new CardLeftClickEventHandle(player_card_LeftClick); _player.MonsterField.SendTo(this.LoseMonster, eDeckId.GRAVEYARD); this.LoseMonster.AddMoveTo(new MoveTo(0.5f, GlobalSetting.Default.PlayerGrave)); this.LoseMonster = null; this.Step = eBattleStep.END_STEP; } if (_computer.MonsterField.ListCard.Contains(LoseMonster)) { this.LoseMonster.LeftClick -= new CardLeftClickEventHandle(computer_card_LeftClick); _computer.MonsterField.SendTo(this.LoseMonster, eDeckId.GRAVEYARD); this.LoseMonster.AddMoveTo(new MoveTo(0.5f, ComputerSetting.Default.GraveYard)); this.LoseMonster = null; this.Step = eBattleStep.END_STEP; } } this.Step = eBattleStep.END_STEP; break; case eBattleStep.END_STEP: //if (this.MonsterATK == null) //{ // this.Step = eBattleStep.START_STEP; // break; //} if (_player.IsAction || _computer.IsAction) break; this.MonsterATK.CanATK = false; this.MonsterATK.LeftClick -= player_card_LeftClick; this.List_monsterATK.Remove(this.MonsterATK); this.MonsterATK.SwitchBattlePosition = false; this.Step = eBattleStep.START_STEP; break; case eBattleStep.ENDPHASE: //active some card effect this.End(_player, _computer); break; default: break; } }
public void Begin(Player _player, Computer _computer, ePlayerId _id) { EffectManager.GetInstance().Play(eSoundId.battle_turn); this.Step = eBattleStep.START_STEP; this.m_playerTurn = _id; this.List_monsterATK.Clear(); if (m_playerTurn == ePlayerId.PLAYER) { foreach (var card in _player.MonsterField.ListCard) { if ((card as Monster).CanATK) { List_monsterATK.AddLast(card); card.LeftClick += new CardLeftClickEventHandle(player_card_LeftClick); } } foreach (var card in _computer.MonsterField.ListCard) { card.LeftClick += new CardLeftClickEventHandle(computer_card_LeftClick); } } else { foreach (var card in _computer.MonsterField.ListCard) { if ((card as Monster).CanATK) { List_monsterATK.AddLast(card); } } } }