Ejemplo n.º 1
0
 public void AddEscapee(Escapee e)
 {
     Escapees.Add(e);
     e.SetupGraphics(Game);
     e.SwitchGraphic("run");
     e.Collided += new EventHandler<CollisionEventArgs>(Escapee_Collide);
     collisions.AddEntity(e);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            TimeOnRound += gameTime.ElapsedGameTime.Milliseconds;

            if (RemainingParticipants > 0)
            {
                NextWaveTimer += gameTime.ElapsedGameTime.Milliseconds;

                if ((NextWaveTimer / 1000f) >= Current.WaveInterval)
                {
                    Escapee e;

                    foreach (Vector2 spawn in spawnLocations)
                    {
                        e = new Escapee { Position = spawn, Alive = true, Free = false, Tint = Escapee.Tints[rand.Next(0, 3)] };
                        escapeeManager.AddEscapee(e);
                        currentEscapees.Add(e);

                        RemainingParticipants--;

                        if (RemainingParticipants == 0)
                            break;
                    }

                    NextWaveTimer = 0;
                }
            }

            currentEscapees.RemoveAll(new Predicate<Escapee>((x) => !x.InPlay));

            if (ParticipantsInPlay == 0 && RemainingParticipants == 0 && Next != null)
            {
                Current = Next;
                next = null;
                NextWaveTimer = 0;
                RemainingParticipants = Current.ParticipantCount;

                if (RoundChanged != null)
                    RoundChanged(this, null);
            }

            base.Update(gameTime);
        }