Update() protected method

protected Update ( ) : void
return void
Esempio n. 1
0
 public void Update(GameTime gameTime)
 {
     foreach (ITerrain terrain in Tiles)
     {
         terrain.Update(gameTime);
     }
     for (int i = _creatures.Count - 1; i >= 0; i--)
     {
         _creatures[i].Update(gameTime);
     }
     for (int i = _containers.Count - 1; i >= 0; i--)
     {
         _containers[i].Update(gameTime);
     }
     for (int i = _doors.Count - 1; i >= 0; i--)
     {
         _doors[i].Update(gameTime);
     }
     for (int i = _quests.Count - 1; i >= 0; i--)
     {
         _quests[i].Update(gameTime);
     }
     for (int i = _fire.Count - 1; i >= 0; i--)
     {
         _fire[i].Update(gameTime);
     }
     for (int i = _specialEffects.Count - 1; i >= 0; i--)
     {
         _specialEffects[i].Update(gameTime);
     }
     Player.Update(gameTime);
 }
Esempio n. 2
0
 private void UpdateDetails(GameTime gameTime)
 {
     _info.Update(gameTime);
     _playerCharacter.Update(gameTime);
     _playerCamera.Update(gameTime);
     _currentMap.Update(gameTime);
     _ui.Update(gameTime);
 }
