Ejemplo n.º 1
0
        public bool rotatePlayerToRot(Player p, Vector3 newRot)
        {
            Vector3 newVel = newRot - p.Rotation;

            newVel.Normalize();

            float error = 0.01f;

            if (Vector3.Distance(newRot, p.Rotation) > error) // prevent jitter
            {
                if (switchedToBoss)
                {
                    p.rotate(new Vector3(0, MathHelper.ToRadians(1), 0));
                }
                else
                {
                    p.rotate(new Vector3(0, MathHelper.ToRadians(1), 0));
                }
            }
            else
            {
                p.Rotation = newRot;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public void UpdateBoss(GameTime gameTime)
        {
            Player p = entities[0] as Player;

            if (!endingMove1)
            {
                if (p.Rotation.Y > MathHelper.ToRadians(140))
                {
                    p.rotate(new Vector3(0, -MathHelper.ToRadians(1), 0));
                }
                else
                {
                    endingMove1 = true;
                }
            }
            if (endingMove1 && !endingMove2)
            {
                endingMove2 = movePlayerToPos(p, new Vector3(p.Position.X, -850, p.Position.Z));
            }
            if (endingMove1 && endingMove2 && !lastCharge)
            {
                timeToChargeShot = timeToChargeShot.Subtract(gameTime.ElapsedGameTime);
                if (timeToChargeShot.TotalSeconds <= 0)
                {
                    cb = new ChargeBall(content, new Vector3(p.Position.X + 5, p.Position.Y, p.Position.Z - 5));
                    Add(cb);
                    lastCharge = true;
                }
            }
            if (endingMove1 && endingMove2 && lastCharge && !lastShot)
            {
                if (cb.isDead)
                {
                    Vector3 dir = new Vector3(285, p.Position.Y, -400) - p.Position;
                    dir.Normalize();
                    dir  /= 2;
                    laser = new Laser(content, new Vector3(p.position.X, p.position.Y, p.position.Z), dir);
                    Add(laser);
                    p.CameraEnabled = false;
                    Camera.Instance.rotateCameraPos(new Vector3(MathHelper.ToRadians(60), 0, 0));
                    lastShot = true;
                }
            }
            if (lastShot)
            {
                p.CameraEnabled = false;

                Camera.Instance.UpdateCamera(laser.Position, laser.Rotation);

                if (Vector3.Distance(new Vector3(285, p.Position.Y, -400), laser.Position) < 200)
                {
                    levelEnded = true;
                }
            }
            //p.Position = new Vector3(285, -850, -200);
            CheckCollision();
            levelWorldMat = Matrix.CreateScale(10) * Matrix.CreateRotationY(0) * Matrix.CreateTranslation(position);
            base.Update(gameTime);
        }
Ejemplo n.º 3
0
        public bool rotatePlayerToRot(Player p, Vector3 newRot)
        {
            Vector3 newVel = newRot - p.Rotation;
            newVel.Normalize();

            float error = 0.01f;
            if (Vector3.Distance(newRot, p.Rotation) > error) // prevent jitter
            {
                if (switchedToBoss)
                    p.rotate(new Vector3(0, MathHelper.ToRadians(1), 0));
                else
                    p.rotate(new Vector3(0, MathHelper.ToRadians(1), 0));
            }
            else
            {
                p.Rotation = newRot;
                return true;
            }
            return false;
        }