Пример #1
0
 /// <summary>
 /// Adds the given entity into the list of entities, and adjusts the player location if a player object is added
 /// </summary>
 public void AddEntity(Entity.Entity e)
 {
     e.currentWorld = world;
     Console.WriteLine("Added Entity: " + e.GetType().FullName + " (#" + e.GetHashCode() + ")");
     if (e is Player)
     {
         if (playerLoc == -1)
         {
             playerLoc = 0;
             entities.Insert(0, e);
         }
         else
         {
             entities[playerLoc] = e;
         }
     }
     else
     {
         if (e is NPC)
         {
             civilianCount++;
         }
         // entities.Add(e);
         entitiesToAdd.Add(e);
     }
 }
Пример #2
0
        public void Update(GameTime time)
        {
            for (int x = 0; x < entitiesToAdd.Count; x++)
            {
                entities.Add(entitiesToAdd[x]);
                entitiesToAdd.Remove(entitiesToAdd[x]);
            }
            for (int x = 0; x < entities.Count; x++)
            {
                Entity.Entity e = entities[x];
                if (e.markForDelete)
                {
                    if (e is Player)
                    {
                        Game1.state = GameState.Menu;
                        (Controls.guiElements["mainMenu"] as Menu).GameOver((e as Player).Cash, (e as Player).QuestPoints);

                        (e as Player).health = (e as Player).maxHealth;
                        Game1.Instance.worldManager.Reset();
                        e.markForDelete = false;
                        entities.Remove(e);
                    }
                    else
                    {
                        entities.Remove(e);
                    }
                    if (e is NPC)
                    {
                        civilianCount--;
                    }
                }
                else
                {
                    e.Update(time, this);
                }
            }
        }