Beispiel #1
0
    public void ClearBucket()
    {
        HandEquipment.ResetInvSlot();
        InvSlotContent content = new InvSlotContent(EmptyBucket);

        AssigHandEquipment(content);
    }
Beispiel #2
0
    public void FillUpBucket()
    {
        HandEquipment.ResetInvSlot();
        InvSlotContent content = new InvSlotContent(FullBucket);

        AssigHandEquipment(content);
    }
Beispiel #3
0
    public void CraftItem()
    {
        UpdateShopResourcesAndItemsAmounts();
        InvSlotContent inventorySlotContent = new InvSlotContent(SelectedItem);

        Player.Inventory.GetComponent <Inventory>().AddItem(inventorySlotContent, _tempResourceList, new KeyValuePair <Item.ItemType, int>(_matchedItemType, _matchedItemsCount));
        Player.AllItems.Add(SelectedItem);
        //ChallengesManager.Instance.CheckForChallenge(SelectedItem.Type, Player);
    }
Beispiel #4
0
    public void AddItem(InvSlotContent inventorySlotContent, List <KeyValuePair <Resource.ResourceType, int> > resourceList, KeyValuePair <Item.ItemType, int> _pair)
    {
        foreach (KeyValuePair <Resource.ResourceType, int> pair in resourceList)
        {
            /*int amountToUpdate = 0;
             * foreach (Resource resource in Player.AllResources)
             * {
             *  if (resource.Type == pair.Key)
             *  {
             *      amountToUpdate = resource.Amount - pair.Value;
             *  }
             * }*/
            UpdatePlayerResources(-pair.Value, pair.Key);
        }
        List <InvSlot> tempList      = new List <InvSlot>();
        int            matcheCounter = 0;

        foreach (InvSlot invSlot in _allInvSlots)
        {
            if (matcheCounter < _pair.Value)
            {
                if (invSlot.IsOccupied && invSlot.InvSlotContent.IsItem && invSlot.InvSlotContent.Item.Type == _pair.Key)
                {
                    matcheCounter++;
                    tempList.Add(invSlot);
                }
            }
        }
        foreach (InvSlot slot in tempList)
        {
            Player.AllItems.Remove(slot.InvSlotContent.Item);
            if (slot == HandEquipment)
            {
                CancelItemOnMapPreshow();
            }
            slot.ResetInvSlot();
        }
        foreach (InvSlot invSlot in _allInvSlots)
        {
            if (!invSlot.IsOccupied)
            {
                invSlot.InvSlotContent = inventorySlotContent;
                invSlot.IsOccupied     = true;
                GameObject invSlotObject = Instantiate(InventoryItemPrefab, invSlot.gameObject.transform);
                invSlot.Object = invSlotObject;
                invSlotObject.transform.GetChild(0).gameObject.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + inventorySlotContent.IconName);
                invSlotObject.transform.GetChild(1).gameObject.SetActive(false);
                return;
            }
        }
    }
Beispiel #5
0
    private void SwapItems(InvSlot invSlot, string bodyPart)
    {
        InvSlotContent tempInvSlotContent = invSlot.InvSlotContent;

        invSlot.ResetInvSlot();
        if (bodyPart == "Body")
        {
            AssignBodyEquipment();
        }
        else if (bodyPart == "Hand")
        {
            AssigHandEquipment();
        }
        AddItem(tempInvSlotContent);
    }
Beispiel #6
0
    private void AssigHandEquipment(InvSlotContent content)
    {
        HandEquipment.InvSlotContent = content;
        HandEquipment.IsOccupied     = true;
        GameObject handEquipmentObj = Instantiate(InventoryItemPrefab, HandEqSlot.transform);

        HandEquipment.Object = handEquipmentObj;
        handEquipmentObj.transform.GetChild(1).gameObject.SetActive(false);
        handEquipmentObj.transform.GetChild(0).gameObject.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + HandEquipment.InvSlotContent.IconName);
        if (HandEquipment.InvSlotContent.Resource)
        {
            Player.DamageValue = Player.BasicDamageValue;
        }
        else
        {
            Player.DamageValue = HandEquipment.InvSlotContent.Item.DamageValue;
        }
        InstantiateItemInHand();
    }
