public AnimatedSprite(GameScene newScene, Dictionary<string, Animation> dictionary)
        {
            thisScene = newScene;

            Animations = new Dictionary<string, Animation>();
            AddAnimations(dictionary);
        }
        // Static constructor instantiates the lists required for sweep and prune collision detection.
        public CollisionDetection(GameScene newScene)
        {
            thisScene = newScene;

            axisList = new List<ICollidable>();
            sleepingList = new List<ICollidable>();
            activeList = new List<ICollidable>();
        }
        public ScrollingBackground(GameScene newScene, Vector2 newPosition)
        {
            thisScene = newScene;

            Texture = thisScene.BackgroundTexture;
            Position = newPosition;

            color = thisScene.SequenceColors[thisScene.CurrentSequence];
        }
Beispiel #4
0
        public EvilPlayer(GameScene scene, Vector2 newPos)
        {
            thisScene = scene;
            Position = newPos;

            Texture = thisScene.PlayerTexture;
            FrameWidth = 48;
            FrameHeight = 48;

            Initialize();
        }
        public SequenceCrystal(GameScene newScene, Vector2 newPos)
        {
            thisScene = newScene;
            color = thisScene.SequenceColors[thisScene.CurrentSequence + 1];
            Position = newPos;

            FrameWidth = 48;
            FrameHeight = 48;

            Initialize();
        }
Beispiel #6
0
        public Block(GameScene scene, Vector2 newPos)
        {
            // Initialize fields.
            thisScene = scene;
            Position = newPos;
            Texture = thisScene.BlockTexture;

            color = thisScene.SequenceColors[thisScene.CurrentSequence];

            // Run initialization logic.
            Initialize();
        }
Beispiel #7
0
        public SequenceText(GameScene newScene, string text, Vector2 position, float leftLimit, float rightLimit, float highSpeed, float lowSpeed)
        {
            thisScene = newScene;
            thisText = text;
            Position = position;

            maxSpeed = highSpeed;
            minSpeed = lowSpeed;

            leftBarrier = leftLimit;
            rightBarrier = rightLimit;

            velocity = highSpeed;
        }
Beispiel #8
0
        public Animation(GameScene newScene, Texture2D tex, int width, int height, int[] frames, float framesPerSecond, bool looping)
        {
            Texture = tex;
            Frames = frames;

            thisScene = newScene;

            if(Frames.Length > 0)
                CurrentFrame = Frames[0];

            FrameRate = 1 / framesPerSecond;
            Looping = looping;

            frameWidth = width;
            frameHeight = height;
        }
        // Store the last gap to retroactively add danger to the gap if need be (this allows prediction of player jumping paths)
        //private Rectangle lastGap;
        public WorldGenerator(GameScene newScene)
        {
            thisScene = newScene;
            rand = new Random();

            // Randomize the rules for platform generation in this world.
            gapChance = (float)(rand.NextDouble() * (MAX_GAP_CHANCE - MIN_GAP_CHANCE)) + MIN_GAP_CHANCE;

            minGapWidth = (float)(rand.NextDouble() * (MAX_MIN_GAP_WIDTH - MIN_MIN_GAP_WIDTH)) + MIN_MIN_GAP_WIDTH;
            maxGapWidth = (float)(rand.NextDouble() * (MAX_MAX_GAP_WIDTH - MIN_MAX_GAP_WIDTH)) + MIN_MAX_GAP_WIDTH;

            minPlatformWidth = rand.Next(MIN_MIN_PLATFORM_WIDTH, MAX_MIN_PLATFORM_WIDTH + 1);
            maxPlatformWidth = rand.Next(MIN_MAX_PLATFORM_WIDTH, MAX_MAX_PLATFORM_WIDTH + 1);

            minPlatformHeight = rand.Next(MIN_MIN_PLATFORM_HEIGHT, MAX_MIN_PLATFORM_HEIGHT + 1);
            maxPlatformHeight = rand.Next(MIN_MAX_PLATFORM_HEIGHT, MAX_MAX_PLATFORM_HEIGHT + 1);

            verticalPlatformChance = (float)(rand.NextDouble() * (MAX_VERTICAL_PLATFORM_CHANCE - MIN_VERTICAL_PLATFORM_CHANCE)) + MIN_VERTICAL_PLATFORM_CHANCE;
        }
Beispiel #10
0
 public AnimatedSprite(GameScene newScene)
 {
     thisScene = newScene;
     Animations = new Dictionary<string, Animation>();
 }
Beispiel #11
0
        // Creates a platform, which is nothing more than a cohesive set of blocks
        public Platform(GameScene newScene, Vector2 position, int width, int height)
        {
            xWidth = width;
            thisScene = newScene;
            blocks = new List<Block>();
            blockGrid = new Block[height, width];

            rand = new Random();

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Block newBlock = new Block(thisScene, new Vector2(position.X + (x * 32), position.Y + (y * 32)));
                    blockGrid[y, x] = newBlock;
                    blocks.Add(newBlock);
                }
            }

            if (thisScene.CurrentSequence < 11)
            {
                // Check for special item spawns...

                // Check to see if a sequence crystal should spawn
                if (thisScene.sequenceLength > thisScene.sequenceCrystalMinLength && !thisScene.crystalAppeared)
                {
                    // Store the probability of spawn based on the current length of the sequence
                    float probability = (thisScene.sequenceLength - thisScene.sequenceCrystalMinLength) / (thisScene.sequenceCrystalMaxLength - thisScene.sequenceCrystalMinLength);

                    if (rand.NextDouble() < probability)
                    {
                        // Spawn a sequence crystal in the middle of the platform
                        new SequenceCrystal(thisScene, new Vector2(MiddleOfPlatform() - 24, Y - 48));

                        // Remove all falling blocks from the platform.
                    }
                }
                else
                {
                    // Check to see if the platform generated should roll for falling blocks
                    if (thisScene.CurrentSequence >= 3)
                    {
                        float probability = (.05f * thisScene.CurrentSequence);
                        if (rand.NextDouble() < probability)
                        {
                            // The platform rolls for falling blocks now.
                            for (int x = 0; x < xWidth; x++)
                            {
                                if (rand.NextDouble() < probability)
                                {
                                    // The block is a falling block.
                                    blockGrid[0, x].FallingBlock = true;
                                    blockGrid[0, x].fallTime = 1.7f - ((thisScene.CurrentSequence - 3) * .2f);
                                    blockGrid[0, x].linkedBlocks = new List<Block>();

                                    if (height > 1)
                                    {
                                        for (int y = 1; y < height; y++)
                                        {
                                            blockGrid[0, x].linkedBlocks.Add(blockGrid[y, x]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // It's literally the 11th hour, so create the final "boss"
                thisScene.evilPlayer = new EvilPlayer(thisScene, new Vector2(X + 2000, Y - thisScene.player.Hitbox.Height));
                thisScene.player.SetPosition(new Vector2(X + 500, Y - thisScene.player.Hitbox.Height));
            }
        }
Beispiel #12
0
 public Gravity(GameScene gameScene)
 {
     thisScene = gameScene;
 }