Esempio n. 1
0
    public bool Buy(MarketplaceID ID, int amount)
    {
        Debug.Log("Buy " + ID.ToString() + " " + amount + "\n");
        FXRate rate = Marketplace.getFXRate(ID);

        _process(ID, amount);
        _process(default_currency, -amount * rate.buy_rate);

        getObject(ID).UpdateLabels(getCurrentAmount(ID), getDefaultCurrency());
        setSellAllButton();
        updateDefaultCurrency();
        return(true);
    }
Esempio n. 2
0
    private bool _process(MarketplaceID ID, float amount)
    {
        Debug.Log("Processing " + ID + " " + amount);

        Tracker.Log(PlayerEvent.MarketPlace, false,
                    customAttributes: new Dictionary <string, string>()
        {
            { "attribute_1", ID.ToString() }
        },
                    customMetrics: new Dictionary <string, double>()
        {
            { "metric_1", amount }
        });

        switch (ID)
        {
        case MarketplaceID.Sensible:
            Peripheral.Instance.my_inventory.AddWish(WishType.Sensible, Mathf.FloorToInt(amount), 1);
            return(true);

        case MarketplaceID.MoreDamage:
            Peripheral.Instance.my_inventory.AddWish(WishType.MoreDamage, 1, Mathf.FloorToInt(amount));
            return(true);

        case MarketplaceID.MoreHealth:
            Peripheral.Instance.my_inventory.AddWish(WishType.MoreHealth, 1, Mathf.FloorToInt(amount));
            return(true);

        case MarketplaceID.MoreDreams:
            Peripheral.Instance.my_inventory.AddWish(WishType.MoreDreams, 1, Mathf.FloorToInt(amount));
            return(true);

        case MarketplaceID.MoreXP:
            Peripheral.Instance.my_inventory.AddWish(WishType.MoreXP, 1, Mathf.FloorToInt(amount));
            return(true);

        case MarketplaceID.ScorePoint:
            int new_score = ScoreKeeper.Instance.getTotalScore() + Mathf.FloorToInt(amount);
            Debug.Log("new score " + new_score + "\n");
            ScoreKeeper.Instance.SetTotalScore(new_score);
            return(true);

        case MarketplaceID.Dreams:
            Peripheral.Instance.addDreams(amount, Vector3.zero, false);
            return(true);
        }
        return(false);
    }
Esempio n. 3
0
    public bool Sell(MarketplaceID ID, int amount, bool all)
    {
        if (all)
        {
            amount = getCurrentAmount(ID);
        }
        if (amount == 0)
        {
            return(true);
        }
        Debug.Log("Sell " + ID.ToString() + " " + amount + "\n");
        FXRate rate = Marketplace.getFXRate(ID);

        _process(ID, -amount);
        _process(default_currency, amount * rate.sell_rate);

        getObject(ID).UpdateLabels(getCurrentAmount(ID), getDefaultCurrency());
        setSellAllButton();
        updateDefaultCurrency();
        return(true);
    }