Ejemplo n.º 1
0
        //trigger the specified event
        public static void TriggerEvent(Events _event)
        {
            if (RoomsManager.CurrentRoom == RoomsManager.Rooms.tutorial0)
            {
                switch (_event)
                {
                case Events.introMonologue:
                    MonologuesManager.monologuesRoomManagers[(int)RoomsManager.CurrentRoom].PlayMonologue(0);
                    happening             = Events.introMonologue;
                    elapsedEventsDuration = 0;
                    break;

                case Events.finalMonologue:
                    MonologuesManager.monologuesRoomManagers[(int)RoomsManager.CurrentRoom].PlayMonologue(1);
                    happening             = Events.finalMonologue;
                    elapsedEventsDuration = 0;
                    break;

                case Events.finalCutscene:
                    Game1.currentGameState = Game1.GameStates.ending;
                    CutscenesManager.cutscenes[1].ChangeSentence
                        (CutscenesManager.cutscenes[1].GetNUmOfSentences() - 1, "Your Time: " + GameStats.GetTimeString() +
                        "                                                                                            ");
                    happening             = Events.finalCutscene;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.tutorial3)
            {
                switch (_event)
                {
                case Events.keySpawns1_tutorial3:
                    CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].AddCollectableToMap(
                        new Collectable(new Point(350, 132), Collectable.ItemType.brassKey));
                    happening             = Events.keySpawns1_tutorial3;
                    elapsedEventsDuration = 0;
                    break;

                case Events.key1Collected_tutorial3:
                    eventAlreadyHappened[(int)Events.key1Collected_tutorial3] = true;
                    break;

                case Events.keySpawns2_tutorial3:
                    CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].AddCollectableToMap(
                        new Collectable(new Point(350, 46), Collectable.ItemType.silverKey));
                    happening             = Events.keySpawns2_tutorial3;
                    elapsedEventsDuration = 0;
                    break;

                case Events.key2Collected_tutorial3:
                    eventAlreadyHappened[(int)Events.key2Collected_tutorial3] = true;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.churchBellTower0)
            {
                switch (_event)
                {
                case Events.unlockDoubleJump:
                    Player.doubleJumpUnlocked = true;
                    AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.CurrentRoom].AddTempAnimatedSprite(
                        new AnimatedSprite(new Vector2(211, 926), AnimatedSprite.AnimationType.displayDoubleJumpRelic, false));
                    happening             = Events.unlockDoubleJump;
                    elapsedEventsDuration = 0;
                    break;

                case Events.showDoubleJumpScreen:
                    Game1.currentGameState = Game1.GameStates.doubleJump;
                    happening             = Events.showDoubleJumpScreen;
                    elapsedEventsDuration = 0;
                    break;

                case Events.unlockWallJump:
                    Player.wallJumpUnlocked = true;
                    AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.CurrentRoom].AddTempAnimatedSprite(
                        new AnimatedSprite(new Vector2(239, 926), AnimatedSprite.AnimationType.displayWallJumpRelic, false));
                    happening             = Events.unlockWallJump;
                    elapsedEventsDuration = 0;
                    break;

                case Events.showWallJumpScreen:
                    Game1.currentGameState = Game1.GameStates.wallJump;
                    happening             = Events.showWallJumpScreen;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.midBoss)
            {
                switch (_event)
                {
                case Events.keyAndPowerUpSpawn_midBoss:
                    CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].AddCollectableToMap(
                        new Collectable(new Point(280, 140), Collectable.ItemType.wallJump_powerup));
                    CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].AddCollectableToMap(
                        new Collectable(new Point(216, 148), Collectable.ItemType.brassKey));
                    happening             = Events.keyAndPowerUpSpawn_midBoss;
                    elapsedEventsDuration = 0;
                    break;

                case Events.pUpCollected_midBoss:
                    eventAlreadyHappened[(int)Events.pUpCollected_midBoss] = true;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.churchGroundFloor0)
            {
                switch (_event)
                {
                case Events.activateMovingPlatforms_churchGroundFloor0:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[16].active = true;
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[17].active = true;
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[18].active = true;
                    happening = Events.activateMovingPlatforms_churchGroundFloor0;
                    eventAlreadyHappened[(int)Events.resetMovingPlatforms_churchGroundFloor0] = false;
                    elapsedEventsDuration = 0;
                    break;

                case Events.resetMovingPlatforms_churchGroundFloor0:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[16].Reset(false);
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[17].Reset(false);
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[18].Reset(false);
                    happening = Events.resetMovingPlatforms_churchGroundFloor0;
                    eventAlreadyHappened[(int)Events.activateMovingPlatforms_churchGroundFloor0] = false;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.church1stFloor0)
            {
                switch (_event)
                {
                case Events.showInvisibleTiles_church1stFloor0:
                    List <AnimatedSprite> animatedSprites = new List <AnimatedSprite>();
                    for (int row = 0; row < MapsManager.maps[(int)RoomsManager.CurrentRoom].roomHeightTiles; row++)
                    {
                        for (int col = 0; col < MapsManager.maps[(int)RoomsManager.CurrentRoom].roomWidthTiles; col++)
                        {
                            if (MapsManager.maps[(int)RoomsManager.CurrentRoom].array[row, col].tileType == Tile.TileType.solidEmpty)
                            {
                                animatedSprites.Add(new AnimatedSprite(new Vector2(col * Tile.tileSize, row * Tile.tileSize),
                                                                       AnimatedSprite.AnimationType.invisibleTile));
                            }
                        }
                    }
                    AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.CurrentRoom].AddAnimatedSprites(animatedSprites);
                    if (Player.position.X < 1032 && Player.position.X >= 1000)
                    {
                        CameraManager.MoveCamera(0, new Vector2(856, MapsManager.maps[(int)RoomsManager.CurrentRoom].RoomHeightPx), 8);
                    }
                    else if (Player.position.X < 684 && Player.position.X >= 664)
                    {
                        CameraManager.MoveCamera(0, new Vector2(528, MapsManager.maps[(int)RoomsManager.CurrentRoom].RoomHeightPx), 8);
                    }
                    else if (Player.position.X < 364 && Player.position.X >= 344)
                    {
                        CameraManager.MoveCamera(0, new Vector2(204, MapsManager.maps[(int)RoomsManager.CurrentRoom].RoomHeightPx), 8);
                    }
                    happening = Events.showInvisibleTiles_church1stFloor0;
                    eventAlreadyHappened[(int)Events.hide_InvisibleTiles_church1stFloor0] = false;
                    elapsedEventsDuration = 0;
                    break;

                case Events.hide_InvisibleTiles_church1stFloor0:
                    AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.CurrentRoom].ClearAnimatedSprites();
                    CameraManager.MoveCamera(1, CameraManager.pointLocked, 8);
                    happening = Events.hide_InvisibleTiles_church1stFloor0;
                    eventAlreadyHappened[(int)Events.showInvisibleTiles_church1stFloor0] = false;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.churchAltarRoom)
            {
                switch (_event)
                {
                case Events.spawnKey_altar:
                    CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].AddCollectableToMap(
                        new Collectable(new Point(230, 400), Collectable.ItemType.silverKey));
                    eventAlreadyHappened[(int)Events.spawnKey_altar] = true;
                    break;

                case Events.keyCollected_altar:
                    eventAlreadyHappened[(int)Events.keyCollected_altar] = true;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.finalBoss)
            {
                switch (_event)
                {
                case Events.terrainCollapseFinalBoss:
                    List <int[]> tilesToRemove = new List <int[]>();
                    for (int col = 1; col < (MapsManager.maps[(int)RoomsManager.CurrentRoom].roomWidthTiles + 1) / 2; col++)
                    {
                        tilesToRemove.Add(new int[2] {
                            57, col
                        });
                        tilesToRemove.Add(new int[2] {
                            57, MapsManager.maps[(int)RoomsManager.CurrentRoom].roomWidthTiles - col - 1
                        });
                        tilesToRemove.Add(new int[2] {
                            56, col
                        });
                        tilesToRemove.Add(new int[2] {
                            56, MapsManager.maps[(int)RoomsManager.CurrentRoom].roomWidthTiles - col - 1
                        });
                    }
                    CollectablesManager.collectablesRoomManagers[(int)RoomsManager.CurrentRoom].RemoveCollectablesFromMap();
                    CameraManager.shakeForTime(eventsDuration[(int)Events.terrainCollapseFinalBoss]);
                    CameraManager.MoveCamera(0.3f, FinalBoss.fireballsCenter, 1);
                    MapsManager.maps[(int)RoomsManager.CurrentRoom].RemoveGroupOfTiles(tilesToRemove, 0.03f, 3);
                    happening             = Events.terrainCollapseFinalBoss;
                    elapsedEventsDuration = 0;
                    break;

                case Events.finalBossComesAlive:
                    CameraManager.shakeForTime(eventsDuration[(int)Events.finalBossComesAlive]);
                    FinalBoss.WakeUp();
                    happening             = Events.finalBossComesAlive;
                    elapsedEventsDuration = 0;
                    break;

                case Events.activatePlatformsFinalBoss:
                    for (int i = 0; i < 6; i++)
                    {
                        PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[i].active = true;
                    }
                    happening             = Events.activatePlatformsFinalBoss;
                    elapsedEventsDuration = 0;
                    break;

                case Events.escapeFinalBossRoom:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[6].active = true;
                    CameraManager.MoveCamera(1, FinalBoss.fireballsCenter, 1);
                    LavaGeyserManager.SweepAcross(2, 0.7f, 1, 0, 24, false);
                    happening             = Events.escapeFinalBossRoom;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.escape0)
            {
                switch (_event)
                {
                case Events.monologue_escape0:
                    MonologuesManager.monologuesRoomManagers[(int)RoomsManager.CurrentRoom].PlayMonologue(0);
                    happening             = Events.monologue_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lavaEruption1_escape0:
                    LavaGeyserManager.ShootGeyser(new float[] { MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 308 }, 0, -1000);
                    List <int[]> tilesToRemove = new List <int[]>();
                    for (int i = 0; i < 10; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            tilesToRemove.Add(new int[2] {
                                MapsManager.maps[(int)RoomsManager.Rooms.escape0].roomHeightTiles - i - 1,
                                MapsManager.maps[(int)RoomsManager.Rooms.escape0].roomWidthTiles - 40 + j
                            });
                        }
                    }
                    MapsManager.maps[(int)RoomsManager.CurrentRoom].RemoveGroupOfTiles(tilesToRemove, 0.01f, 3, 0.3f);
                    happening             = Events.lavaEruption1_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lowerFloor1_escape0:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[0].active = true;
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[1].active = true;
                    happening             = Events.lowerFloor1_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.removeFloor1_escape0:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[0].RemovePlatform();
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[1].RemovePlatform();
                    happening             = Events.removeFloor1_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lavaEruption2_escape0:
                    LavaGeyserManager.ShootGeyser(new float[]
                    {
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 664,
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 640
                    }, 0);
                    happening             = Events.lavaEruption2_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lavaEruption3_escape0:
                    LavaGeyserManager.ShootGeyser(new float[]
                    {
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1032,
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1008
                    }, 0, -600);
                    happening             = Events.lavaEruption3_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lavaEruption4_escape0:
                    LavaGeyserManager.ShootGeyser(new float[]
                    {
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 972,
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 948
                    }, 0, -600);
                    happening             = Events.lavaEruption4_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.raiseFloor2_escape0:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[2].active = true;
                    happening             = Events.raiseFloor2_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lavaEruption5_escape0:
                    LavaGeyserManager.ShootGeyser(new float[] { MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1388 }, 1.5f, -800);
                    happening             = Events.lavaEruption5_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.raiseFloor3_escape0:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.CurrentRoom].movingPlatforms[3].active = true;
                    happening             = Events.raiseFloor3_escape0;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lavaEruption6_escape0:
                    LavaGeyserManager.ShootGeyser(new float[]
                    {
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1688,
                        MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1664
                    }, 0);
                    happening             = Events.lavaEruption6_escape0;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.escape1)
            {
                switch (_event)
                {
                case Events.activatePlatform_escape1:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.Rooms.escape1].movingPlatforms[0].active = true;
                    happening             = Events.activatePlatform_escape1;
                    elapsedEventsDuration = 0;
                    break;

                case Events.raiseFloor1_escape1:
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.Rooms.escape1].movingPlatforms[1].active = true;
                    PlatformsManager.platformsRoomManagers[(int)RoomsManager.Rooms.escape1].movingPlatforms[2].active = true;
                    happening             = Events.raiseFloor1_escape1;
                    elapsedEventsDuration = 0;
                    break;

                case Events.lavaEruption1_escape1:
                    LavaGeyserManager.SweepAcross(0.2f, 0, 10, 0, 96, true);
                    happening             = Events.lavaEruption1_escape1;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
            else if (RoomsManager.CurrentRoom == RoomsManager.Rooms.escape2)
            {
                switch (_event)
                {
                case Events.lavaEruption_escape2:
                    LavaGeyserManager.ShootGeyser(new float[] { 396 }, 0f);
                    LavaGeyserManager.ShootGeyser(new float[] { 376 }, 0.2f);
                    LavaGeyserManager.ShootGeyser(new float[] { 356 }, 0.4f);
                    LavaGeyserManager.ShootGeyser(new float[] { 336 }, 0.6f);
                    LavaGeyserManager.ShootGeyser(new float[] { 316 }, 0.8f);
                    LavaGeyserManager.ShootGeyser(new float[] { 296 }, 1f);
                    LavaGeyserManager.ShootGeyser(new float[] { 276 }, 1.2f);
                    LavaGeyserManager.ShootGeyser(new float[] { 256 }, 1.4f);
                    LavaGeyserManager.ShootGeyser(new float[] { 236 }, 1.6f);
                    LavaGeyserManager.ShootGeyser(new float[] { 216 }, 1.8f);
                    LavaGeyserManager.ShootGeyser(new float[] { 196 }, 2f);
                    LavaGeyserManager.ShootGeyser(new float[] { 176 }, 2.2f);
                    LavaGeyserManager.ShootGeyser(new float[] { 156 }, 2.4f);
                    LavaGeyserManager.ShootGeyser(new float[] { 136 }, 2.6f);
                    LavaGeyserManager.ShootGeyser(new float[] { 116 }, 2.8f);
                    LavaGeyserManager.ShootGeyser(new float[] { 96 }, 3f);
                    happening             = Events.lavaEruption_escape2;
                    elapsedEventsDuration = 0;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

#if LEVEL_EDITOR
            MapsManager.Inizialize(Content.Load <Texture2D>("tiles"));
            CameraManager.Inizialize
            (
                new Texture2D[(int)RoomsManager.Rooms.total]
            {
                Content.Load <Texture2D>(@"backgrounds\tutorial0"),
                Content.Load <Texture2D>(@"backgrounds\tutorial1"),
                Content.Load <Texture2D>(@"backgrounds\tutorial2"),
                Content.Load <Texture2D>(@"backgrounds\tutorial3"),
                Content.Load <Texture2D>(@"backgrounds\tutorial4"),
                Content.Load <Texture2D>(@"backgrounds\bellTower0"),
                Content.Load <Texture2D>(@"backgrounds\bellTower1"),
                Content.Load <Texture2D>(@"backgrounds\bellTower2"),
                Content.Load <Texture2D>(@"backgrounds\midBoss"),
                Content.Load <Texture2D>(@"backgrounds\groundFloor"),
                Content.Load <Texture2D>(@"backgrounds\altarRoom"),
                Content.Load <Texture2D>(@"backgrounds\firstFloor"),
                Content.Load <Texture2D>(@"backgrounds\secondFloor"),
                Content.Load <Texture2D>(@"backgrounds\descent"),
                Content.Load <Texture2D>(@"backgrounds\finalBoss"),
                Content.Load <Texture2D>(@"backgrounds\escape0"),
                Content.Load <Texture2D>(@"backgrounds\escape1"),
                Content.Load <Texture2D>(@"backgrounds\escape2"),
            }
            );
            spriteFont = Content.Load <SpriteFont>(@"fonts\monologue");
            PlatformsManager.Inizialize(Content.Load <Texture2D>("platforms"));
            levelEditor = new LevelEditor(Content.Load <SpriteFont>(@"fonts\arial32"),
                                          Content.Load <SpriteFont>(@"fonts\arial14"),
                                          Content.Load <Texture2D>("whiteTile"));
#else
            //load the game assets here
            currentGameState = GameStates.titleScreen;
            LoadSaveManager.Inizialize();
            GameStats.Inizialize();
            Achievements.Initialize(Content.Load <SpriteFont>(@"fonts\monologue"),
                                    Content.Load <SpriteFont>(@"fonts\LiberationMono12"));
            MapsManager.Inizialize(Content.Load <Texture2D>("tiles"));
            CameraManager.Inizialize
            (
                new Texture2D[(int)RoomsManager.Rooms.total]
            {
                Content.Load <Texture2D>(@"backgrounds\tutorial0"),
                Content.Load <Texture2D>(@"backgrounds\tutorial1"),
                Content.Load <Texture2D>(@"backgrounds\tutorial2"),
                Content.Load <Texture2D>(@"backgrounds\tutorial3"),
                Content.Load <Texture2D>(@"backgrounds\tutorial4"),
                Content.Load <Texture2D>(@"backgrounds\bellTower0"),
                Content.Load <Texture2D>(@"backgrounds\bellTower1"),
                Content.Load <Texture2D>(@"backgrounds\bellTower2"),
                Content.Load <Texture2D>(@"backgrounds\midBoss"),
                Content.Load <Texture2D>(@"backgrounds\groundFloor"),
                Content.Load <Texture2D>(@"backgrounds\altarRoom"),
                Content.Load <Texture2D>(@"backgrounds\firstFloor"),
                Content.Load <Texture2D>(@"backgrounds\secondFloor"),
                Content.Load <Texture2D>(@"backgrounds\descent"),
                Content.Load <Texture2D>(@"backgrounds\finalBoss"),
                Content.Load <Texture2D>(@"backgrounds\escape0"),
                Content.Load <Texture2D>(@"backgrounds\escape1"),
                Content.Load <Texture2D>(@"backgrounds\escape2"),
            }
            );
            PlatformsManager.Inizialize(Content.Load <Texture2D>("platforms"));
            ProjectilesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            Player.Inizialize(Content.Load <Texture2D>(@"characters\player"), new Vector2(16, 185));
            RoomsManager.Inizialize();
            GameEvents.Inizialize();
            FireBallsManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            LavaGeyserManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            EnemyManager.Initialise(Content.Load <Texture2D>(@"characters\enemy1"), Content.Load <Texture2D>(@"characters\enemy2"));
            MidBoss.Initialise(Content.Load <Texture2D>(@"characters\midboss"));
            FinalBoss.Inizialize(Content.Load <Texture2D>(@"characters\finalBoss"),
                                 new Texture2D[] { Content.Load <Texture2D>(@"characters\stoneWing"),
                                                   Content.Load <Texture2D>(@"characters\healthyWing"),
                                                   Content.Load <Texture2D>(@"characters\damagedWing"),
                                                   Content.Load <Texture2D>(@"characters\deadWing") });
            CollectablesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            MonologuesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"),
                                         Content.Load <SpriteFont>(@"fonts\monologue"));
            DoorsManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            AnimatedSpritesManager.Inizialize(Content.Load <Texture2D>("animatedSprites"));
            TorchManager.Initialize(Content.Load <Texture2D>("firePot"));
            PlayerDeathManager.Initialize(Content.Load <Texture2D>(@"menus\deathScreen"),
                                          Content.Load <Texture2D>(@"menus\menuOptions"));
            MenusManager.Initialize(Content.Load <Texture2D>(@"menus\menuOptions"),
                                    new Texture2D[]
            {
                Content.Load <Texture2D>(@"menus\titleScreen"),
                Content.Load <Texture2D>(@"menus\controls"),
                Content.Load <Texture2D>(@"menus\credits"),
                Content.Load <Texture2D>(@"menus\pause"),
                Content.Load <Texture2D>(@"menus\quit"),
                Content.Load <Texture2D>(@"menus\doubleJump"),
                Content.Load <Texture2D>(@"menus\wallJump"),
                Content.Load <Texture2D>(@"menus\achievements"),
            });
            CutscenesManager.Initialize(Content.Load <Texture2D>(@"characters\enemy1"),
                                        Content.Load <Texture2D>(@"characters\player"),
                                        Content.Load <SpriteFont>(@"fonts\monologue"));
            SoundEffects.Initialise
            (
                //Player Sound Effects
                Content.Load <SoundEffect>(@"sounds\pJump"),
                Content.Load <SoundEffect>(@"sounds\pShoot"),
                Content.Load <SoundEffect>(@"sounds\pHurt"),
                Content.Load <SoundEffect>(@"sounds\pickup"),

                //Enemy Sound Effects
                Content.Load <SoundEffect>(@"sounds\enemyAttack"),
                Content.Load <SoundEffect>(@"sounds\enemyHurt"),
                Content.Load <SoundEffect>(@"sounds\e2Attack"),

                //Midboss Sound Effects
                Content.Load <SoundEffect>(@"sounds\midMove"),
                Content.Load <SoundEffect>(@"sounds\midAttack"),
                Content.Load <SoundEffect>(@"sounds\midHurt"),

                Content.Load <SoundEffect>(@"sounds\finAttack"),
                Content.Load <SoundEffect>(@"sounds\finHurt"),
                Content.Load <SoundEffect>(@"sounds\finAwaken"),
                Content.Load <SoundEffect>(@"sounds\finRecover"),
                Content.Load <Song>(@"sounds\finalBossMusic")
            );
            gameInitialized = true;
            Zoom1();
#endif
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            currentKeyboard   = Keyboard.GetState();
            currentGamePad    = GamePad.GetState(PlayerIndex.One);
            currentMouseState = Mouse.GetState();
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            //update logic here
#if LEVEL_EDITOR
            levelEditor.Update(currentMouseState, previousMouseState, tilesPerRow, infoBoxHeightPx);
            CameraManager.Update(elapsedTime);
            PlatformsManager.platformsRoomManagers[levelEditor.currentRoomNumber].Update(elapsedTime);
#else
            //update only relevant classes depending on the state of the game
            switch (currentGameState)
            {
            case GameStates.titleScreen:
                if (!gameInitialized)
                {
                    LoadContent();
                }
                MenusManager.menus[(int)MenusManager.MenuType.titleScreen].Update();
                break;

            case GameStates.loadGame:
                if (LoadSaveManager.LoadGame())
                {
                    currentGameState = GameStates.playing;
                }
                else
                {
                    currentGameState = GameStates.titleScreen;
                }
                break;

            case GameStates.controls:
                MenusManager.menus[(int)MenusManager.MenuType.controls].Update();
                break;

            case GameStates.achievements:
                MenusManager.menus[(int)MenusManager.MenuType.achievements].Update();
                break;

            case GameStates.credits:
                MenusManager.menus[(int)MenusManager.MenuType.credits].Update();
                break;

            case GameStates.intro:
                if (CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.intro].active)
                {
                    CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.intro].Update(elapsedTime);
                }
                else
                {
                    currentGameState = GameStates.playing;
                }
                break;

            case GameStates.playing:
                GameStats.Update(elapsedTime);
                if ((currentKeyboard.IsKeyDown(Keys.P) && !previousKeyboard.IsKeyDown(Keys.P)) ||
                    (currentKeyboard.IsKeyDown(Keys.M) && !previousKeyboard.IsKeyDown(Keys.M)) ||
                    (currentGamePad.Buttons.Start == ButtonState.Pressed && previousGamePad.Buttons.Start == ButtonState.Released))
                {
                    currentGameState = GameStates.pause;
                    break;
                }
                RoomsManager.Update(elapsedTime);
                Player.Update(elapsedTime);
                ProjectilesManager.Update(elapsedTime);
                GameEvents.Update(elapsedTime);
                Collisions.Update(elapsedTime);
                CollectablesManager.Update(elapsedTime);
                break;

            case GameStates.pause:
                if ((currentKeyboard.IsKeyDown(Keys.P) && !previousKeyboard.IsKeyDown(Keys.P)) ||
                    (currentKeyboard.IsKeyDown(Keys.M) && !previousKeyboard.IsKeyDown(Keys.M)) ||
                    (currentGamePad.Buttons.Start == ButtonState.Pressed && previousGamePad.Buttons.Start == ButtonState.Released))
                {
                    MenusManager.menus[(int)MenusManager.MenuType.pause].Reset();
                    currentGameState = GameStates.playing;
                    break;
                }
                MenusManager.menus[(int)MenusManager.MenuType.pause].Update();
                break;

            case GameStates.confirmQuit:
                MenusManager.menus[(int)MenusManager.MenuType.confirmQuit].Update();
                if (currentGameState == GameStates.titleScreen)
                {
                    gameInitialized = false;
                }
                break;

            case GameStates.dead:
                GameStats.Update(elapsedTime);
                PlayerDeathManager.Update(elapsedTime);
                break;

            case GameStates.ending:
                if (!CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.ending].active)
                {
                    LoadSaveManager.SaveHighScores(new AchievementsSaveData
                                                       (true,
                                                       (GameStats.deathsCount == 0) || Achievements.noDeath,
                                                       (GameStats.hitsCount == 0) || Achievements.noHits,
                                                       ((GameStats.gameTime < Achievements.bestTime) || (Achievements.bestTime == 0)) ? GameStats.gameTime : Achievements.bestTime
                                                       ));;
                    LoadSaveManager.DeleteSaveFile();
                    currentGameState = GameStates.achievements;
                    gameInitialized  = false;
                }
                CutscenesManager.cutscenes[(int)CutscenesManager.CutsceneType.ending].Update(elapsedTime);
                break;

            case GameStates.quit:
                Exit();
                break;

            case GameStates.doubleJump:
                MenusManager.menus[(int)MenusManager.MenuType.doubleJump].Update();
                break;

            case GameStates.wallJump:
                MenusManager.menus[(int)MenusManager.MenuType.wallJump].Update();
                break;
            }
