Esempio n. 1
0
        public Stack(int stackId)
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            _gameDataRepository = CallContext <GameDataRepository> .GetData("GameDataRepository");

            _stackRecord = _gameDataRepository.GetStackById(stackId);
            var unitRecords = _gameDataRepository.GetUnitsByStackId(stackId);

            Units = new Units();
            foreach (var unitRecord in unitRecords)
            {
                Units.Add(new Unit(unitRecord.Id));
            }

            _gameDataRepository.StackUpdated += StackUpdated;
        }
Esempio n. 2
0
        internal SecondaryFrame(SettlementView settlementView, Vector2 topLeftPosition, string textureAtlas) :
            base("SecondaryFrame")
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            Size     = new PointI(556, 741);
            Position = topLeftPosition.ToPointI();

            SettlementView = settlementView;

            var pairs = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("textureName1", $"{textureAtlas}.frame_main"),
                new KeyValuePair <string, string>("textureName2", $"{textureAtlas}.frame2_whole"),
                new KeyValuePair <string, string>("textureName3", $"{textureAtlas}.frame_bottom"),
                new KeyValuePair <string, string>("position1", $"{Convert.ToInt32(topLeftPosition.X)};{Convert.ToInt32(topLeftPosition.Y)}"),
                new KeyValuePair <string, string>("size1", $"{Size.X};{Size.Y}")
            };

            var spec = ResourceReader.ReadResource("PhoenixGamePresentation.Views.SettlementViewComposite.SecondaryFrameControls.txt", Assembly.GetExecutingAssembly());

            Controls = ControlCreator.CreateFromSpecification(spec, pairs);

            var buildingsView = new BuildingsView("buildingsView", settlementView, textureAtlas);
            var frmBuildings  = Controls["frmSecondary.frmBuildings"];

            frmBuildings.AddControl(buildingsView, Alignment.TopCenter);

            var slots10  = new DynamicSlots("slots20", $"{textureAtlas}.slot", new PointI(515, 65), 5, 2, 10.0f);
            var frmUnits = Controls["frmSecondary.frmUnits"];

            frmUnits.AddControl(slots10, Alignment.TopLeft, Alignment.TopLeft, new PointI(0, 5));
            CreateUnitLabels(slots10);

            var slots5   = new DynamicSlots("slots2", $"{textureAtlas}.slot", new PointI(515, 65), 5, 1, 10.0f);
            var frmOther = Controls["frmSecondary.frmOther"];

            frmOther.AddControl(slots5, Alignment.TopLeft, Alignment.TopLeft, new PointI(0, 5));
            CreateOtherLabels(slots5);
        }
Esempio n. 3
0
        public MainGame(PointI desiredResolution)
        {
            _graphicsDeviceManager = new GraphicsDeviceManager(this);
            Content.RootDirectory  = "Content";

            var gameConfigRepository = new GameConfigRepository();

            CallContext <GameConfigRepository> .SetData("GameConfigRepository", gameConfigRepository);

            var gameConfigCache = new GameConfigCache();

            CallContext <GameConfigCache> .SetData("GameConfigCache", gameConfigCache);

            var gameDataRepository = new GameDataRepository();

            CallContext <GameDataRepository> .SetData("GameDataRepository", gameDataRepository);

            var presentationContext = new GlobalContextPresentation {
                DesiredResolution = desiredResolution
            };

            CallContext <GlobalContextPresentation> .SetData("GlobalContextPresentation", presentationContext);
        }
Esempio n. 4
0
        public Settlement(string name, int raceId, PointI location, byte settlementSize, CellGrid cellGrid, int[] buildingIds)
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            _id = location.Y * Constants.WORLD_MAP_COLUMNS + location.X;

            Name               = name;
            Race               = _gameConfigCache.GetRaceConfigById(raceId);
            Location           = location;
            _populationGrowth  = 0;
            _currentlyBuilding = new CurrentlyBuilding(-1, -1, -1, 0);
            _buildingsBuilt    = new List <int>();
            foreach (var buildingId in buildingIds)
            {
                _buildingsBuilt.Add(buildingId);
            }
            Citizens = new SettlementCitizens(this, settlementSize, _buildingsBuilt);

            // control
            _catchmentCells = cellGrid.GetCatchment(location.X, location.Y, 2);
            foreach (var item in _catchmentCells)
            {
                var cell = cellGrid.GetCell(item.Column, item.Row);
                cellGrid.SetCell(cell, cell.SeenState, 1);
            }
            _catchmentCells = cellGrid.GetCatchment(location.X, location.Y, 2);
            cellGrid.CellFactionChange(_catchmentCells);

            // sight
            _seenCells = cellGrid.GetCatchment(location.X, location.Y, 3);
            foreach (var item in _seenCells)
            {
                var cell = cellGrid.GetCell(item.Column, item.Row);
                cellGrid.SetCell(cell, SeenState.CurrentlySeen);
            }
        }