示例#1
0
 public void GiveCraftMats()
 {
     for (int i = 0; i < 20; i++)
     {
         player.AddItem(CraftMaterialsClasses.Copper());
         player.AddItem(CraftMaterialsClasses.Linen());
         player.AddItem(CraftMaterialsClasses.Wood());
     }
 }
示例#2
0
    public bool PlayerBuyItem(int arrayNum)
    {
        Item itemToBuy = vendorItems[arrayNum];

        if (player.Gold >= itemToBuy.Value)         //If we have enough gold to buy
        {
            if (player.AddItem(itemToBuy))
            {
                player.ModifyGold(-1 * itemToBuy.Value);
                vendorItems.RemoveAt(arrayNum);
                return(true);
            }
        }

        return(false);
    }
示例#3
0
    public void MoveFromBankToPlayer(int arrayNum)
    {
        bool added = player.AddItem(player.Stash[arrayNum]);

        if (added)
        {
            player.Stash.RemoveAt(arrayNum);
        }
    }
示例#4
0
    public void CompleteQuest(NPCQuest quest)
    {
        if (player.Inventory.Count + quest.QuestReward.Count <= player.MaxInventorySpace)
        {
            for (int i = 0; i < quest.QuestReward.Count; i += 0)
            {
                bool addedItem = player.AddItem(quest.QuestReward[i]);
                if (addedItem)
                {
                    quest.QuestReward.RemoveAt(i);
                }
                else
                {
                    Debug.Log("Stack is full");
                }
            }

            if (quest.QuestReward.Count == 0)
            {
                player.AddExp(quest.QuestExpReward);
                player.ModifyGold(quest.QuestGoldReward);
                quest.isFinished = true;
                player.questsComplete.Add(quest);

                if (quest.qego != null && !quest.EnableQuestGOPerm)
                {
                    quest.qego.DisableGameObjects();
                }
                if (quest.numberToObtain > 0)
                {
                    for (int i = 0; i < player.Inventory.Count; i++)
                    {
                        if (player.Inventory[i].Name == quest.nameOfItem)
                        {
                            player.Inventory[i].CurStacks -= quest.numberToObtain;
                            if (player.Inventory[i].CurStacks <= 0)
                            {
                                player.Inventory.RemoveAt(i);
                            }
                        }
                    }
                }

                player.QuestsInProgress.Remove(quest);
                EnterDialog();
            }
        }
        else
        {
            Debug.Log("Inventory is Full!");
        }
    }
示例#5
0
    void PlayerPickUp()
    {
        float viewDist = Vector3.Distance(transform.position, playerNew.transform.position);

        if (viewDist < 4)
        {
            bool added = playerNew.AddItem(myItem);

            if (added)
            {
                Destroy(gameObject);
            }
        }
        else
        {
            CharacterControl.useNewPosition       = true;
            CharacterControl.newPosition          = transform.position;
            CharacterControl.arrivedAtDestination = false;
        }
    }
    public void InventoryDo(string method, int cnt)
    {
        if (method == "DropItem")
        {
            if (_pc.Inventory[cnt].CanBeDropped)
            {
                _pc.Inventory.RemoveAt(cnt);
            }
            else
            {
                Debug.Log("Can't destroy this item!");
            }
        }
        else if (method == "UseItem")
        {
            if (_pc.Inventory[cnt].ItemType == ItemEquipType.Clothing ||
                _pc.Inventory[cnt].ItemType == ItemEquipType.Weapon)
            {
                if (_pc.playerState == PlayerState.Normal)
                {
                    GUIHandler.EquipAnItem(cnt);
                }
                else
                {
                    Debug.Log("Can't equip item right now.");
                }
            }
            else if (_pc.Inventory[cnt].ItemType == ItemEquipType.Consumable)
            {
                //IEnumerator for cooldown of using potions
                Consumable c       = _pc.Inventory[cnt] as Consumable;
                bool       usedPot = _pc.UseConsumable((int)c.VitalToRestore, c.AmountToHeal);
                if (usedPot)
                {
                    if (c.CurStacks == 1)
                    {
                        _pc.Inventory.RemoveAt(cnt);
                    }
                    else
                    {
                        c.CurStacks -= 1;
                    }
                }
                else
                {
                    Debug.Log("Using pots on cooldown");
                }
            }
            else if (_pc.Inventory[cnt].ItemType == ItemEquipType.Socket)
            {
                MyGUI.itemIsPickedUp         = true;
                MyGUI.itemPickedUpIcon       = _pc.Inventory[cnt].Icon;
                MyGUI.itemIsForUse           = true;
                MyGUI.pickedUpItemIdentifier = string.Format("Inventory{0}", cnt);
            }
            else
            {
                Debug.Log("Unknown : This is a " + _pc.Inventory[cnt].Name);
            }
        }
        else
        {
            if (_pc.Inventory.Count < _maxInventorySpace)
            {
                switch (method)
                {
                //Returning Equipped Items
                case "ReturnEquippedWeapon":
                    _pc.AddItem(_pc.EquipedWeapon);
                    _pc.EquipedWeapon = null;
                    break;

                case "ReturnEquippedArmorHead":
                    _pc.AddItem(_pc.EquipedArmorHead);
                    _pc.EquipedArmorHead = null;
                    break;

                case "ReturnEquippedArmorChest":
                    _pc.AddItem(_pc.EquipedArmorChest);
                    _pc.EquipedArmorChest = null;
                    break;

                case "ReturnEquippedArmorGloves":
                    _pc.AddItem(_pc.EquipedArmorGloves);
                    _pc.EquipedArmorGloves = null;
                    break;

                case "ReturnEquippedArmorLegs":
                    _pc.AddItem(_pc.EquipedArmorLegs);
                    _pc.EquipedArmorLegs = null;
                    break;

                case "ReturnEquippedArmorFeet":
                    _pc.AddItem(_pc.EquipedArmorFeet);
                    _pc.EquipedArmorFeet = null;
                    break;

                case "ReturnEquippedArmorBack":
                    _pc.AddItem(_pc.EquipedArmorBack);
                    _pc.EquipedArmorBack = null;
                    break;
                }
            }
            else
            {
                Debug.Log("Inventory is full");
                Debug.Log("Your Inventory is full.");
            }
        }

        _pc.UpdateStats();
    }