예제 #1
0
 private void DamageCalculate(Player _player, Computer _computer, int _dif)
 {
     if (_player.MonsterField.ListCard.Contains(LoseMonster))
     {
         _player.Lp_change.Position = LoseMonster.Position;
         _player.LifePoint -= Math.Abs(_dif);
     }
     if (_computer.MonsterField.ListCard.Contains(LoseMonster))
     {
         _computer.Lp_change.Position = LoseMonster.Position;
         _computer.LifePoint -= Math.Abs(_dif);
     }
 }
예제 #2
0
        public override void Init(Game _game)
        {
            base.Init(_game);
            background = new Sprite(Game.Content, "fie_burn");
            background.Position = new Vector2(230, 0);
            background.Depth = 0.0f;

            Player = new Player(_game.Content);
            Player.Init(Game.Content);

            Computer = new Computer();
            Computer.Init(Game.Content);

            switch (first)
            {
                case ePlayerId.PLAYER:
                    Player.IsTurn = true;
                    Computer.IsTurn = false;
                    break;
                case ePlayerId.COMPUTER:
                    Player.IsTurn = false;
                    Computer.IsTurn = true;
                    break;
                default:
                    break;
            }

            YNDialog = new YesNoDialog(_game.Content, "String");
            YNDialog.Position = new Vector2(
                x: this.Game.Window.ClientBounds.Center.X - YNDialog.Sprite.Bound.Width / 2,
                y: this.Game.Window.ClientBounds.Center.Y - YNDialog.Sprite.Bound.Height / 2);

            phaseSelector = new PhaseSelector(_game.Content);
            phaseSelector.DrawPhaseButton.ButtonEvent += new Action(DrawPhaseButton_ButtonEvent);
            phaseSelector.StandbyButton.ButtonEvent += new Action(StandbyButton_ButtonEvent);
            phaseSelector.Main1Button.ButtonEvent +=new Action(Main1Button_ButtonEvent);
            phaseSelector.EndPhaseButton.ButtonEvent += new Action(EndPhaseButton_ButtonEvent);
            phaseSelector.Main2Button.ButtonEvent += new Action(Main2Button_ButtonEvent);
            phaseSelector.BattleButton.ButtonEvent += new Action(BattleButton_ButtonEvent);

            _rasterizerState = new RasterizerState() { ScissorTestEnable = true };
            DetailSideBar = new DetailSideBar(_game.Content);
            battlePhase = new BattlePhase(_game.Content);
        }
예제 #3
0
 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;
     }
 }
예제 #4
0
 private void AtkDirectly(Player _player, Computer _computer)
 {
     if (_player.MonsterField.ListCard.Contains(MonsterATK))
     {
         _computer.Lp_change.Position = ComputerSetting.Default.LP_Change;
         _computer.LifePoint -= MonsterATK.Atk;
     }
     if (_computer.MonsterField.ListCard.Contains(MonsterATK))
     {
         _player.Lp_change.Position = GlobalSetting.Default.LP_Change;
         _player.LifePoint -= MonsterATK.Atk;
     }
 }
예제 #5
0
        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;
            }
        }
예제 #6
0
 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();
 }
예제 #7
0
 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);
             }
         }
     }
 }