Beispiel #1
0
        private void show_sell_prompt(MasterItemParam _master, DataItemParam _data)
        {
            m_goPrompt.SetActive(true);
            m_btnPromptYes.onClick.RemoveAllListeners();
            m_btnPromptYes.onClick.AddListener(() =>
            {
                m_goPrompt.SetActive(false);

                //DataManager.Instance.gold -= _master.price;
                if (_master.category == "equip")
                {
                    DataManager.Instance.data_item_equip.list.Remove(_data);
                }
                else
                {
                    DataManager.Instance.data_item_consume.list.Remove(_data);
                }
                DataManager.Instance.gold += _master.sell_price;
                m_txtGold.text             = string.Format("{0}g", DataManager.Instance.gold);
            });

            m_txtPrompt.text            = string.Format("{0}で売却しますか", _master.sell_price);
            m_btnPromptYes.interactable = true;
            m_btnPromptNo.interactable  = true;
        }
Beispiel #2
0
        private IEnumerator sell(List <DataItemParam> _list)
        {
            m_goList.SetActive(true);
            m_goDetail.SetActive(false);
            m_goPrompt.SetActive(false);

            for (int i = 0; i < m_shopItemButtonArr.Length; i++)
            {
                if (i < _list.Count)
                {
                    m_shopItemButtonArr[i].gameObject.SetActive(true);

                    int           item_id = _list[i].item_id;
                    DataItemParam data    = _list[i];

                    MasterItemParam master = DataManager.Instance.master_item.list.Find(p => p.item_id == item_id);

                    m_shopItemButtonArr[i].m_txtName.text  = master.name;
                    m_shopItemButtonArr[i].m_txtPrice.text = master.price.ToString();
                    m_shopItemButtonArr[i].m_btn.onClick.AddListener(() =>
                    {
                        show_detail(master);
                        show_sell_prompt(master, data);
                    });
                }
                else
                {
                    m_shopItemButtonArr[i].gameObject.SetActive(false);
                }
            }
            yield return(null);
        }
Beispiel #3
0
        private void show_buy_prompt(MasterItemParam _master)
        {
            m_goPrompt.SetActive(true);
            m_btnPromptYes.onClick.RemoveAllListeners();
            m_btnPromptYes.onClick.AddListener(() =>
            {
                m_goPrompt.SetActive(false);

                //DataManager.Instance.gold -= _master.price;
                if (_master.category == "equip")
                {
                    DataItemParam new_item = new DataItemParam();
                    new_item.item_id       = _master.item_id;
                    DataManager.Instance.data_item_equip.AddItem(new_item);
                }
                else
                {
                    DataItemParam new_item = new DataItemParam();
                    new_item.item_id       = _master.item_id;
                    DataManager.Instance.data_item_consume.AddItem(new_item);
                }
                DataManager.Instance.gold -= _master.price;
                m_txtGold.text             = string.Format("{0}g", DataManager.Instance.gold);
            });

            if (_master.price <= DataManager.Instance.gold)
            {
                m_txtPrompt.text            = string.Format("{0}で購入しますか", _master.price);
                m_btnPromptYes.interactable = true;
                m_btnPromptNo.interactable  = true;
            }
            else
            {
                m_txtPrompt.text            = string.Format("<color=red>ゴールドが不足しています</color>");
                m_btnPromptYes.interactable = false;
                m_btnPromptNo.interactable  = true;
            }

            //DataManager.Instance.gold -= _master.price;

            bool bHasLimit;

            if (_master.category == "equip")
            {
                bHasLimit = DataManager.Instance.data_item_equip.list.Count < item_limit;
                if (bHasLimit == false)
                {
                    m_txtPrompt.text = string.Format("<color=red>装備が持ちきれません</color>");
                }
            }
            else
            {
                bHasLimit = DataManager.Instance.data_item_consume.list.Count < item_limit;
                if (bHasLimit == false)
                {
                    m_txtPrompt.text = string.Format("<color=red>アイテムが持ちきれません</color>");
                }
            }
            m_btnPromptYes.interactable = bHasLimit;
        }
Beispiel #4
0
        private void OnEnable()
        {
            if (m_iSelectingItemSerial.Value == 0)
            {
                return;
            }
            m_dataItemParam   = DataManager.Instance.m_dataItem.list.Find(p => p.item_serial == m_iSelectingItemSerial.Value);
            m_masterItemParam = DataManager.Instance.m_masterItem.list.Find(p => p.item_id == m_dataItemParam.item_id);

            m_headerBanner.Initialize(m_dataItemParam);

            m_btnUse.gameObject.SetActive(m_masterItemParam.field);

            m_txtDescription.text = m_masterItemParam.description;

            // 味方全体の場合はいきなり使うボタンが押せる
            if (m_masterItemParam.item_target == "friendall")
            {
                m_btnUse.interactable = true;
            }
            else if (m_masterItemParam.item_target == "friendone")
            {
                m_btnUse.interactable = false;
                m_fieldMenu.OnDataUnitParam.AddListener(SelectCardUnit);
            }
            else
            {
                Debug.LogError($"okashi_item_target:{m_masterItemParam.item_target}");
            }
        }
