示例#1
0
文件: Game.cs 项目: Simsso/Crusades
        // fight procedure
        public void Fight(Unit Attacker, Unit Defender)
        {
            int Distance = Coord.DistanceBetweenCoord(Attacker.Position, Defender.Position);

            Attacker.AttackedThisRound = true;
            Attacker.Range = 0; // attacker can't move after attacking

            int AttackerHealthBeforeFight = Attacker.Health;
            int AttackerPower = Attacker.GetCombatSkills()[0][(int)Defender.GetClass()], DefenderPower = Defender.GetCombatSkills()[1][(int)Attacker.GetClass()];
            int AttackerBuildingBasedBonus = (Map.GetBuildingByCoord(Attacker.Position) != null) ? Map.GetBuildingByCoord(Attacker.Position).GetAttackBonus() : 0;
            int DefenderGroundBasedBonus = Map.GetSurfaceByCoord(Defender.Position).DefenseBonus;

            Attacker.DecrementAmmunition();
            Defender.DecrementAmmunition();

            if (!(Defender.GetFiringRange() < Distance))
                if (!Attacker.DecreaseHealth((int)Math.Round(2 * ((Defender.Health / (double)Defender.GetMaxHealth()) * (DefenderPower / ((AttackerPower == 0) ? 1 : AttackerPower))) + DefenderGroundBasedBonus + 0.5, 0)))
                    RemoveUnit(Attacker, true);

            if (!(Attacker.GetFiringRange() < Distance))
                if (!Defender.DecreaseHealth((int)Math.Round(2 * ((AttackerHealthBeforeFight / (double)Attacker.GetMaxHealth()) * (AttackerPower / ((DefenderPower == 0) ? 1 : DefenderPower))) + AttackerBuildingBasedBonus + 0.5, 0)))
                    RemoveUnit(Defender, true);
        }
示例#2
0
        public void ShowUnitTypeInformationPopup(Unit Unit)
        {
            Label_UnitInfoInfantryAttack.Content = Unit.GetCombatSkills()[0][0].ToString();
            Label_UnitInfoInfantryDefend.Content = Unit.GetCombatSkills()[1][0].ToString();
            Label_UnitInfoCavalryAttack.Content = Unit.GetCombatSkills()[0][1].ToString();
            Label_UnitInfoCavalryDefend.Content = Unit.GetCombatSkills()[1][1].ToString();
            Label_UnitInfoArtilleryAttack.Content = Unit.GetCombatSkills()[0][2].ToString();
            Label_UnitInfoArtilleryDefend.Content = Unit.GetCombatSkills()[1][2].ToString();
            Label_UnitInfoAirForceAttack.Content = Unit.GetCombatSkills()[0][3].ToString();
            Label_UnitInfoAirForceDefend.Content = Unit.GetCombatSkills()[1][3].ToString();
            Label_UnitInfoNavyAttack.Content = Unit.GetCombatSkills()[0][4].ToString();
            Label_UnitInfoNavyDefend.Content = Unit.GetCombatSkills()[1][4].ToString();

            Grid_UnitTypeInformationPopup.Visibility = Visibility.Visible;
        }