Beispiel #1
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            float         seconds  = (float)gameTime.ElapsedGameTime.TotalSeconds;
            KeyboardState keyState = Keyboard.GetState();

            player.KeyState = keyState;

            player.Update(seconds);

            for (int i = 0; i < sprites.Count; i++)
            {
                ISceneObject s1 = sprites[i];
                if (s1 != null)
                {
                    s1.Update(seconds);
                    Collide((ISceneObject)player, s1);
                    for (int j = i; j < sprites.Count; j++)
                    {
                        ISceneObject s2 = sprites[j];
                        if (s2 != null)
                        {
                            Collide(s1, s2);
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            float         seconds  = (float)gameTime.ElapsedGameTime.TotalSeconds;
            KeyboardState keyState = Keyboard.GetState();

            secondsToNextMeteor -= seconds;
            if (secondsToNextMeteor <= 0)
            {
                secondsToNextMeteor = 10;
                AddSceneObject <Meteor>();
            }

            player.KeyState = keyState;

            player.Update(seconds);

            for (int i = 0; i < sprites.Count; i++)
            {
                ISceneObject s = sprites[i];
                if (s != null)
                {
                    s.Update(seconds);
                }
            }

            base.Update(gameTime);
        }
 private void SyncReceivedObject(ISceneObject o, NetIncomingMessage msg)
 {
     o.Update(msg.SenderConnection.AverageRoundtripTime / 2);
 }