Exemple #1
0
    //Used when a player profession is changed.
    public void UpdatePlayerProfession(Profession profession)
    {
        //Update with common gender sprites
        body.sprite       = profession.body;
        idleArm.sprite    = profession.arm;
        holdingArm.sprite = profession.arm;
        topLeg.sprite     = profession.leg;
        bottomLeg.sprite  = profession.leg;

        //Gender check.
        if (CurrentLevelVariableManagement.GetMainGameData().chosenGender == 0)
        {
            head.sprite = profession.maleHead;
        }
        else
        {
            head.sprite = profession.femaleHead;
        }

        //Add the initial items for the profession to the inventory.
        for (int i = 0; i < profession.initialObjects.Length; i++)
        {
            playerInventory.AssignNewItemToBestSlot(profession.initialObjects[i]);
        }
    }
Exemple #2
0
    //Coroutine that checks for the activation of a W key.
    IEnumerator CheckForPurchase()
    {
        while (true)
        {
            if (Vector2.Distance(player.transform.position, transform.position) < 1)
            {
                if (Input.GetKeyDown(KeyCode.W))
                {
                    if (GiveMoneyToPlayer(-1 * int.Parse(cost.text)))
                    {
                        Debug.Log("Name of item is " + heldItem.uiSlotContent.itemScreenName);
                        playerInventory.AssignNewItemToBestSlot(heldItem);
                        RemovePanel();
                        Debug.Log("Gave to player");
                    }
                    else
                    {
                        Debug.Log("Player had insufficient money");
                    }
                }
            }

            yield return(null);
        }
    }
 public void PickupItem(GameObject item)
 {
     if (playerInventory == null)
     {
         playerInventory = CurrentLevelVariableManagement.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);
         }
     }
 }
Exemple #4
0
    //Used when a player profession is changed.
    public void UpdatePlayerProfession(Profession profession)
    {
        //Update with common gender sprites
        body.sprite         = profession.body;
        idleArm.sprite      = profession.arm1;
        idleHand.sprite     = profession.arm2;
        occupiedArm.sprite  = profession.arm1;
        occupiedHand.sprite = profession.arm2;
        topLeg.sprite       = profession.leg1;
        topFoot.sprite      = profession.leg2;
        bottomLeg.sprite    = profession.leg1;
        bottomFoot.sprite   = profession.leg2;

        //Gender check.
        if (GameData.GetChosenGender() == GameData.Gender.MALE)
        {
            head.sprite = profession.maleHead;
        }
        else
        {
            head.sprite = profession.femaleHead;
        }

        //Add the initial items for the profession to the inventory.
        if (profession.initialObjects != null)
        {
            for (int i = 0; i < profession.initialObjects.Length; i++)
            {
                playerInventory.AssignNewItemToBestSlot(profession.initialObjects [i]);
            }
        }
    }