Update() public method

public Update ( ) : void
return void
    public void Update()
    {
        // Systems that update every frame.
        mouseController.Update(IsModal);
        keyboardManager.Update(IsModal);
        cameraController.Update(IsModal);
        timeManager.Update();

        // Systems that update every frame when not paused.
        if (IsPaused == false)
        {
            World.TickEveryFrame(timeManager.DeltaTime);
            Scheduler.Scheduler.Current.Update(timeManager.DeltaTime);
        }

        if (timeManager.TotalDeltaTime >= gameTickDelay)
        {
            // Systems that update at fixed frequency.
            if (IsPaused == false)
            {
                // Systems that update at fixed frequency when not paused.
                World.TickFixedFrequency(timeManager.TotalDeltaTime);
                questController.Update(timeManager.TotalDeltaTime);
            }

            timeManager.ResetTotalDeltaTime();
        }

        soundController.Update(Time.deltaTime);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }
            if (InputManager.InputManager.KeyJustPressed(Keys.Escape))
            {
                LocalClient.Disconnect();
            }

            // TODO: Add your update logic here
            InputManager.InputManager.Update(Keyboard.GetState(), Mouse.GetState(), IsActive);
            TimeManager.Update(gameTime);
            BackgroundWall.Update();

            if (Program.Hosting)
            {
                Server.Update();
            }

            LocalClient.Update();
            PlatformWorld.Update();

            base.Update(gameTime);
        }
