Ejemplo n.º 1
0
    public override void DoAction(PlayerCharacter character, Selectable select)
    {
        PlayerData pdata = PlayerData.Get();

        if (pdata.CanTakeItem(take_item.id, 1))
        {
            pdata.AddItem(take_item.id, 1);
            select.Destroy();
        }
    }
Ejemplo n.º 2
0
    //Kill the destructible
    public void Kill()
    {
        if (!dead)
        {
            dead = true;

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

            //Loot
            foreach (CraftData item in loots)
            {
                float   radius = Random.Range(0.5f, 1f);
                float   angle  = Random.Range(0f, 360f) * Mathf.Rad2Deg;
                Vector3 pos    = transform.position + new Vector3(Mathf.Cos(angle), 0f, Mathf.Sin(angle)) * radius;
                if (item is ItemData)
                {
                    Item.Create((ItemData)item, pos, 1);
                }
                if (item is ConstructionData)
                {
                    Construction construct = Construction.Create((ConstructionData)item, pos);
                    construct.FinishContruction();
                }
            }

            if (!was_built)
            {
                PlayerData.Get().RemoveObject(GetUID());
            }

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

            //FX
            if (death_fx != null)
            {
                Instantiate(death_fx, transform.position, Quaternion.identity);
            }

            TheAudio.Get().PlaySFX("destruct", death_sound);

            select.Destroy(destroy_delay);
        }
    }