Exemplo n.º 1
0
 public Player(Faction playerFaction, int PlayerNumber)
 {
     faction = playerFaction;
     playerNumber = PlayerNumber;
     OwnedPlanets = new List<Planet>();
     OwnedSystems = new List<PlanetsSystem>();
     Name = "Player";
     resources = new ResourceManager();
 }
Exemplo n.º 2
0
 public Player()
 {
     faction = new One();
     OwnedPlanets = new List<Planet>();
     OwnedSystems = new List<PlanetsSystem>();
     playerNumber = 1;
     Name = "Player";
     resources = new ResourceManager();
 }
Exemplo n.º 3
0
 public void UpdateResources(ResourceManager manager)
 {
     model.UpdatePlayerResources(manager.GetFormattedResourceDetails());
 }
Exemplo n.º 4
0
        public void Update(GameTime theTime, SaveGameData Data, StrategyGame game, ResourceManager manager,
            Overview overview, int elapsedHours, int elapsedDays)
        {
            model.UpdateUI(manager.money, manager.income, manager.deductions, manager.net,
                elapsedHours, elapsedDays);

            mouseOverHUD = IsMouseOver();

            if (needZoomIn)
            {
                ZoomIn.Invoke(this, new EventArgs());
                zoom = systemZoom;
                needZoomIn = false;
            }

            if (NeedZoomOut)
            {
                ZoomOut.Invoke(this, new EventArgs());
                model.OnSystemZoomedOut();
                NeedZoomOut = false;
            }

            data = Data;

            mousePos = mouseState.X.ToString() + " " + mouseState.Y.ToString();
            keyboardState = Microsoft.Xna.Framework.Input.Keyboard.GetState();

            UserInterface.UpdateInput(theTime.ElapsedGameTime.TotalMilliseconds);

            debug.Update();

            UserInterface.UpdateLayout(theTime.ElapsedGameTime.TotalMilliseconds);

            if (!pause)
            {
                #region Map Move & Zoom Controls

                if (moveEnabled)
                {
                    if (keyboardState.IsKeyDown(Keys.Left))
                    {
                        TempCentre = new Vector2(centre.X - cameraSpeed, centre.Y);
                        if (ValidMove(TempCentre, data.MapSize, 'L'))
                        {
                            centre = TempCentre;
                            BackgroundPosition.X += (cameraSpeed / 50f);
                        }
                    }
                    if (keyboardState.IsKeyDown(Keys.Right))
                    {
                        TempCentre = new Vector2(centre.X + cameraSpeed, centre.Y);
                        if (ValidMove(TempCentre, data.MapSize, 'R'))
                        {
                            centre = TempCentre;
                            BackgroundPosition.X -= (cameraSpeed / 50f);
                        }
                    }

                    if (keyboardState.IsKeyDown(Keys.Up))
                    {
                        TempCentre = new Vector2(centre.X, centre.Y - cameraSpeed);
                        if (ValidMove(TempCentre, data.MapSize, 'U'))
                        {
                            centre = TempCentre;
                            BackgroundPosition.Y += (cameraSpeed / 50f);
                        }
                    }
                    if (keyboardState.IsKeyDown(Keys.Down))
                    {
                        TempCentre = new Vector2(centre.X, centre.Y + cameraSpeed);
                        if (ValidMove(TempCentre, data.MapSize, 'D'))
                        {
                            centre = TempCentre;
                            BackgroundPosition.Y -= (cameraSpeed / 50f);
                        }
                    }
                }

                if (!mouseOverHUD)
                {

                    if (oldScrollValue != mouseState.ScrollWheelValue)
                    {
                        if (mouseState.ScrollWheelValue > oldScrollValue)
                        {
                            if (zoom >= 0.95 && zoomedIn == false)
                            {
                                zoomedIn = true;
                                needZoomIn = true;
                                systemZoom = 1;
                            }
                        }

                        if (mouseState.ScrollWheelValue > oldScrollValue)
                        {
                            if (zoom < 0.95)
                            {
                                zoom += 0.1;
                            }
                        }

                        if (mouseState.ScrollWheelValue < oldScrollValue)
                        {
                            if (zoom > 0.55)
                            {
                                zoom -= 0.1;
                                if (zoom > 0.5)
                                {
                                    if (centre.X > (data.MapSize.X - Graphics.PreferredBackBufferWidth * 1.5))
                                    {
                                        centre = new Vector2(centre.X - (Graphics.PreferredBackBufferWidth / 2f), centre.Y);
                                    }
                                }
                            }

                            if (zoomedIn)
                            {
                                zoomedIn = false;
                                NeedZoomOut = true;
                            }
                        }
                    }
                }



                currentTime += (float)theTime.ElapsedGameTime.TotalSeconds; //Time passed since last Update() 

                if (keyboardState.IsKeyDown(Keys.Down) || keyboardState.IsKeyDown(Keys.Up) || keyboardState.IsKeyDown(Keys.Left) || keyboardState.IsKeyDown(Keys.Right))
                {
                    if (currentTime >= countDuration)
                    {
                        currentTime -= countDuration; // "use up" the time
                        cameraSpeed = 5;
                    }
                }
                else if (keyboardState.IsKeyUp(Keys.Down) || keyboardState.IsKeyUp(Keys.Up) || keyboardState.IsKeyUp(Keys.Left) || keyboardState.IsKeyUp(Keys.Right))
                {
                    cameraSpeed = 1;
                }
                #endregion
            }

            oldMouseState = mouseState;
            oldKeyboardState = keyboardState;
            oldScrollValue = mouseState.ScrollWheelValue;
        }
Exemplo n.º 5
0
 public void UpdatePlanetInfo(PlanetInfo info, PlanetResourcesDetails resDetails, 
     List<Building> buildings, ResourceManager manager, List<ResourceDeposit> unusedResources,
     BuildQueue queue)
 {
     model.UpdatePlanetInfo(info, resDetails, buildings, unusedResources, queue);
     UpdateResources(manager);
 }