Esempio n. 3
0
        public void Update(float dt)
        {
            hero.Update(dt);

            // We need to check for doors AFTER the player has moved

            // Loop torugh the layout, the Tile class does not know if it is a door or not.
            for (int row = 0; row < currentRoom.Length; ++row)
            {
                for (int col = 0; col < currentRoom[row].Length; ++col)
                {
                    // The tile is a door if it had a 2 in the layout!
                    if (currentRoom[row][col].IsDoor)
                    {
                        // Get the door's bounding rectangle
                        Rectangle doorRect = GetTileRect(new PointF(col * 30, row * 30));

                        // Get a small rectangle in the center of the player
                        Rectangle playerCenter = new Rectangle((int)hero.Center.X - 2, (int)hero.Center.Y - 2, 4, 4);

                        // Look for an intersection
                        Rectangle intersection = Intersection.Rect(doorRect, playerCenter);

                        // Intersection happens if the intersect rectangle has an area > 0
                        if (intersection.Width * intersection.Height > 0)
                        {
                            // If we are in room1, move to room 2
                            if (currentRoom == room1)
                            {
                                // Set active room
                                currentRoom = room2;

                                // Reposition hero to tile outside of door
                                hero.Position.X = 1 * 30; // Column 1
                                hero.Position.Y = 1 * 30; // Row 1
                            }
                            // If we are in room 2, move to room 1
                            else
                            {
                                // Set active room
                                currentRoom = room1;

                                // Reposition hero to tile outside of door
                                hero.Position.X = 6 * 30; // Column 6
                                hero.Position.Y = 4 * 30; // Row 4
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 // Update is called once per frame
 void Update()
 {
     PlayerCharacter.Update(Time.deltaTime);
     if (PlayerCharacter.IsOnline)
     {
         PlayerName.color = new UnityEngine.Color(0, 1, 0);
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     PlayerName.transform.rotation = Camera.main.transform.rotation;
     gameObject.transform.position = new Vector3(PlayerCharacter.Position.X, gameObject.transform.position.y,
                                                 PlayerCharacter.Position.Y);
     gameObject.transform.rotation = Quaternion.Euler(0, PlayerCharacter.RotationAngle, 0);
 }
Esempio n. 5
0
        public void Update(GameTime time)
        {
            // Only update periodically (not every frame)
            if (time.TotalGameTime.TotalSeconds - LastMoveTime > SecondsPerMove)
            {
                // Update the last updated time
                LastMoveTime = time.TotalGameTime.TotalSeconds;

                // Add the new position
                PickNextPosition();

                // Set the new animation targets
                (Wumpus.GetAnimation(AnimationType.MoveToNewMenuTile) as SpriteMoveAnimation).TargetPosition          = Path.LatestValue;
                (PlayerCharacter.GetAnimation(AnimationType.MoveToNewMenuTile) as SpriteMoveAnimation).TargetPosition = Path.EarliestValue;
            }

            // Update the animations every frame
            Wumpus.Update(time);
            PlayerCharacter.Update(time);
        }
Esempio n. 6
0
        public override void Update(GameTime gameTime)
        {
            NetIncomingMessage msg;

            while ((msg = Main.Client.ReadMessage()) != null)
            {
                if (msg.MessageType == NetIncomingMessageType.Data)
                {
                    PacketType packetType = (PacketType)msg.ReadByte();

                    switch (packetType)
                    {
                    case PacketType.PlayerConnectPacket:
                        PlayerConnectPacket connectPacket = PlayerConnectPacket.FromMessage(msg);
                        break;

                    case PacketType.PlayerChatPacket:
                        PlayerChatPacket chatPacket = PlayerChatPacket.FromMessage(msg);
                        break;

                    case PacketType.PlayerMovePacket:
                        PlayerMovePacket movePacket = PlayerMovePacket.FromMessage(msg);
                        if (movePacket.Username == Program.UserName)
                        {
                            player.Rotation = movePacket.Rotation;
                            player.Position = movePacket.Position;
                        }
                        else
                        {
                        }
                        break;

                    case PacketType.PlayerListPacket:

                        PlayerListPacket listPacket = PlayerListPacket.FromMessage(msg);
                        HandlePlayerList(listPacket.Players);
                        break;

                    default:
                        break;
                    }
                }
            }

            input.Update(gameTime, camera);
            colorCycle.Update(gameTime);
            camera.Update(gameTime);
            player.Update(gameTime, camera);
            if (input.NeedsMoveSend)
            {
                PlayerMovePacket.New(Program.UserName, input.Position, input.Rotation).Send(Main.Client);
                input.SentMove();
            }
            foreach (Character npc in npcs)
            {
                npc.Update(gameTime, camera);
            }

            foreach (Character c in players.Values.AsEnumerable())
            {
                c.Update(gameTime, camera);
            }

            cameraLock.Syncronize();
            Bullet.Update(gameTime);
        }
 public void Update(TimeSpan delta)
 {
     _char.Update(delta);
     _map.Update(delta);
 }
Esempio n. 8
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            KeyboardState keys  = Keyboard.GetState();
            MouseState    mouse = Mouse.GetState();


            if (keys.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            player.Update(gameTime);
            creature.Update(gameTime);
            creature.Updatee(gameTime, mapView.X, mapView.Y);

            Rectangle delta = mapView;

            if (keys.IsKeyDown(Keys.Down))
            {
                delta.Y += 1;
                player.MoveSprite(gameTime);
                player.MoveDown(this.Content);
            }

            if (keys.IsKeyDown(Keys.Up))
            {
                delta.Y -= 1;
                player.MoveSprite(gameTime);
                player.MoveUp(this.Content);
            }

            if (keys.IsKeyDown(Keys.Right))
            {
                delta.X += 1;
                player.MoveSprite(gameTime);
                player.MoveRight(this.Content);
            }

            if (keys.IsKeyDown(Keys.Left))
            {
                delta.X -= 1;
                player.MoveSprite(gameTime);
                player.MoveLeft(this.Content);
            }

            if (maps[mapIdx].Bounds.Contains(delta))
            {
                player.position.X += delta.X - mapView.X;
                player.position.Y += delta.Y - mapView.Y;
                mapView.X          = delta.X;
                mapView.Y          = delta.Y;
            }
            //exitButtonSourceRect = new Rectangle(0, 0, 100, 100);
            exitButton.Update(gameTime);
            base.Update(gameTime);
        }
Esempio n. 9
0
 public void Update(GameTime deltaTime)
 {
     playerChar.Update(deltaTime);
     controller.Update(deltaTime);
     mailbox.Update(deltaTime);
 }