#endif
            previousKeyboard   = currentKeyboard;
            previousGamePad    = currentGamePad;
            previousMouseState = currentMouseState;
            base.Update(gameTime);
        }
Ejemplo n.º 4
0
        public void ApplySaveData()
        {
            GameStats.Inizialize(gameTime, deathsCount, hitsCount);
            FinalBoss.Dead            = finalBossDead;
            MidBoss.Dead              = midBossDead;
            RoomsManager.CurrentRoom  = (RoomsManager.Rooms)currentRoom;
            RoomsManager.PreviousRoom = (RoomsManager.Rooms)previousRoom;
            Player.healthPoints       = health;
            Player.position           = new Vector2(playerPosition[0], playerPosition[1]);
            if (eventAlreadyHappened[(int)GameEvents.Events.unlockDoubleJump])
            {//enable double jump if it was already unlocked
                Player.doubleJumpUnlocked = true;
                AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.Rooms.churchBellTower0].AddTempAnimatedSprite(
                    new AnimatedSprite(new Vector2(211, 926), AnimatedSprite.AnimationType.displayDoubleJumpRelic, false));
            }
            if (eventAlreadyHappened[(int)GameEvents.Events.unlockWallJump])
            {//enable wall jump if it was already unlocked
                Player.wallJumpUnlocked = true;
                AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.Rooms.churchBellTower0].AddTempAnimatedSprite(
                    new AnimatedSprite(new Vector2(239, 926), AnimatedSprite.AnimationType.displayWallJumpRelic, false));
            }
            foreach (CollectablesRoomManager r in CollectablesManager.collectablesRoomManagers)
            {//remove collectables already collected
                for (int i = 0; i < r.collectables.Count; i++)
                {
                    bool delete = true;
                    foreach (int j in itemsOnMap)
                    {
                        if (r.collectables[i].ID == j || r.collectables[i].ID == -1)
                        {
                            delete = false;
                            break;
                        }
                    }
                    if (delete)
                    {
                        r.collectables.RemoveAt(i);
                        i--;
                    }
                }
            }
            CollectablesManager.collectedItems.Clear();
            foreach (int i in itemsInInventory)
            {//place items in inventory
                CollectablesManager.AddToInventory(new Collectable(Point.Zero, (Collectable.ItemType)i));
            }
            int room = 0;

            foreach (DoorsRoomManager r in DoorsManager.doorsRoomManagers)
            {//remove doors that have been opend already
                for (int i = 0; i < r.doors.Count; i++)
                {
                    bool delete = true;
                    foreach (int j in closedDoor)
                    {
                        if (r.doors[i].ID == j)
                        {
                            delete = false;
                            break;
                        }
                    }
                    if (delete)
                    {
                        r.doors[i].OpenDoor(room);
                        r.doors.RemoveAt(i);
                        i--;
                    }
                }
                room++;
            }
            GameEvents.eventAlreadyHappened = eventAlreadyHappened;
            PlayerDeathManager.ResetVariables();
            CameraManager.SwitchCamera(RoomsManager.CurrentRoom);
        }