public Game(ICollection <string> userIds, IMapInfo mapInfo, IGameSettings settings) { if (userIds == null) { throw new ArgumentNullException(nameof(userIds)); } if (mapInfo == null) { throw new ArgumentNullException(nameof(mapInfo)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } this.actionPoints = settings.ActionPoints; var tanks = userIds.Select(x => new Tank(new Health(settings.TankHealthPoint), x)).ToArray(); var map = new Map(new MapCreationData(mapInfo, tanks), new BattlefieldBuilder(), new RandomSpawnService()); // намерено скрываем типы используемых интерфейсов внутри класса игры this.mapAdapter = new MapAdapter(map); this.bulletService = new BulletService(this.mapAdapter, settings.BulletActionPoints); this.moveService = new MoveService(this.mapAdapter); this.zoneService = new ZoneService(this.mapAdapter, settings.ZoneRadius); this.DestroyedObjects = new DestroyedInfo(new Dictionary <string, Coordinates>(), new ICellContentInfo[0]); }
public void GameSetup() { scoreboard = new ScoreboardRound(); foreach (Player player in playerList) { scoreboard.AddPlayer(player); } Random rand = new Random(); int r = rand.Next(100); MapDirector mapDirector; if (r < 30) { mapDirector = new MapDirector(new ConcreteMapBuilder()); } else if (r < 60) { mapDirector = new MapDirector(new DefaultMapBuilder()); } else { mapDirector = new MapDirector(new TeleporterMapBuilder()); } Map mapFromCache = Server.GetMapByName(mapDirector.getMap().mapName); //If the map was already generated, clone it //If the map was not generated before, generate it and put a copy of it in cache if (mapFromCache != null) { map = new MapAdapter(mapFromCache); } else { mapDirector.constructMap(); Map temp = mapDirector.getMap(); map = new MapAdapter(temp); Server.AddMap(temp); } Server.current = map.GetMapFacade(); }
public MoveService(IMapAdapter mapAdapter) { this.mapAdapter = mapAdapter; }
public BulletService(IMapAdapter mapAdapter, byte bulletActionPointCount) { this.mapAdapter = mapAdapter; this.bulletActionPointCount = bulletActionPointCount; }
public ZoneService(IMapAdapter mapAdapter, byte radius) { this.mapAdapter = mapAdapter; this.Radius = radius; }