Example #1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            Metal steel = new Metal(MetalType.Steel);
            Unit uUnit1 = new Unit(80, 15, new Weapon(WeaponType.Sword, steel), new Armor(steel));
            Unit uUnit2 = new Unit(80, 15, new Weapon(WeaponType.Axe, steel), new Armor(steel));
            Terrain tt = new Terrain();

            tt.AddNeighboringTerrain(Directions.North, new Terrain());
            tt.AddNeighboringTerrain(Directions.NorthEast, new Terrain(new List<Directions>{Directions.SouthWest, Directions.South}));

            tt.IsDirectionTravelable(Directions.North);
            tt.IsDirectionTravelable(Directions.NorthWest);
            tt.IsDirectionTravelable(Directions.NorthEast);
            tt.IsDirectionTravelable(Directions.South);
            tt.IsDirectionTravelable(Directions.SouthWest);
            tt.IsDirectionTravelable(Directions.SouthEast);
            tt.IsDirectionTravelable(Directions.East);
            tt.IsDirectionTravelable(Directions.West);

            uUnit1.AddOpponent(uUnit2);
            uUnit2.ChargeBonus = true;

            while (true)
            {
            uUnit1.ProcessBattles();
            }
        }
Example #2
0
        //calculates the morale shocks to be administered to the losing side of one 'round' of combat
        //decided by who did more damage as a percent of total soldiers.
        public void CalculatePostBattleMoraleShocks(double UnitADmg, double UnitBDmg, Unit UnitA, Unit UnitB)
        {
            double Apercentdmg;
            double Bpercentdmg;

            Apercentdmg = UnitBDmg / UnitA.SoldierCount;
            Bpercentdmg = UnitADmg / UnitB.SoldierCount;

            if (Apercentdmg > Bpercentdmg)
            {
                UnitA.MoraleShock();
            }
            else if (Bpercentdmg > Apercentdmg)
            {
                UnitB.MoraleShock();
            }
        }
Example #3
0
        //returns the relevant Charge bonus for the ChargingUnit relative to the DefendingUnit
        public double GetChargeBonus(Unit ChargingUnit, Unit DefendingUnit)
        {
            double result;

            result = ChargingUnit.Weapon.GetChargingDamage();

            if (ChargingUnit.IsMounted)
            {
                result = result + 1;
            }

            //charges are less effective against spears than normal attacks
            if (DefendingUnit.Weapon.DoesStopCharge())
            {
                result = .9;
            }
            ChargingUnit.ChargeBonus = false;
            return result;
        }
Example #4
0
 //adds to this units opponents list
 public void AddOpponent(Unit Opponent)
 {
     CurrentOpponents.Add(Opponent);
     Opponent.CurrentOpponents.Add(this);
 }
Example #5
0
        //calculate morale shocks based on 2 fighting units numbers and equipment
        //  -you get a morale shock if the enemy has 20% more soldiers and
        //    if the enemy has double the soldiers (note that this stacks)
        //  -you also get a morale shock if the enemy armor is higher quality
        public void CalculatePreBattleMoraleShocks(Unit UnitA, Unit UnitB)
        {
            if (UnitA.SoldierCount > ((double)UnitB.SoldierCount * 1.2))
            {
                UnitB.MoraleShock();
            }

            if (UnitB.SoldierCount > ((double)UnitA.SoldierCount * 1.2))
            {
                UnitA.MoraleShock();
            }

            if (UnitA.SoldierCount > ((double)UnitB.SoldierCount * 2))
            {
                UnitB.MoraleShock();
            }

            if (UnitB.SoldierCount > ((double)UnitA.SoldierCount * 2))
            {
                UnitA.MoraleShock();
            }

            if (UnitB.Armor > UnitA.Armor)
            {
                UnitA.MoraleShock();
            }

            if(UnitA.Armor > UnitB.Armor)
            {
                UnitB.MoraleShock();
            }
        }