Ejemplo n.º 1
0
        public override string OnUpdate(GameTime gameTime, KeyboardState keyState, MouseState mouseState)
        {
            // Do network stuff.
            (Sm as InfiniminerGame).UpdateNetwork(gameTime);

            skyplaneEngine.Update(gameTime);
            playerEngine.Update(gameTime);
            interfaceEngine.Update(gameTime);
            particleEngine.Update(gameTime);

            return(nextState);
        }
Ejemplo n.º 2
0
        public override string OnUpdate(GameTime gameTime, KeyboardState keyState, MouseState mouseState)
        {
            // Update network stuff.
            (Sm as InfiniminerGame).UpdateNetwork(gameTime);

            // Update the current screen effect.
            P.screenEffectCounter += gameTime.ElapsedGameTime.TotalSeconds;

            // Update engines.
            skyplaneEngine.Update(gameTime);
            playerEngine.Update(gameTime);
            interfaceEngine.Update(gameTime);
            particleEngine.Update(gameTime);

            // Count down the tool cooldown.
            if (P.PlayerContainer.PlayerToolCooldown > 0)
            {
                P.PlayerContainer.PlayerToolCooldown -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (P.PlayerContainer.PlayerToolCooldown <= 0)
                {
                    P.PlayerContainer.PlayerToolCooldown = 0;
                }
            }

            // Moving the mouse changes where we look.
            if (Sm.WindowHasFocus())
            {
                if (mouseInitialized)
                {
                    int dx = mouseState.X - Sm.GraphicsDevice.Viewport.Width / 2;
                    int dy = mouseState.Y - Sm.GraphicsDevice.Viewport.Height / 2;

                    if ((Sm as InfiniminerGame).InvertMouseYAxis)
                    {
                        dy = -dy;
                    }

                    P.PlayerContainer.PlayerCamera.Yaw  -= dx * P.SettingsContainer.MouseSensitivity;
                    P.PlayerContainer.PlayerCamera.Pitch = (float)Math.Min(Math.PI * 0.49, Math.Max(-Math.PI * 0.49, P.PlayerContainer.PlayerCamera.Pitch - dy * P.SettingsContainer.MouseSensitivity));
                }
                else
                {
                    mouseInitialized = true;
                }
                Mouse.SetPosition(Sm.GraphicsDevice.Viewport.Width / 2, Sm.GraphicsDevice.Viewport.Height / 2);
            }
            else
            {
                mouseInitialized = false;
            }

            // Digging like a freaking terrier! Now for everyone!
            if (mouseInitialized && mouseState.LeftButton == ButtonState.Pressed && !P.PlayerContainer.PlayerDead && P.PlayerContainer.PlayerToolCooldown == 0 && P.PlayerContainer.PlayerTools[P.PlayerContainer.PlayerToolSelected] == PlayerTools.Pickaxe)
            {
                P.FirePickaxe();
                P.PlayerContainer.PlayerToolCooldown = P.GetToolCooldown(PlayerTools.Pickaxe) * (P.PlayerContainer.PlayerClass == PlayerClass.Miner ? 0.4f : 1.0f);
            }

            // Prospector radar stuff.
            if (!P.PlayerContainer.PlayerDead && P.PlayerContainer.PlayerToolCooldown == 0 && P.PlayerContainer.PlayerTools[P.PlayerContainer.PlayerToolSelected] == PlayerTools.ProspectingRadar)
            {
                float oldValue = P.PlayerContainer.RadarValue;
                P.ReadRadar(ref P.PlayerContainer.RadarDistance, ref P.PlayerContainer.RadarValue);
                if (P.PlayerContainer.RadarValue != oldValue)
                {
                    if (P.PlayerContainer.RadarValue == 200)
                    {
                        P.PlaySound(InfiniminerSound.RadarLow);
                    }
                    if (P.PlayerContainer.RadarValue == 1000)
                    {
                        P.PlaySound(InfiniminerSound.RadarHigh);
                    }
                }
            }

            // Update the player's position.
            if (!P.PlayerContainer.PlayerDead)
            {
                UpdatePlayerPosition(gameTime, keyState);
            }

            // Update the camera regardless of if we're alive or not.
            P.UpdateCamera(gameTime);

            return(nextState);
        }