Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            if (GeneralManager.CheckKeyEdge(Keys.Escape))
            {
                GeneralManager.Game.Exit();
            }
            if (hp > 0)
            {
                IsWalking = Fixture.Body.LinearVelocity.X > 1f || Fixture.Body.LinearVelocity.Y > 1f;

                PlayerSensor.Body.Position = Fixture.Body.Position + GeneralManager.MousePos + new Vector2(Camera.GetRect.X, Camera.GetRect.Y) - GetPosition();

                SoundEngine.SetPosition(this.GetPosition(), 0); //We need to have angle from ACTUAL animation;

                Camera.GetRect = new Rectangle(Position.X - GeneralManager.ScreenX / 2 + Position.Width / 2, Position.Y - GeneralManager.ScreenY / 2 + Position.Height / 2, Camera.GetRect.Width, Camera.GetRect.Height);

                if (IsWalking)
                {
                    WalkAnim.Angle       = -Helper.GetAngleFromVector(GeneralManager.MousePos + new Vector2(Camera.GetRect.X, Camera.GetRect.Y) - GetPosition()) + (float)Math.PI;
                    WalkNormalAnim.Angle = WalkAnim.Angle;

                    WalkAnim.Update(gameTime);
                    WalkNormalAnim.Update(gameTime);
                }
                else
                {
                    IdleAnim.Angle       = -Helper.GetAngleFromVector(GeneralManager.MousePos + new Vector2(Camera.GetRect.X, Camera.GetRect.Y) - GetPosition()) + (float)Math.PI;
                    IdleNormalAnim.Angle = IdleAnim.Angle;

                    IdleAnim.Update(gameTime);
                    IdleNormalAnim.Update(gameTime);
                }

                ShootLight.Position  = new Vector3(GetPosition(), 0);
                ShootLight.Direction = new Vector3(GeneralManager.MousePos + new Vector2(Camera.GetRect.X, Camera.GetRect.Y), 0) - ShootLight.Position + new Vector3(0, 0, 10);
                ShootLight.Direction.Normalize();

                ShootLight.Power *= 0.8f;

                weapon.actCD -= gameTime.ElapsedGameTime.Milliseconds;

                //if (key.Position.X > Position.X) Logger.Write(key.Position.X + " RIGHT " + Position.X);
                //if (key.Position.X < Position.X) Logger.Write(key.Position.X + " Left " + Position.X);

                //if (key.Position.Y > Position.Y) Logger.Write(key.Position.Y + " Down " + Position.Y);
                //if (key.Position.Y < Position.Y) Logger.Write(key.Position.Y + " Up " + Position.Y);

                if (key.pickedUp && showEndMsg && GeneralManager.CheckKey(Keys.Enter))
                {
                    showEndMsg = false;
                }
            }

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        public bool HandleInput()
        {
            bool Result = false;

            if (hp > 0)
            {
                if (GeneralManager.CheckKey(Keys.D))
                {
                    MoveRight();
                    Result = true;
                }
                else if (GeneralManager.CheckKey(Keys.A))
                {
                    MoveLeft();
                    Result = true;
                }

                if (GeneralManager.CheckKey(Keys.S))
                {
                    MoveDown();
                    Result = true;
                }
                else if (GeneralManager.CheckKey(Keys.W))
                {
                    MoveTop();
                    Result = true;
                }

                if (GeneralManager.IsLMBClicked())
                {
                    ShootBullet(new Vector2(Camera.GetRect.X + GeneralManager.MousePos.X, Camera.GetRect.Y + GeneralManager.MousePos.Y));
                    Result = true;
                }
            }

            return(Result);
        }