/// <summary> /// 開く /// </summary> public static void Open( SingleBattleResultPopupContent prefab, Master.SingleStageData stageData, SinglePlayApi.ClearResponseData response, Rank clearRank, Action onClose) { //報酬 var rewards = response.firstReward.Concat(response.normalReward).ToArray(); //ローダー準備 var loader = new AssetListLoader(rewards .Select(x => CommonIconUtility.GetItemInfo(x.itemType, x.itemId)) .Where(x => !x.IsCommonSprite()) .Select(x => new AssetLoader <Sprite>(x.GetSpritePath()))); //ロード中はタッチブロック SharedUI.Instance.DisableTouch(); //ロード loader.Load(() => { //タッチブロック解除 SharedUI.Instance.EnableTouch(); //ダイアログ開く var dialog = SharedUI.Instance.ShowSimpleDialog(); var content = dialog.AddContent(prefab); content.Setup(dialog, stageData, response, clearRank, rewards, loader, onClose); }); }
/// <summary> /// セットアップ /// </summary> private void Setup( SimpleDialog dialog, Master.SingleStageData stageData, SinglePlayApi.ClearResponseData response, Rank clearRank, SinglePlayApi.RewardData[] rewards, AssetListLoader loader, Action onClose) { this.dialog = dialog; this.dialog.onClose = onClose; this.response = response; this.rewards = rewards; this.loader = loader; //星マーク for (int i = 0; i < this.starImage.Length; i++) { this.starImage[i].enabled = i < (int)clearRank - 2; } //通常報酬が8個以下なら if (this.rewards.Length < 9) { //非スクロールエリアに報酬アイコンを生成する this.horizontalLayoutGroup.gameObject.SetActive(true); this.scrollView.gameObject.SetActive(false); for (int i = 0; i < this.rewards.Length; i++) { var icon = Instantiate(this.rewardIconPrefab, this.horizontalLayoutGroup.transform, false); this.OnUpdateRewardIconView(icon.gameObject, i); } } //通常報酬が9個以上なら else { //スクロールエリアに報酬アイコンを生成する this.horizontalLayoutGroup.gameObject.SetActive(true); this.scrollView.gameObject.SetActive(true); this.scrollView.Initialize(this.rewardIconPrefab.gameObject, this.rewards.Length, this.OnUpdateRewardIconView); } //タイトルテキスト設定 this.dialog.titleText.text = Masters.LocalizeTextDB.Get("Result"); //ステージセレクトへ戻るボタンの追加 var button = this.dialog.AddOKButton(); button.text.text = Masters.LocalizeTextDB.Get("ToStageSelect"); button.onClick = this.OnClickOKButton; }