备份CatanBuilding瘦身独立工程
This commit is contained in:
74
Assets/Scripts/Others/AiHelpManager.cs
Normal file
74
Assets/Scripts/Others/AiHelpManager.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using AIHelp;
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
public class AiHelpManager
|
||||
{
|
||||
private static AiHelpManager _instance;
|
||||
public static AiHelpManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new AiHelpManager();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void Login()
|
||||
{
|
||||
AIHelpSupport.ResetUserInfo();
|
||||
var playerData = GContext.container.Resolve<PlayerData>();
|
||||
var userService = GContext.container.Resolve<IUserService>();
|
||||
var userData = new JObject();
|
||||
userData["pfid"] = userService.UserId;
|
||||
int lvl = playerData.lv;
|
||||
int vip = playerData.vip;
|
||||
int paylvl = playerData.PriceLv;
|
||||
userData["lvl"] = lvl;
|
||||
userData["vip"] = vip;
|
||||
userData["pay_level"] = paylvl;
|
||||
userData["create"] = userService.CreateTime;
|
||||
userData["lastlogin"] = userService.LoginTime;
|
||||
|
||||
UserConfig userConfig = new UserConfig.Builder()
|
||||
.SetUserName(userService.DisplayName)
|
||||
.SetCustomData(userData.ToString(Formatting.None))
|
||||
.Build();
|
||||
|
||||
LoginConfig loginConfig = new LoginConfig.Builder()
|
||||
.SetUserId(userService.CustomId)
|
||||
.SetUserConfig(userConfig)
|
||||
.Build();
|
||||
|
||||
AIHelpSupport.Login(loginConfig);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var playerData = GContext.container.Resolve<PlayerData>();
|
||||
var userService = GContext.container.Resolve<IUserService>();
|
||||
|
||||
var userData = new JObject();
|
||||
userData["pfid"] = userService.UserId;
|
||||
int lvl = playerData.lv;
|
||||
int vip = playerData.vip;
|
||||
int paylvl = playerData.PriceLv;
|
||||
userData["lvl"] = lvl;
|
||||
userData["vip"] = vip;
|
||||
userData["pay_level"] = paylvl;
|
||||
userData["create"] = userService.CreateTime;
|
||||
userData["lastlogin"] = userService.LoginTime;
|
||||
|
||||
UserConfig userConfig = new UserConfig.Builder()
|
||||
.SetUserName(userService.DisplayName)
|
||||
.SetCustomData(userData.ToString(Formatting.None))
|
||||
.Build();
|
||||
AIHelpSupport.UpdateUserInfo(userConfig);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/AiHelpManager.cs.meta
Normal file
11
Assets/Scripts/Others/AiHelpManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7c495e770009494a9c28f141b029634
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Others/AmbientColorController.cs
Normal file
16
Assets/Scripts/Others/AmbientColorController.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class EnvironmentLightingController : MonoBehaviour
|
||||
{
|
||||
public Color ambientColor = Color.gray;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
SetAmbientColor();
|
||||
}
|
||||
public void SetAmbientColor()
|
||||
{
|
||||
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
|
||||
RenderSettings.ambientLight = ambientColor;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/AmbientColorController.cs.meta
Normal file
11
Assets/Scripts/Others/AmbientColorController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c69d3b437e4ff224b92bafaec2feef97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
430
Assets/Scripts/Others/BatchedRewardFly.cs
Normal file
430
Assets/Scripts/Others/BatchedRewardFly.cs
Normal file
@@ -0,0 +1,430 @@
|
||||
using asap.core;
|
||||
using asap.core.common;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
using System;
|
||||
using Game;
|
||||
using TMPro;
|
||||
|
||||
public class BatchedRewardFly : MonoBehaviour, IPoolableObject
|
||||
{
|
||||
public Image icon;
|
||||
public Image icon_card;
|
||||
public Image icon_card_logo;
|
||||
public Image icon_card_num;
|
||||
public Image icon_rod;
|
||||
public TMP_Text text_num;
|
||||
public Animation ani;
|
||||
[SerializeField] private GameObject /*fxTrace, */iconRoot, fxRoot;
|
||||
[SerializeField] private CanvasGroup canvasGroup;
|
||||
[SerializeField] private ParticleSystem fxTrail;
|
||||
private const string IN = "rewardfly_show_batched", OUT = "rewardfly_out_batched", OUT_STASH = "rewardfly_out_bag_batched",
|
||||
FLY_BATCHED = "rewardfly_fly_batched", FLY_SINGLE = "rewardfly_fly_single", GeneratedFlag = "[generated]", IN_SINGLE = "rewardfly_show_single";
|
||||
private IObjectPool _pool;
|
||||
private readonly DefaultRectTr DefaultLocalTextTransform = new DefaultRectTr();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// Debug.Log($"[RewardFly] Enabled.", this);
|
||||
icon.gameObject.SetActive(false);
|
||||
icon_card.gameObject.SetActive(false);
|
||||
icon_rod.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public virtual async Task SingleFlyAsync(BatchedRewardFlyRequest request, RewardFlyAnimationParams para)
|
||||
{
|
||||
// Debug.Log($"[RewardFly] SingleFly");
|
||||
ani.Play(FLY_SINGLE);
|
||||
SetText("");
|
||||
canvasGroup.alpha = para.alphaShow;
|
||||
iconRoot.transform.localScale = Vector3.one;
|
||||
if (request.StartPoint.Size != 0.0f)
|
||||
{
|
||||
var sourceScale = GetTransitionScale(request.StartPoint.Size, request.StartPoint.LossyScale);
|
||||
iconRoot.transform.localScale = sourceScale * para.scaleShow * Vector3.one;
|
||||
iconRoot.transform.DOScale(sourceScale, para.ShowDuration).SetEase(para.CurveShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
iconRoot.transform.localScale = para.scaleShow * Vector3.one;
|
||||
iconRoot.transform.DOScale(1, para.ShowDuration).SetEase(para.CurveShow);
|
||||
}
|
||||
if (request.icon != null)
|
||||
SetData(request.icon);
|
||||
else if (string.IsNullOrEmpty(request.iconName))
|
||||
SetData(request.itemID);
|
||||
else
|
||||
SetData(request.iconName);
|
||||
transform.position = request.StartPoint.Pos;
|
||||
// if (request.sourceTextRt != null)
|
||||
// {
|
||||
// var rt = text_num.transform as RectTransform;
|
||||
// rt.anchorMin = request.sourceTextRt.anchorMin;
|
||||
// rt.anchorMax = request.sourceTextRt.anchorMax;
|
||||
// rt.pivot = request.sourceTextRt.pivot;
|
||||
// rt.anchoredPosition = request.sourceTextRt.anchoredPosition;
|
||||
// rt.sizeDelta = request.sourceTextRt.sizeDelta;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var rt = text_num.transform as RectTransform;
|
||||
// rt.anchorMin = DefaultLocalTextTransform.anchorMin;
|
||||
// rt.anchorMax = DefaultLocalTextTransform.anchorMax;
|
||||
// rt.pivot = DefaultLocalTextTransform.pivot;
|
||||
// rt.anchoredPosition = DefaultLocalTextTransform.anchoredPosition;
|
||||
// rt.sizeDelta = DefaultLocalTextTransform.sizeDelta;
|
||||
// }
|
||||
if (para.IsPlayOpen)
|
||||
{
|
||||
OpenFx(ERewardFlyStage.Show, para.FxSingle, out var fx);
|
||||
ani.Play(IN_SINGLE);
|
||||
await transform.DOMove(request.StartPoint.Pos, para.ShowDuration).SetEase(Ease.InOutSine).AsyncWaitForCompletion();
|
||||
CloseFx(fx);
|
||||
}
|
||||
|
||||
string audioFly = para.GetAudioUrl(1, request.Quantity != null && request.Quantity.Value > 1);
|
||||
GContext.Publish(new EventUISound(audioFly));
|
||||
OpenFx(ERewardFlyStage.Fly, para.FxSingle, out var flyFx);
|
||||
transform.DOMoveX(request.EndPoint.Pos.x, para.FlyDuration).SetEase(para.CurveX);
|
||||
transform.DOMoveY(request.EndPoint.Pos.y, para.FlyDuration).SetEase(para.CurveY);
|
||||
var targetScale = GetTransitionScale(request.EndPoint.Size, request.EndPoint.LossyScale);
|
||||
iconRoot.transform.DOScale(targetScale, para.FlyDuration).SetEase(para.CurveScale);
|
||||
iconRoot.transform.DORotate(Vector3.zero, para.FlyDuration).SetEase(Ease.InOutSine);
|
||||
await Awaiters.Seconds(para.FlyDuration);
|
||||
CloseFx(flyFx);
|
||||
if (!para.IsPlayClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OpenFx(request.isDestinationRewardStash ? ERewardFlyStage.OutStash : ERewardFlyStage.Out, para.FxSingle, out var outFx);
|
||||
if (request.isDestinationRewardStash)
|
||||
{
|
||||
ani.Play(OUT_STASH);
|
||||
}
|
||||
else
|
||||
{
|
||||
ani.Play(OUT);
|
||||
}
|
||||
|
||||
string audioOut = para.GetAudioUrl(2, request.Quantity != null && request.Quantity.Value > 1);
|
||||
GContext.Publish(new EventUISound(audioOut));
|
||||
await Awaiters.Seconds(para.CloseDuration);
|
||||
CloseFx(outFx);
|
||||
}
|
||||
|
||||
public virtual async Task BatchShowAsync(BatchedRewardFlyRequest request, RewardFlyAnimationParams para)
|
||||
{
|
||||
// Debug.Log($"[RewardFly] BatchShow");
|
||||
canvasGroup.alpha = 1f;
|
||||
iconRoot.transform.localScale = Vector3.one;
|
||||
SetText(request.Quantity, request.itemID);
|
||||
float sourceScale = 1;
|
||||
if (request.StartPoint.Size != 0.0f)
|
||||
{
|
||||
sourceScale = GetTransitionScale(request.StartPoint.Size, request.StartPoint.LossyScale);
|
||||
iconRoot.transform.localScale = new Vector3(sourceScale, sourceScale, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
iconRoot.transform.localScale = para.scaleShow * Vector3.one;
|
||||
iconRoot.transform.DOScale(1, para.ShowDuration).SetEase(para.CurveShow);
|
||||
}
|
||||
|
||||
if (request.icon != null)
|
||||
SetData(request.icon);
|
||||
else if (string.IsNullOrEmpty(request.iconName))
|
||||
SetData(request.itemID);
|
||||
else
|
||||
SetData(request.iconName);
|
||||
transform.position = request.StartPoint.Pos;
|
||||
if (request.sourceTextRt != null)
|
||||
{
|
||||
var rt = text_num.GetComponent<RectTransform>();
|
||||
rt.anchorMin = request.sourceTextRt.anchorMin;
|
||||
rt.anchorMax = request.sourceTextRt.anchorMax;
|
||||
rt.anchoredPosition = request.sourceTextRt.anchoredPosition;
|
||||
rt.sizeDelta = request.sourceTextRt.sizeDelta;
|
||||
rt.pivot = request.sourceTextRt.pivot;
|
||||
}
|
||||
else
|
||||
{
|
||||
var rt = text_num.GetComponent<RectTransform>();
|
||||
rt.anchorMin = DefaultLocalTextTransform.anchorMin;
|
||||
rt.anchorMax = DefaultLocalTextTransform.anchorMax;
|
||||
rt.anchoredPosition = DefaultLocalTextTransform.anchoredPosition;
|
||||
rt.sizeDelta = DefaultLocalTextTransform.sizeDelta;
|
||||
rt.pivot = DefaultLocalTextTransform.pivot;
|
||||
}
|
||||
OpenFx(ERewardFlyStage.Show, para.FxBatched, out var fx);
|
||||
ani.Play(IN);
|
||||
await Task.Delay(TimeSpan.FromSeconds(para.ShowDuration));
|
||||
CloseFx(fx);
|
||||
}
|
||||
|
||||
public virtual async Task BatchFlyAsync(BatchedRewardFlyRequest request, RewardFlyAnimationParams para)
|
||||
{
|
||||
// Debug.Log($"[RewardFly] BatchFly");
|
||||
ani.Play(FLY_BATCHED);
|
||||
SetText("");
|
||||
canvasGroup.alpha = para.alphaShow;
|
||||
iconRoot.transform.localScale = Vector3.one;
|
||||
if (request.StartPoint.Size != 0.0f)
|
||||
{
|
||||
var sourceScale = GetTransitionScale(request.StartPoint.Size, request.StartPoint.LossyScale) *
|
||||
(request.Quantity != null && request.Quantity.Value > 1 ? para.MultipleIconScaleModifier : 1f);
|
||||
iconRoot.transform.localScale = sourceScale * para.scaleShow * Vector3.one;
|
||||
iconRoot.transform.DOScale(sourceScale, para.ShowDuration).SetEase(para.CurveShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
iconRoot.transform.localScale = para.scaleShow * Vector3.one;
|
||||
iconRoot.transform.DOScale(1, para.ShowDuration).SetEase(para.CurveShow);
|
||||
}
|
||||
if (request.icon != null)
|
||||
SetData(request.icon);
|
||||
else if (string.IsNullOrEmpty(request.iconName))
|
||||
SetData(request.itemID);
|
||||
else
|
||||
SetData(request.iconName);
|
||||
transform.position = request.StartPoint.Pos;
|
||||
var delta = Vector3.zero;
|
||||
|
||||
if (para.IsPlayOpen)
|
||||
{
|
||||
if (request.Quantity != null && request.Quantity > 1)
|
||||
{
|
||||
// ani.Play(IN);
|
||||
delta = (Vector3)FtMathUtils.GetCornSpread(para.SpreadHalfAngle, para.SpreadNearRange, para.SpreadFarRange);
|
||||
if (para.MaxTiltAngle > 0)
|
||||
{
|
||||
var angle = UnityEngine.Random.Range(-para.MaxTiltAngle, para.MaxTiltAngle);
|
||||
iconRoot.transform.DORotate(new Vector3(0, 0, angle), para.ShowDuration).SetEase(Ease.InOutSine);
|
||||
}
|
||||
}
|
||||
canvasGroup.DOFadeAlpha(1f, para.ShowDuration).SetEase(para.CurveShow);
|
||||
await transform.DOMove(request.StartPoint.Pos + delta, para.ShowDuration).SetEase(Ease.InOutSine).AsyncWaitForCompletion();
|
||||
}
|
||||
|
||||
string audioFly = para.GetAudioUrl(1, request.Quantity != null && request.Quantity.Value > 1);
|
||||
GContext.Publish(new EventUISound(audioFly));
|
||||
// SetText("");
|
||||
// ShowTrace();
|
||||
OpenFx(ERewardFlyStage.Fly, para.FxBatched, out var fx);
|
||||
transform.DOMoveX(request.EndPoint.Pos.x, para.FlyDuration).SetEase(para.CurveX);
|
||||
transform.DOMoveY(request.EndPoint.Pos.y, para.FlyDuration).SetEase(para.CurveY);
|
||||
var targetScale = GetTransitionScale(request.EndPoint.Size, request.EndPoint.LossyScale);
|
||||
iconRoot.transform.DOScale(targetScale, para.FlyDuration).SetEase(para.CurveScale);
|
||||
iconRoot.transform.DORotate(Vector3.zero, para.FlyDuration).SetEase(Ease.InOutSine);
|
||||
await Awaiters.Seconds(para.FlyDuration);
|
||||
CloseFx(fx);
|
||||
if (!para.IsPlayClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OpenFx(request.isDestinationRewardStash ? ERewardFlyStage.OutStash : ERewardFlyStage.Out, para.FxBatched, out var outFx);
|
||||
if (request.isDestinationRewardStash)
|
||||
{
|
||||
ani.Play(OUT_STASH);
|
||||
// Debug.Log("[RewardFly] PlayClose OUT_STASH", this);
|
||||
}
|
||||
else
|
||||
{
|
||||
ani.Play(OUT);
|
||||
// Debug.Log("[RewardFly] PlayClose OUT", this);
|
||||
}
|
||||
|
||||
string audioOut = para.GetAudioUrl(2, request.Quantity != null && request.Quantity.Value > 1);
|
||||
GContext.Publish(new EventUISound(audioOut));
|
||||
await Awaiters.Seconds(para.CloseDuration);
|
||||
CloseFx(outFx);
|
||||
// Debug.Log("[RewardFly] PlayClose Done", this);
|
||||
}
|
||||
|
||||
void PlayOpen()
|
||||
{
|
||||
ani.Play("reward_common_open");
|
||||
}
|
||||
|
||||
void PlayClose()
|
||||
{
|
||||
ani.Play("reward_common_close");
|
||||
}
|
||||
|
||||
void SetData(string iconName)
|
||||
{
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, iconName, BasePanel.PanelName);
|
||||
}
|
||||
|
||||
void SetData(Sprite iconSprite)
|
||||
{
|
||||
icon.gameObject.SetActive(true);
|
||||
icon.sprite = iconSprite;
|
||||
}
|
||||
|
||||
void SetText(string numStr)
|
||||
{
|
||||
text_num.gameObject.SetActive(true);
|
||||
text_num.text = numStr;
|
||||
}
|
||||
void SetText(int? quantity, int itemId)
|
||||
{
|
||||
if (quantity.HasValue && quantity.Value > 1)
|
||||
{
|
||||
var value = quantity.Value;
|
||||
if (itemId == 1002)
|
||||
value = value = ConvertTools.KeepThreeSignificantDigits(value);
|
||||
SetText("x" + ConvertTools.GetNumberString(value));
|
||||
}
|
||||
else
|
||||
SetText("");
|
||||
}
|
||||
|
||||
void SetData(int itemID)
|
||||
{
|
||||
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(itemID);
|
||||
if (item.Type == 5 && (item.SubType == 1 || item.SubType == 2))
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
List<string> BgNameList;
|
||||
if (item.SubType == 1)
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbFishCardDrop.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbGeneralCardWeight.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
uiService.SetImageSprite(icon_card, BgNameList[0], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(icon_card_logo, BgNameList[1], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(icon_card_num, BgNameList[2], BasePanel.PanelName);
|
||||
icon_card.gameObject.SetActive(true);
|
||||
}
|
||||
else if (item.Type == 3 && (item.SubType == 1 || item.SubType == 3))
|
||||
{
|
||||
icon_rod.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rod, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
}
|
||||
|
||||
private float GetTransitionScale(float targetIconSize, float targetLossyScale)
|
||||
{
|
||||
if (!icon.gameObject.TryGetComponent<RectTransform>(out var iconRect))
|
||||
{
|
||||
Debug.Log("[RewardFly] Cannot find icon RectTransform.", this);
|
||||
return 1;
|
||||
}
|
||||
// This is hard core.
|
||||
var res = targetIconSize * targetLossyScale / (iconRect.rect.width * iconRect.lossyScale.x / iconRoot.transform.localScale.x / iconRect.localScale.x);
|
||||
// Debug.Log($"[RewardFly] res {res} = {targetIconSize} * {targetLossyScale} / ({iconRect.rect.width} * {iconRect.lossyScale.x} / {iconRoot.transform.localScale.x} / {iconRect.localScale.x})", this);
|
||||
return res;
|
||||
}
|
||||
|
||||
public void OnSpawn()
|
||||
{
|
||||
// Debug.Log("[RewardFly] Spawn in Obj pool.");
|
||||
transform.SetParent(UIManager.Instance.RectTrans);
|
||||
transform.localScale = Vector3.one;
|
||||
// text_num.gameObject.SetActive(false);
|
||||
iconRoot.transform.localScale = Vector3.one;
|
||||
// ani.Play(FLY);
|
||||
}
|
||||
|
||||
public void OnDespawn()
|
||||
{
|
||||
// Debug.Log("[RewardFly] Despawn in Obj pool.");
|
||||
// ShowTrace(false);
|
||||
RemoveGeneratedRenderer(fxRoot);
|
||||
// transform.SetParent(UIManager.Instance.RectTrans);
|
||||
}
|
||||
|
||||
public void OnPoolCreate(IObjectPool objectPool)
|
||||
{
|
||||
_pool = objectPool;
|
||||
// Debug.Log("[RewardFly] Created in pool.");
|
||||
}
|
||||
|
||||
public void OnPoolDestroy()
|
||||
{
|
||||
_pool = null;
|
||||
}
|
||||
|
||||
public void ReturnPool()
|
||||
{
|
||||
_pool?.DespawnObject(this);
|
||||
}
|
||||
|
||||
private void RemoveGeneratedRenderer(GameObject go)
|
||||
{
|
||||
var cc = go.transform.childCount;
|
||||
if (cc > 0)
|
||||
{
|
||||
for (int i = 0; i < cc; i++)
|
||||
{
|
||||
var child = go.transform.GetChild(i).gameObject;
|
||||
RemoveGeneratedRenderer(child);
|
||||
}
|
||||
}
|
||||
if (go.name.StartsWith(GeneratedFlag))
|
||||
{
|
||||
Destroy(go);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenFx(ERewardFlyStage stage, string[] fxList, out GameObject fx)
|
||||
{
|
||||
fx = null;
|
||||
try
|
||||
{
|
||||
if (fxList != null && fxList.Length > (int)stage)
|
||||
{
|
||||
var tr = transform.Find("FxRoot/" + fxList[(int)stage]);
|
||||
if (tr != null)
|
||||
fx = tr.gameObject;
|
||||
if (fx != null)
|
||||
fx.SetActive(true);
|
||||
else
|
||||
Debug.Log($"[BatchedRewardFly] Fx not found: \"{fxList[(int)stage]}\"", this);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log($"[BatchedRewardFly] OpenFx Error: {e.Message}\n{e.StackTrace}", this);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseFx(GameObject fx)
|
||||
{
|
||||
if (fx != null)
|
||||
fx.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ERewardFlyStage
|
||||
{
|
||||
Show = 0,
|
||||
Fly = 1,
|
||||
Out = 2,
|
||||
OutStash = 3
|
||||
}
|
||||
|
||||
public class DefaultRectTr
|
||||
{
|
||||
public Vector2 anchorMax = 0.5f * Vector2.one;
|
||||
public Vector2 anchorMin = 0.5f * Vector2.one;
|
||||
public Vector2 pivot = 0.5f * Vector2.one;
|
||||
public Vector2 anchoredPosition = new Vector2(0, -94);
|
||||
public Vector2 sizeDelta = new Vector2(166, 56);
|
||||
}
|
||||
11
Assets/Scripts/Others/BatchedRewardFly.cs.meta
Normal file
11
Assets/Scripts/Others/BatchedRewardFly.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e764040391e3f804aa040a2a5d28b52f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/Scripts/Others/FishingCamHelper.cs
Normal file
53
Assets/Scripts/Others/FishingCamHelper.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FishingCamHelper : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Camera fishCam;
|
||||
private Camera mainCam;
|
||||
|
||||
private LayerMask mainCamMask;
|
||||
[SerializeField]
|
||||
private LayerMask fishCamMask;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
mainCam = Camera.main;
|
||||
mainCamMask = mainCam.cullingMask;
|
||||
EnableFishingCam(false);
|
||||
}
|
||||
|
||||
public void EnableFishingCam(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
fishCam.cullingMask = fishCamMask;
|
||||
mainCam.cullingMask = mainCamMask - fishCamMask;
|
||||
fishCam.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
fishCam.cullingMask = 0;
|
||||
mainCam.cullingMask = mainCamMask;
|
||||
fishCam.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("ActivateFishingCam")]
|
||||
private void ActivateFishingCam()
|
||||
{
|
||||
EnableFishingCam(true);
|
||||
}
|
||||
|
||||
[ContextMenu("DeactivateFishingCam")]
|
||||
private void DeactivateFishingCam()
|
||||
{
|
||||
EnableFishingCam(false);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
fishCam.fieldOfView = mainCam.fieldOfView;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/FishingCamHelper.cs.meta
Normal file
11
Assets/Scripts/Others/FishingCamHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90c7b85abe1668040bf6e320ef59e3f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Scripts/Others/FogController.cs
Normal file
22
Assets/Scripts/Others/FogController.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class FogController : MonoBehaviour
|
||||
{
|
||||
public bool enableFog = true;
|
||||
public Color fogColor = Color.gray;
|
||||
public FogMode m_fogMode = FogMode.Linear;
|
||||
public float fogDensity = 0.02f;
|
||||
public float startDistance = 0.0f;
|
||||
public float endDistance = 100.0f;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
RenderSettings.fog = enableFog;
|
||||
RenderSettings.fogMode = m_fogMode;
|
||||
RenderSettings.fogColor = fogColor;
|
||||
RenderSettings.fogDensity = fogDensity;
|
||||
RenderSettings.fogStartDistance = startDistance;
|
||||
RenderSettings.fogEndDistance = endDistance;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/FogController.cs.meta
Normal file
11
Assets/Scripts/Others/FogController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5aca486565608374eabaf329240ae66c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/Others/GameClickEffect.cs
Normal file
25
Assets/Scripts/Others/GameClickEffect.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using asap.core;
|
||||
using Coffee.UIExtensions;
|
||||
using Game;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class GameClickEffect : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private UIParticle uiParticle;
|
||||
|
||||
//[SerializeField]
|
||||
//private AssetReferenceT<AudioClip> assetReference;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (uiParticle != null && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
uiParticle.rectTransform.position = Input.mousePosition;
|
||||
uiParticle.Stop();
|
||||
uiParticle.Play();
|
||||
//GContext.Publish(new AssetReferenceAudioClip(assetReference));
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/GameClickEffect.cs.meta
Normal file
11
Assets/Scripts/Others/GameClickEffect.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 779bfa6fe8cebbc47b4be840be5306d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/Scripts/Others/ImageMatPropChange.cs
Normal file
30
Assets/Scripts/Others/ImageMatPropChange.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ImageMatPropChange : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Image image;
|
||||
private Material mat;
|
||||
|
||||
[SerializeField]
|
||||
private string propName = "_Color";
|
||||
private int propID = Shader.PropertyToID("_Color");
|
||||
|
||||
void Start()
|
||||
{
|
||||
propID = Shader.PropertyToID(propName);
|
||||
mat = image?.material;
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
mat?.SetFloat(propID, 1);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
mat?.SetFloat(propID, 0);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Others/ImageMatPropChange.cs.meta
Normal file
11
Assets/Scripts/Others/ImageMatPropChange.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28fdeb37c165b8d4a9bb985498037a9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Scripts/Others/QualityLimit.cs
Normal file
35
Assets/Scripts/Others/QualityLimit.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class QualityLimit
|
||||
{
|
||||
private static string[][] _keywordsList;
|
||||
public static string[][] KeywordsList
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_keywordsList == null)
|
||||
{
|
||||
var data = Addressables.LoadAssetAsync<TextAsset>("gpulimitdata").WaitForCompletion();
|
||||
_keywordsList = Newtonsoft.Json.JsonConvert.DeserializeObject<string[][]>(data.text);
|
||||
}
|
||||
return _keywordsList;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsLimitDevice()
|
||||
{
|
||||
var deviceName = SystemInfo.graphicsDeviceName;
|
||||
|
||||
if(string.IsNullOrEmpty(deviceName))
|
||||
return true;
|
||||
|
||||
foreach (var keywords in KeywordsList)
|
||||
{
|
||||
if (keywords.All(k => deviceName.IndexOf(k) >= 0))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/QualityLimit.cs.meta
Normal file
11
Assets/Scripts/Others/QualityLimit.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8894cd7acae0004f9c199fc61e0a2cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
260
Assets/Scripts/Others/RewardFly.cs
Normal file
260
Assets/Scripts/Others/RewardFly.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using asap.core;
|
||||
using asap.core.common;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
|
||||
public struct CollectionItemFly
|
||||
{
|
||||
public int itemID;
|
||||
/// <summary>
|
||||
/// 没有ItemID 直接iconName
|
||||
/// </summary>
|
||||
public string iconName;
|
||||
/// <summary>
|
||||
/// 也可以直接放 icon Sprite
|
||||
/// </summary>
|
||||
public Sprite icon;
|
||||
public string numStr;
|
||||
public Vector2 scale;
|
||||
public float sourceIconSize;
|
||||
public float targetIconSize;
|
||||
public Vector3 sourcePos;
|
||||
public Vector3 destPos;
|
||||
//public float showDuration;
|
||||
//public float flyDuration;
|
||||
public bool isPlayOpen;
|
||||
public bool isPlayClose;
|
||||
public bool isDestinationRewardStash;
|
||||
}
|
||||
|
||||
public class RewardFly : MonoBehaviour, IPoolableObject
|
||||
{
|
||||
public Image icon;
|
||||
public Image icon_card;
|
||||
public Image icon_card_logo;
|
||||
public Image icon_card_num;
|
||||
public Image icon_rod;
|
||||
public TMP_Text text_num;
|
||||
public Animation ani;
|
||||
public AnimationCurve curveX;
|
||||
public AnimationCurve curveY;
|
||||
public AnimationCurve curveScale;
|
||||
public float flyDuration = 0.4f;
|
||||
public float showDuration = 0.5f;
|
||||
public float closeAnimationDurationStash = 0.33f;
|
||||
public float closeAnimationDuration = 0.5f;
|
||||
// public float showTraceDelay = 0.05f;
|
||||
[SerializeField] protected GameObject fxTrace, iconRoot, fxRoot;
|
||||
protected const string IN = "rewardfly_show", OUT = "rewardfly_out", OUT_STASH = "rewardfly_out_bag", FLY = "rewardfly_fly", GeneratedFlag = "[generated]";
|
||||
private IObjectPool _pool;
|
||||
[SerializeField] private ParticleSystem fxTrail;
|
||||
private void OnEnable()
|
||||
{
|
||||
// Debug.Log($"[RewardFly] Enabled.");
|
||||
icon.gameObject.SetActive(false);
|
||||
icon_card.gameObject.SetActive(false);
|
||||
icon_rod.gameObject.SetActive(false);
|
||||
}
|
||||
public virtual async Task ShowAsync(CollectionItemFly itemFly)
|
||||
{
|
||||
SetText(itemFly.numStr);
|
||||
if (itemFly.sourceIconSize != 0.0f)
|
||||
{
|
||||
var sourceScale = GetTransitionScale(itemFly.sourceIconSize);
|
||||
iconRoot.transform.localScale = new Vector3(sourceScale, sourceScale, 1f);
|
||||
}
|
||||
if (itemFly.icon != null)
|
||||
{
|
||||
SetData(itemFly.icon);
|
||||
}
|
||||
else if (string.IsNullOrEmpty(itemFly.iconName))
|
||||
{
|
||||
SetData(itemFly.itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetData(itemFly.iconName);
|
||||
}
|
||||
// transform.localScale = itemFly.scale;
|
||||
transform.position = itemFly.sourcePos;
|
||||
if (itemFly.isPlayOpen)
|
||||
{
|
||||
ani.Play(IN);
|
||||
await Awaiters.Seconds(showDuration);
|
||||
// PlayOpen();
|
||||
}
|
||||
else
|
||||
{
|
||||
//ani.Play("reward_common_idle");
|
||||
}
|
||||
//ani.Play("reward_common_idle");
|
||||
SetText("");
|
||||
ShowTrace();
|
||||
transform.DOMoveX(itemFly.destPos.x, flyDuration).SetEase(curveX);
|
||||
transform.DOMoveY(itemFly.destPos.y, flyDuration).SetEase(curveY);
|
||||
var targetScale = GetTransitionScale(itemFly.targetIconSize);
|
||||
iconRoot.transform.DOScale(targetScale, flyDuration).SetEase(curveScale);
|
||||
await Awaiters.Seconds(flyDuration);
|
||||
if (!itemFly.isPlayClose)
|
||||
return;
|
||||
if (itemFly.isDestinationRewardStash)
|
||||
{
|
||||
ani.Play(OUT_STASH);
|
||||
await Awaiters.Seconds(closeAnimationDurationStash);
|
||||
}
|
||||
else
|
||||
{
|
||||
ani.Play(OUT);
|
||||
await Awaiters.Seconds(closeAnimationDuration);
|
||||
}
|
||||
ShowTrace();
|
||||
}
|
||||
|
||||
public async void Show(CollectionItemFly itemFly)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ShowAsync(itemFly);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.Log($"[RewardFly] {e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
void PlayOpen()
|
||||
{
|
||||
ani.Play("reward_common_open");
|
||||
}
|
||||
|
||||
void PlayClose()
|
||||
{
|
||||
ani.Play("reward_common_close");
|
||||
}
|
||||
|
||||
protected void SetData(string iconName)
|
||||
{
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, iconName, BasePanel.PanelName);
|
||||
}
|
||||
|
||||
protected void SetData(Sprite iconSprite)
|
||||
{
|
||||
icon.gameObject.SetActive(true);
|
||||
icon.sprite = iconSprite;
|
||||
}
|
||||
protected void SetText(string numStr)
|
||||
{
|
||||
text_num.gameObject.SetActive(true);
|
||||
text_num.text = numStr;
|
||||
}
|
||||
|
||||
protected void SetData(int itemID)
|
||||
{
|
||||
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(itemID);
|
||||
if (item.Type == 5 && (item.SubType == 1 || item.SubType == 2))
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
List<string> BgNameList;
|
||||
if (item.SubType == 1)
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbFishCardDrop.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbGeneralCardWeight.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
uiService.SetImageSprite(icon_card, BgNameList[0], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(icon_card_logo, BgNameList[1], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(icon_card_num, BgNameList[2], BasePanel.PanelName);
|
||||
icon_card.gameObject.SetActive(true);
|
||||
}
|
||||
else if (item.Type == 3 && (item.SubType == 1 || item.SubType == 3))
|
||||
{
|
||||
icon_rod.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rod, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
}
|
||||
|
||||
protected float GetTransitionScale(float targetIconSize)
|
||||
{
|
||||
if (!icon.gameObject.TryGetComponent<RectTransform>(out var iconRect))
|
||||
{
|
||||
Debug.Log("[RewardFly] Cannot find icon RectTransform.", this);
|
||||
return 1;
|
||||
}
|
||||
var res = targetIconSize / iconRect.rect.width;
|
||||
return res;
|
||||
}
|
||||
|
||||
protected void ShowTrace(bool doesShow = true)
|
||||
{
|
||||
// Debug.Log("[RewardFly] Trace Shown");
|
||||
if (fxTrace != null)
|
||||
fxTrace.SetActive(doesShow);
|
||||
}
|
||||
|
||||
public void OnSpawn()
|
||||
{
|
||||
// Debug.Log("[RewardFly] Spawn in Obj pool.");
|
||||
transform.SetParent(UIManager.Instance.RectTrans);
|
||||
transform.localScale = Vector3.one;
|
||||
text_num.gameObject.SetActive(true);
|
||||
iconRoot.transform.localScale = Vector3.one;
|
||||
// ani.Play(FLY);
|
||||
}
|
||||
|
||||
public void OnDespawn()
|
||||
{
|
||||
// Debug.Log("[RewardFly] Despawn in Obj pool.");
|
||||
// ShowTrace(false);
|
||||
RemoveGeneratedRenderer(fxRoot);
|
||||
// transform.SetParent(UIManager.Instance.RectTrans);
|
||||
}
|
||||
|
||||
public void OnPoolCreate(IObjectPool objectPool)
|
||||
{
|
||||
_pool = objectPool;
|
||||
// Debug.Log("[RewardFly] Created in pool.");
|
||||
}
|
||||
|
||||
public void OnPoolDestroy()
|
||||
{
|
||||
_pool = null;
|
||||
}
|
||||
|
||||
public void ReturnPool()
|
||||
{
|
||||
_pool?.DespawnObject(this);
|
||||
}
|
||||
|
||||
private void RemoveGeneratedRenderer(GameObject go)
|
||||
{
|
||||
var cc = go.transform.childCount;
|
||||
if (cc > 0)
|
||||
{
|
||||
for (int i = 0; i < cc; i++)
|
||||
{
|
||||
var child = go.transform.GetChild(i).gameObject;
|
||||
RemoveGeneratedRenderer(child);
|
||||
}
|
||||
}
|
||||
if (go.name.StartsWith(GeneratedFlag))
|
||||
{
|
||||
Destroy(go);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/RewardFly.cs.meta
Normal file
11
Assets/Scripts/Others/RewardFly.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec0d3cf64e3881640894e00693a00756
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Others/RewardFly.meta
Normal file
8
Assets/Scripts/Others/RewardFly.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72398161b2bbb68468cb4176e7107d3f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Scripts/Others/RewardFly/RewardItemTransfer.cs
Normal file
20
Assets/Scripts/Others/RewardFly/RewardItemTransfer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RewardItemTransfer : MonoBehaviour
|
||||
{
|
||||
public ExchangeItemData data;
|
||||
public Image icon;
|
||||
public TMP_Text text_num;
|
||||
public void Init(ExchangeItemData edata)
|
||||
{
|
||||
data = edata;
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, _tables.GetItemIconName(data.exchangeId));
|
||||
text_num.text = $"x{data.exchangeCount}";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/RewardFly/RewardItemTransfer.cs.meta
Normal file
11
Assets/Scripts/Others/RewardFly/RewardItemTransfer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f253fbd1848ed140988067cc278216b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/Scripts/Others/RewardFlyAnimationParams.cs
Normal file
54
Assets/Scripts/Others/RewardFlyAnimationParams.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class RewardFlyAnimationParams
|
||||
{
|
||||
public string Remark = "通用";
|
||||
public AnimationCurve CurveX;
|
||||
public AnimationCurve CurveY;
|
||||
public AnimationCurve CurveScale;
|
||||
public float ShowDuration = 1f;
|
||||
public float FlyDuration = 0.4f;
|
||||
// public float closeAnimationDurationStash = 0.33f;
|
||||
public float CloseDuration = 0.5f;
|
||||
public float SpreadHalfAngle = 15f;
|
||||
public float SpreadNearRange = 20f;
|
||||
public float SpreadFarRange = 40f;
|
||||
public float SpawnInterval = 0.05f;
|
||||
public float MaxTiltAngle = 90f;
|
||||
public float MultipleIconScaleModifier = 0.75f;
|
||||
public bool IsPlayOpen;
|
||||
public bool IsPlayClose;
|
||||
public string[] AudioSingle;
|
||||
public string[] AudioBatched;
|
||||
public string[] FxSingle;
|
||||
public string[] FxBatched;
|
||||
public AnimationCurve CurveShow;
|
||||
public float alphaShow;
|
||||
public float scaleShow;
|
||||
|
||||
public string GetAudioUrl(int idx, bool isBatched)
|
||||
{
|
||||
if (isBatched)
|
||||
{
|
||||
if (AudioBatched != null && idx < AudioBatched.Length)
|
||||
return AudioBatched[idx];
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[RewardFlyBatched] Audio param error: index{idx} out of range.");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AudioSingle != null && idx < AudioSingle.Length)
|
||||
return AudioSingle[idx];
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[RewardFlySingle] Audio param error: index{idx} out of range.");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/RewardFlyAnimationParams.cs.meta
Normal file
11
Assets/Scripts/Others/RewardFlyAnimationParams.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad7a8c0e4a03b6d4db88202cdc91bb69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
169
Assets/Scripts/Others/RewardFlyBatchController.cs
Normal file
169
Assets/Scripts/Others/RewardFlyBatchController.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using asap.core;
|
||||
using asap.core.common;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Game;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
|
||||
public class RewardFlyBatchController : MonoBehaviour
|
||||
{
|
||||
[Header("Configuration")]
|
||||
[SerializeField] private BatchedRewardFly rewardFlyPrefab;
|
||||
[SerializeField] private int initialPoolSize = 5;
|
||||
[SerializeField] private int maxPoolSize = 20;
|
||||
[SerializeField] private int maxIconsPerRequest = 8;
|
||||
|
||||
[Header("Animation Parameters")]
|
||||
[SerializeField] private RewardFlyAnimationParams[] animationParamList;
|
||||
|
||||
// public IEventAggregator EventBus { get; private set; }
|
||||
private IObjectPoolService _objectPoolService;
|
||||
private IObjectPool _rewardFlyPool;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_objectPoolService = GContext.container.Resolve<IObjectPoolService>();
|
||||
_rewardFlyPool = _objectPoolService.CreatePool(rewardFlyPrefab, initialPoolSize, maxPoolSize);
|
||||
GContext.OnEvent<BatchedRewardFlyRequest>().Subscribe(OnRewardFlyRequest).AddTo(this);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
_objectPoolService?.DestroyPool(typeof(BatchedRewardFly));
|
||||
_rewardFlyPool = null;
|
||||
}
|
||||
|
||||
public async void OnRewardFlyRequest(BatchedRewardFlyRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
await OnRewardFlyRequestAsync(request);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnRewardFlyRequestAsync(BatchedRewardFlyRequest request)
|
||||
{
|
||||
var rewardFlyList = new List<BatchedRewardFly>();
|
||||
try
|
||||
{
|
||||
int iconCount = 1;
|
||||
if (request.Quantity.HasValue)
|
||||
iconCount = Mathf.Clamp(request.Quantity.Value, 1, maxIconsPerRequest);
|
||||
var taskList = new List<Task>();
|
||||
var param = animationParamList[request.AnimationParamIndex];
|
||||
// if (param.IsPlayOpen)
|
||||
// GContext.Publish(new EventUISound("audio_ui_rewardfly_single_fly"));
|
||||
string audioShow = param.GetAudioUrl(0, iconCount > 1);
|
||||
GContext.Publish(new EventUISound(audioShow));
|
||||
BatchedRewardFly rewardFly;
|
||||
//Show
|
||||
if (iconCount <= 1)
|
||||
{
|
||||
rewardFly = _rewardFlyPool.SpawnObject() as BatchedRewardFly;
|
||||
if (rewardFly == null)
|
||||
{
|
||||
Debug.LogError("[RewardFlyBatchController] Failed to spawn RewardFly from pool.");
|
||||
return;
|
||||
}
|
||||
rewardFlyList.Add(rewardFly);
|
||||
rewardFly.gameObject.SetActive(true);
|
||||
await rewardFly.SingleFlyAsync(request, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardFly = _rewardFlyPool.SpawnObject() as BatchedRewardFly;
|
||||
if (rewardFly == null)
|
||||
{
|
||||
Debug.LogError("[RewardFlyBatchController] Failed to spawn RewardFly from pool.");
|
||||
return;
|
||||
}
|
||||
rewardFlyList.Add(rewardFly);
|
||||
rewardFly.gameObject.SetActive(true);
|
||||
await rewardFly.BatchShowAsync(request, param);
|
||||
for (int i = 0; i < iconCount; i++)
|
||||
{
|
||||
rewardFly = _rewardFlyPool.SpawnObject() as BatchedRewardFly;
|
||||
if (rewardFly == null)
|
||||
{
|
||||
Debug.LogError("[RewardFlyBatchController] Failed to spawn RewardFly from pool.");
|
||||
continue;
|
||||
}
|
||||
rewardFlyList.Add(rewardFly);
|
||||
rewardFly.gameObject.SetActive(true);
|
||||
taskList.Add(rewardFly.BatchFlyAsync(request, param));
|
||||
if (iconCount > 1)
|
||||
{
|
||||
await Task.Delay(System.TimeSpan.FromSeconds(param.SpawnInterval));
|
||||
}
|
||||
}
|
||||
await Task.WhenAll(taskList.ToArray());
|
||||
}
|
||||
rewardFlyList.ForEach(rf => rf.ReturnPool());
|
||||
rewardFlyList.Clear();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.Log($"[RewardFlyBatchController] {e.Message}\n{e.StackTrace}");
|
||||
rewardFlyList.ForEach(rf => Destroy(rf.gameObject));
|
||||
rewardFlyList.Clear();
|
||||
}
|
||||
// Debug.Log("[RewardFlyBatchController] Done.");
|
||||
}
|
||||
}
|
||||
|
||||
public class BatchedRewardFlyRequest
|
||||
{
|
||||
// Pick one of these three, things just work.
|
||||
public int itemID; public string iconName; public Sprite icon;
|
||||
public int? Quantity;
|
||||
public BatchedRewardFlyPoint StartPoint;
|
||||
public BatchedRewardFlyPoint EndPoint;
|
||||
public RectTransform sourceTextRt = null;
|
||||
public bool isDestinationRewardStash;
|
||||
public int AnimationParamIndex;
|
||||
public BatchedRewardFlyRequest() { }
|
||||
}
|
||||
|
||||
public class BatchedRewardFlyPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Global position of a transform
|
||||
/// </summary>
|
||||
public readonly Vector3 Pos;
|
||||
/// <summary>
|
||||
/// Literal size of a transform
|
||||
/// </summary>
|
||||
public readonly float Size;
|
||||
/// <summary>
|
||||
/// Lossy scale of a transform
|
||||
/// </summary>
|
||||
public readonly float LossyScale;
|
||||
|
||||
public BatchedRewardFlyPoint(Vector3 pos, float size, float lossyScale)
|
||||
{
|
||||
Pos = pos;
|
||||
Size = size;
|
||||
LossyScale = lossyScale;
|
||||
}
|
||||
|
||||
public BatchedRewardFlyPoint(Vector3 pos)
|
||||
{
|
||||
Pos = pos;
|
||||
Size = 0f;
|
||||
LossyScale = 1f;
|
||||
}
|
||||
|
||||
public BatchedRewardFlyPoint(RectTransform t)
|
||||
{
|
||||
Pos = t.position;
|
||||
Size = t.sizeDelta.x;
|
||||
LossyScale = t.lossyScale.x;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/RewardFlyBatchController.cs.meta
Normal file
11
Assets/Scripts/Others/RewardFlyBatchController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3538e30bc6dae1409dbe2e8ae8c99b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
84
Assets/Scripts/Others/TikTokEventManager.cs
Normal file
84
Assets/Scripts/Others/TikTokEventManager.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using game;
|
||||
using UniRx;
|
||||
|
||||
public class TikTokEventManager : IDisposable
|
||||
{
|
||||
private static TikTokEventManager _instance;
|
||||
private CompositeDisposable disposable;
|
||||
|
||||
private TikTokEventManager() { }
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if(_instance != null)
|
||||
{
|
||||
_instance.Dispose();
|
||||
_instance = null;
|
||||
}
|
||||
_instance = new TikTokEventManager();
|
||||
_instance.disposable = new CompositeDisposable();
|
||||
_instance.Subscribe();
|
||||
UnityEngine.Debug.Log($"[TikTokEventManager]Init");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
createTime = null;
|
||||
}
|
||||
|
||||
private void Subscribe()
|
||||
{
|
||||
GContext.OnEvent<OnLvChangeEvent>().Subscribe(OnLvChange).AddTo(disposable);
|
||||
GContext.OnEvent<ClubStateChangeEvent>().Where(_ => _.joinClub).Subscribe(OnJoinClub).AddTo(disposable);
|
||||
}
|
||||
|
||||
private void OnLvChange(OnLvChangeEvent evt)
|
||||
{
|
||||
if(!IsFirstDay()) return;
|
||||
|
||||
//UnityEngine.Debug.Log($"[TikTokEventManager]OnLvChange: {evt.lvl}");
|
||||
|
||||
switch(evt.lvl)
|
||||
{
|
||||
case 10:
|
||||
using(GEvent.GameEvent("af_d0_charalevel_10", true)){}
|
||||
break;
|
||||
case 20:
|
||||
using(GEvent.GameEvent("af_d0_charalevel_20", true)){}
|
||||
using(GEvent.GameEvent("af_d0_completetutorial", true)){}
|
||||
break;
|
||||
case 30:
|
||||
using(GEvent.GameEvent("af_d0_charalevel_30", true)){}
|
||||
break;
|
||||
case 40:
|
||||
using(GEvent.GameEvent("af_d0_charalevel_40", true)){}
|
||||
break;
|
||||
case 50:
|
||||
using(GEvent.GameEvent("af_d0_charalevel_50", true)){}
|
||||
break;
|
||||
case 60:
|
||||
using(GEvent.GameEvent("af_d0_charalevel_60", true)){}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnJoinClub(ClubStateChangeEvent evt)
|
||||
{
|
||||
using(GEvent.GameEvent("af_joinclub", true)){}
|
||||
}
|
||||
|
||||
private static DateTime? createTime;
|
||||
|
||||
public static bool IsFirstDay()
|
||||
{
|
||||
if(createTime == null)
|
||||
createTime = GContext.container.Resolve<IUserService>().CreateTime;
|
||||
var utcNow = ZZTimeHelper.UtcNow();
|
||||
return (utcNow - createTime) < TimeSpan.FromHours(24);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Others/TikTokEventManager.cs.meta
Normal file
11
Assets/Scripts/Others/TikTokEventManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 905f7770975a345fbb1574cb9f6ecb40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
111
Assets/Scripts/Others/UIParticleAttractorCenter.cs
Normal file
111
Assets/Scripts/Others/UIParticleAttractorCenter.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using asap.core;
|
||||
using Coffee.UIExtensions;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ParticleAttractorData
|
||||
{
|
||||
public bool IgnorePack;
|
||||
public int Type;
|
||||
public int SubType;
|
||||
public int ParticleCount;
|
||||
public int Priority;
|
||||
public UIParticleAttractorCenter uIParticleAttractorCenter;
|
||||
}
|
||||
public class UIParticleAttractorCenter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] UIParticleAttractor uiParticleAttractorTemplate;
|
||||
private List<UIParticleAttractor> _uiParticleAttractors;
|
||||
public int Type;
|
||||
public int SubType;
|
||||
public int Priority;
|
||||
Animator ani;
|
||||
IDisposable disposable;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
_uiParticleAttractors = GetComponents<UIParticleAttractor>().ToList();
|
||||
uiParticleAttractorTemplate = GetComponent<UIParticleAttractor>();
|
||||
|
||||
// uIParticleAttractor = uiParticleAttractors.FirstOrDefault(x => !x.IsTaken);
|
||||
// if (uIParticleAttractor == null)
|
||||
// {
|
||||
// uIParticleAttractor = gameObject.AddComponent<UIParticleAttractor>();
|
||||
// }
|
||||
// uIParticleAttractor.enabled = false;
|
||||
// uIParticleAttractor.destinationRadius = 1;
|
||||
|
||||
//uIParticleAttractor.delay = 0.2f;
|
||||
// uIParticleAttractor.maxSpeed = 0.6f;
|
||||
ani = GetComponent<Animator>();
|
||||
if (ani != null && uiParticleAttractorTemplate != null)
|
||||
{
|
||||
uiParticleAttractorTemplate.onAttractedStart.AddListener(() => ani.Play("reward_gain_loop"));
|
||||
uiParticleAttractorTemplate.onAttractedEnd.AddListener(OnEnd);
|
||||
}
|
||||
}
|
||||
async void OnEnd()
|
||||
{
|
||||
await Awaiters.Seconds(0.2f);
|
||||
if (ani)
|
||||
{
|
||||
ani.Play("Init");
|
||||
}
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
disposable = GContext.OnEvent<ParticleAttractorData>().Subscribe(OnParticleAttractor);
|
||||
}
|
||||
void OnParticleAttractor(ParticleAttractorData data)
|
||||
{
|
||||
bool doesTypeMatch = (!data.IgnorePack && Type == -1) || (data.Type == Type && data.SubType == SubType);
|
||||
if (doesTypeMatch && data.Priority < Priority)
|
||||
{
|
||||
data.Priority = Priority;
|
||||
data.uIParticleAttractorCenter = this;
|
||||
}
|
||||
}
|
||||
|
||||
public UIParticleAttractor GetUIParticleAttractor()
|
||||
{
|
||||
var uiParticleAttractor = _uiParticleAttractors.FirstOrDefault(x => x.particleSystem == null);
|
||||
if (uiParticleAttractor == null)
|
||||
{
|
||||
uiParticleAttractor = gameObject.AddComponent<UIParticleAttractor>();
|
||||
_uiParticleAttractors.Add(uiParticleAttractor);
|
||||
}
|
||||
|
||||
uiParticleAttractor.enabled = false;
|
||||
|
||||
if (uiParticleAttractorTemplate != null)
|
||||
{
|
||||
uiParticleAttractor.destinationRadius = uiParticleAttractorTemplate.destinationRadius;
|
||||
uiParticleAttractor.delay = uiParticleAttractorTemplate.delay;
|
||||
uiParticleAttractor.maxSpeed = uiParticleAttractorTemplate.maxSpeed;
|
||||
if (ani != null)
|
||||
{
|
||||
uiParticleAttractor.onAttractedStart = uiParticleAttractorTemplate.onAttractedStart;
|
||||
uiParticleAttractor.onAttractedEnd = uiParticleAttractorTemplate.onAttractedEnd;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uiParticleAttractor.destinationRadius = 1;
|
||||
}
|
||||
|
||||
return uiParticleAttractor;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/UIParticleAttractorCenter.cs.meta
Normal file
11
Assets/Scripts/Others/UIParticleAttractorCenter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39664ae4fd62c5840ba32237f0be3366
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
125
Assets/Scripts/Others/ZZTimeHelper.cs
Normal file
125
Assets/Scripts/Others/ZZTimeHelper.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
|
||||
public struct RequestSvrTimeEvent
|
||||
{
|
||||
public bool Status;
|
||||
}
|
||||
|
||||
public class ZZTimeHelper
|
||||
{
|
||||
public static TimeSpan timeDiff = TimeSpan.Zero;
|
||||
public static bool isAttachedToFChange = false;
|
||||
|
||||
static bool isRequesting = false;
|
||||
|
||||
public static int LocalTimeOffsetInSec = 0;
|
||||
|
||||
public static DateTime UtcNow()
|
||||
{
|
||||
return DateTime.UtcNow.AddSeconds(LocalTimeOffsetInSec) + timeDiff;
|
||||
}
|
||||
|
||||
public static void AdjustTime(DateTime svrTime)
|
||||
{
|
||||
var diff = svrTime - DateTime.UtcNow;
|
||||
if(Mathf.Abs((float)diff.TotalSeconds) < 60)
|
||||
{
|
||||
timeDiff = TimeSpan.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeDiff = diff;
|
||||
}
|
||||
//UnityEngine.Debug.Log("[ZZTimeHelper] AdjustTime:" + timeDiff);
|
||||
}
|
||||
|
||||
public static void WathForcusChange()
|
||||
{
|
||||
if (!isAttachedToFChange)
|
||||
{
|
||||
UnityEngine.Application.focusChanged += focused =>
|
||||
{
|
||||
if (focused)
|
||||
{
|
||||
UnityEngine.Debug.Log("[ZZTimeHelper] RequestSvrTime");
|
||||
_ = RequestSvrTime();
|
||||
}
|
||||
};
|
||||
|
||||
isAttachedToFChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Request ServerTime, but also sync data.
|
||||
/// </summary>
|
||||
/// <param name="syncData">True if needing to sync data.</param>
|
||||
public static async Task RequestSvrTime()
|
||||
{
|
||||
if (isRequesting)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameCore.UIManager.ShowWaitingBlock("RequestSvrTime");
|
||||
isRequesting = true;
|
||||
var SvrTime = await GetSvrTime();
|
||||
isRequesting = false;
|
||||
GameCore.UIManager.HideWaitingBlock("RequestSvrTime");
|
||||
if(SvrTime != null)
|
||||
{
|
||||
AdjustTime(SvrTime.Value);
|
||||
GContext.Publish(new RequestSvrTimeEvent() { Status = true });
|
||||
}
|
||||
else
|
||||
{
|
||||
GContext.Publish(new RequestSvrTimeEvent() { Status = false });
|
||||
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
|
||||
var NoticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
|
||||
string info = LocalizationMgr.GetText("UI_FishingReconnectPanel_101003");
|
||||
string label = LocalizationMgr.GetText("UI_FishingRewardPanel_101022");
|
||||
string title = LocalizationMgr.GetText("UI_FishingReconnectPanel_101002");
|
||||
NoticeConfirmPopupPanel.Init(1, title, info,
|
||||
onClickLeft: async () => {await RequestSvrTime();},
|
||||
onClose: async () =>{ await RequestSvrTime();},
|
||||
btn_left_text: label);
|
||||
}
|
||||
}
|
||||
|
||||
private const string timeUrl = "http://time.bamboogames.cc";
|
||||
private static async Task<DateTime?> GetSvrTime()
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpClient client = new HttpClient();
|
||||
client.Timeout = TimeSpan.FromSeconds(5);
|
||||
//IConfig config = GContext.container.Resolve<IConfig>();
|
||||
//string apiUrl = config.Get<string>(GConstant.K_Event_API_URL, "http://192.168.9.101:5292/");
|
||||
//string url = $"{apiUrl}account/svrtime";
|
||||
var svrTimeStr = await client.GetStringAsync(timeUrl);
|
||||
|
||||
if (!string.IsNullOrEmpty(svrTimeStr))
|
||||
{
|
||||
if(DateTime.TryParse(svrTimeStr, out DateTime SvrTime))
|
||||
{
|
||||
if(SvrTime.Kind == DateTimeKind.Local)
|
||||
SvrTime = SvrTime.ToUniversalTime();
|
||||
return SvrTime;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch(System.Exception)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("[ZZTimeHelper] RequestSvrTime error");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Others/ZZTimeHelper.cs.meta
Normal file
11
Assets/Scripts/Others/ZZTimeHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5f49231514f1ce4f904c5a2a40ae78a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user