Beispiel #1
0
 public void Initialise()
 {
     for (var gridX = 0; gridX < _shipTopology.GridWidth; gridX++)
     {
         for (var gridZ = 0; gridZ < _shipTopology.GridHeight; gridZ++)
         {
             var gridPosition = new Point(gridX, gridZ);
             var child        = Entity.Create();
             child.Add(new Transform
             {
                 Location = HexagonHelpers.GetGridWorldPosition(gridPosition),
                 Rotation = Quaternion.CreateFromYawPitchRoll(0, 0, 0)
             });
             child.Add(new BuildNode(gridPosition, _shipTopology));
         }
     }
 }
Beispiel #2
0
 public void Render(RenderContext context)
 {
     if (PlacingSection != null)
     {
         if (HoverNode != null)
         {
             _shipRenderer.Render(
                 context,
                 new Transform
             {
                 Location = HexagonHelpers.GetGridWorldPosition(HoverNode.GridLocation)
             }.WorldTransform,
                 PlacingSection
                 );
         }
     }
 }
Beispiel #3
0
        public void Initialise()
        {
            _flightNode = new FlightNode[_topology.GridWidth, _topology.GridHeight];
            this.Update(() =>
            {
                for (var gridX = 0; gridX < _topology.GridWidth; gridX++)
                {
                    for (var gridZ = 0; gridZ < _topology.GridHeight; gridZ++)
                    {
                        var gridPosition = new Point(gridX, gridZ);
                        var child        = Entity.Create();
                        child.Add(new Transform(Transform)
                        {
                            Location = HexagonHelpers.GetGridWorldPosition(gridPosition),
                            Rotation = Quaternion.CreateFromYawPitchRoll(0, 0, 0)
                        });
                        _flightNode[gridX, gridZ] = child.Add(new FlightNode(this, gridPosition, _topology));
                    }
                }

                Fuel   = MaxFuel;
                Energy = MaxEnergy;
            });
        }
Beispiel #4
0
        public override void Initialise()
        {
            AddSingleton(new SpaceBackgroundScroll());

            var focusLocation = HexagonHelpers.GetGridWorldPosition(new Point(2, 2));

            var camera    = Create();
            var cameraPos = camera.Add(new Transform()
            {
                Rotation = Quaternion.CreateFromYawPitchRoll(0, 0, (float)(Math.PI)),
                Location = focusLocation + (Vector3.Backward + Vector3.Up * 1.8f) * 10
            });

            //CameraManager.ActiveCamera = camera.Add(new Camera(new OrthographicCameraParameters(10)));
            CameraManager.ActiveCamera = camera.Add(new Camera(new PerspectiveCameraParameters()
            {
                AspectRatio = GraphicsDevice.Viewport.AspectRatio
            }));
            CameraManager.ActiveCamera.LookAt(focusLocation);
            CameraManager.ActiveCamera.Recalculate();
            camera.Add(new BuildCameraControl());

            // Background planet.
            var planetEnt = Create();

            planetEnt.Add(new Transform()
            {
                Location = cameraPos.Location + CameraManager.ActiveCamera.Forwards * 100 + Vector3.Forward * 50
            });
            var planetRenderer = planetEnt.Add(new PlanetRenderer()
            {
                AutoRender  = true,
                Planet      = _planet,
                Scale       = 80f,
                RenderOrder = 20
            });

            var floor = Create();

            floor.Add(new BuildFloor(_shipTopology));

            var productionLine = AddSingleton(new ProductionLine());
            var gameMode       = AddSingleton(new BuildMode(_shipTopology, _planet));

            var placerEnt = Create();
            var placer    = placerEnt.Add(new BuildPlacer(CameraManager.ActiveCamera, _shipTopology, productionLine));

            placerEnt.Add(new BuildPlacerCursor());

            var shipRenderer = AddSingleton(new ShipSectionRenderer());

            UserInterfaceManager.AddSceneUI(this, new BuildScreenTemplate(gameMode, _planet, productionLine, placer, shipRenderer));
            if (_planet == Planet.Earth)
            {
                UIDispose closeBeginScreen = null;
                closeBeginScreen = UserInterfaceManager.Create(new BeginScreenTemplate(() => {
                    gameMode.Start();
                    EntityManager.Update(() =>
                    {
                        closeBeginScreen?.Invoke();
                    });
                }));
            }
            else
            {
                gameMode.Start();
            }

            MusicManager.Start("Building");
        }