Example #1
0
 public void Update(float elapsedTime)
 {
     for (int i = collectables.Count - 1; i >= 0; i--)
     {
         if (collectables[i].Collected)
         {
             if (collectables[i].type == Collectable.ItemType.heart)
             {
                 Player.IncreaseHealth();
             }
             else
             {
                 CollectablesManager.AddToInventory(collectables[i]);
             }
             collectables.RemoveAt(i);
         }
         else
         {
             collectables[i].Update(elapsedTime);
         }
     }
 }
Example #2
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);
        }