Esempio n. 1
0
        public Unit(PlayerState owner, int id, UnitConfiguration configuration, Server server)
        {
            Owner = owner;
            Id = id;
            Faction = server.GetFaction(configuration.FactionId);
            Type = Faction.GetUnitType(configuration.UnitTypeId);
            Upgrades = new List<UnitUpgrade>();
            _Points = Type.Points;
            UpgradeSlotsOccupied = new HashSet<int>();
            foreach (var upgradeId in configuration.UpgradeIds)
                AddUpgrade(GetUpgrade(upgradeId));

            Hex = null;
            Strength = GameConstants.FullUnitStrength;

            Entrenched = false;

            AttritionDuration = 0;

            UpdateStats();
            ResetUnitForNewTurn();

            // Only air units are automatically "deployed" since they don't need to be placed on the map
            Deployed = Stats.Flags.Contains(UnitFlag.Air);
        }
Esempio n. 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);
        }
Esempio n. 3
0
 public PlayerState(Game game, Faction faction, PlayerIdentifier identifier)
 {
     Game = game;
     Faction = faction;
     Identifier = identifier;
 }