Beispiel #5
0
        public void Initialize(DataItemParam _param)
        {
            m_dataItemParam = _param;
            MasterItemParam master = DataManager.Instance.m_masterItem.list
                                     .Find((p => p.item_id == _param.item_id));

            Initialize(master);
        }
Beispiel #6
0
        private void clear_items()
        {
            if (item_list != null)
            {
                foreach (MenuItemsButton btn in item_list)
                {
                    Destroy(btn.gameObject);
                }
                item_list.Clear();
            }
            item_list = new List <MenuItemsButton>();
            for (int i = 0; i < 10; i++)
            {
                GameObject inst = Instantiate(
                    m_prefItemButton,
                    m_rootItemList.transform);
                inst.SetActive(true);
                MenuItemsButton script = inst.GetComponent <MenuItemsButton>();

                if (i < DataManager.Instance.data_item_consume.list.Count)
                {
                    DataItemParam   data   = DataManager.Instance.data_item_consume.list[i];
                    MasterItemParam master = DataManager.Instance.master_item.list.Find(p => p.item_id == DataManager.Instance.data_item_consume.list[i].item_id);
                    script.m_txtName.text = master.name;
                    script.m_btn.onClick.AddListener(() =>
                    {
                        m_iSelectedItemSerial = data.item_serial;
                        OnUpdate = select_chara;

                        es.SetSelectedGameObject(null);
                        m_btnDiscard.interactable = true;

                        foreach (CharaSlot cs in chara_slot_list)
                        {
                            cs.m_btn.interactable = true;
                        }
                    });
                }
                else
                {
                    script.m_txtName.text = "";
                }
                item_list.Add(script);
            }
        }
Beispiel #7
0
        public void top(bool _bInit)
        {
            if (_bInit)
            {
                m_btnUse.interactable     = false;
                m_btnDiscard.interactable = false;

                m_btnUse.onClick.AddListener(() =>
                {
                    DataItemParam data_item     = DataManager.Instance.data_item_consume.list.Find(p => p.item_serial == m_iSelectedItemSerial);
                    MasterItemParam master_item = DataManager.Instance.master_item.list.Find(p => p.item_id == data_item.item_id);

                    Debug.Log(string.Format("{0}を使った", master_item.name));

                    DataManager.Instance.data_item_consume.list.Remove(data_item);

                    clear_items();
                    clear_charaslot();
                });
                m_btnDiscard.onClick.AddListener(() =>
                {
                    Debug.Log(m_iSelectedItemSerial);
                    DataItemParam data_item     = DataManager.Instance.data_item_consume.list.Find(p => p.item_serial == m_iSelectedItemSerial);
                    MasterItemParam master_item = DataManager.Instance.master_item.list.Find(p => p.item_id == data_item.item_id);

                    Debug.Log(string.Format("{0}を捨てた", master_item.name));

                    DataManager.Instance.data_item_consume.list.Remove(data_item);
                    clear_items();
                    clear_charaslot();
                });



                m_prefItemButton.SetActive(false);
                clear_items();


                // CharaSlot
                m_prefCharaSlot.SetActive(false);
                clear_charaslot();
            }
        }
Beispiel #8
0
        public override void Initialize()
        {
            base.Initialize();
            master_quest = new MasterQuest();
            master_quest.Load(m_taMasterQuest);
            master_item = new MasterItem();
            master_item.Load(m_taMasterItem);
            master_chara = new MasterChara();
            master_chara.Load(m_taMasterChara);

            data_quest = new DataQuest();
            data_quest.SetSaveFilename("data/data_quest");
            if (data_quest.Load() == false)
            {
                Debug.Log("loaderror.data_quest");
            }

            data_item_consume = new DataItem();
            data_item_consume.SetSaveFilename("data/data_item_consume");
            if (data_item_consume.Load() == false)
            {
                DataItemParam item = new DataItemParam
                {
                    item_id = 1
                };
                data_item_consume.AddItem(item);
                DataItemParam item2 = new DataItemParam
                {
                    item_id = 1
                };
                data_item_consume.AddItem(item2);
                Debug.Log("loaderror.data_item_consume");
            }
            data_item_equip = new DataItem();
            data_item_equip.SetSaveFilename("data/data_item_equip");
            if (data_item_equip.Load() == false)
            {
                Debug.Log("loaderror.data_item_equip");
            }

            data_chara = new DataChara();
            data_chara.SetSaveFilename("data/data_chara");
            if (data_chara.Load() == false)
            {
                DataCharaParam slime = new DataCharaParam
                {
                    chara_id = 1,
                    position = 1
                };
                slime.Build(1, master_chara.list.Find(p => p.chara_id == 1));
                data_chara.list.Add(slime);
                DataCharaParam fairy = new DataCharaParam
                {
                    chara_id = 3,
                    position = 2
                };
                fairy.Build(1, master_chara.list.Find(p => p.chara_id == 3));
                data_chara.list.Add(fairy);
            }

            gold = 100;

            Initialized = true;
        }