コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        // Load in handler from playerprefs
        string strHandler = PlayerPrefs.GetString("ShopItemHandler");

        handler = JsonUtility.FromJson <ShopItemHandler>(strHandler);

        headoptions = new List <bool>(new bool[] { handler.Head01, handler.Head02 });
        legoptions  = new List <bool>(new bool[] { handler.Legs01, handler.Legs02, handler.Legs03, handler.Legs04, handler.Legs05 });
        faceoptions = new List <bool>(new bool[] { handler.Face01, handler.Face02, handler.Face03, handler.Face04, handler.Face05 });
        bodyoptions = new List <bool>(new bool[] { handler.Body01, handler.Body02, handler.Body03, handler.Body04, handler.Body05, handler.Body08, handler.Body07, handler.Body08 });
    }
コード例 #2
0
    void Awake()
    {
        // Load in handler from playerprefs
        string strHandler = PlayerPrefs.GetString("ShopItemHandler");

        handler = JsonUtility.FromJson <ShopItemHandler>(strHandler);


        // Load in coin amount from playerprefs
        if (PlayerPrefs.HasKey("NumCoins"))
        {
            coins = PlayerPrefs.GetInt("NumCoins");
        }
        else
        {
            coins = 1000;
        }
        coinsText.text = coins.ToString();
        Debug.Log(coins);
    }
コード例 #3
0
    void Start()
    {
        if (!PlayerPrefs.HasKey("ShopItemHandler"))
        {
            handler          = new ShopItemHandler();
            handler.Head01   = true;
            handler.Body01   = true;
            handler.Face01   = true;
            handler.BodyGrey = true;
            handler.Legs01   = true;
            handler.SetEquippedHead(1);
            handler.SetEquippedBody(1);
            handler.SetEquippedLegs(1);
            handler.SetEquippedFace(1);
            handler.SetEquippedColor("grey");

            // Save handler in playerprefs
            string strHandler = JsonUtility.ToJson(handler);
            PlayerPrefs.SetString("ShopItemHandler", strHandler);
        }
    }
コード例 #4
0
        public async Task Buy(string itemSlot, string itemName)
        {
            var account = UserManager.GetAccount(Context.Message.Author);

            if (itemSlot.Equals("potions"))
            {
                await Context.Channel.SendMessageAsync("Not Implemented yet");
            }
            else if (itemSlot.Equals("weapon"))
            {
                switch (itemName)
                {
                case "fist":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(Fist), Context, account);

                    break;

                case "rock":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(Rock), Context, account);

                    break;

                case "bat":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(Bat), Context, account);

                    break;

                case "hoe":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(Hoe), Context, account);

                    break;

                case "divinerapier":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(DivineRapier), Context, account);

                    break;

                default:
                    await Context.Channel.SendMessageAsync("Weapon not found");

                    await Task.Delay(10000);

                    await Context.Message.DeleteAsync();

                    break;
                }
            }
            else if (itemSlot.Equals("armor"))
            {
                switch (itemName)
                {
                case "naked":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(Naked), Context, account);

                    break;

                case "leatherarmor":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(LeatherArmor), Context, account);

                    break;

                case "woodenarmor":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(WoodenArmor), Context, account);

                    break;

                case "bronzearmor":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(BronzeArmor), Context, account);

                    break;

                case "divinearmor":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(DivineArmor), Context, account);

                    break;

                default:
                    await Context.Channel.SendMessageAsync("Armor not found");

                    await Task.Delay(10000);

                    await Context.Message.DeleteAsync();

                    break;
                }
            }
            else if (itemSlot.Equals("shield"))
            {
                switch (itemName)
                {
                case "handblock":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(HandBlock), Context, account);

                    break;

                case "woodenshield":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(WoodenShield), Context, account);

                    break;

                case "bronzeshield":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(BronzeShield), Context, account);

                    break;

                case "silbershield":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(SilberShield), Context, account);

                    break;

                case "vikingshield":
                    await ShopItemHandler.BuyItem(itemSlot, typeof(VikingShield), Context, account);

                    break;

                default:
                    await Context.Channel.SendMessageAsync("Shield not found");

                    await Task.Delay(10000);

                    await Context.Message.DeleteAsync();

                    break;
                }
            }
            // todo
            else if (itemSlot.Equals("points"))
            {
                await Context.Channel.SendMessageAsync("Not Implemented yet");
            }
            else
            {
                await Context.Channel.SendMessageAsync("Please enter a valid type.");
            }
        }