Exemple #1
0
        public bool Battle(Heroes.Core.Hero attackHero, Heroes.Core.Hero defendHero, Heroes.Core.Monster monster)
        {
            lock (frmGame2._lockMe)
            {
                using (frmBattle f = new frmBattle())
                {
                    _frmBattle = f;

                    f._playerIdMe = this._playerIdMe;

                    // set multiplayer flag
                    if (defendHero != null) f._isMultiPlayer = true;
                    else f._isMultiPlayer = false;

                    f.CommandIssued += new frmBattle.CommandIssuedEventHandler(f_CommandIssued);

                    f.ShowDialog(attackHero, defendHero, monster, null);

                    using (Heroes.Core.Battle.frmBattleResult f2 = new Heroes.Core.Battle.frmBattleResult())
                    {
                        if (f._victory == Heroes.Core.Battle.BattleSideEnum.Attacker)
                        {
                            if (f._engine._attacker._playerId == this._playerIdMe)
                            {
                                // victory
                                f2.ShowDialog(1, f._engine._attacker, this._playerIdMe,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                this._frmDuel._currentHero._experience += f2._experience;
                                this._frmDuel.LevelUp(this._frmDuel._currentHero);

                                return true;
                            }
                            else
                            {
                                // defeat
                                f2.ShowDialog(2, f._engine._attacker, this._playerIdMe,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                // do not remove hero
                                this._frmDuel.ResurrectHero(this._frmDuel._currentHero);
                                //_currentPlayer._heroes.Remove(this._currentHero);
                                //_currentHero = null;

                                return false;
                            }
                        }
                        else
                        {
                            if (f._engine._defender != null)
                            {
                                if (f._engine._defender._playerId == this._playerIdMe)
                                {
                                    // victory
                                    f2.ShowDialog(1, f._engine._defender, this._playerIdMe,
                                        f._engine._attacker, f._engine._defender, f._engine._monster);

                                    this._frmDuel._currentHero._experience += f2._experience;
                                    this._frmDuel.LevelUp(this._frmDuel._currentHero);

                                    return true;
                                }
                                else
                                {
                                    // defeat
                                    f2.ShowDialog(2, f._engine._defender, this._playerIdMe,
                                        f._engine._attacker, f._engine._defender, f._engine._monster);

                                    // do not remove hero
                                    this._frmDuel.ResurrectHero(this._frmDuel._currentHero);
                                    //_currentPlayer._heroes.Remove(this._currentHero);
                                    //_currentHero = null;

                                    return false;
                                }
                            }
                            else if (f._engine._monster != null)
                            {
                                // defeat
                                f2.ShowDialog(2, f._engine._monster, this._playerIdMe,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                // do not remove hero
                                this._frmDuel.ResurrectHero(this._frmDuel._currentHero);
                                //_currentPlayer._heroes.Remove(this._currentHero);
                                //_currentHero = null;

                                return false;
                            }
                        }
                    }
                }
            }

            return false;
        }
Exemple #2
0
        private bool ShowBattleResult(Heroes.Core.Battle.BattleSideEnum victory,
            int currentPlayerId,
            Heroes.Core.Hero attackHero, Heroes.Core.Hero defendHero, Heroes.Core.Monster monster)
        {
            using (Heroes.Core.Battle.frmBattleResult f2 = new Heroes.Core.Battle.frmBattleResult())
            {
                if (victory == Heroes.Core.Battle.BattleSideEnum.Attacker)
                {
                    if (attackHero._playerId == currentPlayerId)
                    {
                        // victory
                        f2.ShowDialog(1, attackHero, currentPlayerId,
                            attackHero, defendHero, monster);

                        this._currentHero._experience += f2._experience;
                        this.LevelUp(this._currentHero);

                        return true;
                    }
                    else
                    {
                        // defeat
                        f2.ShowDialog(2, attackHero, currentPlayerId,
                            attackHero, defendHero, monster);

                        // do not remove hero
                        this.ResurrectHero(this._currentHero);
                        //_currentPlayer._heroes.Remove(this._currentHero);
                        //_currentHero = null;

                        return false;
                    }
                }
                else
                {
                    if (defendHero != null)
                    {
                        if (defendHero._playerId == currentPlayerId)
                        {
                            // victory
                            f2.ShowDialog(1, defendHero, currentPlayerId,
                                attackHero, defendHero, monster);

                            this._currentHero._experience += f2._experience;
                            this.LevelUp(this._currentHero);

                            return true;
                        }
                        else
                        {
                            // defeat
                            f2.ShowDialog(2, defendHero, currentPlayerId,
                                attackHero, defendHero, monster);

                            // do not remove hero
                            this.ResurrectHero(this._currentHero);
                            //_currentPlayer._heroes.Remove(this._currentHero);
                            //_currentHero = null;

                            return false;
                        }
                    }
                    else if (monster != null)
                    {
                        // defeat
                        f2.ShowDialog(2, monster, currentPlayerId,
                            attackHero, defendHero, monster);

                        // do not remove hero
                        this.ResurrectHero(this._currentHero);
                        //_currentPlayer._heroes.Remove(this._currentHero);
                        //_currentHero = null;

                        return false;
                    }
                }
            }

            return false;
        }
Exemple #3
0
        private bool Battle(Heroes.Core.Hero hero, Heroes.Core.Monster monster)
        {
            this.Hide();

            try
            {
                using (frmBattle f = new frmBattle())
                {
                    f.ShowDialog(hero, null, monster, null);

                    using (Heroes.Core.Battle.frmBattleResult f2 = new Heroes.Core.Battle.frmBattleResult())
                    {
                        if (f._victory == Heroes.Core.Battle.BattleSideEnum.Attacker)
                        {
                            if (f._engine._attacker._playerId == this._playerMe._id)
                            {
                                // victory
                                f2.ShowDialog(1, f._engine._attacker, this._playerMe._id,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                this._currentHero._experience += f2._experience;
                                LevelUp(this._currentHero);

                                return true;
                            }
                            else
                            {
                                // defeat
                                f2.ShowDialog(2, f._engine._attacker, this._playerMe._id,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                _currentPlayer._heroes.Remove(this._currentHero);
                                _currentHero = null;

                                return false;
                            }
                        }
                        else
                        {
                            if (f._engine._defender != null)
                            {
                                if (f._engine._defender._playerId == this._playerMe._id)
                                {
                                    // victory
                                    f2.ShowDialog(1, f._engine._defender, this._playerMe._id,
                                        f._engine._attacker, f._engine._defender, f._engine._monster);

                                    this._currentHero._experience += f2._experience;
                                    LevelUp(this._currentHero);

                                    return true;
                                }
                                else
                                {
                                    // defeat
                                    f2.ShowDialog(2, f._engine._defender, this._playerMe._id,
                                        f._engine._attacker, f._engine._defender, f._engine._monster);

                                    _currentPlayer._heroes.Remove(this._currentHero);
                                    _currentHero = null;

                                    return false;
                                }
                            }
                            else if (f._engine._monster != null)
                            {
                                // defeat
                                f2.ShowDialog(2, f._engine._monster, this._playerMe._id,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                _currentPlayer._heroes.Remove(this._currentHero);
                                _currentHero = null;

                                return false;
                            }
                        }
                    }
                }
            }
            finally
            {
                this.Show();
            }

            return false;
        }
Exemple #4
0
        private bool Battle(Heroes.Core.Hero attackHero, Heroes.Core.Hero defendHero, Heroes.Core.Monster monster)
        {
            lock (frmGame2._lockMe)
            {
                using (frmBattle f = new frmBattle())
                {
                    f.ShowDialog(attackHero, defendHero, monster, null);

                    using (Heroes.Core.Battle.frmBattleResult f2 = new Heroes.Core.Battle.frmBattleResult())
                    {
                        if (f._victory == Heroes.Core.Battle.BattleSideEnum.Attacker)
                        {
                            if (f._engine._attacker._playerId == this._currentPlayer._id)
                            {
                                // victory
                                f2.ShowDialog(1, f._engine._attacker, this._currentPlayer._id,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                this._currentHero._experience += f2._experience;
                                LevelUp(this._currentHero);

                                return true;
                            }
                            else
                            {
                                // defeat
                                f2.ShowDialog(2, f._engine._attacker, this._currentPlayer._id,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                // do not remove hero
                                ResurrectHero(this._currentHero);
                                //_currentPlayer._heroes.Remove(this._currentHero);
                                //_currentHero = null;

                                return false;
                            }
                        }
                        else
                        {
                            if (f._engine._defender != null)
                            {
                                if (f._engine._defender._playerId == this._currentPlayer._id)
                                {
                                    // victory
                                    f2.ShowDialog(1, f._engine._defender, this._currentPlayer._id,
                                        f._engine._attacker, f._engine._defender, f._engine._monster);

                                    this._currentHero._experience += f2._experience;
                                    LevelUp(this._currentHero);

                                    return true;
                                }
                                else
                                {
                                    // defeat
                                    f2.ShowDialog(2, f._engine._defender, this._currentPlayer._id,
                                        f._engine._attacker, f._engine._defender, f._engine._monster);

                                    // do not remove hero
                                    ResurrectHero(this._currentHero);
                                    //_currentPlayer._heroes.Remove(this._currentHero);
                                    //_currentHero = null;

                                    return false;
                                }
                            }
                            else if (f._engine._monster != null)
                            {
                                // defeat
                                f2.ShowDialog(2, f._engine._monster, this._currentPlayer._id,
                                    f._engine._attacker, f._engine._defender, f._engine._monster);

                                // do not remove hero
                                ResurrectHero(this._currentHero);
                                //_currentPlayer._heroes.Remove(this._currentHero);
                                //_currentHero = null;

                                return false;
                            }
                        }
                    }
                }
            }

            return false;
        }