Ejemplo n.º 1
0
        public override void OnEnter()
        {
            base.OnEnter();
            treasureMain.m_txtListTitle.text = string.Format("おたから図鑑({0}/{1})",
                                                             DataManager.Instance.dataTreasureAlbum.list.Count,
                                                             DataManager.Instance.masterTreasure.list.Count);

            treasureMain.m_btnBack.gameObject.SetActive(true);
            treasureMain.m_btnBuy.gameObject.SetActive(false);
            treasureMain.m_btnGradeup.gameObject.SetActive(false);

            SetupEquip();

            treasureMain.m_btnBack.onClick.AddListener(() =>
            {
                Fsm.Event("back");
            });

            treasureMain.treasure_list.Clear();
            MonoBehaviourEx.DeleteObjects <IconInventry>(treasureMain.m_goListContents);
            foreach (DataTreasureParam treasure in DataManager.Instance.dataTreasureAlbum.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);
            }
        }
Ejemplo n.º 2
0
        public override void OnEnter()
        {
            base.OnEnter();
            treasureMain.m_goBuyWindow.SetActive(true);

            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);

            treasureMain.icon_buy.Initialize(data, master);
            treasureMain.m_txtPrice.text = MasterTreasure.GetSellPrice(data, master).ToString();

            treasureMain.m_btnBuyYes.onClick.AddListener(() =>
            {
                DataTreasureParam remove_data     = DataManager.Instance.dataTreasure.list.Find(p => p.serial == treasure_serial.Value);
                MasterTreasureParam remove_master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == remove_data.treasure_id);

                int add_gold = MasterTreasure.GetSellPrice(remove_data, remove_master);
                DataManager.Instance.AddCoin(add_gold);
                DataManager.Instance.dataTreasure.list.Remove(remove_data);

                Fsm.Event("buy");
            });
            treasureMain.m_btnBuyCancel.onClick.AddListener(() =>
            {
                Fsm.Event("cancel");
            });
        }
Ejemplo n.º 3
0
        private void OnSelectListTreasure(DataTreasureParam arg0)
        {
            treasureMain.SelectListData(arg0.serial);
            MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == arg0.treasure_id);

            treasureMain.m_treasureInfo.Setup(arg0, master);
        }
Ejemplo n.º 4
0
        public void SetupEquip()
        {
            treasureMain.m_prefIconInventry.SetActive(false);
            treasureMain.equip_treasure_list.Clear();
            MonoBehaviourEx.DeleteObjects <IconInventry>(treasureMain.m_rootSettingTreasure);
            for (int i = 0; i < 3; i++)
            {
                IconInventry icon = PrefabManager.Instance.MakeScript <IconInventry>(treasureMain.m_prefIconInventry, treasureMain.m_rootSettingTreasure);

                DataTreasureParam equip_data = DataManager.Instance.dataTreasure.list.Find(p => p.equip == i + 1);
                if (equip_data != null)
                {
                    MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == equip_data.treasure_id);
                    icon.Initialize(equip_data, master);
                }
                else
                {
                    equip_data             = new DataTreasureParam();
                    equip_data.equip       = i + 1;
                    equip_data.treasure_id = 0;
                    icon.Initialize(equip_data, null);
                }

                treasureMain.equip_treasure_list.Add(icon);
                icon.OnClickTreasure.AddListener(OnSelectEquipBase);
            }
            treasureMain.SelectEquip(0);
        }
Ejemplo n.º 5
0
        private void OnSelectListTreasure(DataTreasureParam arg0)
        {
            treasure_serial = arg0.serial;
            treasureMain.SelectListData(arg0.serial);
            treasureMain.m_btnSet.interactable = CheckExchangeButton();

            MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == arg0.treasure_id);

            treasureMain.m_treasureInfo.Setup(arg0, master);
        }
Ejemplo n.º 6
0
        public override void OnSelectEquip(DataTreasureParam arg0)
        {
            MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == arg0.treasure_id);

            treasureMain.m_treasureInfo.Setup(arg0, master);

            treasureMain.SelectEquip(arg0.equip);
            treasureMain.SelectListData(0);

            treasure_serial.Value = arg0.serial;
        }
