Example #1
0
    void CheckPlayerFunds(Item item, int quantity)
    {
        float price = PriceChecker.AppraiseItem(item, "Purchase") * quantity;

        if (price <= playerWallet.GetCurrentBalance())
        {
            CommitPurchase(item, quantity, price);
        }
        else
        {
            Debug.Log("Insufficient funds, balance: $" + playerWallet.GetCurrentBalance());
            shopDialogue.SetCurrentMessage(LoadShop.MessageType.LOW_GOLD);
        }
    }
Example #2
0
    private PlayerData PackagePlayerData()
    {
        PlayerData data = new PlayerData();

        Vector3 pos = transform.position;

        data.currentPosition = new SavedPosition {
            x = pos.x, y = pos.y, z = pos.z
        };

        data.currentInventory = inventory.GetInventoryItems();
        data.currentGold      = wallet.GetCurrentBalance();
        data.bodyParts        = myBody.GetBodyParts();

        data.combatSkillLevels     = combatSkills.GetCombatLevels();
        data.combatSkillExperience = combatSkills.GetCombatExperience();
        data.weaponSkillLevels     = combatSkills.GetWeaponLevels();
        data.weaponSkillExperience = combatSkills.GetWeaponExperience();
        return(data);
    }
Example #3
0
    public void ShopSlotRightClicked(Item item)
    {
        if (item == null)
        {
            return;
        }

        ShopDialogue        shopDialogue = InventoryManager.GetInstance().GetShopDialogue();
        CheckInventorySpace invCheck     = InventoryManager.GetInstance().GetInventorySpaceChecker();

        float price = PriceChecker.AppraiseItem(item, "Purchase") * item.quantity;

        if (playerWallet.GetCurrentBalance() >= price && invCheck.CheckItem(item))
        {
            InventoryManager.GetInstance().GetShopInventory().Remove(item);
            InventoryManager.GetInstance().GetInventory().AddItem(item);
            playerWallet.Withdraw(price);
            shopDialogue.SetCurrentMessage(LoadShop.MessageType.SUCCESS);
        }
        else
        {
            shopDialogue.SetCurrentMessage(LoadShop.MessageType.INVAL_QNTY); //SHOULD BE "GENERIC_NO"
        }
    }