Esempio n. 1
0
    public void Select()
    {
        if (GetComponent <Toggle>().isOn)
        {
            GetComponent <Image>().color = new Color(1.0f, 1.0f, 1.0f, 0.3f);
            ItemList.Items item    = ItemList.item_table[itemNo];
            Texture2D      texture = Resources.Load(item.item_img) as Texture2D;
            GameObject.Find("ItemImage").GetComponent <Image>().sprite          = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
            GameObject.Find("ItemImage").GetComponent <Image>().color           = new Color(1.0f, 1.0f, 1.0f, 1.0f);
            GameObject.Find("Description").GetComponentInChildren <Text>().text = "【" + item.item_name + "】\n" + item.item_desc;

            switch (item.item_type)
            {
            case (int)ItemList.Eff.Hp_damage:
            case (int)ItemList.Eff.Df_up:
            case (int)ItemList.Eff.Ag_up:
            case (int)ItemList.Eff.At_up:
                if (SceneManager.GetActiveScene().name != "battle")
                {
                    GameObject.Find("Use").GetComponent <Button>().enabled       = false;
                    GameObject.Find("Use").GetComponentInChildren <Text>().color = new Color(0.3f, 0.3f, 0.3f);
                }
                else
                {
                    goto default;
                }
                break;

            case (int)ItemList.Eff.Key_item:
                GameObject.Find("Use").GetComponent <Button>().enabled       = false;
                GameObject.Find("Use").GetComponentInChildren <Text>().color = new Color(0.3f, 0.3f, 0.3f);
                if (SceneManager.GetActiveScene().name != "battle")
                {
                    GameObject.Find("Remove").GetComponent <Button>().enabled       = false;
                    GameObject.Find("Remove").GetComponentInChildren <Text>().color = new Color(0.3f, 0.3f, 0.3f);
                }
                else
                {
                    GameObject.Find("Back").GetComponent <Button>().enabled       = false;
                    GameObject.Find("Back").GetComponentInChildren <Text>().color = new Color(0.3f, 0.3f, 0.3f);
                }
                break;

            default:
                GameObject.Find("Use").GetComponent <Button>().enabled       = true;
                GameObject.Find("Use").GetComponentInChildren <Text>().color = new Color(1.0f, 1.0f, 1.0f);
                if (SceneManager.GetActiveScene().name != "battle")
                {
                    GameObject.Find("Remove").GetComponent <Button>().enabled       = true;
                    GameObject.Find("Remove").GetComponentInChildren <Text>().color = new Color(1.0f, 1.0f, 1.0f);
                }
                else
                {
                    GameObject.Find("Back").GetComponent <Button>().enabled       = true;
                    GameObject.Find("Back").GetComponentInChildren <Text>().color = new Color(1.0f, 1.0f, 1.0f);
                }
                break;
            }
        }
        else
        {
            GetComponent <Image>().color = new Color(1.0f, 1.0f, 1.0f, 0);
        }
    }
Esempio n. 2
0
    public void Use()
    {
        ToggleGroup toggleGroup = GameObject.Find("ItemContainer").GetComponent <ToggleGroup>();

        if (toggleGroup.AnyTogglesOn())
        {
            foreach (Toggle itemObj in toggleGroup.ActiveToggles())
            {
                List <int> my_items = PlayerContoroller.my_items;
                int        itemNo   = itemObj.GetComponent <ItemToggleController>().itemNo;
                for (int i = my_items.Count; i-- >= 0;)
                {
                    if (itemNo == my_items[i])
                    {
                        string[]       messeage;
                        ItemList.Items item = ItemList.item_table[itemNo];
                        switch (item.item_type) // アイテムを使う処理
                        {
                        case (int)ItemList.Eff.Hp_heal:
                            item.item_effect = AddRunNum(item.item_effect);
                            PlayerContoroller.player_status["hp"] = Mathf.Min(PlayerContoroller.player_status["hp"] + item.item_effect, PlayerContoroller.player_status["mhp"]);
                            messeage = new string[] { item.item_name + " を使った\n" + PlayerContoroller.player_name + "のHPが" + item.item_effect + "回復した!" };
                            if (SceneManager.GetActiveScene().name != "battle")
                            {
                                LogController.logController.printText(messeage);
                            }
                            else
                            {
                                bm.isUsedItem = true;
                                LogController.logController.printText(messeage).then(bm.AttackToPlayer);
                            }
                            break;

                        case (int)ItemList.Eff.Hp_damage:
                            item.item_effect = AddRunNum(item.item_effect);
                            EnemyController.enemy_status["hp"] -= item.item_effect;
                            bm.isUsedItem = true;
                            messeage      = new string[] { item.item_name + " を使った\n" + EnemyController.monster_name + "に" + item.item_effect + "のダメージ!" };
                            if (EnemyController.enemy_status["hp"] < 0)
                            {
                                LogController.logController.printText(messeage).cancel(bm.Enemy_die);
                            }
                            else
                            {
                                LogController.logController.printText(messeage).then(bm.AttackToPlayer);
                            }
                            break;

                        case (int)ItemList.Eff.At_up:
                            PlayerContoroller.player_status["at"] = item.item_effect;
                            bm.isUsedItem = true;
                            messeage      = new string[] { item.item_name + " を使った\n" + PlayerContoroller.player_name + "の力が" + item.item_effect + "上がった!" };
                            LogController.logController.printText(messeage).then(bm.AttackToPlayer);
                            break;

                        case (int)ItemList.Eff.Df_up:
                            PlayerContoroller.player_status["df"] = item.item_effect;
                            bm.isUsedItem = true;
                            messeage      = new string[] { item.item_name + " を使った\n" + PlayerContoroller.player_name + "の防御力が" + item.item_effect + "上がった!" };
                            LogController.logController.printText(messeage).then(bm.AttackToPlayer);
                            break;

                        case (int)ItemList.Eff.Ag_up:
                            PlayerContoroller.player_status["ag"] = item.item_effect;
                            bm.isUsedItem = true;
                            messeage      = new string[] { item.item_name + " を使った\n" + PlayerContoroller.player_name + "の素早さ" + item.item_effect + "上がった!" };
                            LogController.logController.printText(messeage).then(bm.AttackToPlayer);
                            break;

                        default:
                            break;
                        }
                        my_items.Remove(my_items[i]);
                        break;
                    }
                }
            }
            Back();
            statusWindow.GetComponent <StatusController>().Print();
        }
    }