Ejemplo n.º 7
0
        public override void OnEnter()
        {
            base.OnEnter();

            treasureMain.m_btnEdit.gameObject.SetActive(false);
            treasureMain.m_btnAlbum.gameObject.SetActive(false);

            treasureMain.m_btnBuyBulk.interactable = false;
            treasureMain.m_txtBuyBulkPrice.text    = "0";

            treasureMain.m_goBulkPriceRoot.SetActive(true);

            treasureMain.m_btnBuyBulkCancel.onClick.RemoveAllListeners();
            treasureMain.m_btnBuyBulkCancel.onClick.AddListener(() =>
            {
                Finish();
            });
            treasureMain.m_btnBack.gameObject.SetActive(true);
            treasureMain.m_btnBack.onClick.RemoveAllListeners();
            treasureMain.m_btnBack.onClick.AddListener(() =>
            {
                Finish();
            });


            bulk_list.Clear();
            foreach (IconInventry icon in treasureMain.treasure_list)
            {
                icon.OnSelect(false);
                icon.OnClickTreasure.RemoveAllListeners();
                icon.OnClickTreasure.AddListener(OnSelectListTreasure);
            }

            treasureMain.m_btnBuyBulk.onClick.RemoveAllListeners();
            treasureMain.m_btnBuyBulk.onClick.AddListener(() =>
            {
                int total_price = 0;
                foreach (DataTreasureParam buy in bulk_list)
                {
                    DataTreasureParam data     = DataManager.Instance.dataTreasure.list.Find(p => p.serial == buy.serial);
                    MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id);
                    total_price += MasterTreasure.GetSellPrice(data, master);
                }
                DataManager.Instance.AddCoin(total_price);
                foreach (DataTreasureParam buy in bulk_list)
                {
                    DataManager.Instance.dataTreasure.list.Remove(buy);
                }
                DataManager.Instance.dataTreasure.Save();
                DataManager.Instance.user_data.Save();
                Finish();
            });
        }
Ejemplo n.º 8
0
        public override void OnSelectEquip(DataTreasureParam arg0)
        {
            equip_position = arg0.equip;
            treasureMain.SelectEquip(arg0.equip);


            MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == arg0.treasure_id);

            treasureMain.m_treasureInfo.Setup(arg0, master);

            treasureMain.m_btnSet.interactable = CheckExchangeButton();
        }
Ejemplo n.º 9
0
    public void add_treasure_assist(MasterTreasureParam _treasure, int _iLevel)
    {
        int iParam = _treasure.GetParam(_iLevel);

        switch (_treasure.type)
        {
        case "coin":
            coin += iParam;
            break;

        case "hp":
        case "hp_max":
            hp += iParam;
            break;

        case "def":
            def += iParam;
            break;

        case "mind":
            mind += iParam;
            break;

        case "move":
            move += iParam;
            break;

        case "attack":
            attack += iParam;
            break;

        case "heal":
            heal += iParam;
            break;

        case "luck":
            luck += iParam;
            break;

        default:
            break;
        }
    }
Ejemplo n.º 10
0
    public static TreasureAssist GetTreasureAssist(List <DataTreasureParam> _data_treasure_list)
    {
        TreasureAssist ret = new TreasureAssist();

        ret.coin   = 100;
        ret.hp     = 100;
        ret.def    = 100;
        ret.mind   = 100;
        ret.move   = 100;
        ret.attack = 100;
        ret.heal   = 100;
        ret.luck   = 100;

        foreach (DataTreasureParam data in _data_treasure_list)
        {
            MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id);
            ret.add_treasure_assist(master, data.level);
        }
        return(ret);
    }
