Esempio n. 1
0
 /// <summary>
 /// Retrievs all services and components needed to start the game
 /// </summary>
 private void GetComponentsServicesToEnable()
 {
     this.cameraService   = this.Game.GetService <CameraService>();
     this.pickingService  = this.Game.GetService <PickingService>();
     this.gameScreen      = this.Game.Components.OfType <GameScreen>().ElementAt(0);
     this.gameField       = this.Game.Components.OfType <GameField>().ElementAt(0);
     this.humansParent    = this.Game.Components.OfType <HumansParent>().ElementAt(0);
     this.buildingsParent = this.Game.Components.OfType <BuildingsParent>().ElementAt(0);
     this.resourcesParent = this.Game.Components.OfType <ResourcesParent>().ElementAt(0);
     this.menuCaller      = this.Game.Components.OfType <MenusCaller>().ElementAt(0);
     this.resourcesHUD    = this.Game.Components.OfType <ResourcesHUD>().ElementAt(0);
 }
Esempio n. 2
0
        public GameField(Game game)
            : base(game)
        {
            this.camera = game.GetService <CameraService>();
            game.RegisterGameService <PickingService>(out this.pickingService, true);
            if (MAP_WIDTH.CompareTo(MAP_HEIGHT) != 0)
            {
                throw new Exception("The width and the height of the field must be equal");
            }
            this.cellVertices = new VertexPositionColor[8];

            this.Game.RegisterGameComponent <ResourcesHUD>(out this.resourcesHUD, true, true);
            this.Game.RegisterGameComponent <BuildingsParent>(out this.buildingsParent, true, true);
            this.buildingsParent.SetParent(this, ref this.resourcesHUD);
            this.Game.RegisterGameComponent <ResourcesParent>(out this.resourcesParent, true, true);
            this.resourcesParent.SetParent(this, ref this.resourcesHUD);
            this.listOfTypes            = GameFieldHelper.GetResourcesNeeded(this.CheckResources, this.DecreaseResources);
            this.typeOfBuildingSelected = CellState.Forbidden;
            this.Game.RegisterGameComponent <HumansParent>(out this.humansParent, true, true);
            this.humansParent.SetParent(this);
        }
 public ZoomInOutHUD(Game game)
     : base(game)
 {
     this.cameraService = game.GetService <CameraService>();
 }