Exemplo n.º 1
0
 public void AddUpgrade(UnitUpgrade upgrade)
 {
     if (UpgradeSlotsOccupied.Contains(upgrade.Slot))
         throw new GameException("An upgrade slot was already occupied");
     UpgradeSlotsOccupied.Add(upgrade.Slot);
     Upgrades.Add(upgrade);
     _Points += upgrade.Points;
 }
Exemplo n.º 2
0
 public void AddUpgrade(UnitUpgrade upgrade)
 {
     if (UpgradeSlotsOccupied.Contains(upgrade.Slot))
     {
         throw new GameException("An upgrade slot was already occupied");
     }
     UpgradeSlotsOccupied.Add(upgrade.Slot);
     Upgrades.Add(upgrade);
     _Points += upgrade.Points;
 }
Exemplo n.º 3
0
        public void UpgradeUnit(Unit unit, UnitUpgrade unitUpgrade)
        {
            int points = unitUpgrade.Points;

            if (points > ReinforcementPoints)
            {
                throw new GameException("Not enough reinforcement points left to purchase this upgrade");
            }
            unit.AddUpgrade(unitUpgrade);
            _ReinforcementPoints -= points;
        }
Exemplo n.º 4
0
        static void GenerateFactions()
        {
            UnitStats stats = new UnitStats();
            stats.SoftAttack = 4;
            stats.SoftDefence = 4;
            stats.HardAttack = 3;
            stats.HardDefence = 3;
            stats.BombardmentDefence = 3;
            stats.Movement = 3;
            stats.Flags.Add(UnitFlag.Infantry);

            UnitStats bonus = new UnitStats();
            bonus.HardAttack = 1;
            bonus.HardDefence = 1;

            UnitUpgrade upgrade = new UnitUpgrade();
            upgrade.Name = "Upgrade";
            upgrade.Points = 5;
            upgrade.Slot = 0;

            UnitType unit = new UnitType();
            unit.Name = "Name";
            unit.Points = 20;
            unit.Hardness = 0.0;
            unit.Stats = stats;;
            unit.Upgrades.Add(upgrade);

            Faction faction = new Faction();
            faction.Name = "Faction";
            faction.Description = "Description";
            faction.Units.Add(unit);

            FactionConfiguration factions = new FactionConfiguration();
            factions.Factions.Add(faction);

            var serialiser = new Nil.Serialiser<FactionConfiguration>("Factions.xml");
            serialiser.Store(factions);
        }
Exemplo n.º 5
0
 public void UpgradeUnit(Unit unit, UnitUpgrade unitUpgrade)
 {
     int points = unitUpgrade.Points;
     if (points > ReinforcementPoints)
         throw new GameException("Not enough reinforcement points left to purchase this upgrade");
     unit.AddUpgrade(unitUpgrade);
     _ReinforcementPoints -= points;
 }