Ejemplo n.º 11
0
        public override void OnEnter()
        {
            base.OnEnter();
            DateTime check_datetime;

            DataManager.Instance.user_data.Write(
                Defines.KEY_LAST_REWARD_TIME_FREE_TREASURE,
                NTPTimer.Instance.now.ToString("yyyy/MM/dd HH:mm:ss"));
            check_datetime = System.DateTime.Parse(DataManager.Instance.user_data.Read(Defines.KEY_LAST_REWARD_TIME_FREE_TREASURE));

            GachaMain.Instance.OnGachaFinished.RemoveAllListeners();
            GachaMain.Instance.OnGachaFinished.AddListener(() =>
            {
                GachaMain.Instance.Close();
                Finish();
            });
            List <MasterTreasureParam> hit_list = DataManager.Instance.masterTreasure.list.FindAll(p => 1 <= p.rarity && p.rarity <= 3);

            int[] prob_arr = new int[hit_list.Count];
            for (int i = 0; i < hit_list.Count; i++)
            {
                prob_arr[i] = hit_list[i].GetGachaProbFree();
            }
            int index = UtilRand.GetIndex(prob_arr);

            MasterTreasureParam get_item = hit_list[index];

            DataManager.Instance.dataTreasure.Add(get_item.treasure_id);

            GachaMain.ChestData chest_data = new GachaMain.ChestData();
            chest_data.rarity    = get_item.rarity;
            chest_data.spr_item  = shop.m_sprAtlasTreasure.GetSprite(get_item.sprite_name);
            chest_data.spr_chest = shop.m_sprAtlasIcons.GetSprite("chest_t_01");

            DataManager.Instance.dataTreasure.Save();
            DataManager.Instance.dataTreasureAlbum.Save();
            DataManager.Instance.user_data.Save();
            GachaMain.Instance.GachaSingle(chest_data);
        }
Ejemplo n.º 12
0
        private void OnSelectListTreasure(DataTreasureParam arg0)
        {
            if (0 < arg0.equip)
            {
                return;
            }
            if (bulk_list.Contains(arg0))
            {
                bulk_list.Remove(arg0);
            }
            else
            {
                bulk_list.Add(arg0);
            }
            foreach (IconInventry icon in treasureMain.treasure_list)
            {
                bool bFlag = false;
                foreach (DataTreasureParam w in bulk_list)
                {
                    if (w.serial == icon.m_dataTreasure.serial)
                    {
                        bFlag = true;
                    }
                }
                icon.OnSelect(bFlag);
            }

            int total_price = 0;

            foreach (DataTreasureParam buy in bulk_list)
            {
                DataTreasureParam   data   = DataManager.Instance.dataTreasure.list.Find(p => p.serial == buy.serial);
                MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == data.treasure_id);
                total_price += MasterTreasure.GetSellPrice(data, master);
            }
            treasureMain.m_txtBuyBulkPrice.text    = total_price.ToString();
            treasureMain.m_btnBuyBulk.interactable = 0 < bulk_list.Count;
        }
Ejemplo n.º 13
0
    public bool AddAlbum(int _iTreasureId)
    {
        DataTreasureParam check_exist = list.Find(p => p.treasure_id == _iTreasureId);

        if (check_exist != null)
        {
            return(false);
        }

        MasterTreasureParam master_exist = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == _iTreasureId);

        if (master_exist == null)
        {
            // そもそもない
            return(false);
        }

        // シリアルは使わない
        DataTreasureParam add = new DataTreasureParam(0, _iTreasureId);

        list.Add(add);
        return(true);
    }
Ejemplo n.º 14
0
    public void Initialize(DataTreasureParam _data, MasterTreasureParam _master)
    {
        m_dataTreasure = _data;

        if (_master != null)
        {
            m_goShowRoot.SetActive(true);
            m_goNotInventry.SetActive(false);
            m_imgIcon.sprite = m_spriteAtlas.GetSprite(_master.sprite_name);
            m_goEquip.SetActive(0 < _data.equip);

            if (0 < _data.level)
            {
                m_txtLevel.text = string.Format("+{0}", _data.level);
            }
            else
            {
                m_txtLevel.text = "";
            }
            for (int i = 0; i < star_list.Count; i++)
            {
                star_list[i].sprite = i < _master.rarity ? m_sprStarOn : m_sprStarOff;
            }
        }
        else
        {
            m_goShowRoot.SetActive(false);
            m_goNotInventry.SetActive(true);
        }

        m_btn.onClick.RemoveAllListeners();
        m_btn.onClick.AddListener(() =>
        {
            OnClickTreasure.Invoke(m_dataTreasure);
        });
    }
Ejemplo n.º 15
0
    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;
    }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