Beispiel #7
0
    public void PickUp()
    {
        //SFX: loot sound

        /*foreach (GameObject col in AllColliders)
         * {
         *  if (col.transform.tag == "Resource Drop")
         *  {
         *      NearbyResourceDrop = col.GetComponent<ResourceDrop>();
         *      break;
         *  }
         *  else if (col.transform.tag == "Item Drop")
         *  {
         *      NearbyItemDrop = col.GetComponent<ItemDrop>();
         *      break;
         *  }
         * }*/
        //GetClosestObject("Enter");
        //add check whether mine or resources are present
        if (NearbyResourceDrop != null)
        {
            if (!_inventory.IsInventoryFull(NearbyResourceDrop))
            {
                InvSlotContent inventorySlotContent = new InvSlotContent(NearbyResourceDrop, NearbyResourceDrop.Amount);
                Inventory.GetComponent <Inventory>().AddItem(inventorySlotContent); _instructionsToggled.Remove(NearbyResourceDrop.transform.Find("Instructions Image").gameObject);
                _instructionsToggled.Remove(NearbyResourceDrop.transform.Find("Instructions Image").gameObject);
                _firstInstruction = true;
                Destroy(NearbyResourceDrop.gameObject);
            }
        }
        else if (NearbyItemDrop != null)
        {
            if (!_inventory.IsInventoryFull())
            {
                InvSlotContent inventorySlotContent = new InvSlotContent(NearbyItemDrop.Item);
                Inventory.GetComponent <Inventory>().AddItem(inventorySlotContent); _instructionsToggled.Remove(NearbyItemDrop.transform.Find("Instructions Image").gameObject);
                _instructionsToggled.Remove(NearbyItemDrop.transform.Find("Instructions Image").gameObject);
                _firstInstruction = true;
                Destroy(NearbyItemDrop.gameObject);
                //GetClosestObject("Enter");
            }
        }
    }
Beispiel #8
0
    public void AddItem(InvSlotContent inventorySlotContent)
    {
        bool isDuplicate = false;

        if (inventorySlotContent.Resource)
        {
            foreach (InvSlot invSlot in _allInvSlots)
            {
                if (invSlot.IsOccupied && invSlot.InvSlotContent.Resource)
                {
                    if (invSlot.InvSlotContent.ResourceDrop.Type == inventorySlotContent.ResourceDrop.Type)
                    {
                        isDuplicate = true;
                    }
                }
            }
            if (isDuplicate)
            {
                //int newAmount = 0;
                foreach (InvSlot invSlot in _allInvSlots)
                {
                    if (invSlot.IsOccupied && invSlot.InvSlotContent.Resource)
                    {
                        if (invSlot.InvSlotContent.ResourceDrop.Type == inventorySlotContent.ResourceDrop.Type)
                        {
                            //newAmount = invSlot.InvSlotContent.Amount + inventorySlotContent.Amount;
                            UpdatePlayerResources(inventorySlotContent.Amount, invSlot.InvSlotContent.ResourceDrop.Type);
                        }
                    }
                }
            }
            else
            {
                foreach (InvSlot invSlot in _allInvSlots)
                {
                    if (!invSlot.IsOccupied)
                    {
                        invSlot.InvSlotContent = inventorySlotContent;
                        invSlot.IsOccupied     = true;
                        GameObject invSlotObject = Instantiate(InventoryItemPrefab, invSlot.gameObject.transform);
                        invSlot.Object = invSlotObject;
                        invSlotObject.transform.GetChild(0).gameObject.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + inventorySlotContent.IconName);
                        UpdatePlayerResources(inventorySlotContent.Amount, inventorySlotContent.ResourceDrop.Type);
                        return;
                    }
                }
            }
        }
        else
        {
            foreach (InvSlot invSlot in _allInvSlots)
            {
                if (!invSlot.IsOccupied)
                {
                    invSlot.InvSlotContent = inventorySlotContent;
                    invSlot.IsOccupied     = true;
                    GameObject invSlotObject = Instantiate(InventoryItemPrefab, invSlot.gameObject.transform);
                    invSlot.Object = invSlotObject;
                    invSlotObject.transform.GetChild(0).gameObject.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + inventorySlotContent.IconName);
                    invSlotObject.transform.GetChild(1).gameObject.SetActive(false);
                    return;
                }
            }
        }
    }
Beispiel #9
0
 public void ResetInvSlot()
 {
     IsOccupied     = false;
     InvSlotContent = null;
     Destroy(Object);
 }