Пример #1
0
        public override void SelectionMade()
        {
            string id = items[selectedIndex].Item as string;
            Entity e  = EntityFactory.EntityFromId(id, 0, 0);

            Zone.AddEntity(e);
        }
        public static void DropFromInventory(Item itemComp)
        {
            Entity    entityToBeDropped = itemComp.Owner;
            Inventory inventory         = itemComp.ContainingInventory;

            // clone the dropping entity's position
            Position dropperPos = inventory.Owner.GetComponent <Position>();
            Position thisPos    = new Position();

            thisPos.Pos = dropperPos.Pos;
            entityToBeDropped.AddComponent(thisPos);

            // remove the entity from the inventory that contains it
            inventory.Contents.Remove(entityToBeDropped);

            // add it to the zone if the zone does not already contain it
            if (!Zone.Entities.Contains(entityToBeDropped))
            {
                Zone.AddEntity(entityToBeDropped);
            }

            itemComp.ContainingInventory = null;
            itemComp.OnGround            = true;
        }
Пример #3
0
        /// <summary>
        /// Switches a player from their current zone to one specified.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="zone">The zone to switch the player into</param>
        /// <param name="position"></param>
        public void SwitchToZoneAndPosition(Player player, Zone zone, Vector2 position)
        {
            if(zone == null)
                throw new ArgumentNullException("The zone cannot be null");

            // Remove our player from here
            player.Zone.RemoveEntity(player);

            // Add them to the new zone and move them
            player.Position = position;
            zone.AddEntity(player);
        }
Пример #4
0
 public void MoveEntity(Entity entity, Zone newZone)
 {
     lock (zoneMngrLock)
     {
         if (entity_lookup.ContainsKey(entity.Id))
         {
             Zone z = entity_lookup[entity.Id];
             if (z != newZone)
             {
                 z.RemoveEntity(entity);
                 newZone.AddEntity(entity);
                 entity.Zone = newZone.Id;
                 entity_lookup[entity.Id] = newZone;
             }
         }
         else
         {
             newZone.AddEntity(entity);
             entity.Zone = newZone.Id;
             entity_lookup.Add(entity.Id, newZone);
         }
     }
 }