0
        public override void OnEnter()
        {
            base.OnEnter();

            main.m_btnQuest.onClick.RemoveAllListeners();
            main.m_btnQuest.onClick.AddListener(() =>
            {
                Fsm.Event("quest");
            });

            // charaview
            main.m_charaView.Initialize();

            // weapon
            DataWeaponParam   data_equip   = DataManager.Instance.dataWeapon.list.Find(p => 0 < p.equip);
            MasterWeaponParam master_equip = DataManager.Instance.masterWeapon.list.Find(p => p.weapon_id == data_equip.weapon_id);

            main.m_weaponInfo.Setup(data_equip, master_equip);

            // treasure
            main.m_prefIconTreasure.SetActive(false);
            main.treasure_list.Clear();
            MonoBehaviourEx.DeleteObjects <IconInventry>(main.m_goTreasureRoot);
            for (int i = 0; i < 3; i++)
            {
                IconInventry      icon       = PrefabManager.Instance.MakeScript <IconInventry>(main.m_prefIconTreasure, main.m_goTreasureRoot);
                DataTreasureParam equip_data = DataManager.Instance.dataTreasure.list.Find(p => p.equip == i + 1);
                if (equip_data != null)
                {
                    MasterTreasureParam master = DataManager.Instance.masterTreasure.list.Find(p => p.treasure_id == equip_data.treasure_id);
                    icon.Initialize(equip_data, master);
                }
                else
                {
                    equip_data             = new DataTreasureParam();
                    equip_data.equip       = i + 1;
                    equip_data.treasure_id = 0;
                    icon.Initialize(equip_data, null);
                }
                main.treasure_list.Add(icon);
            }

            // armor
            main.icon_armor_list.Clear();
            main.m_prefIconArmor.SetActive(false);
            MonoBehaviourEx.DeleteObjects <IconArmor>(main.m_goArmorLeft);
            MonoBehaviourEx.DeleteObjects <IconArmor>(main.m_goArmorRight);
            for (int i = 0; i < 4; i++)
            {
                IconArmor script = PrefabManager.Instance.MakeScript <IconArmor>(main.m_prefIconArmor, main.m_goArmorLeft);
                main.icon_armor_list.Add(script);
            }
            for (int i = 0; i < 4; i++)
            {
                IconArmor script = PrefabManager.Instance.MakeScript <IconArmor>(main.m_prefIconArmor, main.m_goArmorRight);
                main.icon_armor_list.Add(script);
            }

            for (int i = 0; i < MasterArmor.ArmorPositionArr.Length; i++)
            {
                DataArmorParam data = DataManager.Instance.dataArmor.list.Find(p => p.position == MasterArmor.ArmorPositionArr[i]);
                main.icon_armor_list[i].Initialize(data, DataManager.Instance.masterArmor.list);
            }
            main.m_panelStage.gameObject.SetActive(false);
            ShowParamsTotal();
            Finish();
        }
