Esempio n. 1
0
 public void Throw(char controller, ItemScript.ItemType type, Vector3 direction)
 {
     spriteRenderer.sprite = GameManager.Instance.sprites[(int)type];
     itemType = type;
     velocity = direction;
     owner    = controller;
 }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     id = item.itemId;
     gameObject.GetComponent <SpriteRenderer>().sprite = item.itemSprite;
     type     = item.type;
     itemCost = item.itemCost;
 }
Esempio n. 3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        var gameObject = collision.gameObject;

        if (gameObject.CompareTag("Casa") && gameObject.GetComponent <HouseScript>().owner == controller)
        {
            if (currentItem != ItemScript.ItemType.None)
            {
                if (gameObject.GetComponent <HouseScript>().StoreItem(currentItem))
                {
                    ResetItemCarregado();
                }
            }
        }

        switch (collision.gameObject.tag)
        {
        case "Item":
            var itemScript = collision.gameObject.GetComponent <ItemScript>();
            currentItem = itemScript.itemType;
            itemCarregadoSpriteRenderer.sprite = GameManager.Instance.sprites[(int)currentItem];
            GameObject.Destroy(collision.gameObject);
            break;

        case "ItemLancado":
            var itemLancado = collision.gameObject.GetComponent <ItemLancado>();
            if (itemLancado.owner != controller)
            {
                GameObject.Destroy(collision.gameObject);
                StartCoroutine(Stun(itemLancado));
            }
            break;
        }
    }
Esempio n. 4
0
    public bool StoreItem(ItemScript.ItemType item)
    {
        var success = false;

        switch (item)
        {
        case ItemScript.ItemType.Wool:
            if (inventoryWool == 3)
            {
                success = false;
            }
            else
            {
                inventoryWool++;
                success = true;
                VerificaUpgrade();
            }
            break;

        case ItemScript.ItemType.Wood:
            if (inventoryWood == 3)
            {
                success = false;
            }
            else
            {
                inventoryWood++;
                success = true;
                VerificaUpgrade();
            }
            break;

        case ItemScript.ItemType.IronCoin:
            if (inventoryIron == 3)
            {
                success = false;
            }
            else
            {
                inventoryIron++;
                success = true;
                VerificaUpgrade();
            }
            break;

        case ItemScript.ItemType.Hammer:
            success = true;
            Upgrade();
            break;
        }

        return(success);
    }
Esempio n. 5
0
    public void OnTriggerEnter2D(Collider2D collider)
    {
        switch (collider.gameObject.tag)
        {
        case "Item":
            var itemScript = collider.gameObject.GetComponent <ItemScript>();
            currentItem = itemScript.itemType;
            itemCarregadoSpriteRenderer.sprite = GameManager.Instance.sprites[(int)currentItem];
            GameObject.Destroy(collider.gameObject);
            break;

        case "ItemLancado":
            var itemLancado = collider.gameObject.GetComponent <ItemLancado>();
            if (itemLancado.owner != controller)
            {
                GameObject.Destroy(collider.gameObject);
                StartCoroutine(Stun(itemLancado));
            }
            break;
        }
    }
Esempio n. 6
0
 private void ResetItemCarregado()
 {
     currentItem = ItemScript.ItemType.None;
     itemCarregadoSpriteRenderer.sprite = null;
 }