Example #1
0
        public Tile(SerializationInputStream Stream, Map Map, TileRuleSet RuleSet, IdGenerator IdGenerator)
        {
            this.Map      = Map;
            Coordinate    = new Coordinate(Stream);
            HexCoordinate = new HexCoordinate(Coordinate);
            Id            = IdGenerator.GenerateId();
            Configuration = new TileConfiguration(Stream);
            Bounds        = CalculateBounds();

            this.RuleSet = RuleSet;
            Rules        = new TileRulesCalculator(this);
            Configuration.OnReconfigure += (sender, e) => Rules.Recalculate();
        }
Example #2
0
        public Tile(Map Map, Coordinate Coordinate, TileRuleSet RuleSet, IdGenerator IdGenerator)
        {
            this.Map        = Map;
            this.Coordinate = Coordinate;
            this.RuleSet    = RuleSet;
            Id            = IdGenerator.GenerateId();
            HexCoordinate = new HexCoordinate(Coordinate);
            Bounds        = CalculateBounds();

            Configuration = new TileConfiguration();
            Rules         = new TileRulesCalculator(this);
            Configuration.OnReconfigure += (sender, e) => Rules.Recalculate();
        }
Example #3
0
 public Unit(Army Army, UnitConfiguration UnitConfiguration, IdGenerator IdGenerator)
 {
     this.Army          = Army;
     _BaseConfiguration = UnitConfiguration;
     if (UnitConfiguration.PrimaryWeapon.Ammunition > 0)
     {
         _PrimaryAmmunition = UnitConfiguration.PrimaryWeapon.Ammunition;
     }
     if (UnitConfiguration.SecondaryWeapon.Ammunition > 0)
     {
         _SecondaryAmmunition = UnitConfiguration.SecondaryWeapon.Ammunition;
     }
     Id = IdGenerator.GenerateId();
 }
Example #4
0
        public PlayerOrm AddPlayer(PlayerOrm Player)
        {
            var p = GetPlayer(Player.Username);

            if (p != null)
            {
                return(null);
            }

            p = new PlayerOrm(_IdGenerator.GenerateId(), Player.Username, Player.PasswordHash, Player.PasswordSalt);
            lock (_Players)
            {
                _Players.Add(p.Id, p);
            }
            return(p);
        }
Example #5
0
        public Army(Match Match, SightFinder SightFinder, ArmyConfiguration ArmyConfiguration, IdGenerator IdGenerator)
        {
            _Id              = IdGenerator.GenerateId();
            this.Match       = Match;
            this.SightFinder = SightFinder;

            Configuration = ArmyConfiguration;
            Deployments   = ArmyConfiguration.DeploymentConfigurations.Select(
                i => i.GenerateDeployment(this, IdGenerator)).ToList();

            Match.Relay.OnUnitDestroy += UnitDestroyed;
            Match.Relay.OnUnitCapture += UnitCaptured;

            SightFinder.TrackingArmy = this;
            SightFinder.Hook(Match.Relay);
            _IdGenerator = IdGenerator;
        }
Example #6
0
        public IEnumerable <UnitConfigurationPack> Generate(IEnumerable <UnitConfigurationLock> UnitConfigurationLocks)
        {
            var idGenerator = new IdGenerator();

            foreach (Faction faction in _Factions.Concat(new Faction[] { null }))
            {
                foreach (UnitClass unitClass in Enum.GetValues(typeof(UnitClass)).Cast <UnitClass>())
                {
                    var locks =
                        UnitConfigurationLocks.Where(FactionFilter(faction)).Where(UnitClassFilter(unitClass)).ToList();
                    if (locks.Count > 0)
                    {
                        yield return(new UnitConfigurationPack(
                                         idGenerator.GenerateId(),
                                         PackName(faction, unitClass),
                                         9,
                                         locks));
                    }
                }
            }
        }
Example #7
0
 protected Deployment(Army Army, IEnumerable <Unit> Units, IdGenerator IdGenerator)
 {
     this.Army  = Army;
     this.Units = Units.ToList();
     _Id        = IdGenerator.GenerateId();
 }
Example #8
0
 public ArmyBuilder(IdGenerator IdGenerator, ArmyParameters Parameters)
 {
     Id = IdGenerator.GenerateId();
     this.Parameters = Parameters;
 }