Ejemplo n.º 3
0
    void OnState()
    {
        switch (gameState)
        {
        case GameState.Start:
            OnStartGame();
            InGameMenuController.Instance.InitMenu(InGameMenuController.Instance.finishPos.position.y);
            break;

        case GameState.Playing:
            timeManager.Update();
            if (InGameMenuController.Instance.currentValue >= InGameMenuController.Instance.FinalValue)
            {
                gameState = GameState.GoJi;
            }
            break;

        case GameState.End:
            OnEndGame();
            break;

        case GameState.GameOver:
            OnGameOver();
            break;

        case GameState.GoJi:
            MoveToGoji();
            InGameMenuController.Instance.InitBoss(GameObject.FindObjectOfType <GojiMovement>());
            break;

        default:
            break;
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// This is the highest level update method,
        /// which is responsible for calling all of the updates methods associated with
        /// object states which change over time
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            TimeManager.Update(gameTime);
            GridInteractionManager.Update(this, this.grid);

            if (TimeManager.Paused)
            {
                //Graphics.state = GameState.Pause;
                return;
            }
            if (TimeManager.HasGrassTicked)
            {
                this.AddHerbivoreFood();
            }


            Utility.AttributeUpdater.UpdateAttributes(this.grid.Organisms, this.WeatherOverlay.WeatherSetting, TimeManager.HasSimulationTicked, TimeManager);

            this.grid.UpdateFood();

            this.fsm.UpdateStates(this.grid, TimeManager);

            for (var i = this.particleEffects.Count - 1; i >= 0; i--)
            {
                this.particleEffects[i].Update(gameTime);

                if (this.particleEffects[i].Complete)
                {
                    this.particleEffects.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 5
0
    public void Update()
    {
        //NetMessage.Update();
        TimeManager.Update(Time.deltaTime);

        //if (Input.GetKeyDown(KeyCode.KeypadMinus))
        //    WindowManager.Open(WindowId.GM_CONSOLE);
    }
Ejemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         TimeManager.AddSecondsHack(secondsOnSpace);
     }
     TimeManager.Update();
     //Debug.Log (TimeManager.timed_actions);
 }
Ejemplo n.º 7
0
    protected override void Update(GameTime gameTime)
    {
        getInput();
        time.Update();
        getShaderColors();
        camera.Update(isUpPressed, isDownPressed, isLeftPressed, isRightPressed, isPageDownPressed, isPageUpPressed);
        mouse.Update(camera.cameraPosition, backbufferJamz, worldFont);
        worldMap.Update(this, rando);
        uiHelper.Update(mouse, playerHandler, returnPositionCameraOffset(Vector2.Zero), dataManager, travelHandler, worldMap, rando, this);

        //GameState
        //Traveling
        if (currentGameState == GameState.Traveling)
        {
            if (travelHandler.IsPausedForEvent() == false)
            {
                int minutes = travelHandler.TravelTick(playerHandler, dataManager, rando, uiHelper, worldMap.GridNodeTerrainType(travelHandler.currentGridLocation), worldMap.IsGridRoad(travelHandler.currentGridLocation), worldMap, time.Hour);
                if (minutes == -1)
                {
                    ChangeGameState(GameState.Idle);
                    travelHandler.TravelCleanup(worldMap);
                }
                else
                {
                    time.timeTick(minutes);
                }
            }
        }
        //Resting
        else if (currentGameState == GameState.Resting)
        {
            if (time.OKToSleepTick() == true)
            {
                int minutes = 5;
                playerHandler.RestTick();
                time.timeTick(minutes);

                //check for valid sleep events
                travelHandler.CheckForValidSleepEvents(playerHandler, dataManager, rando, worldMap.GridNodeTerrainType(travelHandler.currentGridLocation), worldMap.IsGridRoad(travelHandler.currentGridLocation), worldMap, time.Hour, uiHelper);


                //wake up?
                if (playerHandler.OKToWakeUp() == true)
                {
                    travelHandler.RunCurrentWakeEvent(playerHandler, rando, uiHelper);
                    ChangeGameState(GameState.Idle);
                }
            }
        }

        //debug
        checkForEnterPressed();
        checkForSpacePressed();

        base.Update(gameTime);
    }
Ejemplo n.º 8
0
 void Update()
 {
     if (isRunning)
     {
         TimeManager.Update();
         UpdateMissions();
         HandleGameFinishChecks();
         Player.Update();
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            base.Update(gameTime);
            TimeManager.Update(gameTime);
            InputManager.Update();
            base.Update(gameTime);

            TimeManager.Update(gameTime);
            InputManager.Update();

            _time += (float)TimeManager.ElapsedGameTime;
            if (InputManager.IsKeyDown(Keys.Left))
            {
                _radius += 5f;
            }
            if (InputManager.IsKeyDown(Keys.Right))
            {
                _radius -= 5f;
            }
            if (InputManager.IsKeyDown(Keys.Down))
            {
                _speed -= 0.1f;
            }
            if (InputManager.IsKeyDown(Keys.Up))
            {
                _speed += 0.1f;
            }
            if (InputManager.IsKeyDown(Keys.LeftAlt))
            {
                _wobbling -= 0.1f;
            }
            if (InputManager.IsKeyDown(Keys.LeftControl))
            {
                _wobbling += 0.1f;
            }



            spriteAnimator.AnimateSpiralSinusoidal(_radius, _time, _speed, _wobbling);


            base.Update(gameTime);
        }
Ejemplo n.º 10
0
        public void Update(float deltaT)
        {
            if (_timeTilNextInput >= 0.0f)
            {
                _timeTilNextInput -= deltaT;
            }

            _background.Position = new Vector2f(GP.WindowGameView.Center.X - GP.WindowSize.X / 2, GP.WindowGameView.Center.Y - GP.WindowSize.Y / 2);

            TimeObject to = Timing.Update(deltaT);

            Input.Update();
            JamUtilities.Mouse.Update();
            TweenManager.Update(to);
            TimeManager.Update(to);
            _state.Update(to);

            CanBeQuit = false;
        }
Ejemplo n.º 11
0
        static void TestCoroutine()
        {
            Console.WriteLine(DateTime.Now);

            var coroutine = coroutineManager.StartCoroutine(Routine2(100));

            int n = 0;

            while (true)
            {
                //Console.WriteLine("tick:{0}", timeManager.FixedTicks);
                timeManager.Update();

                Thread.Sleep(100);
                n++;
                if (n == 20)
                {
                    Console.WriteLine("stop");
                    coroutine.Stop();
                }
            }
        }
Ejemplo n.º 12
0
        public void Update(float delta)
        {
            if (!IsInitialized)
            {
                Console.WriteLine("GameManager not initialized (this is quite fatal)");
                return;
            }

            loadingManager.Update(delta);
            coroutineManager.Step();

            timeManager.Update(delta);
            worldManager.Update(delta);

            cameraManager.Update(delta);
            lightingManager.Update(delta);

            screenSpaceSelector.Update(delta);
            updateLoop.Update(delta);
            chunkManager.Update(delta);
            moduleManager.Update(delta);
        }
Ejemplo n.º 13
0
        public void Update()
        {
            foreach (IController currentController in controllers)
            {
                currentController.Update();
            }
            if (game.reversingTime)
            {
                timeManager.ReverseTime();
                game.lightingManager.Update();
                game.player.ActiveItems.Clear();
            }
            else
            {
                game.player.Update();
                game.currentRoom.UpdateBlocks();
                game.currentRoom.UpdateNPCS();
                if (game.player.ItemCounts[PlayerStuff.ItemType.Clock] == 0)
                {
                    game.currentRoom.UpdateEnemies();
                }
                game.currentRoom.UpdateItems();
                game.currentRoom.UpdateDoors();
                game.currentRoom.UpdateWalls();

                List <IGameObject> allGameObjects = game.currentRoom.Blocks.Concat <IGameObject>(game.currentRoom.Items).Concat(game.currentRoom.Doors).Concat(game.currentRoom.Walls).Concat(game.currentRoom.Enemies).Concat(game.currentRoom.NPCs).Concat(game.player.ActiveItems).Concat(new List <IGameObject>()
                {
                    game.player, game.player.Sword
                }).ToList();
                CollisionDetection.DetectCollisions(allGameObjects);

                game.lightingManager.Update();
                game.hud.Update();

                timeManager.Update();
            }
        }
Ejemplo n.º 14
0
 private void Update()
 {
     Shoot();
     timeManager.Update();
 }
Ejemplo n.º 15
0
        public void Update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            factions.Update(gameTime);
            resources.Update(gameTime);
            ships.Update(gameTime);
            cameras.Update(gameTime);

            sea.Update(elapsedTime);
            if (ambientOn)
            {
                waterWave.Update(elapsedTime);
            }

            cannonBalls.Update(gameTime);
            islands.Update(gameTime);
            if (ambientOn)
            {
                lowerParticles.Update(gameTime);
            }
            if (ambientOn)
            {
                upperParticles.Update(gameTime);
            }
            if (ambientOn)
            {
                lowerAmbients.Update(gameTime);
            }
            if (ambientOn)
            {
                upperAmbients.Update(gameTime);
            }
            map.Update(gameTime);

            //by 刘欣 李翔
            timeManager.Update(gameTime);
            collector.Update(gameTime);

            foreach (var item in ships)
            {
                item.PerformCommand();
                Vector2 p = item.AbsolutePosition;
                if (p.X > mapSize.X / 2 || p.X < -mapSize.X / 2 || p.Y > mapSize.Y / 2 || p.Y < -mapSize.Y / 2)
                {
                    item.Armor -= OutOfRangeDamage * elapsedTime;
                }
            }

            float t = -(InputState.previousMouseState.ScrollWheelValue - InputState.currentMouseState.ScrollWheelValue) / 1000f;

            if (t != 0)
            {
                commonCamera.Scale += t;
            }
            #region 判断胜负
            if (!isGameEnd)
            {
                if (f1 != null && f2 != null)
                {
                    //by 刘欣 李翔 剩余时间为零
                    if (timeManager.FullMilisecond <= 0)
                    {
                        isGameEnd = true;
                        //首先判断船的数量
                        int s1 = ships.Count(p => p.Faction == f1);
                        int s2 = ships.Count(p => p.Faction == f2);
                        if (s1 > s2)
                        {
                            winner = 1;
                        }
                        else if (s1 < s2)
                        {
                            winner = 2;
                        }
                        else
                        {
                            //然后判断岛的数量
                            if (f1.ResourceNum > f2.ResourceNum)
                            {
                                winner = 1;
                            }
                            else if (f1.ResourceNum < f2.ResourceNum)
                            {
                                winner = 2;
                            }
                            else
                            {
                                //然后判断总血量
                                float a1 = 0;
                                float a2 = 0;
                                foreach (var s in ships)
                                {
                                    if (s.Faction == f1)
                                    {
                                        a1 += s.Armor;
                                    }
                                    else if (s.Faction == f2)
                                    {
                                        a2 += s.Armor;
                                    }
                                }
                                if (a1 > a2)
                                {
                                    winner = 1;
                                }
                                else if (a1 < a2)
                                {
                                    winner = 2;
                                }
                                else
                                {
                                    //最后判断造成的总伤害
                                    if (f1.TotalDamage > f2.TotalDamage)
                                    {
                                        winner = 1;
                                    }
                                    else if (f1.TotalDamage < f2.TotalDamage)
                                    {
                                        winner = 2;
                                    }
                                    else
                                    {
                                        winner = 0;
                                    }
                                }
                            }
                        }
                    }

                    if (ships.Count(p => p.Faction == f1) == 0)//如果f1全挂了
                    {
                        //其它操作有待添加
                        isGameEnd = true;

                        winner = 2;
                    }

                    if (ships.Count(p => p.Faction == f2) == 0)//如果f2全挂了
                    {
                        //其它操作有待添加
                        isGameEnd = true;

                        winner = 1;
                    }
                }
            }
            #endregion

            if (game.IsActive)
            {
                #region 调整视野
                float screenWInGame = game.GraphicsDevice.Viewport.Width / currentCamera.Scale;
                float screenHInGame = game.GraphicsDevice.Viewport.Height / currentCamera.Scale;

                if (InputState.CurrentMousePosition.X <= 2 || InputState.currentMouseState.Y <= 2 ||
                    InputState.CurrentMousePosition.X >= GameOperators.GraphicsDevice.Viewport.Width - 2 ||
                    InputState.CurrentMousePosition.Y >= GameOperators.GraphicsDevice.Viewport.Height - 2)
                {
                    Vector2 screenCenter = new Vector2(GameOperators.GraphicsDevice.Viewport.Width / 2, GameOperators.GraphicsDevice.Viewport.Height / 2);
                    if (screenCenter != InputState.CurrentMousePosition)
                    {
                        Vector2 translator = Vector2.Normalize(InputState.CurrentMousePosition - screenCenter) * 1000f * (float)gameTime.ElapsedGameTime.TotalSeconds / currentCamera.Scale;
                        float   borderX    = Math.Abs(MapSize.X / 2 - screenWInGame / 2);
                        float   borderY    = Math.Abs(MapSize.Y / 2 - screenHInGame / 2);
                        //currentCamera.Center += translator;
                        if (translator.X > 0 && currentCamera.Center.X <= borderX)
                        {
                            currentCamera.Center.X += translator.X;
                        }
                        else if (translator.X < 0 && currentCamera.Center.X >= -borderX)
                        {
                            currentCamera.Center.X += translator.X;
                        }
                        if (translator.Y > 0 && currentCamera.Center.Y <= borderY)
                        {
                            currentCamera.Center.Y += translator.Y;
                        }
                        else if (translator.Y < 0 && currentCamera.Center.Y >= -borderY)
                        {
                            currentCamera.Center.Y += translator.Y;
                        }
                    }
                }

                #endregion
                if (InputState.IsKeyPressed(Keys.Space))
                {
                    currentCamera.Center = Vector2.Zero;
                }
                if (InputState.IsKeyPressed(Keys.Escape))
                {
                    isGameEnd = true;
                }
                #region  标选择
                mouseOnShip = null;
                if (InputState.currentMouseState.LeftButton == ButtonState.Pressed)
                {
                    if (!mouseDowned)
                    {
                        rec0        = InputState.CurrentMousePosition;
                        rec1        = rec0;
                        mouseDowned = true;
                    }
                    else
                    {
                        rec1 = InputState.CurrentMousePosition;
                    }
                }
                else if (InputState.currentMouseState.LeftButton == ButtonState.Released)
                {
                    if (mouseDowned)
                    {
                        bool playerControled = ships.Count(p => p.Faction.ControllerType == FactionControllerType.Player) > 0;
                        humanSelectedShips.Clear();

                        float ax, bx, ay, by;
                        ax = currentCamera.ReversePoint(rec0).X;
                        ay = currentCamera.ReversePoint(rec0).Y;
                        bx = currentCamera.ReversePoint(rec1).X;
                        by = currentCamera.ReversePoint(rec1).Y;
                        BoundingBox bb = new BoundingBox(new Vector3(MathHelper.Min(ax, bx), MathHelper.Min(ay, by), 0), new Vector3(MathHelper.Max(ax, bx), MathHelper.Max(ay, by), 0));

                        foreach (var item in ships)
                        {
                            BoundingSphere bs = new BoundingSphere(new Vector3(item.AbsolutePosition, 0), item.SelectionRadius);
                            if (bb.Intersects(bs))
                            {
                                if (!playerControled || (playerControled && item.Faction.ControllerType == FactionControllerType.Player))
                                {
                                    humanSelectedShips.Add(item);
                                }
                            }
                        }
                        mouseDowned = false;
                    }
                }

                foreach (var item in ships)
                {
                    if (item.IsMouseOn())
                    {
                        mouseOnShip = item;

                        if (InputState.CursorState == Base.CursorState.Normal)
                        {
                            InputState.CursorState = Base.CursorState.Select;
                        }

                        if (InputState.IsMouseButtonPressed(MouseButton.LeftButton) && (rec0 == rec1))
                        {
                            humanSelectedShips.Clear();
                            humanSelectedShips.Add(item);//选中船只
                        }
                        break;
                    }
                }
                #endregion
            }
            texts.Update(gameTime);

            foreach (var item in ships)
            {
                foreach (var item2 in ships)
                {
                    if (item != item2)
                    {
                        float d = 0;
                        if (IsShipCollided(item, item2, ref d))
                        {
                            if (Vector2.DistanceSquared(item.Positionl, item2.AbsolutePosition) > d)//如果碰撞且距离拉近(卡住)
                            {
                                float dmg = item.GetKnockDamage(item2);
                                if (dmg > 0)
                                {
                                    item2.ReceiveDamage(dmg, 0.1f, true);
                                    item.ReceiveDamage(dmg / 2, 0.1f, true);
                                }
                                item.Block(Vector2.Normalize(item.AbsolutePosition - item2.AbsolutePosition) * (item.BoundingRadius + item2.BoundingRadius + 0.2f - Vector2.Distance(item.AbsolutePosition, item2.AbsolutePosition)));
                                //item.Block();//那么就触发碰撞事件

                                /*if (!BlockedShips.Contains(item) && !BlockedShips.Contains(item2))
                                 * {
                                 *  BlockedShips.Add(item);
                                 *  BlockedShips.Add(item2);
                                 * }*/
                            }
                        }

                        //d < (float)Math.Pow(object1.BoundingRadius + object2.BoundingRadius,2)
                        if (item.IsMoving && Vector2.DistanceSquared(item.AbsolutePosition, item2.AbsolutePosition) <= (float)Math.Pow(item.BoundingRadius + item2.BoundingRadius + 0.5, 2))
                        {
                            item.IsBlocked = true;
                        }
                    }
                }
                foreach (var island in islands)
                {
                    float d = 0;
                    if (IsShipCollided(item, island, ref d))
                    {
                        if (Vector2.DistanceSquared(item.Positionl, island.AbsolutePosition) > d)    //如果碰撞且距离拉近(卡住)
                        {
                            item.Block(Vector2.Normalize(item.AbsolutePosition - island.AbsolutePosition) * (item.BoundingRadius + island.BoundingRadius + 0.2f - Vector2.Distance(item.AbsolutePosition, island.AbsolutePosition)));

                            /*if (!BlockedShips.Contains(item))
                             * {
                             *  BlockedShips.Add(item);
                             * }*/
                        }
                    }
                }
            }

            /*if (BlockedShips.Count != 0)
             * {
             *  MoreBlocked();
             *  foreach (Ship s in BlockedShips)
             *  {
             *      s.Block();
             *  }
             *  BlockedShips.Clear();
             * }*/
        }
Ejemplo n.º 16
0
 void Update()
 {
     TimeManager.Update();
 }
Ejemplo n.º 17
0
 // Update is called once per frame
 void Update()
 {
     m_timeManager.Update();
     m_modelManager.Update();
 }
Ejemplo n.º 18
0
 // Update is called once per frame
 void Update()
 {
     m_timeManager.Update();
     m_effectManager.Update();
 }
Ejemplo n.º 19
0
 private void Update()
 {
     TimeManager.Update();
     EventManager.ExecuteEvent(EventType.Update);
     InputManager();
 }
Ejemplo n.º 20
0
 public void Update()
 {
     s.Update();
     t.Update();
 }
Ejemplo n.º 21
0
	// Update is called once per frame
	void Update () {
		if (!_globalPause) {
			_timeManager.Update(Time.deltaTime);
		}
	}