Esempio n. 1
0
    public void OnMove(IntVector2 to)
    {
        List <GameObject> collectables = intTransform.GetLevel().GetCollectablesAt(to);

        foreach (GameObject collectable in collectables.ToArray())
        {
            ItemCollectable itemCollectable = collectable.GetComponent <ItemCollectable>();
            if (itemCollectable && itemCollectable.item.GetType() == typeof(Weapon))
            {
                // Drop our item
                if (weapon)
                {
                    weapon.OnUnequip(this.gameObject);
                    intTransform.GetLevel().SpawnItem(weapon, to);
                }

                // Grab the item
                weapon = (Weapon)itemCollectable.item;
                weapon.OnEquip(this.gameObject);
                Destroy(collectable);
                intTransform.GetLevel().RemoveCollectableAt(collectable, to);

                SoundManager.S.Play(SoundManager.S.pickup);
            }
        }
    }
Esempio n. 2
0
    public void addItem(ItemCollectable item)
    {
        int i = 0;

        foreach (InventoryItem invItem in inventory.ToList())
        {
            if (invItem != null && invItem.Item != null)
            {
                if (invItem.Item == item.item && i == 0)
                {
                    invItem.StackSize += item.stack;
                    i++;
                }
            }
        }

        if (i == 0)
        {
            for (int j = 0; j < inventory.Count; j++)
            {
                if (inventory[j] == null && i == 0)
                {
                    inventory[j] = new InventoryItem(item.item, item.stack);
                    i++;
                }
            }
        }
    }
Esempio n. 3
0
    public void spawnCollectable(Item _item, int _stack, Vector3 _location)
    {
        ItemCollectable collectable = GameManager.instance.collectablePrefab;

        collectable.item  = _item;
        collectable.stack = _stack;
        Instantiate(collectable, _location, Quaternion.identity);
    }
Esempio n. 4
0
 public Item(int i, string n, string desc, string s)
 {
     id              = i;
     name            = n;
     description     = desc;
     sellerDialog    = s;
     collectableData = new ItemCollectable();
     cost            = new CostItem();
 }
Esempio n. 5
0
        private void Start()
        {
            rb               = GetComponent <Rigidbody2D>();
            fallChecker      = GetComponent <FallChecker>();
            itemCollectable  = GetComponent <ItemCollectable>();
            parentConstraint = GetComponent <ParentConstraint>();

            var groundCheckers = GetComponentsInChildren <GroundChecker>();

            side1Check = groundCheckers[0];
            side2Check = groundCheckers[1];

            rb.gravityScale = 0;
            spawnLocation   = transform.position;

            itemCollectable.Collected  += () => Collected();
            itemCollectable.Dropped    += () => Dropped();
            itemCollectable.StateReset += () => Reset();
        }
Esempio n. 6
0
	// Here we check to see which collectable we have obtained since that is
	// when this is called.
	void UseCollectable(ItemCollectable.ItemCollectableTypes typeUsing, int maxValue, AudioClip sfxToPlay)
	{
		switch(typeUsing)
		{
		case ItemCollectable.ItemCollectableTypes.Heal:
			_charStatus.WasHealed(maxValue);
			break;
		}
		// Each collectable should have a audio clip.
		if(sfxToPlay != null)
			AudioSource.PlayClipAtPoint(sfxToPlay, myTransform.position);
		else Debug.LogWarning("Item's audio clip was null!");
	}