Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard.Lottery/LotteryPage.cs
gamer147 824309ec44 feat(battle-engine): close the AI-simulation subsystem (verbatim)
Copied the 89 uncopied AI*SimulationUtility/extension files defining the
AIVirtualCard/AIVirtualField extension methods; the compile loop then auto-closed
the revealed type deps (~3049 files total, drift-clean). 10.0k -> 62 errors.
2026-06-05 20:30:59 -04:00

860 lines
33 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Cute;
using UnityEngine;
using Wizard.Bingo;
namespace Wizard.Lottery;
public class LotteryPage : UIBase
{
private enum BoxType
{
NORMAL,
DOUBLE_CHANCE,
MISSION,
BIG_CHANCE
}
public struct LayoutData
{
public Vector3 BackGroundPosition { get; private set; }
public int BackGroundWidth { get; private set; }
public Vector3 GridPosition { get; private set; }
public Vector2 GridInterval { get; private set; }
public bool EnableCategoryLabel { get; private set; }
public Vector2 MissionBoxBackgroundInterval { get; private set; }
public Vector2 MisshonBoxBackgroundPosition { get; private set; }
public bool UseDefaultTreasureBox { get; private set; }
public bool UseDefaultTodayEffect { get; private set; }
public LayoutData(Vector3 backgroundPosition, int backGroundWidth, Vector3 gridPosition, Vector2 gridInterval, Vector2 missionBoxBackgroundInterval, Vector2 misshonBoxBackgroundPosition, bool enableCategoryLabel, bool useDefaultTreasureBox, bool useDefaultTodayEffect)
{
BackGroundPosition = backgroundPosition;
BackGroundWidth = backGroundWidth;
GridPosition = gridPosition;
GridInterval = gridInterval;
EnableCategoryLabel = enableCategoryLabel;
UseDefaultTreasureBox = useDefaultTreasureBox;
UseDefaultTodayEffect = useDefaultTodayEffect;
MissionBoxBackgroundInterval = missionBoxBackgroundInterval;
MisshonBoxBackgroundPosition = misshonBoxBackgroundPosition;
}
}
private readonly Vector3[] MISSION_TREASURE_BOX_POSITION = new Vector3[4]
{
new Vector3(-88f, 46f, 0f),
new Vector3(90f, 46f, 0f),
new Vector3(-88f, -73f, 0f),
new Vector3(90f, -73f, 0f)
};
private readonly Vector3[] MISSION_TREASURE_BOX_POSITION_WITH_BIG_CHANCE = new Vector3[3]
{
new Vector3(-160f, -14f, 0f),
new Vector3(0f, -14f, 0f),
new Vector3(160f, -14f, 0f)
};
private readonly Vector3[] MISSION_TREASURE_BOX_POSITION_6TH_ANNIVERSARY = new Vector3[10]
{
new Vector3(-276f, 54f, 0f),
new Vector3(-138f, 54f, 0f),
new Vector3(0f, 54f, 0f),
new Vector3(138f, 54f, 0f),
new Vector3(276f, 54f, 0f),
new Vector3(-276f, -72f, 0f),
new Vector3(-138f, -72f, 0f),
new Vector3(0f, -72f, 0f),
new Vector3(138f, -72f, 0f),
new Vector3(276f, -72f, 0f)
};
private readonly string[] MISSION_TREASURE_BOX_CATEGORY_TEXT = new string[4] { "Story_0052", "Mission_0079", "MyPage_0009", "MyPage_0011" };
private readonly string[] MISSION_BIGCHANCE_TREASURE_BOX_CATEGORY_TEXT = new string[3] { "Mission_0093", "Mission_0094", "Mission_0095" };
private readonly string[] MISSION_6TH_ANNIVERSARY_TEXT = new string[10] { "Mission_0099", "Mission_0100", "Mission_0101", "Mission_0102", "Mission_0103", "Mission_0104", "Mission_0105", "Mission_0106", "Mission_0107", "Mission_0108" };
private const int SIXTH_ANNIVERSARY_ID = 11;
private const int SEVENTH_ANNIVERSARY_ID = 13;
private const int END_OF_YEAR_CAMPAIGN_ID = 14;
private const int EIGHT_ANNIVERSARY_ID = 15;
public const string TEXTURE_NAME_RECEIVED_LOTTERY_BOX = "thumbnail_lottery";
public const string TEXTURE_NAME_BLANK = "thumbnail_blank";
private const string TEXTURE_NAME_W_CHANCE_TITLE = "lottery_w_chance";
private const string TEXTURE_NAME_BIG_CHANCE_TITLE = "campaign_title_03";
private const string TODAY_EFFECT_DEFAULT = "cmn_login_icon_3";
private const string TODAY_EFFECT_SMALL = "cmn_campaign_icon_1";
public const string TEXTURE_LOTTERY_TICKET = "box_lottery_01_close";
public const string TEXTURE_LOTTERY_TICKET2 = "box_lottery_02_close";
public const string SE_BOX_OPEN_LOTTERY_TICKET_01 = "se_sys_box_open_lottery_ticket_01";
private Dictionary<int, LayoutData> LAYOUT_SETTING = new Dictionary<int, LayoutData>
{
{
10,
new LayoutData(new Vector3(-184f, -50f, 0f), 912, new Vector3(0f, 0f, 0f), new Vector2(147f, 121f), new Vector2(349f, 254f), new Vector2(138f, -50f), enableCategoryLabel: false, useDefaultTreasureBox: true, useDefaultTodayEffect: true)
},
{
12,
new LayoutData(new Vector3(-184f, -50f, 0f), 912, new Vector3(0f, 0f, 0f), new Vector2(147f, 121f), new Vector2(349f, 254f), new Vector2(138f, -50f), enableCategoryLabel: false, useDefaultTreasureBox: false, useDefaultTodayEffect: true)
},
{
14,
new LayoutData(new Vector3(-177f, -50f, 0f), 1059, new Vector3(5f, -5f, 0f), new Vector2(145f, 118f), new Vector2(349f, 254f), new Vector2(138f, -50f), enableCategoryLabel: false, useDefaultTreasureBox: true, useDefaultTodayEffect: true)
},
{
0,
new LayoutData(new Vector3(0f, 0f, 0f), 623, new Vector3(0f, 0f, 0f), new Vector2(0f, 0f), new Vector2(912f, 285f), new Vector2(-180f, -55f), enableCategoryLabel: true, useDefaultTreasureBox: true, useDefaultTodayEffect: false)
}
};
private Dictionary<int, LayoutData> LAYOUT_SETTING_BIG_CHANCE = new Dictionary<int, LayoutData> {
{
10,
new LayoutData(new Vector3(-431f, -50f, 0f), 610, new Vector3(0f, -14f, 0f), new Vector2(110f, 118f), new Vector2(488f, 133f), new Vector2(130f, 10f), enableCategoryLabel: true, useDefaultTreasureBox: true, useDefaultTodayEffect: false)
} };
[SerializeField]
private UITexture _textureTopImage;
[SerializeField]
private UILabel _labelCampaignPeriod;
[SerializeField]
private UITexture _backGround;
[SerializeField]
private GameObject _originalTreasureBox;
[SerializeField]
private GameObject _originalTreasureBox2;
[SerializeField]
private UIGrid _gridTreasureBox;
[SerializeField]
private LotterySpecialRewardDialog _prefabSpecialRewardDialog;
[SerializeField]
private LotteryTreasureBox _doubleChanceTreasureBox;
[SerializeField]
private LotteryTreasureBox _bigChanceTreasureBox;
[SerializeField]
private UITexture _textureWChanceTitle;
[SerializeField]
private UISprite _treasureBoxBackGround;
[SerializeField]
private GameObject _missionListRoot;
[SerializeField]
private GameObject _missionListParent;
[SerializeField]
private GameObject _missionListTreasureBoxOriginal;
[SerializeField]
private UIButton _missionFactorButton;
[SerializeField]
private UISprite _missionBoxBackGround;
[SerializeField]
private GameObject _missionDialogPrefab;
[SerializeField]
private GameObject _rewardSiteButton;
[SerializeField]
private GameObject _categoryLabel;
[SerializeField]
private GameObject _itemListRoot;
[SerializeField]
private GameObject _clickProtectCollider;
private List<string> _loadedResourceList = new List<string>();
private Dictionary<int, int> GRID_PER_LINE = new Dictionary<int, int>
{
{ 8, 4 },
{ 10, 5 },
{ 12, 6 },
{ 14, 7 },
{ 0, 0 }
};
private GameObject _boxOpenEffectObj;
private GameObject _treasureEffectObj;
private string _infoSiteUrl = string.Empty;
private GameObject _effectCurrentBox;
private bool _isPlayBoxOpenEffect;
private static int _lotteryNo;
private bool _isBigChance;
private DateTime _bigChanceOpenTime;
private readonly bool IS_ONE_MILLION_CAMPAIGN;
public static void ChangeSceneLotteryPage(int no)
{
_lotteryNo = no;
UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.LotteryPage);
}
private static bool Is6thAnniversary()
{
return _lotteryNo == 11;
}
private static bool Is7thAnniversary()
{
return _lotteryNo == 13;
}
private static bool Is8thAnniversary()
{
return _lotteryNo == 15;
}
public override void onFirstStart()
{
base.IsShowFooterMenu = true;
base.onFirstStart();
}
public void OnClickInfoSiteBtn()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
UIManager.ShowDialogUrl(Data.SystemText.Get("Mission_0049"), _infoSiteUrl);
}
protected override void onOpen()
{
base.onOpen();
_clickProtectCollider.SetActive(value: false);
string titleMsg = Data.SystemText.Get("Mission_0048");
UIManager.GetInstance().CreateTopBar(base.gameObject, titleMsg, UIManager.ViewScene.MyPage).gameObject.layer = LayerMask.NameToLayer("MyPage");
InitFooter();
LotteryInfoTask task = new LotteryInfoTask();
task.SetParameter(_lotteryNo);
StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
{
Init(task.Result);
}));
}
protected override void onClose()
{
base.onClose();
UnloadResources();
UIManager.GetInstance()._Footer.CancelOverwriteLabelColors();
}
private void Init(LotteryInfoTask.LotteryInfoData lotteryData)
{
_isBigChance = lotteryData.BigChanceMission != null && lotteryData.BigChanceReward != null;
_bigChanceOpenTime = lotteryData.BigChanceOpenTime;
string text = ConvertTime.ToLocal(lotteryData.StartTime, lotteryData.EndTime);
string text2 = ConvertTime.ToLocal(lotteryData.CloseTime);
if (Is6thAnniversary() || Is7thAnniversary() || Is8thAnniversary() || _lotteryNo == 14)
{
string text3 = ConvertTime.ToLocal(lotteryData.EndTime);
string text4 = ConvertTime.ToLocal(lotteryData.OpenTime);
string text5 = ConvertTime.ToLocal(lotteryData.CloseTime);
_labelCampaignPeriod.text = Data.SystemText.Get("Mission_0097", text3, text4, text5);
}
else
{
_labelCampaignPeriod.text = Data.SystemText.Get("Mission_0057", text, text2);
}
if (lotteryData.MissionRewardList != null && lotteryData.MissionRewardList.Count > 0)
{
_missionFactorButton.onClick.Add(new EventDelegate(delegate
{
OnClickMissionFactorButton(lotteryData);
}));
}
else
{
_missionFactorButton.gameObject.SetActive(value: false);
Vector3 localPosition = _rewardSiteButton.transform.localPosition;
localPosition.y = 0f;
_rewardSiteButton.transform.localPosition = localPosition;
}
_infoSiteUrl = lotteryData.InfoUrl;
_gridTreasureBox.maxPerLine = GRID_PER_LINE[lotteryData.LotteryRewardList.Count];
bool useDefaultTreasureBox = true;
Dictionary<int, LayoutData> dictionary = LAYOUT_SETTING;
if (_isBigChance)
{
dictionary = LAYOUT_SETTING_BIG_CHANCE;
}
if (dictionary.TryGetValue(lotteryData.LotteryRewardList.Count, out var value))
{
_treasureBoxBackGround.width = value.BackGroundWidth;
_treasureBoxBackGround.transform.localPosition = value.BackGroundPosition;
_gridTreasureBox.transform.localPosition = value.GridPosition;
_gridTreasureBox.cellWidth = value.GridInterval.x;
_gridTreasureBox.cellHeight = value.GridInterval.y;
_categoryLabel.SetActive(value.EnableCategoryLabel);
useDefaultTreasureBox = value.UseDefaultTreasureBox;
_missionBoxBackGround.width = (int)value.MissionBoxBackgroundInterval.x;
_missionBoxBackGround.height = (int)value.MissionBoxBackgroundInterval.y;
_missionBoxBackGround.transform.localPosition = value.MisshonBoxBackgroundPosition;
}
StartCoroutine(LoadResources(lotteryData, delegate
{
CreateTreasureBoxGrid(lotteryData.LotteryRewardList, useDefaultTreasureBox);
if (lotteryData.DoubleChanceReward != null)
{
CreateDoubleChanceTreasureBox(lotteryData.DoubleChanceReward);
string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("lottery_w_chance", ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
_textureWChanceTitle.mainTexture = Toolbox.ResourcesManager.LoadObject(assetTypePath) as Texture;
}
else
{
_doubleChanceTreasureBox.gameObject.SetActive(value: false);
}
if (_isBigChance)
{
CreateBigChanceTreasureBox(lotteryData.BigChanceMission, lotteryData.BigChanceReward);
}
else
{
_bigChanceTreasureBox.gameObject.SetActive(value: false);
}
string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(lotteryData.BannerFileName, ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
_textureTopImage.mainTexture = Toolbox.ResourcesManager.LoadObject(assetTypePath2) as Texture;
string assetTypePath3 = Toolbox.ResourcesManager.GetAssetTypePath(lotteryData.BackGroundFileName, ResourcesManager.AssetLoadPathType.Background, isfetch: true);
_backGround.mainTexture = Toolbox.ResourcesManager.LoadObject(assetTypePath3) as Texture;
InitializeMissionList(lotteryData);
UIManager.GetInstance().OnReadyViewScene(isFadein: true);
}));
AddSeCueSheet();
UIButton component = _rewardSiteButton.GetComponent<UIButton>();
component.onClick.Clear();
component.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
OpenDetail(lotteryData);
}));
}
private void InitializeMissionList(LotteryInfoTask.LotteryInfoData lotteryData)
{
if (lotteryData.MissionRewardList == null || lotteryData.MissionRewardList.Count == 0)
{
_missionListRoot.SetActive(value: false);
return;
}
for (int i = 0; i < lotteryData.MissionRewardList.Count; i++)
{
LotteryRewardData data = lotteryData.MissionRewardList[i];
string categoryText = (_isBigChance ? Data.SystemText.Get(MISSION_BIGCHANCE_TREASURE_BOX_CATEGORY_TEXT[i]) : (Is6thAnniversary() ? Data.SystemText.Get(MISSION_6TH_ANNIVERSARY_TEXT[i]) : Data.SystemText.Get(MISSION_TREASURE_BOX_CATEGORY_TEXT[i])));
GameObject gameObject = NGUITools.AddChild(_missionListParent.gameObject, _missionListTreasureBoxOriginal);
gameObject.transform.localPosition = (_isBigChance ? MISSION_TREASURE_BOX_POSITION_WITH_BIG_CHANCE[i] : (Is6thAnniversary() ? MISSION_TREASURE_BOX_POSITION_6TH_ANNIVERSARY[i] : MISSION_TREASURE_BOX_POSITION[i]));
LotteryMissionTreasureBox box = gameObject.GetComponent<LotteryMissionTreasureBox>();
box.Initialize(data, categoryText, delegate
{
OnClickTreasureBox(box, BoxType.MISSION);
});
if (Is6thAnniversary())
{
box.SetCategoryLabelLineWitdh(95);
}
}
_missionListTreasureBoxOriginal.SetActive(value: false);
}
private IEnumerator LoadResources(LotteryInfoTask.LotteryInfoData lotteryInfoData, Action callBack)
{
ResourcesManager resMgr = Toolbox.ResourcesManager;
List<string> assetList = new List<string>();
for (int i = 0; i < lotteryInfoData.LotteryRewardList.Count; i++)
{
if (lotteryInfoData.LotteryRewardList[i].NormalGotRewardList.Count > 0)
{
LotteryRewardData.NormalGotRewardData normalGotRewardData = lotteryInfoData.LotteryRewardList[i].NormalGotRewardList[0];
string assetTypePath = resMgr.GetAssetTypePath(normalGotRewardData.TextureName, ResourcesManager.AssetLoadPathType.Item);
if (!assetList.Contains(assetTypePath) && !_loadedResourceList.Contains(assetTypePath))
{
assetList.Add(assetTypePath);
}
}
}
if (lotteryInfoData.DoubleChanceReward != null)
{
List<LotteryRewardData.NormalGotRewardData> normalGotRewardList = lotteryInfoData.DoubleChanceReward.RewardData.NormalGotRewardList;
if (normalGotRewardList.Count > 0)
{
string assetTypePath2 = resMgr.GetAssetTypePath(normalGotRewardList[0].TextureName, ResourcesManager.AssetLoadPathType.Item);
if (!assetList.Contains(assetTypePath2) && !_loadedResourceList.Contains(assetTypePath2))
{
assetList.Add(assetTypePath2);
}
}
assetList.Add(resMgr.GetAssetTypePath("lottery_w_chance", ResourcesManager.AssetLoadPathType.Lottery));
}
if (lotteryInfoData.BigChanceReward != null)
{
List<LotteryRewardData.NormalGotRewardData> normalGotRewardList2 = lotteryInfoData.BigChanceReward.NormalGotRewardList;
if (normalGotRewardList2.Count > 0)
{
string assetTypePath3 = resMgr.GetAssetTypePath(normalGotRewardList2[0].TextureName, ResourcesManager.AssetLoadPathType.Item);
if (!assetList.Contains(assetTypePath3) && !_loadedResourceList.Contains(assetTypePath3))
{
assetList.Add(assetTypePath3);
}
}
assetList.Add(resMgr.GetAssetTypePath("campaign_title_03", ResourcesManager.AssetLoadPathType.Arena));
}
if (lotteryInfoData.LotteryMissionList != null)
{
foreach (LotteryMissionData lotteryMission in lotteryInfoData.LotteryMissionList)
{
string userGoodsImageName = UserGoods.GetUserGoodsImageName(lotteryMission.UserGoodsType, lotteryMission.ItemId);
string assetTypePath4 = resMgr.GetAssetTypePath(userGoodsImageName, ResourcesManager.AssetLoadPathType.Item);
assetList.Add(assetTypePath4);
}
}
for (int j = 0; j < lotteryInfoData.MissionRewardList.Count; j++)
{
if (lotteryInfoData.MissionRewardList[j].NormalGotRewardList.Count > 0)
{
LotteryRewardData.NormalGotRewardData normalGotRewardData2 = lotteryInfoData.MissionRewardList[j].NormalGotRewardList[0];
string assetTypePath5 = resMgr.GetAssetTypePath(normalGotRewardData2.TextureName, ResourcesManager.AssetLoadPathType.Item);
if (!assetList.Contains(assetTypePath5) && !_loadedResourceList.Contains(assetTypePath5))
{
assetList.Add(assetTypePath5);
}
}
}
assetList.Add(resMgr.GetAssetTypePath(lotteryInfoData.BannerFileName, ResourcesManager.AssetLoadPathType.Lottery));
assetList.Add(resMgr.GetAssetTypePath("thumbnail_lottery", ResourcesManager.AssetLoadPathType.Lottery));
assetList.Add(resMgr.GetAssetTypePath("thumbnail_blank", ResourcesManager.AssetLoadPathType.Lottery));
assetList.Add(resMgr.GetAssetTypePath(lotteryInfoData.BackGroundFileName, ResourcesManager.AssetLoadPathType.Background));
assetList.Add(resMgr.GetAssetTypePath("box_lottery_01_close", ResourcesManager.AssetLoadPathType.Lottery));
assetList.Add(resMgr.GetAssetTypePath("box_lottery_02_close", ResourcesManager.AssetLoadPathType.Lottery));
string effectPath = "cmn_login_icon_3";
Dictionary<int, LayoutData> dictionary = LAYOUT_SETTING;
if (_isBigChance)
{
dictionary = LAYOUT_SETTING_BIG_CHANCE;
}
if (dictionary.TryGetValue(lotteryInfoData.LotteryRewardList.Count, out var value) && !value.UseDefaultTodayEffect)
{
effectPath = "cmn_campaign_icon_1";
}
assetList.Add(resMgr.GetAssetTypePath(effectPath, ResourcesManager.AssetLoadPathType.Effect2D));
if (assetList.Count > 0)
{
yield return StartCoroutine(resMgr.LoadAssetGroupAsync(assetList, null));
_loadedResourceList.AddRange(assetList);
}
_effectCurrentBox = UnityEngine.Object.Instantiate(resMgr.LoadObject(resMgr.GetAssetTypePath(effectPath, ResourcesManager.AssetLoadPathType.Effect2D, isfetch: true))) as GameObject;
_loadedResourceList.AddRange(GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(_effectCurrentBox, delegate
{
_effectCurrentBox.gameObject.SetActive(value: false);
callBack.Call();
}));
}
private void UnloadResources()
{
if (_loadedResourceList != null)
{
Toolbox.ResourcesManager.RemoveAssetGroup(_loadedResourceList);
_loadedResourceList.Clear();
}
}
private void CreateTreasureBoxGrid(List<LotteryRewardData> rewardDataList, bool useDefaultTeasureBox)
{
GameObject prefab = (useDefaultTeasureBox ? _originalTreasureBox : _originalTreasureBox2);
for (int i = 0; i < rewardDataList.Count; i++)
{
LotteryRewardData lotteryRewardData = rewardDataList[i];
LotteryTreasureBox treasureBox = NGUITools.AddChild(_gridTreasureBox.gameObject, prefab).GetComponent<LotteryTreasureBox>();
string infoText = Data.SystemText.Get("Mission_0056", (i + 1).ToString());
treasureBox.SetData(lotteryRewardData, infoText, delegate
{
OnClickTreasureBox(treasureBox, BoxType.NORMAL);
});
if (lotteryRewardData.IsCurrent)
{
PlayCurrentRewardEffect(treasureBox.gameObject);
}
}
if (rewardDataList.Count <= 0)
{
_itemListRoot.SetActive(value: false);
}
_originalTreasureBox.gameObject.SetActive(value: false);
_originalTreasureBox2.gameObject.SetActive(value: false);
_gridTreasureBox.repositionNow = true;
}
private void CreateDoubleChanceTreasureBox(DoubleChanceData doubleChanceData)
{
string infoText = Data.SystemText.Get("Mission_0058", doubleChanceData.RequireNum.ToString());
_doubleChanceTreasureBox.SetData(doubleChanceData.RewardData, infoText, delegate
{
OnClickTreasureBox(_doubleChanceTreasureBox, BoxType.DOUBLE_CHANCE);
});
}
private void CreateBigChanceTreasureBox(LotteryMissionData bigChanceMissionData, LotteryRewardData bigChanceReward)
{
string infoText = "";
if (bigChanceReward.state == LotteryRewardData.eLotteryRewardState.Unapplied)
{
infoText = Data.SystemText.Get("Mission_0088", bigChanceMissionData.MissionCurrent.ToString(), bigChanceMissionData.MissionMax.ToString());
}
else if (bigChanceReward.state == LotteryRewardData.eLotteryRewardState.Applied || bigChanceReward.state == LotteryRewardData.eLotteryRewardState.WaitResult)
{
string text = ConvertTime.ToLocal(_bigChanceOpenTime);
infoText = Data.SystemText.Get("Mission_0090", text);
}
_bigChanceTreasureBox.SetData(bigChanceReward, infoText, delegate
{
OnClickTreasureBox(_bigChanceTreasureBox, BoxType.BIG_CHANCE);
});
}
private void PlayCurrentRewardEffect(GameObject boxObj)
{
_effectCurrentBox.transform.parent = boxObj.transform;
_effectCurrentBox.transform.localPosition = Vector3.zero;
_effectCurrentBox.gameObject.SetActive(value: true);
}
private void OnClickTreasureBox(LotteryTreasureBox treasureBox, BoxType boxType)
{
if (_isPlayBoxOpenEffect)
{
return;
}
LotteryRewardData lotteryRewardData = treasureBox.LotteryRewardData;
if (lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.NotReceived)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_LOTTERY_BOX_TOUCH);
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
switch (boxType)
{
case BoxType.NORMAL:
case BoxType.MISSION:
{
LotteryReceiveTask task3 = new LotteryReceiveTask();
task3.SetParameter(lotteryRewardData.MissionId);
StartCoroutine(Toolbox.NetworkManager.Connect(task3, delegate
{
OnSuccessLotteryReceive(treasureBox, task3.Result);
}));
break;
}
case BoxType.DOUBLE_CHANCE:
{
LotteryReceiveDoubleChanceTask task2 = new LotteryReceiveDoubleChanceTask();
task2.SetParameter(_lotteryNo, lotteryRewardData.MissionId);
StartCoroutine(Toolbox.NetworkManager.Connect(task2, delegate
{
OnSuccessLotteryReceive(treasureBox, task2.Result);
}));
break;
}
case BoxType.BIG_CHANCE:
{
LotteryReceiveBigChanceTask task = new LotteryReceiveBigChanceTask();
task.SetParameter(_lotteryNo, lotteryRewardData.MissionId);
StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
{
OnSuccessLotteryReceive(treasureBox, task.Result);
}));
break;
}
}
}
else if (lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.Received && lotteryRewardData.IsSpecial)
{
ShowReceivedDialog(lotteryRewardData);
}
}
private void OnSuccessLotteryReceive(LotteryTreasureBox treasureBox, LotteryRewardData receiveRewardData)
{
SetProtectColliderEnable(enableProtect: true);
List<string> assetList = new List<string>();
List<LotteryRewardData.NormalGotRewardData> normalGotRewardList = receiveRewardData.NormalGotRewardList;
for (int i = 0; i < normalGotRewardList.Count; i++)
{
string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(normalGotRewardList[i].TextureName, ResourcesManager.AssetLoadPathType.Item);
if (!assetList.Contains(assetTypePath) && !_loadedResourceList.Contains(assetTypePath))
{
assetList.Add(assetTypePath);
}
}
bool isBigChanceTreasureBox = treasureBox as LotteryBigChanceTreasureBox != null;
StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(assetList, delegate
{
_loadedResourceList.AddRange(assetList);
StartCoroutine(RunOpenBoxEffect(receiveRewardData.DialogMessage, isBigChanceTreasureBox, delegate
{
receiveRewardData.UpdateHaveUserGoodsByNormalRwardList();
treasureBox.UpdateData(receiveRewardData);
ShowReceivedDialog(receiveRewardData);
}));
}));
}
private void SetProtectColliderEnable(bool enableProtect)
{
_clickProtectCollider.SetActive(enableProtect);
GameMgr.GetIns().GetInputMgr().isBackKeyEnable = !enableProtect;
}
private void ShowReceivedDialog(LotteryRewardData lotteryRewardData)
{
SetProtectColliderEnable(enableProtect: false);
if (lotteryRewardData.IsSpecial && IS_ONE_MILLION_CAMPAIGN)
{
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetSize(DialogBase.Size.M);
dialogBase.SetTitleLabel(lotteryRewardData.DialogMessage);
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
dialogBase.OnClose = HideBoxEffect;
GameObject gameObject = UnityEngine.Object.Instantiate(_prefabSpecialRewardDialog.gameObject);
dialogBase.SetObj(gameObject);
gameObject.GetComponent<LotterySpecialRewardDialog>().Init(lotteryRewardData);
return;
}
DialogBase dialogBase2 = UIManager.GetInstance().CreateDialogClose();
dialogBase2.SetSize(DialogBase.Size.M);
dialogBase2.SetTitleLabel(lotteryRewardData.DialogMessage);
dialogBase2.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
dialogBase2.SetLayer("Loading");
dialogBase2.OnClose = HideBoxEffect;
GameObject gameObject2 = UnityEngine.Object.Instantiate(UIManager.GetInstance().GetRewardDialogPrefab().gameObject);
dialogBase2.SetObj(gameObject2);
RewardBase component = gameObject2.GetComponent<RewardBase>();
for (int i = 0; i < lotteryRewardData.NormalGotRewardList.Count; i++)
{
LotteryRewardData.NormalGotRewardData normalGotRewardData = lotteryRewardData.NormalGotRewardList[i];
NguiObjs nguiObjs = component.AddReward(normalGotRewardData.RewardType, normalGotRewardData.RewardId, normalGotRewardData.RewardGotNum);
if (lotteryRewardData.LotteryId > 0 && lotteryRewardData.Description.IsNotNullOrEmpty())
{
nguiObjs.labels[0].text = lotteryRewardData.Description;
}
}
component.EndCreate();
if (!string.IsNullOrEmpty(lotteryRewardData.PrizeMessage))
{
component.SetTitleLabel(isEnabled: true, lotteryRewardData.PrizeMessage);
}
else
{
component.SetTitleLabel(isEnabled: false, "");
}
}
private IEnumerator RunOpenBoxEffect(string message, bool isBigChanceTreasureBox, Action endAction)
{
_isPlayBoxOpenEffect = true;
UIManager.GetInstance().OpenNotTouch();
GameMgr.GetIns().GetInputMgr().isBackKeyEnable = false;
_boxOpenEffectObj = NGUITools.AddChild(base.gameObject, Resources.Load("UI/layoutParts/RankWinnerRewardResultPanel") as GameObject);
NguiObjs component = _boxOpenEffectObj.GetComponent<NguiObjs>();
UISprite bg = component.sprites[0];
UISprite window = component.sprites[1];
UISprite uISprite = component.sprites[2];
UIWidget box = uISprite;
if (isBigChanceTreasureBox)
{
uISprite.spriteName = "box_2pick_06_close";
UIManager.GetInstance().AttachAtlas(uISprite.gameObject);
}
else
{
uISprite.gameObject.SetActive(value: false);
UITexture uITexture = component.textures[0];
uITexture.gameObject.SetActive(value: true);
string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("box_lottery_02_close", ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
uITexture.mainTexture = Toolbox.ResourcesManager.LoadObject(assetTypePath) as Texture;
box = uITexture;
}
UILabel label = component.labels[0];
label.text = message;
UIPanel panel = _boxOpenEffectObj.GetComponent<UIPanel>();
panel.alpha = 0f;
string loadEffectName = (isBigChanceTreasureBox ? "cmn_arena_treasure_7" : "cmn_arena_treasure_6");
List<string> loadList = new List<string> { Toolbox.ResourcesManager.GetAssetTypePath(loadEffectName, ResourcesManager.AssetLoadPathType.Effect2D) };
yield return StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(loadList, null));
_loadedResourceList.AddRange(loadList);
_treasureEffectObj = UnityEngine.Object.Instantiate(Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(loadEffectName, ResourcesManager.AssetLoadPathType.Effect2D, isfetch: true)) as GameObject);
_treasureEffectObj.transform.parent = _boxOpenEffectObj.transform;
_loadedResourceList.AddRange(GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(_treasureEffectObj, null));
_boxOpenEffectObj.SetLayer(LayerMask.NameToLayer("MyPage"), isSetChildren: true);
bg.alpha = 0f;
box.alpha = 0f;
label.alpha = 0f;
panel.alpha = 1f;
TweenAlpha.Begin(bg.gameObject, 0.5f, 0.65f);
TweenAlpha.Begin(label.gameObject, 0.5f, 1f);
TweenAlpha.Begin(box.gameObject, 0.5f, 1f);
label.transform.localPosition = new Vector3(100f, 0f, 0f);
window.transform.localScale = new Vector3(1f, 0.01f, 1f);
box.transform.localPosition = new Vector3(180f, 0f, 0f);
iTween.MoveTo(label.gameObject, iTween.Hash("x", 20f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
iTween.ScaleTo(window.gameObject, iTween.Hash("y", 1f, "time", 0.5f, "easetype", iTween.EaseType.easeInOutExpo));
iTween.MoveTo(box.gameObject, iTween.Hash("y", 20f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
yield return new WaitForSeconds(0.8f);
TweenAlpha.Begin(label.gameObject, 0.5f, 0f);
iTween.MoveTo(box.gameObject, iTween.Hash("x", 0f, "time", 0.7f, "islocal", true, "easetype", iTween.EaseType.easeInOutExpo));
GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_sys_box_open_lottery_ticket_01", "se_sys_box_open_lottery_ticket_01", 0f, 0L);
yield return new WaitForSeconds(1f);
_treasureEffectObj.transform.localPosition = box.transform.localPosition;
_treasureEffectObj.transform.localScale = Vector3.one * 320f * 1.75f;
_treasureEffectObj.SetActive(value: true);
box.gameObject.SetActive(value: false);
yield return new WaitForSeconds(1.2f);
endAction.Call();
UIManager.GetInstance().offNotTouch();
GameMgr.GetIns().GetInputMgr().isBackKeyEnable = true;
}
private void HideBoxEffect()
{
if (_isPlayBoxOpenEffect)
{
StartCoroutine(RunHideBoxEffect());
}
}
private IEnumerator RunHideBoxEffect()
{
NguiObjs component = _boxOpenEffectObj.GetComponent<NguiObjs>();
UISprite uISprite = component.sprites[0];
UISprite obj = component.sprites[1];
TweenAlpha.Begin(uISprite.gameObject, 0.3f, 0f);
TweenAlpha.Begin(obj.gameObject, 0.3f, 0f);
_treasureEffectObj.SetActive(value: false);
yield return new WaitForSeconds(0.3f);
_boxOpenEffectObj.SetActive(value: false);
UnityEngine.Object.Destroy(_boxOpenEffectObj);
_isPlayBoxOpenEffect = false;
}
private void OnClickMissionFactorButton(LotteryInfoTask.LotteryInfoData lotteryData)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
LotteryMissionDialog.Create(_missionDialogPrefab, lotteryData);
}
private void AddSeCueSheet()
{
Toolbox.AudioManager.AddCueSheet("se_sys_box_open_lottery_ticket_01", "se_sys_box_open_lottery_ticket_01.acb", "s/");
}
private void InitFooter()
{
UIManager.GetInstance()._Footer.UpdateCurrentIndex(0);
}
private void InitSpriteAtlasOverwriter()
{
UIAtlas component = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("dummy", ResourcesManager.AssetLoadPathType.QuestAtlas, isfetch: true)).GetComponent<UIAtlas>();
UISpriteAtlasOverwriter.TargetObject[] targetObjects = new UISpriteAtlasOverwriter.TargetObject[2]
{
new UISpriteAtlasOverwriter.TargetObject(base.gameObject, includeChildren: true),
new UISpriteAtlasOverwriter.TargetObject(UIManager.GetInstance()._Footer.gameObject, includeChildren: true)
};
base.gameObject.AddMissingComponent<UISpriteAtlasOverwriter>().Init(component, targetObjects);
}
private void AddAtlasOverrider(DialogBase dialog)
{
UIAtlas component = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("dummy", ResourcesManager.AssetLoadPathType.QuestAtlas, isfetch: true)).GetComponent<UIAtlas>();
UISpriteAtlasOverwriter.TargetObject[] targetObjects = new UISpriteAtlasOverwriter.TargetObject[1]
{
new UISpriteAtlasOverwriter.TargetObject(dialog.gameObject, includeChildren: true)
};
dialog.gameObject.AddMissingComponent<UISpriteAtlasOverwriter>().Init(component, targetObjects);
}
private void OpenDetail(LotteryInfoTask.LotteryInfoData lotteryData)
{
if (!string.IsNullOrEmpty(lotteryData.AnnounceId))
{
UIManager.GetInstance().WebViewHelper.OpenAnnounceWebView(lotteryData.AnnounceId, delegate(DialogBase dialog)
{
SetExceptionDialog(dialog);
});
return;
}
if (!string.IsNullOrEmpty(lotteryData.InfoUrl))
{
UIManager.ShowDialogUrl(Data.SystemText.Get("Mission_0049"), lotteryData.InfoUrl);
return;
}
SystemText systemText = Data.SystemText;
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetSize(DialogBase.Size.M);
dialogBase.SetTitleLabel(systemText.Get("Bingo_0007"));
dialogBase.SetText(systemText.Get("Quest_0034"));
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
SetExceptionDialog(dialogBase);
}
private void SetExceptionDialog(DialogBase dialog)
{
List<UISpriteAtlasOverwriter.TargetObject> exceptionObjects = new List<UISpriteAtlasOverwriter.TargetObject>
{
new UISpriteAtlasOverwriter.TargetObject(dialog.gameObject, includeChildren: true)
};
UISpriteAtlasOverwriter component = base.gameObject.GetComponent<UISpriteAtlasOverwriter>();
if (component != null)
{
component.AddExceptionObjects(exceptionObjects);
}
}
public void LateUpdate()
{
BingoPage.FixDialogRibbon();
}
}