Exemplo n.º 1
0
        public bool movePlayerToPos(Player p, Vector3 newPos)
        {
            Vector3 newVel = newPos - p.Position;
            newVel.Normalize();

            float error = 4;
            if (Vector3.Distance(newPos, p.Position) > error) // prevent jitter
            {
                if (switchedToBoss || switchedToMiniBoss)
                    p.Velocity = newVel * 8;
                else
                    p.Velocity = newVel;
            }
            else
            {
                p.Velocity = Vector3.Zero;
                p.Position = newPos;
                return true;
            }
            return false;
        }
Exemplo n.º 2
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;
        }
        /// Load graphics content for the game.
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            currentLevel = new Level1(content, ScreenManager.SpriteBatch);
            gameFont = content.Load<SpriteFont>("fonts/gamefont");
            //Used for drawing UI
            spriteBatch = ScreenManager.SpriteBatch;

            player = new Player(content);
            player.resetScore();
            Level.Add(player); //add the player

            UI = content.Load<Texture2D>("ui/UI");
            ShieldBar = content.Load<Texture2D>("ui/shieldbar");
            PowerupBar = content.Load<Texture2D>("ui/powerupbar");
            Needle = content.Load<Texture2D>("ui/Needles");
            Missile = content.Load<Texture2D>("ui/Missile");
            Shield = content.Load<Texture2D>("ui/Shield");
            border = content.Load<Texture2D>("textures/borderTexture");
            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }