Esempio n. 1
0
        public void Setup(Entities.EggItem item)
        {
            this.egg = item;
            if (item.judgment)
            {
                var rarity = "";
                for (int i = 0; i < this.egg.rarity; i++)
                {
                    rarity += "★";
                }
                this.rarity.text = rarity;
            }
            else
            {
                this.rarity.text = "?";
            }

            // 予約中 の場合[予約中]ラベルを表示する
            var data = Entity.Instance.HatchList.items.Find(v => v.uniqid == item.uniqid);

            hatch.SetActive(data != null);

            if (data != null)
            {
                var endtime = data.startTime + data.timeRequired;
                hatchText.text = (endtime < ServerTime.CurrentUnixTime) ? "孵化完了" : "孵化中";
            }
        }
Esempio n. 2
0
        public void TapCellItem(int index, GameObject listItem)
        {
            Entities.EggItem egg = listItem.GetComponent <EggItem>()?.egg;
            if (egg == null)
            {
                egg = listItem.GetComponent <HatchItem>()?.egg;
            }

            if (egg.judgment)
            {
                // 鑑定
                Hatch(egg);
            }
            else
            {
                DialogWindow.OpenYesNo("確認", $"タマゴを鑑定します", () =>
                {
                    // 未鑑定
                    Protocol.Send(new JudgmentSend {
                        guid = egg.uniqid
                    }, (JudgmentReceive r) =>
                    {
                        Entity.Instance.EggList.Modify(r.egg);
                        eggCell.ReloadData();
                        hatchCell.ReloadData();
                    });
                });
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 孵化関連
        /// </summary>
        /// <param name="egg"></param>
        void Hatch(Entities.EggItem egg)
        {
            var hatch = Entity.Instance.HatchList.items.Find(v => v.uniqid == egg.uniqid);

            if (hatch != null)
            {
                var remain = (hatch.startTime + hatch.timeRequired) - Util.Time.ServerTime.CurrentUnixTime;
                if (remain <= 0)
                {
                    DialogWindow.OpenYesNo("確認", $"{egg.race}のタマゴを孵化します", () =>
                    {
                        Protocol.Send(new HatchSend {
                            uniqid = egg.uniqid
                        }, (HatchReceive r) =>
                        {
                            Entity.Instance.BinderList.Modify(r.item.id);
                            Entity.Instance.PetList.Modify(r.item);
                            Entity.Instance.EggList.Remove(r.deleteEgg);
                            Entity.Instance.HatchList.Remove(r.deleteEgg.uniqid);
                            eggCell.ReloadData();  // リスト更新
                            hatchCell.ReloadData();

                            Open <PetDetailWindow>(r.item.uniqid);
                        });
                    });
                }
                else
                {
                    DialogWindow.OpenYesNo("確認", $"孵化残り時間: {remain / 60}:{remain % 60}\n広告を観て 30分短縮しますか?", () =>
                    {
                        var window           = Window.Open <AdvertisementWindow>(AdReward.Hatch, egg.uniqid);
                        window.OnCloseEvent += eggCell.ReloadData;
                        window.OnCloseEvent += hatchCell.ReloadData;
                    });
                }
            }
            else
            {
                // 同時孵化最大数チェック
                if (Entity.Instance.HatchList.items.Count < (int)Const.MaxHatch)
                {
                    DialogWindow.OpenYesNo("確認", $"{egg.race}のタマゴを孵化予約します", () =>
                    {
                        Protocol.Send(new HatchReserveSend {
                            uniqid = egg.uniqid
                        }, (r) =>
                        {
                            Entity.Instance.HatchList.Modify(r.item);
                            eggCell.ReloadData();   // リスト更新
                            hatchCell.ReloadData(); // リスト更新
                        });
                    });
                }
                else
                {
                    DialogWindow.OpenOk("確認", "これ以上の予約ができません");
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 削除する
        /// </summary>
        /// <param name="egg"></param>
        public void Remove(EggItem egg)
        {
            var index = items.FindIndex(v => v.uniqid == egg.uniqid);

            if (index != -1)
            {
                items.RemoveAt(index);
            }
        }
Esempio n. 5
0
        public void Setup(Entities.HatchItem item)
        {
            hatch    = item;
            this.egg = Entity.Instance.EggList.items.Find(v => v.uniqid == item.uniqid);
            var rarity = "";

            for (int i = 0; i < this.egg.rarity; i++)
            {
                rarity += "★";
            }
            this.rarity.text = rarity;
        }
Esempio n. 6
0
        /// <summary>
        /// 変更する
        /// </summary>
        /// <param name="egg"></param>
        public void Modify(EggItem egg)
        {
            var index = items.FindIndex(v => v.uniqid == egg.uniqid);

            if (index != -1)
            {
                items[index] = egg;
            }
            else
            {
                items.Add(egg);
            }
        }
Esempio n. 7
0
        public void PressCellItem(int index, GameObject listItem)
        {
            Entities.EggItem egg    = listItem.GetComponent <EggItem>()?.egg;
            long?            remain = null;
            var hatch = Entity.Instance.HatchList.items.Find(v => v.uniqid == egg.uniqid);

            if (hatch != null)
            {
                remain = (hatch.startTime + hatch.timeRequired) - Util.Time.ServerTime.CurrentUnixTime;
            }

            List <string> choice = new List <string> {
                "OK"
            };

            if (!egg.judgment)
            {
                choice.Add("鑑定");
            }
            else if (hatch == null && Entity.Instance.HatchList.items.Count < (int)Const.MaxHatch)
            {
                choice.Add("孵化予約");
            }
            else if (remain.HasValue && remain <= 0)
            {
                choice.Add("孵化");
            }

            if (choice.Count <= 1)
            {
                DialogWindow.OpenOk("入手場所", Entity.Name(egg.stage));
            }
            else
            {
                DialogWindow.OpenChoice("入手場所", Entity.Name(egg.stage), choice.ToArray(), (res) =>
                {
                    switch (res)
                    {
                    case "鑑定":
                        Protocol.Send(new JudgmentSend {
                            guid = egg.uniqid
                        }, (JudgmentReceive r) =>
                        {
                            Entity.Instance.EggList.Modify(r.egg);
                            eggCell.ReloadData();
                            hatchCell.ReloadData();
                        });
                        break;

                    case "孵化予約":
                        Protocol.Send(new HatchReserveSend {
                            uniqid = egg.uniqid
                        }, (r) =>
                        {
                            Entity.Instance.HatchList.Modify(r.item);
                            eggCell.ReloadData();      // リスト更新
                            hatchCell.ReloadData();    // リスト更新
                        });
                        break;

                    case "孵化":
                        Protocol.Send(new HatchSend {
                            uniqid = egg.uniqid
                        }, (HatchReceive r) =>
                        {
                            Entity.Instance.BinderList.Modify(r.item.id);
                            Entity.Instance.PetList.Modify(r.item);
                            Entity.Instance.EggList.Remove(r.deleteEgg);
                            Entity.Instance.HatchList.Remove(r.deleteEgg.uniqid);
                            eggCell.ReloadData();      // リスト更新
                            hatchCell.ReloadData();

                            Open <PetDetailWindow>(r.item.uniqid);
                        });
                        break;
                    }
                });
            }
        }