Exemple #1
0
        public static void Update()
        {
            if (Input.IsScrollMvdUp)
            {
                ScaleInput = Scale * 1.3f;
            }
            if (Input.IsScrollMvdDown)
            {
                ScaleInput = Scale / 1.3f;
            }

            GameDebugger.WriteLine("scale: " + Scale);
            GameDebugger.WriteLine($"scaleinput {ScaleInput}");
            if (ScreenShakeDuration > 0)
            {
                ScreenShakeDuration -= Time.DeltaTime;
                Position            += new Vector2(Game1.Random.NextFloat(-1, 1) * ScreenShakeIntensity, Game1.Random.NextFloat(-1, 1) * ScreenShakeIntensity);
            }

            if (Input.CurrentMouse.RightButton == ButtonState.Pressed && Focus == null)
            {
                Position -= Vector2.TransformNormal(Input.MouseMovement, Matrix.Invert(Transform));
            }

            if (Focus != null)
            {
                Position = Vector2.Lerp(Position, Focus.Value, FocusSpeed * Time.DeltaTime);
            }
            Scale = MathHelper.Lerp(Scale, ScaleInput, Time.DeltaTime * ScaleSpeed);
        }
Exemple #2
0
        public override void Update()
        {
            base.Update();
            GroundPosition = Position + Center + groundPositionOffset;

            float angle = (float)Math.Atan2(direction.Y, direction.X);
            float pi8   = (float)Math.PI / 8;

            if (angle > -pi8 && angle < pi8)
            {
                facingDirection = FacingDirection.East;
            }
            else if (angle > pi8 && angle < pi8 * 3)
            {
                facingDirection = FacingDirection.SouthEast;
            }
            else if (angle > pi8 * 3 && angle < pi8 * 5)
            {
                facingDirection = FacingDirection.South;
            }
            else if (angle > pi8 * 5 && angle < pi8 * 7)
            {
                facingDirection = FacingDirection.SouthWest;
            }
            else if (angle > pi8 * 7 || angle < -pi8 * 7)
            {
                facingDirection = FacingDirection.West;
            }
            else if (angle < -pi8 && angle > -pi8 * 3)
            {
                facingDirection = FacingDirection.NorthEast;
            }
            else if (angle < -pi8 * 3 && angle > -pi8 * 5)
            {
                facingDirection = FacingDirection.North;
            }
            else if (angle < -pi8 * 5 && angle > -pi8 * 7)
            {
                facingDirection = FacingDirection.NorthWest;
            }
            //beräknar ut riktning på creature


            if (GetType() == typeof(Player))
            {
                GameDebugger.WriteLine("player direction: " + facingDirection);
            }

            if (Stats.Health <= 0)
            {
                Die();
                return;
            }
            if (invulnerable)
            {
                InvulnerabilityTimer();
            }
        }
Exemple #3
0
        public void Update(GameTime gameTime)
        {
            if (!ScreenManager.ContainsScreenType(typeof(PauseMenuScreen)))
            {
                if (!ScreenManager.ContainsScreenType(typeof(MainMenuScreen)))
                {
                    CreatureManager.Update();
                }
                ItemManager.Update();
                ProjectileManager.Update();
            }

            ParticleManager.Update();
            SoundManager.Update();
            ScreenManager.Update();

            Input.Update();
            Time.Update(gameTime);
            GameDebugger.Update();
        }
Exemple #4
0
 public void DrawUserInterface()
 {
     Managers.ForEach(x => x.DrawUserInterface(SpriteBatch));
     GameDebugger.DrawToScreen(SpriteBatch);
 }
Exemple #5
0
 public void DrawToWorldWithoutShader()
 {
     GameDebugger.DrawToWorld(SpriteBatch);
 }