Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard.Lottery/LotteryTreasureBox.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

233 lines
7.3 KiB
C#

using System;
using Cute;
using UnityEngine;
namespace Wizard.Lottery;
public class LotteryTreasureBox : MonoBehaviour
{
private static readonly Color COLOR_NON_ACTIVE_REWARD_IMAGE = new Color32(65, 65, 65, byte.MaxValue);
private static readonly Color COLOR_NON_ACTIVE_NUM_TEXT = new Color32(100, 100, 100, byte.MaxValue);
private static readonly Color COLOR_TICKET_WAIT = new Color32(90, 90, 90, byte.MaxValue);
[SerializeField]
protected UILabel _labelInfoText;
[SerializeField]
protected UILabel _labelStatus;
[SerializeField]
protected UILabel _labelRewardNum;
[SerializeField]
protected UITexture _textureRewardImage;
[SerializeField]
protected UITexture _textureRewardImageFg;
[SerializeField]
protected UISprite _spriteTreasureImage;
[SerializeField]
protected UILabel _labelTreasureTouch;
[SerializeField]
protected GameObject _touchObject;
protected LotteryRewardData _lotteryRewardData;
public LotteryRewardData LotteryRewardData => _lotteryRewardData;
public void SetData(LotteryRewardData rewardData, string infoText, Action onClickEvent = null)
{
_labelInfoText.text = infoText;
UIEventListener.Get(base.gameObject).onClick = null;
UIEventListener.Get(base.gameObject).onClick = delegate
{
onClickEvent.Call();
};
UpdateData(rewardData);
}
public void UpdateData(LotteryRewardData rewardData)
{
_lotteryRewardData = rewardData;
UpdateInfoLabel();
UpdateStatusText();
UpdateRewardImage();
UpdateNonActiveColor();
}
protected virtual void UpdateInfoLabel()
{
if (_lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.NotReceived)
{
_labelInfoText.gameObject.SetActive(value: false);
}
else
{
_labelInfoText.gameObject.SetActive(value: true);
}
}
protected virtual void UpdateStatusText()
{
switch (_lotteryRewardData.state)
{
case LotteryRewardData.eLotteryRewardState.Unapplied:
_labelStatus.text = Data.SystemText.Get("Mission_0051");
break;
case LotteryRewardData.eLotteryRewardState.Applied:
_labelStatus.text = Data.SystemText.Get("Mission_0053");
break;
case LotteryRewardData.eLotteryRewardState.WaitResult:
_labelStatus.text = Data.SystemText.Get("Mission_0052");
break;
case LotteryRewardData.eLotteryRewardState.NotReceived:
_labelStatus.text = string.Empty;
break;
case LotteryRewardData.eLotteryRewardState.Received:
if (_lotteryRewardData.IsSpecial)
{
_labelStatus.text = string.Empty;
}
else
{
_labelStatus.text = Data.SystemText.Get("Mission_0054");
}
break;
default:
_labelStatus.text = string.Empty;
break;
}
}
protected virtual void UpdateRewardImage()
{
bool flag = LotteryRewardData.state == LotteryRewardData.eLotteryRewardState.WaitResult || LotteryRewardData.state == LotteryRewardData.eLotteryRewardState.Applied;
if (_textureRewardImageFg != null)
{
_textureRewardImageFg.gameObject.SetActive(flag);
}
if (_touchObject != null)
{
_touchObject.SetActive(LotteryRewardData.state == LotteryRewardData.eLotteryRewardState.NotReceived);
}
string textureRewardImage = string.Empty;
ChangeSpriteSizeForTicket(isExpandSize: false);
if (_lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.NotReceived)
{
_labelRewardNum.gameObject.SetActive(value: false);
string path = "box_lottery_01_close";
textureRewardImage = Toolbox.ResourcesManager.GetAssetTypePath(path, ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
SetTextureRewardImage(textureRewardImage);
ChangeSpriteSizeForTicket(isExpandSize: true);
_labelTreasureTouch.text = GetTouchText();
}
else if (_lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.Received)
{
if (_lotteryRewardData.IsSpecial)
{
string path2 = "thumbnail_lottery";
textureRewardImage = Toolbox.ResourcesManager.GetAssetTypePath(path2, ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
_labelRewardNum.gameObject.SetActive(value: false);
}
else if (_lotteryRewardData.NormalGotRewardList.Count > 0)
{
string textureName = _lotteryRewardData.NormalGotRewardList[0].TextureName;
textureRewardImage = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
_labelRewardNum.gameObject.SetActive(value: true);
_labelRewardNum.text = _lotteryRewardData.NormalGotRewardList[0].RewardGotNum.ToString();
}
SetTextureRewardImage(textureRewardImage);
}
else if (_textureRewardImageFg != null && flag)
{
_labelRewardNum.gameObject.SetActive(value: false);
string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("thumbnail_blank", ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
SetTextureRewardImage(assetTypePath);
string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath("box_lottery_01_close", ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
SetTextureRewardImageFg(assetTypePath2);
}
else
{
string path3 = "thumbnail_blank";
textureRewardImage = Toolbox.ResourcesManager.GetAssetTypePath(path3, ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
_labelRewardNum.gameObject.SetActive(value: false);
SetTextureRewardImage(textureRewardImage);
}
}
protected string GetTouchText()
{
_ = string.Empty;
return Data.SystemText.Get("Common_0146");
}
private void ChangeSpriteSizeForTicket(bool isExpandSize)
{
_textureRewardImage.width = (isExpandSize ? 115 : 87);
_textureRewardImage.height = (isExpandSize ? 115 : 87);
}
protected void SetTextureRewardImage(string imagePath)
{
_textureRewardImage.gameObject.SetActive(value: true);
_spriteTreasureImage.gameObject.SetActive(value: false);
_textureRewardImage.mainTexture = Toolbox.ResourcesManager.LoadObject(imagePath) as Texture;
}
private void SetTextureRewardImageFg(string imagePath)
{
_textureRewardImageFg.gameObject.SetActive(value: true);
_textureRewardImageFg.mainTexture = Toolbox.ResourcesManager.LoadObject(imagePath) as Texture;
_textureRewardImageFg.color = COLOR_TICKET_WAIT;
}
protected virtual void UpdateNonActiveColor()
{
switch (_lotteryRewardData.state)
{
case LotteryRewardData.eLotteryRewardState.Unapplied:
SetNonActiveColor(isNonActive: true);
break;
case LotteryRewardData.eLotteryRewardState.Received:
if (_lotteryRewardData.IsSpecial)
{
SetNonActiveColor(isNonActive: false);
}
else
{
SetNonActiveColor(isNonActive: true);
}
break;
case LotteryRewardData.eLotteryRewardState.Applied:
case LotteryRewardData.eLotteryRewardState.WaitResult:
case LotteryRewardData.eLotteryRewardState.NotReceived:
SetNonActiveColor(isNonActive: false);
break;
default:
_labelStatus.text = string.Empty;
break;
}
}
protected virtual void SetNonActiveColor(bool isNonActive)
{
if (isNonActive)
{
_textureRewardImage.color = COLOR_NON_ACTIVE_REWARD_IMAGE;
_labelRewardNum.color = COLOR_NON_ACTIVE_NUM_TEXT;
_labelStatus.color = LabelDefine.TEXT_COLOR_CREAM;
}
else
{
_textureRewardImage.color = Color.white;
_labelRewardNum.color = LabelDefine.TEXT_COLOR_NORMAL;
_labelStatus.color = LabelDefine.TEXT_COLOR_NORMAL;
}
}
}