예제 #1
0
파일: Door.cs 프로젝트: aaaivan/999AD
 public void Update()
 {
     //if the player is within the interaction rectangle of the door
     //and they have the proper key, then open the door
     if (InteractionRectangle.Intersects(Player.CollisionRectangle) &&
         CollectablesManager.TryRemoveFromInventory(key, new Vector2(DrawRectangle.Center.X, DrawRectangle.Center.Y)))
     {
         OpenDoor((int)RoomsManager.CurrentRoom);
         AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.CurrentRoom].AddTempAnimatedSprite(
             new AnimatedSprite(new Vector2(position.X, position.Y), AnimatedSprite.GetDoorAnimation(textureType)));
     }
 }
예제 #2
0
파일: GameEvents.cs 프로젝트: aaaivan/999AD
        //this function check some condition to determine whether an event should be triggered
        static void eventHandler(float elapsedTime)
        {
            switch (RoomsManager.CurrentRoom)
            {
            case RoomsManager.Rooms.tutorial0:
                if (!eventAlreadyHappened[(int)Events.introMonologue])
                {
                    TriggerEvent(Events.introMonologue);
                }
                else if (FinalBoss.Dead && Player.position.X < 200 && Player.position.Y <= 176 - Player.height &&
                         !eventAlreadyHappened[(int)Events.finalMonologue])
                {
                    TriggerEvent(Events.finalMonologue);
                }
                else if (eventAlreadyHappened[(int)Events.finalMonologue] && !MonologuesManager.MonologuePlaying)
                {
                    TriggerEvent(Events.finalCutscene);
                }
                break;

            case RoomsManager.Rooms.tutorial3:
                if (EnemyManager.enemyRoomManagers[(int)RoomsManager.CurrentRoom].enemiesType1[0].Dead &&
                    !eventAlreadyHappened[(int)Events.keySpawns1_tutorial3])
                {
                    TriggerEvent(Events.keySpawns1_tutorial3);
                }
                else if (eventAlreadyHappened[(int)Events.keySpawns1_tutorial3] && !eventAlreadyHappened[(int)Events.key1Collected_tutorial3] &&
                         CollectablesManager.collectedItems.Count == 1)
                {
                    TriggerEvent(Events.key1Collected_tutorial3);
                }
                else if (EnemyManager.enemyRoomManagers[(int)RoomsManager.CurrentRoom].enemiesType1[1].Dead &&
                         !eventAlreadyHappened[(int)Events.keySpawns2_tutorial3])
                {
                    TriggerEvent(Events.keySpawns2_tutorial3);
                }
                else if (eventAlreadyHappened[(int)Events.keySpawns2_tutorial3] && !eventAlreadyHappened[(int)Events.key2Collected_tutorial3] &&
                         CollectablesManager.collectedItems.Count == 1)
                {
                    TriggerEvent(Events.key2Collected_tutorial3);
                }
                break;

            case RoomsManager.Rooms.churchBellTower0:
                if (Player.CollisionRectangle.Intersects(new Rectangle(196, 908, 96, 76)) &&
                    CollectablesManager.TryRemoveFromInventory(Collectable.ItemType.doubleJump_powerup, new Vector2(223, 938)) &&
                    !eventAlreadyHappened[(int)Events.unlockDoubleJump])
                {
                    TriggerEvent(Events.unlockDoubleJump);
                }
                else if (eventAlreadyHappened[(int)Events.unlockDoubleJump] && !eventAlreadyHappened[(int)Events.showDoubleJumpScreen])
                {
                    TriggerEvent(Events.showDoubleJumpScreen);
                }
                else if (Player.CollisionRectangle.Intersects(new Rectangle(196, 908, 96, 76)) &&
                         CollectablesManager.TryRemoveFromInventory(Collectable.ItemType.wallJump_powerup, new Vector2(251, 938)) &&
                         !eventAlreadyHappened[(int)Events.unlockWallJump])
                {
                    TriggerEvent(Events.unlockWallJump);
                }
                else if (eventAlreadyHappened[(int)Events.unlockWallJump] && !eventAlreadyHappened[(int)Events.showWallJumpScreen])
                {
                    TriggerEvent(Events.showWallJumpScreen);
                }
                break;

            case RoomsManager.Rooms.midBoss:
                if (MidBoss.Dead && !eventAlreadyHappened[(int)Events.keyAndPowerUpSpawn_midBoss])
                {
                    TriggerEvent(Events.keyAndPowerUpSpawn_midBoss);
                }
                else if (eventAlreadyHappened[(int)Events.keyAndPowerUpSpawn_midBoss] && CollectablesManager.collectedItems.Count > 0)
                {
                    if (!eventAlreadyHappened[(int)Events.pUpCollected_midBoss])
                    {
                        foreach (Collectable collectable in CollectablesManager.collectedItems)
                        {
                            if (collectable.type == Collectable.ItemType.wallJump_powerup)
                            {
                                TriggerEvent(Events.pUpCollected_midBoss);
                                break;
                            }
                        }
                    }
                }
                break;

            case RoomsManager.Rooms.churchGroundFloor0:
                if (Player.position.X >= 88 - Player.width && Player.position.Y < 178)
                {
                    if (Player.IsOnMovingPlatform && !eventAlreadyHappened[(int)Events.activateMovingPlatforms_churchGroundFloor0])
                    {
                        TriggerEvent(Events.activateMovingPlatforms_churchGroundFloor0);
                    }
                }
                else if (!eventAlreadyHappened[(int)Events.resetMovingPlatforms_churchGroundFloor0])
                {
                    TriggerEvent(Events.resetMovingPlatforms_churchGroundFloor0);
                }
                break;

            case RoomsManager.Rooms.church1stFloor0:
                if ((Player.position.X < 1032 && Player.position.X >= 1000) ||
                    (Player.position.X < 684 && Player.position.X >= 664) ||
                    (Player.position.X < 364 && Player.position.X >= 344 && Player.position.Y > 106))
                {
                    if (!eventAlreadyHappened[(int)Events.showInvisibleTiles_church1stFloor0])
                    {
                        TriggerEvent(Events.showInvisibleTiles_church1stFloor0);
                    }
                }
                else if (!eventAlreadyHappened[(int)Events.hide_InvisibleTiles_church1stFloor0])
                {
                    TriggerEvent(Events.hide_InvisibleTiles_church1stFloor0);
                }
                break;

            case RoomsManager.Rooms.churchAltarRoom:
                if (TorchManager.AllTorchesUnlit() && !eventAlreadyHappened[(int)Events.spawnKey_altar])
                {
                    TriggerEvent(Events.spawnKey_altar);
                }
                else if (eventAlreadyHappened[(int)Events.spawnKey_altar] &&
                         !eventAlreadyHappened[(int)Events.keyCollected_altar] &&
                         CollectablesManager.collectedItems.Count > 0)
                {
                    foreach (Collectable c in CollectablesManager.collectedItems)
                    {
                        if (c.type == Collectable.ItemType.silverKey)
                        {
                            TriggerEvent(Events.keyCollected_altar);
                            break;
                        }
                    }
                }
                break;

            case RoomsManager.Rooms.finalBoss:
                if (Player.position.X <= 200 && !eventAlreadyHappened[(int)Events.terrainCollapseFinalBoss])
                {
                    TriggerEvent(Events.terrainCollapseFinalBoss);
                }
                if (eventAlreadyHappened[(int)Events.terrainCollapseFinalBoss] && !eventAlreadyHappened[(int)Events.finalBossComesAlive])
                {
                    TriggerEvent(Events.finalBossComesAlive);
                }
                if (eventAlreadyHappened[(int)Events.finalBossComesAlive] && !eventAlreadyHappened[(int)Events.activatePlatformsFinalBoss])
                {
                    TriggerEvent(Events.activatePlatformsFinalBoss);
                }
                if (FinalBoss.Dead && !eventAlreadyHappened[(int)Events.escapeFinalBossRoom])
                {
                    TriggerEvent(Events.escapeFinalBossRoom);
                }
                break;

            case RoomsManager.Rooms.escape0:
                if (Player.position.X < 1752 && !eventAlreadyHappened[(int)Events.monologue_escape0])
                {
                    TriggerEvent(Events.monologue_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 248 && !eventAlreadyHappened[(int)Events.lavaEruption1_escape0])
                {
                    TriggerEvent(Events.lavaEruption1_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 416 && !eventAlreadyHappened[(int)Events.lowerFloor1_escape0])
                {
                    TriggerEvent(Events.lowerFloor1_escape0);
                }
                if (!PlatformsManager.platformsRoomManagers[(int)RoomsManager.Rooms.escape0].movingPlatforms[1].active &&
                    !eventAlreadyHappened[(int)Events.removeFloor1_escape0] && eventAlreadyHappened[(int)Events.lowerFloor1_escape0])
                {
                    TriggerEvent(Events.removeFloor1_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lowerFloor1_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption2_escape0])
                {
                    TriggerEvent(Events.lavaEruption2_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lavaEruption2_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption3_escape0])
                {
                    TriggerEvent(Events.lavaEruption3_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lavaEruption3_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption4_escape0])
                {
                    TriggerEvent(Events.lavaEruption4_escape0);
                }
                if (eventAlreadyHappened[(int)Events.lowerFloor1_escape0] && !eventAlreadyHappened[(int)Events.raiseFloor2_escape0])
                {
                    TriggerEvent(Events.raiseFloor2_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1352 && !eventAlreadyHappened[(int)Events.lavaEruption5_escape0])
                {
                    TriggerEvent(Events.lavaEruption5_escape0);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape0].RoomWidthtPx - 1448 && !eventAlreadyHappened[(int)Events.raiseFloor3_escape0])
                {
                    TriggerEvent(Events.raiseFloor3_escape0);
                }
                if (eventAlreadyHappened[(int)Events.raiseFloor3_escape0] && !eventAlreadyHappened[(int)Events.lavaEruption6_escape0])
                {
                    TriggerEvent(Events.lavaEruption6_escape0);
                }
                break;

            case RoomsManager.Rooms.escape1:
                if (Player.IsOnMovingPlatform && !eventAlreadyHappened[(int)Events.activatePlatform_escape1])
                {
                    TriggerEvent(Events.activatePlatform_escape1);
                }
                if (Player.position.X < MapsManager.maps[(int)RoomsManager.Rooms.escape1].RoomWidthtPx - 881 && !eventAlreadyHappened[(int)Events.raiseFloor1_escape1])
                {
                    TriggerEvent(Events.raiseFloor1_escape1);
                }
                if (Player.position.X < 104 && !eventAlreadyHappened[(int)Events.lavaEruption1_escape1])
                {
                    TriggerEvent(Events.lavaEruption1_escape1);
                }
                break;

            case RoomsManager.Rooms.escape2:
                if (Player.position.X + Player.width < 424)
                {
                    if (!eventAlreadyHappened[(int)Events.lavaEruption_escape2])
                    {
                        TriggerEvent(Events.lavaEruption_escape2);
                    }
                    else
                    {
                        eventAlreadyHappened[(int)Events.lavaEruption_escape2] = false;
                    }
                }
                break;
            }
        }