public override void DoAction(PlayerCharacter character, Selectable select)
        {
            PlayerData   pdata        = PlayerData.Get();
            Construction construction = select.GetComponent <Construction>();

            if (construction != null)
            {
                ItemData      take_item = construction.data.take_item_data;
                InventoryData inv_data  = character.Inventory.GetValidInventory(take_item, 1);
                if (take_item != null && inv_data != null)
                {
                    BuiltConstructionData bdata = pdata.GetConstructed(construction.GetUID());
                    float durability            = bdata != null ? bdata.durability : take_item.durability;

                    inv_data.AddItem(take_item.id, 1, durability, select.GetUID());
                    select.Destroy();
                }
            }

            Character acharacter = select.GetComponent <Character>();

            if (acharacter != null)
            {
                ItemData      take_item = acharacter.data.take_item_data;
                InventoryData inv_data  = character.Inventory.GetValidInventory(take_item, 1);
                if (take_item != null && inv_data != null)
                {
                    TrainedCharacterData cdata = pdata.GetCharacter(acharacter.GetUID());
                    inv_data.AddItem(take_item.id, 1, take_item.durability, select.GetUID());
                    select.Destroy();
                }
            }
        }
 public void Kill()
 {
     if (destruct != null)
     {
         destruct.Kill();
     }
     else
     {
         selectable.Destroy();
     }
 }
Ejemplo n.º 3
0
 public void Kill()
 {
     if (destruct != null)
     {
         destruct.Kill();
     }
     else if (selectable != null)
     {
         selectable.Destroy();
     }
     else
     {
         Destroy(gameObject);
     }
 }
        //Destroy the object
        public void Destroy()
        {
            Destructible destruct = GetComponent <Destructible>();
            Item         item     = GetComponent <Item>();

            if (destruct != null)
            {
                destruct.Kill(); //Kill destruct to spawn loot and save
            }
            else if (item != null)
            {
                item.DestroyItem(); //Or destroy item if its an item
            }
            else if (cselect != null)
            {
                cselect.Destroy(); //Or destroy selectable otherwise
            }
        }
Ejemplo n.º 5
0
        public void KillNoLoot()
        {
            if (!dead)
            {
                dead = true;
                hp   = 0;

                foreach (Collider collide in colliders)
                {
                    collide.enabled = false;
                }

                PlayerData.Get().RemoveObject(GetUID());
                PlayerData.Get().RemoveCustomValue(GetHpUID());

                if (onDeath != null)
                {
                    onDeath.Invoke();
                }

                select.Destroy(destroy_delay);
            }
        }
Ejemplo n.º 6
0
 public void Kill()
 {
     selectable.Destroy();
 }