コード例 #1
0
        bool OnSensorCollide(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (Vector2.Distance(PlayerSensor.Body.Position, Fixture.Body.Position) <= 60)
            {
                if (fixtureA == PlayerSensor)
                {
                    if (fixtureB.UserData != null)
                    {
                        (fixtureB.UserData as Entity).Sensor(this);
                    }
                }

                if (GeneralManager.CheckKeyEdge(Keys.E))
                {
                    if (fixtureA == PlayerSensor)
                    {
                        if (fixtureB.UserData != null)
                        {
                            (fixtureB.UserData as Entity).PlayerUse(this);
                        }
                    }
                    else
                    {
                        if (fixtureA.UserData != null)
                        {
                            (fixtureA.UserData as Entity).PlayerUse(this);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #2
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);
        }
コード例 #3
0
        public override void Update(GameTime GameTime)
        {
            if (GeneralManager.CheckKeyEdge(Keys.P))
            {
                debug = !debug;
                DebugWindow.Visible = !DebugWindow.Visible;
            }
            Map.Update(GameTime);
            PlayerLight.Position  = new Vector3(Map.Player.GetPosition(), 0);
            PlayerLight.Direction = new Vector3(GeneralManager.MousePos + new Vector2(Camera.GetRect.X, Camera.GetRect.Y), 0) - PlayerLight.Position + new Vector3(0, 0, 10);
            PlayerLight.Direction.Normalize();

            base.Update(GameTime);
        }