Ejemplo n.º 1
0
 public void Kill()
 {
     KillInternal();
     GameManager.EntityManager.UnloadEntity(GetLoadedEntity());
     if (!Inventory.IsEmpty)
     {
         LootSack loot = new LootSack(Vec2i.FromVector3(GetLoadedEntity().transform.position));
         loot.GetInventory().AddAll(Inventory);
         GameManager.WorldManager.AddNewObject(loot);
     }
     GameManager.EventManager.InvokeNewEvent(new EntityDeath(this));
 }
Ejemplo n.º 2
0
    public void Kill()
    {
        KillInternal();
        IsAlive = false;
        EntityManager.Instance.UnloadEntity(GetLoadedEntity(), killEntity: true);
        if (!Inventory.IsEmpty)
        {
            LootSack loot = new LootSack(Vec2i.FromVector3(GetLoadedEntity().transform.position).AsVector3());
            loot.GetInventory().AddAll(Inventory);
            GameManager.WorldManager?.AddNewObject(loot);
        }

        EventManager.Instance.InvokeNewEvent(new EntityDeath(this));
        Debug.Log("Entity  " + this + " is killed");
    }
Ejemplo n.º 3
0
    public Inventory GetSecondInventory()
    {
        if (SecondInventory.Inventory == null)
        {
            Vec2i playerPos = Vec2i.FromVector2(Player.Position2);
            //Get current object on player position
            WorldObjectData currentSpace = GameManager.WorldManager.World.GetWorldObject(playerPos);
            if (currentSpace == null)
            {
                //if there is no object here, we create one
                LootSack lootsack = new LootSack(playerPos);
                GameManager.WorldManager.AddNewObject(lootsack);
                SecondInventory.SetInventory(lootsack.GetInventory());

                SecondInventory.gameObject.SetActive(true);

                return(SecondInventory.Inventory);
            }
            //If current tile is taken, we check all the surrounding tiles
            Vec2i[] surrounding = GameManager.WorldManager.World.EmptyTilesAroundPoint(playerPos);
            foreach (Vec2i v in surrounding)
            {
                WorldObjectData surSpace = GameManager.WorldManager.World.GetWorldObject(v);
                if (surSpace == null)
                {
                    //if there is no object here, we create one
                    LootSack lootsack = new LootSack(v);
                    GameManager.WorldManager.AddNewObject(lootsack);
                    SecondInventory.SetInventory(lootsack.GetInventory());

                    SecondInventory.gameObject.SetActive(true);

                    return(SecondInventory.Inventory);
                }
            }
            //If there is no space near, we return null
            return(null);
        }
        else
        {
            //If the inventory is not null, we add to it
            return(SecondInventory.Inventory);
        }
    }
Ejemplo n.º 4
0
    protected override void KillInternal()
    {
        //If no items, we do nothing
        if (Inventory.GetItems().Count == 0)
        {
            return;
        }

        LootSack lootSack = new LootSack(Vec2i.FromVector3(Position));

        foreach (ItemStack it in Inventory.GetItems())
        {
            lootSack.GetInventory().AddItemStack(it);
        }

        Vec2i pos = Vec2i.FromVector3(Position);

        GameManager.WorldManager.AddNewObject(lootSack);
    }