public void Setup(DataTreasureParam _data, MasterTreasureParam _master) { m_icon.Initialize(_data, _master); if (_master != null) { m_txtName.text = _master.name; m_txtOutline.text = _master.GetOutline(_data.level); } else { m_txtName.text = "なし"; m_txtOutline.text = "-----"; } if (10 <= _data.level) { m_txtGradeupPrice.text = "強化上限"; m_btnGradeup.interactable = false; } else { if (_master != null) { int price = MasterTreasure.GetGradeupPrice(_data, _master); m_txtGradeupPrice.text = price.ToString(); m_btnGradeup.interactable = price <= DataManager.Instance.GetCoin(); } else { m_txtGradeupPrice.text = "-----"; m_btnGradeup.interactable = false; } } m_btnBuyCheck.interactable = _data.treasure_id != 0 && _data.equip == 0; }
public override void OnEnter() { base.OnEnter(); treasure_serial.Value = 0; int iNum = DataManager.Instance.dataTreasure.list.Count; treasureMain.m_txtListTitle.text = string.Format("所持おたから一覧({0}/{1})", iNum, Defines.TREASURE_NUM_LIMIT); treasureMain.m_goBuyWindow.SetActive(false); treasureMain.m_treasureInfo.Setup(new DataTreasureParam(0, 0), null); treasureMain.m_btnBuy.gameObject.SetActive(true); treasureMain.m_btnGradeup.gameObject.SetActive(true); treasureMain.m_btnGradeup.onClick.AddListener(() => { DataTreasureParam data = DataManager.Instance.dataTreasure.list.Find(p => p.serial == treasure_serial.Value); MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id); DataManager.Instance.UseCoin(MasterTreasure.GetGradeupPrice(data, master)); data.level += 1; treasureMain.m_treasureInfo.Setup(data, master); foreach (IconInventry icon in treasureMain.treasure_list) { if (icon.m_dataTreasure.serial == data.serial) { icon.Initialize(data, master); icon.SelectTreasure(data.serial); } } foreach (IconInventry icon in treasureMain.equip_treasure_list) { if (icon.m_dataTreasure.serial == data.serial) { icon.Initialize(data, master); icon.SelectTreasure(data.serial); } } DataManager.Instance.dataTreasure.Save(); DataManager.Instance.user_data.Save(); }); treasureMain.m_btnBuy.onClick.AddListener(() => { Fsm.Event("buy"); }); treasureMain.m_btnEdit.gameObject.SetActive(true); treasureMain.m_btnAlbum.gameObject.SetActive(true); treasureMain.m_btnEdit.onClick.AddListener(() => { Fsm.Event("edit"); }); treasureMain.m_btnAlbum.onClick.AddListener(() => { Fsm.Event("album"); }); treasureMain.m_btnMenuBulk.gameObject.SetActive(true); treasureMain.m_btnMenuBulk.onClick.AddListener(() => { Fsm.Event("bulk"); }); SetupEquip(); treasureMain.treasure_list.Clear(); MonoBehaviourEx.DeleteObjects <IconInventry>(treasureMain.m_goListContents); foreach (DataTreasureParam treasure in DataManager.Instance.dataTreasure.list) { IconInventry icon = PrefabManager.Instance.MakeScript <IconInventry>(treasureMain.m_prefIconInventry, treasureMain.m_goListContents); MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == treasure.treasure_id); icon.Initialize(treasure, master); treasureMain.treasure_list.Add(icon); icon.OnClickTreasure.AddListener(OnSelectListTreasure); } }
public override void OnEnter() { base.OnEnter(); int iNum = DataManager.Instance.dataTreasure.list.Count; treasureMain.m_txtListTitle.text = string.Format("おたから編集({0}/{1})", iNum, Defines.TREASURE_NUM_LIMIT); equip_position = -1; treasure_serial = -1; SetupEquip(); treasureMain.m_btnBuy.gameObject.SetActive(false); treasureMain.m_btnGradeup.gameObject.SetActive(false); treasureMain.m_btnGradeup.onClick.AddListener(() => { DataTreasureParam data = DataManager.Instance.dataTreasure.list.Find(p => p.serial == treasure_serial); MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id); DataManager.Instance.UseCoin(MasterTreasure.GetGradeupPrice(data, master)); data.level += 1; treasureMain.m_treasureInfo.Setup(data, master); foreach (IconInventry icon in treasureMain.treasure_list) { if (icon.m_dataTreasure.serial == data.serial) { icon.Initialize(data, master); icon.SelectTreasure(data.serial); } } foreach (IconInventry icon in treasureMain.equip_treasure_list) { if (icon.m_dataTreasure.serial == data.serial) { icon.Initialize(data, master); icon.SelectTreasure(data.serial); } } DataManager.Instance.dataTreasure.Save(); DataManager.Instance.user_data.Save(); }); treasureMain.m_btnSet.gameObject.SetActive(true); treasureMain.m_btnBack.gameObject.SetActive(true); treasureMain.m_btnSet.interactable = false; treasureMain.m_btnSet.onClick.AddListener(() => { DataTreasureParam temp_data = DataManager.Instance.dataTreasure.list.Find(p => p.serial == treasure_serial); DataTreasureParam preset_data = DataManager.Instance.dataTreasure.list.Find(p => p.equip == equip_position); if (temp_data != null) { if (preset_data != null) { int temp_position = temp_data.equip; preset_data.equip = temp_position; } temp_data.equip = equip_position; } else { if (preset_data != null) { preset_data.equip = 0; } } /* * if(preset_data != null && temp_data != null) * { * if( preset_data.serial == temp_data.serial) * { * // なにもしない * } * else if(temp_data.equip != 0) * { * int temp_position = temp_data.equip; * temp_data.equip = preset_data.equip; * preset_data.equip = temp_position; * } * else * { * temp_data.equip = equip_position; * } * } * else if( temp_data != null) * { * temp_data.equip = equip_position; * } * else if(preset_data != null && temp_data == null) * { * // 外す * preset_data.equip = 0; * } * else * { * // 入らないんじゃない? * } */ DataManager.Instance.dataTreasure.Save(); Fsm.Event("equip"); }); treasureMain.m_btnBack.onClick.RemoveAllListeners(); treasureMain.m_btnBack.onClick.AddListener(() => { Fsm.Event("back"); }); treasureMain.treasure_list.Clear(); MonoBehaviourEx.DeleteObjects <IconInventry>(treasureMain.m_goListContents); IconInventry remove_icon = PrefabManager.Instance.MakeScript <IconInventry>(treasureMain.m_prefIconInventry, treasureMain.m_goListContents); remove_icon.Initialize(new DataTreasureParam(0, 0), null); remove_icon.m_txtNotInventry.text = "はずす"; remove_icon.OnClickTreasure.AddListener(OnSelectListTreasure); treasureMain.treasure_list.Add(remove_icon); foreach (DataTreasureParam treasure in DataManager.Instance.dataTreasure.list) { IconInventry icon = PrefabManager.Instance.MakeScript <IconInventry>(treasureMain.m_prefIconInventry, treasureMain.m_goListContents); MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == treasure.treasure_id); icon.Initialize(treasure, master); treasureMain.treasure_list.Add(icon); icon.OnClickTreasure.AddListener(OnSelectListTreasure); } }