Beispiel #1
0
 public void PickupItem(GameObject item)
 {
     if (playerInventory == null)
     {
         playerInventory = InstanceDatabase.GetMainInventoryReference().GetComponent <InventoryFunctions> ();
     }
     //This does not check the resourcereference property of the attached script as a comparison, only the tag.  Consider changing later.
     if (item.CompareTag("ExpNodule"))
     {
         transform.parent.gameObject.GetComponent <PlayerHealthPanelManager> ().OnExperienceNodulePickedUp();
         Destroy(item);
     }
     else if (item.CompareTag("Coin"))
     {
         transform.parent.gameObject.GetComponent <PlayerHealthPanelManager> ().OnCoinPickedUp(1);
         Destroy(item);
     }
     else
     {
         ResourceReferenceWithStack pendingObject = item.GetComponent <DroppedItemProperties> ().localResourceReference;
         if (!playerInventory.AssignNewItemToBestSlot(pendingObject))
         {
             Debug.LogError("ERROR WHEN ASSIGNING OBJECT");
         }
         else
         {
             Destroy(item);
         }
     }
 }
Beispiel #2
0
    //Initializing the NPC
    protected override void InitializeCharacter()
    {
        //Get required components.
        playerTransform = InstanceDatabase.GetPlayerReference().transform;
        playerInventory = InstanceDatabase.GetMainInventoryReference().GetComponent <InventoryFunctions> ();

        //Initialize the NPC before starting to walk around.
        InitializeNPC();
        //Create and start the coroutine.
        walkAroundCoroutine = WalkAround();
        StartCoroutine(walkAroundCoroutine);
    }
Beispiel #3
0
    //When an item drop hits the player.
    void OnTriggerEnter2D(Collider2D externalTrigger)
    {
        if (playerInventory == null)
        {
            playerInventory = InstanceDatabase.GetMainInventoryReference().GetComponent <InventoryFunctions> ();
        }

        if (((externalTrigger.gameObject.GetComponent <DroppedItemProperties> () != null || externalTrigger.gameObject.CompareTag("Coin") ||
              externalTrigger.gameObject.CompareTag("ExpNodule"))) && playerInventory.IsInitialized())
        {
            PickupItem(externalTrigger.gameObject);
        }
    }
Beispiel #4
0
    /******************************* MOUSE CLICK MANAGER *******************************/

    public void OnPointerClick(PointerEventData data)
    {
        if (data.button == PointerEventData.InputButton.Left)
        {
            if (currentlyAssigned != null)
            {
                if (InstanceDatabase.GetPlayerReference().GetComponent <PlayerHealthPanelManager> ().GiveMoneyToPlayer(-currentlyAssigned.price))
                {
                    //Add the deassigned item to the player inventory and deduct the price of the item.
                    InstanceDatabase.GetMainInventoryReference().GetComponent <InventoryFunctions> ().AssignNewItemToBestSlot(new ResourceReferenceWithStack(currentlyAssigned.mainContentReference.uiSlotContent, 1));
                    ModifyCurrentItemStack(-1);
                }
            }
        }
    }