Ejemplo n.º 18
0
        public override void OnEnter()
        {
            base.OnEnter();

            shop.m_goBannerTreasureFree.SetActive(true);
            shop.m_goBannerTreasure1.SetActive(true);
            shop.m_goBannerTreasure2.SetActive(true);
            if (!DataManager.Instance.user_data.HasKey(Defines.KEY_LAST_REWARD_TIME_FREE_TREASURE))
            {
                check_datetime = new DateTime(2020, 1, 1);
            }
            else
            {
                check_datetime = System.DateTime.Parse(DataManager.Instance.user_data.Read(Defines.KEY_LAST_REWARD_TIME_FREE_TREASURE));
            }
            button_interactable();
            shop.m_goTreasureFreeButtonRoot.SetActive(false);
            shop.m_goTreasureFreeTimeRoot.SetActive(false);

            int treasure_num = DataManager.Instance.dataTreasure.list.Count;

            shop.m_goLimitCoverTreasureFree.SetActive(!(treasure_num + 1 <= Defines.TREASURE_NUM_LIMIT));
            shop.m_goLimitCoverTreasureNormal.SetActive(!(treasure_num + 1 <= Defines.TREASURE_NUM_LIMIT));
            shop.m_goLimitCoverTreasureGold.SetActive(!(treasure_num + 10 <= Defines.TREASURE_NUM_LIMIT));

            shop.m_btnTreasureFree.onClick.AddListener(() =>
            {
                Fsm.Event("free");
            });
            shop.m_btnTreasure1.onClick.AddListener(() =>
            {
                DataManager.Instance.UseKey(50);
                button_interactable();

                GachaMain.Instance.OnGachaFinished.RemoveAllListeners();
                GachaMain.Instance.OnGachaFinished.AddListener(() =>
                {
                    GachaMain.Instance.Close();

                    int treasure_num2 = DataManager.Instance.dataTreasure.list.Count;
                    shop.m_goLimitCoverTreasureFree.SetActive(!(treasure_num2 + 1 <= Defines.TREASURE_NUM_LIMIT));
                    shop.m_goLimitCoverTreasureNormal.SetActive(!(treasure_num2 + 1 <= Defines.TREASURE_NUM_LIMIT));
                    shop.m_goLimitCoverTreasureGold.SetActive(!(treasure_num2 + 10 <= Defines.TREASURE_NUM_LIMIT));
                });
                List <MasterTreasureParam> hit_list = DataManager.Instance.masterTreasure.list.FindAll(p => 2 <= p.rarity && p.rarity <= 3);
                int[] prob_arr = new int[hit_list.Count];
                for (int i = 0; i < hit_list.Count; i++)
                {
                    prob_arr[i] = hit_list[i].GetGachaProb();
                }
                int index = UtilRand.GetIndex(prob_arr);

                MasterTreasureParam get_item = hit_list[index];
                DataManager.Instance.dataTreasure.Add(get_item.treasure_id);

                GachaMain.ChestData chest_data = new GachaMain.ChestData();
                chest_data.rarity    = get_item.rarity;
                chest_data.spr_item  = shop.m_sprAtlasTreasure.GetSprite(get_item.sprite_name);
                chest_data.spr_chest = shop.m_sprAtlasIcons.GetSprite("chest_t_01");
                DataManager.Instance.dataTreasure.Save();
                DataManager.Instance.dataTreasureAlbum.Save();
                DataManager.Instance.user_data.Save();
                GachaMain.Instance.GachaSingle(chest_data);
            });
            shop.m_btnTreasure2.onClick.AddListener(() =>
            {
                DataManager.Instance.UseGoldKey(50);
                button_interactable();

                GachaMain.Instance.OnGachaFinished.RemoveAllListeners();
                GachaMain.Instance.OnGachaFinished.AddListener(() =>
                {
                    GachaMain.Instance.Close();
                    int treasure_num2 = DataManager.Instance.dataTreasure.list.Count;
                    shop.m_goLimitCoverTreasureFree.SetActive(!(treasure_num2 + 1 <= Defines.TREASURE_NUM_LIMIT));
                    shop.m_goLimitCoverTreasureNormal.SetActive(!(treasure_num2 + 1 <= Defines.TREASURE_NUM_LIMIT));
                    shop.m_goLimitCoverTreasureGold.SetActive(!(treasure_num2 + 10 <= Defines.TREASURE_NUM_LIMIT));
                });
                List <MasterTreasureParam> hit_list = DataManager.Instance.masterTreasure.list.FindAll(p => 3 <= p.rarity && p.rarity <= 5);
                int[] prob_arr = new int[hit_list.Count];
                for (int i = 0; i < hit_list.Count; i++)
                {
                    prob_arr[i] = hit_list[i].GetGachaProb();
                }
                int index = UtilRand.GetIndex(prob_arr);

                MasterTreasureParam get_item = hit_list[index];
                if (shop.m_sprAtlasTreasure.GetSprite(get_item.sprite_name) == null)
                {
                    Debug.Log(get_item.sprite_name);
                }
                DataManager.Instance.dataTreasure.Add(get_item.treasure_id);

                GachaMain.ChestData chest_data = new GachaMain.ChestData();
                chest_data.rarity    = get_item.rarity;
                chest_data.spr_item  = shop.m_sprAtlasTreasure.GetSprite(get_item.sprite_name);
                chest_data.spr_chest = shop.m_sprAtlasIcons.GetSprite("chest_t_01");

                DataManager.Instance.dataTreasure.Save();
                DataManager.Instance.dataTreasureAlbum.Save();
                DataManager.Instance.user_data.Save();
                GachaMain.Instance.GachaSingle(chest_data);
            });
        }
Ejemplo n.º 19
0
        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);
            }
        }