Example #1
0
        void UpdateStats()
        {
            Stats = Type.Stats.Clone();
            foreach (var upgrade in Upgrades)
            {
                Stats.Combine(upgrade.Effect);
            }
            if (Deployed)
            {
                UnitStats terrainBonus = Combat.GetTerrainBonus(Hex.Terrain);
                Stats.Combine(terrainBonus);

                if (Entrenched)
                {
                    UnitStats entrenchmentBonus = new UnitStats();
                    entrenchmentBonus.SoftDefence        = 1;
                    entrenchmentBonus.HardDefence        = 1;
                    entrenchmentBonus.BombardmentDefence = 1;
                    Stats.Combine(entrenchmentBonus);
                }
            }
        }
Example #2
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);
        }
Example #3
0
 public UnitType()
 {
     Stats    = new UnitStats();
     Upgrades = new List <UnitUpgrade>();
 }
Example #4
0
 public UnitType()
 {
     Stats = new UnitStats();
     Upgrades = new List<UnitUpgrade>();
 }
Example #5
0
        // Defenders are granted defence bonuses based on the terrain they are in
        static void InitialiseTerrainBonuses()
        {
            if (TerrainBonuses == null)
            {
                UnitStats clear = new UnitStats();

                UnitStats forest = new UnitStats();
                forest.SoftDefence = 1;
                forest.HardDefence = 1;
                forest.BombardmentDefence = 2;

                UnitStats mountain = new UnitStats();
                mountain.SoftDefence = 2;
                mountain.HardDefence = 2;
                mountain.BombardmentDefence = 2;

                UnitStats swamp = new UnitStats();
                swamp.SoftDefence = 1;
                swamp.HardDefence = 2;

                UnitStats hill = new UnitStats();
                hill.SoftDefence = 1;
                hill.HardDefence = 1;
                hill.BombardmentDefence = 1;

                TerrainBonuses = new Dictionary<TerrainType, UnitStats>();
                TerrainBonuses[TerrainType.Clear] = clear;
                TerrainBonuses[TerrainType.Forest] = forest;
                TerrainBonuses[TerrainType.Mountain] = mountain;
                TerrainBonuses[TerrainType.Swamp] = swamp;
                TerrainBonuses[TerrainType.Hill] = hill;
            }
        }
Example #6
0
        void UpdateStats()
        {
            Stats = Type.Stats.Clone();
            foreach (var upgrade in Upgrades)
                Stats.Combine(upgrade.Effect);
            if (Deployed)
            {
                UnitStats terrainBonus = Combat.GetTerrainBonus(Hex.Terrain);
                Stats.Combine(terrainBonus);

                if (Entrenched)
                {
                    UnitStats entrenchmentBonus = new UnitStats();
                    entrenchmentBonus.SoftDefence = 1;
                    entrenchmentBonus.HardDefence = 1;
                    entrenchmentBonus.BombardmentDefence = 1;
                    Stats.Combine(entrenchmentBonus);
                }
            }
        }
Example #7
0
        public void Combine(UnitStats stats)
        {
            SoftAttack = Add(SoftAttack, stats.SoftAttack);
            SoftDefence = Add(SoftDefence, stats.SoftDefence);

            HardAttack = Add(HardAttack, stats.HardAttack);
            HardDefence = Add(HardDefence, stats.HardDefence);

            BombardmentDefence = Add(BombardmentDefence, stats.BombardmentDefence);

            AirAttack = Add(AirAttack, stats.AirAttack);
            AntiAirDefence = Add(AntiAirDefence, stats.AntiAirDefence);

            Range = Add(Range, stats.Range);

            AntiAirRange = Add(AntiAirRange, stats.AntiAirRange);

            Movement = Add(Movement, stats.Movement);
            Flags.AddRange(stats.Flags);
        }