Esempio 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);
        }
Esempio n. 2
0
 public override void Update(GameTime GameTime)
 {
     FanAnim.Update(GameTime);
     FanNormalAnim.Update(GameTime);
 }
Esempio n. 3
0
        public override void Update(GameTime gameTime)
        {
            walkAnim.Update(gameTime);
            walkNormalAnim.Update(gameTime);

            walkAnim.Angle       = -Helper.GetAngleFromVector(Fixture.Body.LinearVelocity);
            walkNormalAnim.Angle = walkAnim.Angle;

            if ((walkAnim.CurrentFrame == 1 || walkAnim.CurrentFrame == 4) && (Math.Abs(Map.Player.Position.X - Position.X) < 1000) && (Math.Abs(Map.Player.Position.Y - Position.Y) < 1000) && !PlayingSound("Content/Sounds/Mobs/zombie_walk.wav"))
            {
                //PlaySound("zombie_walk.wav");
                PlaySound("Content/Sounds/Mobs/zombie_walk.wav");
            }

            if (timer <= 1 && (Math.Abs(Map.Player.Position.X - Position.X) < 1000) && (Math.Abs(Map.Player.Position.Y - Position.Y) < 1000))
            {
                Point start = new Point(Position.X / Map.GetTileSize(), Position.Y / Map.GetTileSize());
                Point end   = new Point(Map.Player.GetRectangle().X / Map.GetTileSize(), Map.Player.GetRectangle().Y / Map.GetTileSize());

                var RetNodes = Map.pfinder.FindPath(start, end);
                if (RetNodes != null)
                {
                    nodes = new List <PathFinderNode>(RetNodes);
                }
                else
                {
                    nodes = null;
                }
            }

            if (nodes != null && nodes.Count > 1)
            {
                int c = nodes.Count - 2;


                if (Position.X < nodes[c].X * Map.GetTileSize() + 32)
                {
                    MoveRight();
                }
                else if (Position.X > nodes[c].X * Map.GetTileSize() + 32)
                {
                    MoveLeft();
                }
                if (Position.Y < nodes[c].Y * Map.GetTileSize() + 32)
                {
                    MoveDown();
                }
                else if (Position.Y > nodes[c].Y * Map.GetTileSize() + 32)
                {
                    MoveTop();
                }
                //Position = new Rectangle(nodes[0].X * Map.GetTileSize(), nodes[0].Y * Map.GetTileSize(), Position.Width, Position.Height);
            }
            else if (nodes != null && nodes.Count <= 1)
            {
                if (Map.Player.Position.X < Position.X)
                {
                    MoveLeft();
                }
                else if (Map.Player.Position.X > Position.X)
                {
                    MoveRight();
                }

                if (Map.Player.Position.Y < Position.Y)
                {
                    MoveTop();
                }
                else if (Map.Player.Position.Y > Position.Y)
                {
                    MoveDown();
                }
            }


            base.Update(gameTime);
        }