Ejemplo n.º 1
0
 public static void SendEvent(AbstractEvent abstractEvent)
 {
     if (currentLevel.IsEventActivated == false)
     {
         currentLevel.RegisterEvent(abstractEvent);
     }
 }
Ejemplo n.º 2
0
 public virtual void RegisterEvent(AbstractEvent abstractEvent)
 {
     this.abstractEvent    = abstractEvent;
     this.IsEventActivated = true;
     abstractEvent.SetEventLists(this, characterList, enemyList, collectableList,
                                 itemList, terrainList, controllerList, itemSetList,
                                 camera, background, hud, music, invincibleMusic);
 }
Ejemplo n.º 3
0
        public virtual void Update()
        {
            //Update all objects' positions, then check for collisions.
            //Unnecessary collision checks are skipped.
            if (IsEventActivated && abstractEvent.IsFinished == false)
            {
                abstractEvent.Update();
                return;
            }
            else
            {
                abstractEvent    = null;
                IsEventActivated = false;
            }

            foreach (AbstractCharacter character in characterList)
            {
                character.Update();
            }
            foreach (IEnemy enemy in enemyList)
            {
                enemy.Update();
            }
            foreach (ICollectable collectable in collectableList)
            {
                collectable.Update();
            }
            foreach (IItem item in itemList)
            {
                item.Update();

                if (item is Door && ((Door)item).ShouldSwitchToNextLevel)
                {
                    TransitionType = ((Door)item).MessageToReceivers;
                    NextLevel      = ((Door)item).NextLevel;
                }
            }
            foreach (ItemSet itemSet in itemSetList)
            {
                itemSet.Update();

                foreach (IReceiver receiver in itemSet.Receivers)
                {
                    if (receiver is Door && ((Door)receiver).ShouldSwitchToNextLevel)
                    {
                        TransitionType = ((Door)receiver).MessageToReceivers;
                        NextLevel      = ((Door)receiver).NextLevel;
                    }
                }

                foreach (ISender sender in itemSet.Senders)
                {
                    if (sender is Door && ((Door)sender).ShouldSwitchToNextLevel)
                    {
                        TransitionType = ((Door)sender).MessageToReceivers;
                        NextLevel      = ((Door)sender).NextLevel;
                    }
                }
            }
            foreach (AbstractTerrain terrain in terrainList)
            {
                terrain.Update();
            }

            camera.Update();
        }