예제 #1
0
        public virtual void LoadContent(ContentManager theContentManager, Profile activeProfile)
        {
            AssetName = "Levels\\" + AssetName;
            base.LoadContent(theContentManager, AssetName);
            mBackground.LoadContent(theContentManager, AssetName + "b");

            mDimensions = activeProfile.Graphics.Resolution;
            mCenterVector = new Vector2(mDimensions.X / 2 - 100, mDimensions.Y * 3 / 4 - 100);

            mAudio = activeProfile.Audio;
            SoundEffect.MasterVolume = mAudio.MasterVolume / 100f;
            MediaPlayer.Volume = mAudio.MasterVolume * mAudio.MusicVolume / 10000f;
            mExitReached = theContentManager.Load<Song>("Sounds\\ExitReached");
            mBackgroundMusic = theContentManager.Load<Song>("Sounds\\Level");
            mCheckpointSound = theContentManager.Load<SoundEffect>("Sounds\\Checkpoint");

            Portals.LoadContent(theContentManager);

            Player = new Character();
            Player.LoadContent(theContentManager);
            Player.Position = Player.InitialPosition = Checkpoints[0].Location;

            foreach (Obstacle spr in Obstacles)
                spr.LoadContent(theContentManager, spr.AssetName);

            foreach (Actor spr in Actors)
                spr.LoadContent(theContentManager, spr.AssetName);

            mGameFont = theContentManager.Load<SpriteFont>("Fonts\\gamefont");
        }
예제 #2
0
        public void Update(bool ducking, Character theMan)
        {
            PortalPosition = theMan.PortalPosition + Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED : ARM_ANCHOR), Matrix.CreateRotationZ(theMan.PortalAngle));

            if (Math.Abs(MathHelper.WrapAngle(Angle)) > MathHelper.PiOver2)
                PortalPosition += Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED_LEFT : ARM_ANCHOR_LEFT), Matrix.CreateRotationZ(theMan.PortalAngle));

            PortalAngle = Angle + theMan.PortalAngle;
        }
예제 #3
0
        public void LoadContent(ScreenManager screenManager, Profile activeProfile)
        {
            if (mLoaded)
                return;

            var theContentManager = screenManager.Game.Content;

            string backgroundMusicName = "Sounds\\" + AssetName;

            if (LevelIdentifier == -1)
            {
                string filepath = "Content\\Levels\\Custom\\" + AssetName;
                base.LoadContent(screenManager.GraphicsDevice, filepath + ".png");

                try
                {
                    mBackground.LoadContent(screenManager.GraphicsDevice, filepath + "b.png");
                    mBackground.Position = Position;
                }
                catch
                {
                    mBackground = null;
                }
            }
            else
            {
                string filepath = "Levels\\" + AssetName;
                base.LoadContent(theContentManager, filepath);

                try
                {
                    mBackground.LoadContent(theContentManager, filepath + "b");
                    mBackground.Position = Position;
                }
                catch
                {
                    mBackground = null;
                }
            }

            mCakeSprite.LoadContent(theContentManager, "Sprites\\Cake\\Cake");
            mCakeSprite.Scale = 1f;
            mCakeSprite.Position = Checkpoints[Checkpoints.Count - 1].Location - Vector2.UnitY * mCakeSprite.Size.Height;

            poofAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Cake\\Poof"), 0.1f, 7, false);
            idleCake = new Animation(theContentManager.Load<Texture2D>("Sprites\\Cake\\Cake"), 0.1f, 1, true);
            mCakeAnimator.PlayAnimation(idleCake);

            mDimensions = activeProfile.Graphics.Resolution;
            mCenterVector = new Vector2(mDimensions.X / 2 - 100, mDimensions.Y * 3 / 4 - 100);

            mAudio = activeProfile.Audio;
            SoundEffect.MasterVolume = mAudio.MasterVolume / 100f;
            MediaPlayer.Volume = mAudio.MasterVolume * mAudio.MusicVolume / 10000f;

            mExitReached = theContentManager.Load<SoundEffect>("Sounds\\ExitReached");
            try
            {
                mBackgroundMusic = theContentManager.Load<Song>(backgroundMusicName);
            }
            catch
            {
                mBackgroundMusic = theContentManager.Load<Song>("Sounds\\Level");
            }
            mCheckpointSound = theContentManager.Load<SoundEffect>("Sounds\\Checkpoint");

            Portals.LoadContent(theContentManager);

            Player = new Character();
            Player.LoadContent(theContentManager);
            Player.Position = Player.InitialPosition = Checkpoints[0].Location;

            foreach (Obstacle spr in Obstacles)
                spr.LoadContent(theContentManager, spr.AssetName);

            foreach (Actor spr in Actors)
                spr.LoadContent(theContentManager, spr.AssetName);

            mGameFont = theContentManager.Load<SpriteFont>("Fonts\\gamefont");

            mLoaded = true;
        }
예제 #4
0
        public SpriteEffects Update(MouseState aCurrentMouseState, bool ducking, Character theMan, Vector2 rel)
        {
            Position = theMan.Position + Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED : ARM_ANCHOR), Matrix.CreateRotationZ(theMan.Angle));

            Angle = (float)Math.Atan2(aCurrentMouseState.Y - (double)(Position.Y + rel.Y), aCurrentMouseState.X - (double)(Position.X + rel.X));

            if (aCurrentMouseState.X < Position.X + rel.X)
            {
                Position += Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED_LEFT : ARM_ANCHOR_LEFT), Matrix.CreateRotationZ(theMan.Angle));
                return SpriteEffects.FlipHorizontally;
            }
            else
                return SpriteEffects.None;
        }
예제 #5
0
        public SpriteEffects Update(MouseState aCurrentMouseState, bool ducking, Character theMan, Vector2 rel)
        {
            if(wasFlipped)
                Position = theMan.Position + Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED + ARM_ANCHOR_DUCKED_LEFT : ARM_ANCHOR + ARM_ANCHOR_LEFT), Matrix.CreateRotationZ(theMan.Angle)) ;
            else
                Position = theMan.Position + Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED : ARM_ANCHOR), Matrix.CreateRotationZ(theMan.Angle));

            bool flip = aCurrentMouseState.X < Position.X + rel.X;
            if (flip && !wasFlipped)
                Position += Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED_LEFT : ARM_ANCHOR_LEFT), Matrix.CreateRotationZ(theMan.Angle));
            else if (!flip && wasFlipped)
                Position -= Vector2.Transform((ducking ? ARM_ANCHOR_DUCKED_LEFT : ARM_ANCHOR_LEFT), Matrix.CreateRotationZ(theMan.Angle));

            wasFlipped = flip;

            Vector2 displacement =  (Position + rel + (flip ? ARM_ANCHOR_OFFSET : ARM_ANCHOR_LEFT_OFFSET));
            Angle = (float)Math.Atan2(aCurrentMouseState.Y - displacement.Y, aCurrentMouseState.X - displacement.X);

            if (flip)
            {
                Center = new Vector2(4, 15);
                mFlip = SpriteEffects.FlipVertically;
                return SpriteEffects.None;
            }
            else
            {
                Center = new Vector2(4, 4);
                mFlip = SpriteEffects.None;
                return SpriteEffects.FlipHorizontally;
            }
        }