备份CatanBuilding瘦身独立工程
This commit is contained in:
18
Assets/Scripts/UI/PartnerFishBowl/EventPartner.cs
Normal file
18
Assets/Scripts/UI/PartnerFishBowl/EventPartner.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventPartner : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/PartnerFishBowl/EventPartner.cs.meta
Normal file
11
Assets/Scripts/UI/PartnerFishBowl/EventPartner.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59769644f04277a459f81e8a4dd2f63d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
184
Assets/Scripts/UI/PartnerFishBowl/EventPartnerAct.cs
Normal file
184
Assets/Scripts/UI/PartnerFishBowl/EventPartnerAct.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using GameCore;
|
||||
using game;
|
||||
using cfg;
|
||||
using UnityEngine.Assertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.U2D;
|
||||
public class EventPartnerAct : AGameAct
|
||||
{
|
||||
public static Context Ctx;
|
||||
public override async System.Threading.Tasks.Task<bool> StartAsync()
|
||||
{
|
||||
Ctx = new Context();
|
||||
// var panelGO = await UIManager.Instance.ShowUI(UITypes.EventPartnerFishbowlPanel);
|
||||
// panelGO.GetComponent<EventPartnerPanel>().Init(_context);
|
||||
await LoadSprites();
|
||||
await LoadAudioClips();
|
||||
await Ctx.ShowMainPanel();
|
||||
return await base.StartAsync();
|
||||
}
|
||||
|
||||
public override async System.Threading.Tasks.Task StopAsync()
|
||||
{
|
||||
Ctx.ReleaseAddressableOperation();
|
||||
UIManager.Instance.DestroyUI(UITypes.EventPartnerPanel);
|
||||
await base.StopAsync();
|
||||
}
|
||||
private async System.Threading.Tasks.Task LoadSprites()
|
||||
{
|
||||
Ctx.SpriteDic = new Dictionary<string, Sprite>();
|
||||
var op = Addressables.LoadAssetAsync<SpriteAtlas>(Ctx.Data.AtlasUrl);
|
||||
Ctx.AddAddressableOperation(op);
|
||||
var atlas = await op.Task;
|
||||
var spinwheelBgList = Ctx.Tables.TbEventPartnerMain[Ctx.Data.RedirectId].SpinBg;
|
||||
foreach (var key in spinwheelBgList.Where(key => !Ctx.SpriteDic.ContainsKey(key)))
|
||||
{
|
||||
Ctx.SpriteDic.Add(key, atlas.GetSprite(key));
|
||||
}
|
||||
var componentIdList = Ctx.Tables.TbEventPartnerMain[Ctx.Data.RedirectId].ComponentList;
|
||||
var componentTable = Ctx.Tables.TbEventPartnerComponent;
|
||||
foreach (var id in componentIdList)
|
||||
{
|
||||
var resList = componentTable[id].ResourceList;
|
||||
foreach (var resId in resList)
|
||||
{
|
||||
Ctx.SpriteDic.Add(resId, atlas.GetSprite(resId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task LoadAudioClips()
|
||||
{
|
||||
Ctx.AudioDic = new Dictionary<string, AudioClip>();
|
||||
var opHandle = Addressables.LoadAssetAsync<AudioClip>(Ctx.Data.MatchBgmUrl);
|
||||
Ctx.AddAddressableOperation(opHandle);
|
||||
Ctx.AudioDic.Add(Ctx.Data.MatchBgmUrl, await opHandle.Task);
|
||||
var opHandle2 = Addressables.LoadAssetAsync<AudioClip>(Ctx.Data.BgmUrl);
|
||||
Ctx.AddAddressableOperation(opHandle2);
|
||||
Ctx.AudioDic.Add(Ctx.Data.BgmUrl, await opHandle2.Task);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
Debug.Log("EventPartnerAct Exit.");
|
||||
}
|
||||
|
||||
public static EPanelState GetPanelState()
|
||||
{
|
||||
if (Ctx == null)
|
||||
return EPanelState.NotOpen;
|
||||
return Ctx.State;
|
||||
}
|
||||
|
||||
public enum EPanelState : int
|
||||
{
|
||||
NotOpen = -2,
|
||||
MainPanel = -1,
|
||||
BuildPanel0 = 0,
|
||||
BuildPanel1 = 1,
|
||||
BuildPanel2 = 2,
|
||||
BuildPanel3 = 3
|
||||
}
|
||||
|
||||
public class Context
|
||||
{
|
||||
private readonly IEventAggregator _eventAggregator = new EventAggregator();
|
||||
public IEventAggregator EventAggregator => _eventAggregator;
|
||||
public int CurrentComponentIdx;
|
||||
public Tables Tables { get; } = GContext.container.Resolve<Tables>();
|
||||
|
||||
private readonly IUserService _userService = GContext.container.Resolve<IUserService>();
|
||||
private readonly EventPartnerData _data = GContext.container.Resolve<EventPartnerData>();
|
||||
public EventPartnerData Data => _data;
|
||||
private EventPartnerPanel _panel;
|
||||
public EventPartnerData.Component Component => _data.Components[CurrentComponentIdx];
|
||||
public Dictionary<string, Sprite> SpriteDic;
|
||||
public Dictionary<string, AudioClip> AudioDic;
|
||||
private readonly List<AsyncOperationHandle> _ops = new List<AsyncOperationHandle>();
|
||||
private System.Threading.Tasks.Task _taskZoom;
|
||||
public EPanelState State { get; private set; } = EPanelState.NotOpen;
|
||||
|
||||
public async System.Threading.Tasks.Task ShowMainPanel(bool doShowMatchTip = false, string namePartner = "", string iconPartner = "", string nameComponent = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_panel == null)
|
||||
{
|
||||
var panelGo = await UIManager.Instance.ShowUI(UITypes.EventPartnerPanel);
|
||||
_panel = panelGo.GetComponent<EventPartnerPanel>();
|
||||
}
|
||||
|
||||
_panel.Init();
|
||||
_panel.ShowMainPanel();
|
||||
_panel.ZoomOut();
|
||||
_panel.PlayUiAnimation();
|
||||
_panel.ShowMatchTip(namePartner, iconPartner, nameComponent, doShowMatchTip);
|
||||
State = EPanelState.MainPanel;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"<color=#c191ff>[EventPartner] Error in show main panel.</color>");
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowBuildPanel(int componentIdx)
|
||||
{
|
||||
Assert.IsTrue(_panel != null, "Main Panel not instantiated.");
|
||||
CurrentComponentIdx = componentIdx;
|
||||
_panel.ShowBuildPanel(this);
|
||||
_panel.ZoomIn(componentIdx);
|
||||
_panel.PlayUiAnimation();
|
||||
State = (EPanelState)componentIdx;
|
||||
}
|
||||
|
||||
public Sprite GetSprite(string key)
|
||||
{
|
||||
// Assert.IsTrue(_context.SpriteDic.ContainsKey(key), $"key \"{key}\" not found in sprite dictionary");
|
||||
if (SpriteDic.TryGetValue(key, out var sprite))
|
||||
return sprite;
|
||||
Debug.LogError($"key \"{key}\" not found in sprite dictionary");
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetUserAvatarUrl()
|
||||
{
|
||||
string s = _userService.AvatarUrl;
|
||||
return s;
|
||||
}
|
||||
|
||||
public void AddAddressableOperation(AsyncOperationHandle op)
|
||||
{
|
||||
_ops.Add(op);
|
||||
}
|
||||
|
||||
public void ReleaseAddressableOperation()
|
||||
{
|
||||
foreach (var op in _ops)
|
||||
{
|
||||
Addressables.Release(op);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpgradeComponent(int componentIdx, int targetGrade)
|
||||
{
|
||||
_panel.SetComponent(componentIdx, targetGrade, isUpgrade: true);
|
||||
}
|
||||
|
||||
public void PlayAddScoreFx(int idx)
|
||||
{
|
||||
if (_panel == null)
|
||||
{
|
||||
Debug.LogWarning($"Event Partner Panel not instantiated.");
|
||||
return;
|
||||
}
|
||||
_panel.PlayAddScoreFx(idx);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerAct.cs.meta
Normal file
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerAct.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5a2021ba30b1ef428c702b8b680bb3f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
62
Assets/Scripts/UI/PartnerFishBowl/EventPartnerBot.cs
Normal file
62
Assets/Scripts/UI/PartnerFishBowl/EventPartnerBot.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using cfg;
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using game;
|
||||
using GameCore;
|
||||
using Random = UnityEngine.Random;
|
||||
using ScrollViewItemInfo = EventPartnerScrollViewItem.ScrollViewItemInfo;
|
||||
|
||||
public class EventPartnerBot
|
||||
{
|
||||
public const char RobotIdentifier = 'R';
|
||||
private static readonly TbRobot RobotTable = GContext.container.Resolve<Tables>().TbRobot;
|
||||
private static readonly IUserService UserService = GContext.container.Resolve<IUserService>();
|
||||
// private static readonly ICustomServerMgr ServerMgr = GContext.container.Resolve<ICustomServerMgr>();
|
||||
private static readonly Tables Tables = GContext.container.Resolve<Tables>();
|
||||
|
||||
public static string Idx2Id(int idx)
|
||||
{
|
||||
return idx.ToString("X5") + RobotIdentifier;
|
||||
}
|
||||
|
||||
public static int Id2Idx(string id)
|
||||
{
|
||||
return int.Parse(id.Trim(RobotIdentifier), NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
public static void GetBotDisplayInfo(string id, out string avatar, out string displayName)
|
||||
{
|
||||
int idx = Id2Idx(id);
|
||||
var res = RobotTable.DataMap.TryGetValue(idx, out var r);
|
||||
if (!res)
|
||||
{
|
||||
avatar = "";
|
||||
displayName = UserService.GetDefaultName(id);
|
||||
return;
|
||||
}
|
||||
|
||||
avatar = r.Avatar;
|
||||
displayName = LocalizationMgr.GetText(r.Name_l10n_key);
|
||||
}
|
||||
|
||||
public static void AddBot(ScrollViewItemInfo botInfo, int slotId)
|
||||
{
|
||||
if (!botInfo.PlayfabId.EndsWith(RobotIdentifier))
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]{botInfo.PlayfabId} is not a robot.</color>");
|
||||
return;
|
||||
}
|
||||
|
||||
int grade = FtMathUtils.GetRandomIdxFromWeightList(Tables.TbEventPartnerRobot.DataList.Select(r => r.Weight));
|
||||
var wakeStartTime = ZZTimeHelper.UtcNow();
|
||||
int wakingSeconds = Random.Range(Tables.TbEventPartnerConfig.RobotDailyActiveTimeWindow[0],
|
||||
Tables.TbEventPartnerConfig.RobotDailyActiveTimeWindow[1]);
|
||||
EventPartnerAct.Ctx.Data.Components[slotId].SetComponent(botInfo);
|
||||
EventPartnerAct.Ctx.Data.Components[slotId].BotWakeTime = wakeStartTime;
|
||||
EventPartnerAct.Ctx.Data.Components[slotId].BotWakingSeconds = wakingSeconds;
|
||||
EventPartnerAct.Ctx.Data.Components[slotId].BotGrade = grade;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerBot.cs.meta
Normal file
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerBot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80eb8cb6ef0a2f843b5c4a23eeb7e742
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
996
Assets/Scripts/UI/PartnerFishBowl/EventPartnerBuildPanel.cs
Normal file
996
Assets/Scripts/UI/PartnerFishBowl/EventPartnerBuildPanel.cs
Normal file
@@ -0,0 +1,996 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using GameCore;
|
||||
using cfg;
|
||||
using asap.core;
|
||||
using game;
|
||||
using DG.Tweening;
|
||||
using UniRx;
|
||||
using Unity.Mathematics;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EventPartnerBuildPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private TMP_Text _textTitle, _textScoreSelf, _textScorePartner, _textScoreSelfAdd,
|
||||
_textScorePartnerAdd, _textProgress, _textTicketCount, _textPlayCost, textNameSelf, textNamePartner;
|
||||
[SerializeField] private Button _btnInfo, _btnPlay, btnTicket;
|
||||
[SerializeField] private Image _imageMe, _imagePartner, _bar, _iconTicket, iconButton;
|
||||
[SerializeField]
|
||||
[Tooltip("Last one is the grand prize.")]
|
||||
private List<RewardItemNew> rewards;
|
||||
[SerializeField] private Transform _wheel, wheelShow;
|
||||
[SerializeField] private EventPartnerWheelPiece[] _wheelPieces;
|
||||
[SerializeField] private EventPartnerMultiplierController _btnMultiplier;
|
||||
[SerializeField] private GameObject turntableGo, iconTicketGo, finishedGo, fxFinishGo, fxTextGlowMe, fxTextGlowPartner, targetContentGo, maskGo;
|
||||
[SerializeField] private Animation _animationMe, _animationPartner, animationLight, animationPointer;
|
||||
[SerializeField] private Animator animatorBtnPlay, animatorBtnMultiplier;
|
||||
[SerializeField] private EventPartnerTips tips;
|
||||
private Tables _tables;
|
||||
private EventPartnerData _data;
|
||||
private IUserService _userService;
|
||||
// private EventPartnerData.Component _component;
|
||||
private PlayerItemData _playerItemData;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private EventPartnerAct.Context _context;
|
||||
private EEventPartnerBuildPanelState _state;
|
||||
private IDisposable _targetUpdateLoopSubscription;
|
||||
private CompositeDisposable _disposables;
|
||||
private int _currentComponentIdx;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_data = GContext.container.Resolve<EventPartnerData>();
|
||||
// Debug.Log($"[EventPartner] Data in Build panel: {_data.GetHashCode()}");
|
||||
_userService = GContext.container.Resolve<IUserService>();
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_btnInfo.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventPartnerInfoPopupPanel));
|
||||
btnTicket.onClick.AddListener(() => tips.ShowBuildTip());
|
||||
_btnPlay.onClick.AddListener(OnClickPlay);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.C))
|
||||
{
|
||||
_debugFlag++;
|
||||
_debugFlag %= 9;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
Debug.Log("Data reset.");
|
||||
_data.ResetData();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
private void OnDestroy()
|
||||
{
|
||||
_targetUpdateLoopSubscription?.Dispose();
|
||||
_targetUpdateLoopSubscription = null;
|
||||
}
|
||||
|
||||
public async void Init()
|
||||
{
|
||||
try
|
||||
{
|
||||
_context = EventPartnerAct.Ctx;
|
||||
_disposables?.Dispose();
|
||||
_disposables = new CompositeDisposable();
|
||||
_currentComponentIdx = _context.CurrentComponentIdx;
|
||||
Debug.Log($"[EventPartner] _component hash: {_data.Components[_currentComponentIdx].GetHashCode()}");
|
||||
_eventAggregator = _context.EventAggregator;
|
||||
// Debug.Log("Init:");
|
||||
// Debug.Log(_eventAggregator.GetHashCode());
|
||||
InitByState(_data.Components[_currentComponentIdx].IsBuilt);
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
InitTitle();
|
||||
InitTarget(_data.Components[_currentComponentIdx].ScoreDisplay);
|
||||
var iconTicket = _tables.TbItem[_tables.TbEventPartnerMain[_data.RedirectId].WheelTicket]
|
||||
.Icon;
|
||||
InitWheel(iconTicket);
|
||||
// await UpdateTarget();
|
||||
_ = GContext.container.Resolve<IUIService>().SetImageSprite(_iconTicket, iconTicket);
|
||||
int cost = _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].SpinRequire * _btnMultiplier.Multiplier;
|
||||
_textTicketCount.color = _data.TicketCount < cost ? Color.red : Color.white;
|
||||
_textTicketCount.text = _data.TicketCount.ToString();
|
||||
_targetUpdateLoopSubscription?.Dispose();
|
||||
_targetUpdateLoopSubscription = null;
|
||||
_targetUpdateLoopSubscription = GContext.OnEvent<RewardPanelClose>().Subscribe(e => _ = UpdateTarget());
|
||||
_eventAggregator.GetEvent<EventPartnerPartnerAddScore>().Subscribe(e => _ = HandlePartnerAddScore()).AddTo(_disposables);
|
||||
_eventAggregator.GetEvent<EventPartnerMultiplierChange>().Subscribe(OnMultiplierChange).AddTo(_disposables);
|
||||
GContext.OnEvent<EventPartnerTicketChangedEvent>().Subscribe(_ => UpdateTicketCount()).AddTo(_disposables);
|
||||
// _eventAggregator.Publish(new EventPartnerMultiplierChange());
|
||||
await InitPartnerAddScore();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitByState(bool isBuilt)
|
||||
{
|
||||
turntableGo.SetActive(!isBuilt);
|
||||
iconTicketGo.SetActive(!isBuilt);
|
||||
finishedGo.SetActive(isBuilt);
|
||||
fxFinishGo.SetActive(isBuilt);
|
||||
}
|
||||
|
||||
private void InitTitle()
|
||||
{
|
||||
string nameSelf = _userService.DisplayName;
|
||||
string namePartner = _data.Components[_currentComponentIdx].PartnerDisplayName;
|
||||
textNameSelf.text = nameSelf;
|
||||
textNamePartner.text = namePartner;
|
||||
_textTitle.text = nameSelf + "&" + namePartner;
|
||||
// Debug.Log($"<color=#22a6f2>[EventPartner]BuildPanel: Set icon self: {_userService.AvatarUrl}</color>");
|
||||
GContext.container.Resolve<IUIService>().SetHeadImage(_imageMe, _userService.AvatarUrl);
|
||||
var partnerIconUrl = _data.Components[_currentComponentIdx].IsPartnerRobot ? _tables.TbRobot[_data.Components[_currentComponentIdx].BotIndex].Avatar : _data.Components[_currentComponentIdx].PartnerAvatarUrl;
|
||||
// Debug.Log($"<color=#22a6f2>[EventPartner]BuildPanel: Set icon partner: {partnerIconUrl} Robot: {_component.IsPartnerRobot}</color>");
|
||||
GContext.container.Resolve<IUIService>().SetHeadImage(_imagePartner, partnerIconUrl);
|
||||
// if (_component.IsPartnerRobot)
|
||||
// Debug.Log($"<color=#22a6f2>[EventPartner]{_component.PartnerDisplayName} robot avatar url: {_tables.TbRobot[_component.BotIndex].Avatar}</color>");
|
||||
// else
|
||||
// Debug.Log($"<color=#22a6f2>[EventPartner]{_component.PartnerDisplayName} avatar url: {_component.PartnerAvatarUrl}</color>");
|
||||
_textScoreSelf.text = _data.Components[_currentComponentIdx].ScoreSelfDisplay.ToString();
|
||||
_textScorePartner.text = _data.Components[_currentComponentIdx].ScorePartnerDisplay.ToString();
|
||||
_textScoreSelfAdd.gameObject.SetActive(true);
|
||||
_textScorePartnerAdd.gameObject.SetActive(true);
|
||||
_textScoreSelfAdd.transform.localScale = Vector3.zero;
|
||||
_textScorePartnerAdd.transform.localScale = Vector3.zero;
|
||||
}
|
||||
|
||||
private void SetRewardItem(RewardItemNew item, int dropId = -1, int scoreTarget = -1, bool isReceived = false)
|
||||
{
|
||||
item.SetReceived(isReceived);
|
||||
if (dropId == -1)
|
||||
return;
|
||||
var rewardList = _playerItemData.GetItemDataByDropId(dropId);
|
||||
if (rewardList.Count > 1) //big reward
|
||||
{
|
||||
// item.SetIcon(_tables.TbEventPartnerMain[_component.RedirectID].RewardIcon);
|
||||
// item.text_num.gameObject.SetActive(true);
|
||||
}
|
||||
else //small reward
|
||||
{
|
||||
item.SetData(rewardList[0].id, ((int)rewardList[0].count).ToString());
|
||||
item.text_num.gameObject.SetActive(true);
|
||||
item.text_num.text = ConvertTools.GetNumberString((int)rewardList[0].count);
|
||||
}
|
||||
|
||||
// item.text_num.gameObject.SetActive(false);
|
||||
item.btn_click.onClick.RemoveAllListeners();
|
||||
item.btn_click.onClick.AddListener(async () =>
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.EventPartnerTip);
|
||||
if (panel == null)
|
||||
return;
|
||||
int progress = _data.Components[_currentComponentIdx].GetProgressIdx(_data.Components[_currentComponentIdx].Score);
|
||||
if (progress >= 5)
|
||||
progress = 4;
|
||||
panel.GetComponent<EventPartnerRewardTip>().Init(rewardList, _data.Components[_currentComponentIdx].Score, scoreTarget, item.btn_click.gameObject.transform);
|
||||
});
|
||||
// item.transform.Find("text_num").gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private readonly float[] _targetPositions = { 0, 0, -193, -386, -386, -386 };
|
||||
|
||||
private readonly int[,] _rewardVisibilityCheckList = { { 0, 1 }, { 0, 1 }, { 1, 2 }, { 2, 3 }, { 2, 3 }, { 2, 3 } };
|
||||
|
||||
private void InitTarget(int score)
|
||||
{
|
||||
int progress = _data.Components[_currentComponentIdx].GetProgressIdx(score);
|
||||
var rewardDrops = _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].StageReward;
|
||||
var scoreStage = _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].StagePoint;
|
||||
_bar.fillAmount = _data.Components[_currentComponentIdx].GetProgress(score);
|
||||
for (int i = 0; i < rewards.Count; i++)
|
||||
{
|
||||
var item = rewards[i];
|
||||
SetRewardItem(item, rewardDrops[i], scoreStage[i], _data.Components[_currentComponentIdx].LastProgressReceived > i);
|
||||
item.gameObject.SetActive(i == rewards.Count - 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
rewards[_rewardVisibilityCheckList[progress, i]].gameObject.SetActive(true);
|
||||
// SetRewardItem(rewards[^1].transform.Find("reward").GetComponent<RewardItemNew>(), rewardDrops[4], scoreStage[4],progress >= 5);
|
||||
if (progress > 5)
|
||||
progress = 5;
|
||||
_textProgress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9", $"{progress}/{rewardDrops.Count}");
|
||||
var pos = targetContentGo.GetComponent<RectTransform>().anchoredPosition;
|
||||
pos.y = _targetPositions[progress];
|
||||
targetContentGo.GetComponent<RectTransform>().anchoredPosition = pos;
|
||||
_scoreDisplayLocal = _data.Components[_currentComponentIdx].ScoreDisplay;
|
||||
}
|
||||
|
||||
private void InitWheel(string iconTicket)
|
||||
{
|
||||
var _component = _data.Components[_currentComponentIdx];
|
||||
var eventPartnerMain = _tables.TbEventPartnerMain[_component.RedirectID];
|
||||
// Debug.Log("Before giving:");
|
||||
// Debug.Log(_eventAggregator.GetHashCode());
|
||||
_btnMultiplier.Init(_data.RedirectId, _eventAggregator);
|
||||
for (int i = 0; i < _wheelPieces.Length; i++)
|
||||
_wheelPieces[i].Init(eventPartnerMain.SpinBg[i],
|
||||
eventPartnerMain.SpinPoint[i] * _btnMultiplier.Multiplier,
|
||||
_context);
|
||||
|
||||
_textPlayCost.text = (eventPartnerMain.SpinRequire * _btnMultiplier.Multiplier).ToString();
|
||||
_wheel.rotation = Quaternion.AngleAxis(_data.LastWheelRotation, Vector3.forward);
|
||||
wheelShow.rotation = Quaternion.AngleAxis(_data.LastWheelRotation, Vector3.forward);
|
||||
spinWeightList = new List<int>(eventPartnerMain.SpinWeight);
|
||||
for (int i = spinWeightList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
for (int j = i - 1; j >= 0; j--)
|
||||
{
|
||||
spinWeightList[i] += spinWeightList[j];
|
||||
}
|
||||
}
|
||||
|
||||
spinPointList = eventPartnerMain.SpinPoint;
|
||||
// Debug.Log($"{System.Threading.Thread.CurrentThread.ManagedThreadId}: InitWheel");
|
||||
// _btnPlay.onClick.AddListener(OnClickPlay);
|
||||
animatorBtnPlay.Play("Normal");
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
_ = GContext.container.Resolve<IUIService>().SetImageSprite(iconButton, iconTicket);
|
||||
}
|
||||
|
||||
private int _EvComponentId, _EvMultiplier, _EvPoints, _evItemCount, _evAvailableTicket;
|
||||
private string _evTeammateId, _evRobotId;
|
||||
|
||||
private async void OnClickPlay()
|
||||
{
|
||||
maskGo.SetActive(true);
|
||||
// Debug.Log($"{System.Threading.Thread.CurrentThread.ManagedThreadId}: OnClickPlay");
|
||||
if (_state != EEventPartnerBuildPanelState.Standby)
|
||||
{
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_state = EEventPartnerBuildPanelState.Playing;
|
||||
_btnPlay.enabled = false;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(false);
|
||||
var lastCost = await SpinWheel();
|
||||
switch (lastCost)
|
||||
{
|
||||
// Debug.Log($"Spin res: {canPlay}.");
|
||||
case -1:
|
||||
// Debug.Log("Insufficient fund.");
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_88"));
|
||||
tips.ShowBuildBtnTip();
|
||||
_btnPlay.enabled = true;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(true);
|
||||
animatorBtnPlay.Play("Normal");
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
case -2:
|
||||
_btnPlay.enabled = true;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(true);
|
||||
animatorBtnPlay.Play("Normal");
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
_EvMultiplier = _btnMultiplier.Multiplier;
|
||||
_evItemCount = lastCost;
|
||||
_evAvailableTicket = _data.TicketCount;
|
||||
if (lastCost > _data.TicketCount)
|
||||
{
|
||||
_btnMultiplier.SwitchToNextMax();
|
||||
OnMultiplierChange(new EventPartnerMultiplierChange());
|
||||
}
|
||||
|
||||
var newCost = _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].SpinRequire * _btnMultiplier.Multiplier;
|
||||
_textTicketCount.color = _data.TicketCount < newCost ? Color.red : Color.white;
|
||||
// var doesGiveRewards = TryGiveRewards() == ERewardDistributeState.Given;
|
||||
// if (doesGiveRewards)
|
||||
// _component.ResetBotNextScoreTime();
|
||||
await UpdateTitle();
|
||||
if (_data.Components[_currentComponentIdx].GetProgressIdx(_data.Components[_currentComponentIdx].Score) <= _data.Components[_currentComponentIdx].GetProgressIdx(_data.Components[_currentComponentIdx].ScoreDisplay))
|
||||
_context.PlayAddScoreFx(_data.Components[_currentComponentIdx].ComponentIndex);
|
||||
// Debug.Log($"<color=#e23f31>SDL: {_component.ScoreDisplay}</color>");
|
||||
_scoreDisplayLocal = _data.Components[_currentComponentIdx].ScoreDisplay;
|
||||
await UpdateTarget();
|
||||
GContext.container.Resolve<FishingEventData>().SaveTransitionData(_data.EventId, _data.TicketCount);
|
||||
// Debug.Log("Update Target Finished.");
|
||||
_data.Components[_currentComponentIdx].SyncDisplayScore();
|
||||
_data.SavePlayerPreferenceData();
|
||||
// await HandlePartnerAddScore();
|
||||
_EvComponentId = _data.Components[_currentComponentIdx].ComponentId;
|
||||
if (_data.Components[_currentComponentIdx].IsPartnerRobot)
|
||||
{
|
||||
_evTeammateId = "";
|
||||
_evRobotId = EventPartnerBot.Id2Idx(_data.Components[_currentComponentIdx].PartnerId).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_evRobotId = "";
|
||||
_evTeammateId = _data.Components[_currentComponentIdx].PartnerId;
|
||||
}
|
||||
|
||||
#region EventTracking
|
||||
// Debug.Log($"<color=#22a6f2>_______________________________________________________________________________</color>");
|
||||
// Debug.Log($"<color=#22a6f2>component_id: {_EvComponentId}</color>");
|
||||
// Debug.Log($"<color=#22a6f2>teammate_id: {_evTeammateId}</color>");
|
||||
// Debug.Log($"<color=#22a6f2>robot_id: {_evRobotId}</color>");
|
||||
// Debug.Log($"<color=#22a6f2>multiple: {_EvMultiplier}</color>");
|
||||
// Debug.Log($"<color=#22a6f2>item_count: {_evItemCount}</color>");
|
||||
// Debug.Log($"<color=#22a6f2>available_ticket: {_evAvailableTicket}</color>");
|
||||
// Debug.Log($"<color=#22a6f2>points: {_EvPoints}</color>");
|
||||
// Debug.Log($"<color=#22a6f2>_______________________________________________________________________________</color>");
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_partners"))
|
||||
{
|
||||
e.AddContent("component_id", _EvComponentId)
|
||||
.AddContent("teammate_id", _evTeammateId)
|
||||
.AddContent("robot_id", _evRobotId)
|
||||
.AddContent("multiple", _EvMultiplier)
|
||||
.AddContent("item_count", _evItemCount)
|
||||
.AddContent("available_ticket", _evAvailableTicket)
|
||||
.AddContent("points", _EvPoints);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
maskGo.SetActive(false);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task InitPartnerAddScore()
|
||||
{
|
||||
maskGo.SetActive(true);
|
||||
// Debug.Log($"<color=#c191ff>Handle Partner Add Score Detected.</color>");
|
||||
bool needAddSelf = _data.Components[_currentComponentIdx].ScoreSelfDisplay < _data.Components[_currentComponentIdx].ScoreSelf;
|
||||
bool needAddPartner = _data.Components[_currentComponentIdx].ScorePartnerDisplay < _data.Components[_currentComponentIdx].ScorePartner;
|
||||
if (_state != EEventPartnerBuildPanelState.Standby || (!needAddSelf && !needAddPartner))
|
||||
{
|
||||
// Debug.Log( $"<color=#c191ff>Stash. {_state != EEventPartnerBuildPanelState.Standby} {_component.ScorePartnerDisplay >= _component.ScorePartner}</color>")
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log($"<color=#c191ff>Pass.</color>");
|
||||
_state = EEventPartnerBuildPanelState.Playing;
|
||||
_btnPlay.enabled = false;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(false);
|
||||
animatorBtnMultiplier.Play("Pressed");
|
||||
animatorBtnPlay.Play("Pressed");
|
||||
if (!needAddSelf)
|
||||
_EvStageTrigger = 2;
|
||||
else
|
||||
{
|
||||
int selfAddOnly = _data.Components[_currentComponentIdx].ScoreSelf + _data.Components[_currentComponentIdx].ScorePartnerDisplay;
|
||||
_EvStageTrigger = _data.Components[_currentComponentIdx].GetProgressIdx(selfAddOnly) > _data.Components[_currentComponentIdx].LastProgressReceived ? 1 : 2;
|
||||
}
|
||||
|
||||
TryGiveRewards();
|
||||
// if (rewardRes != ERewardDistributeState.Given)
|
||||
// {
|
||||
// Debug.Log($"<color=#c191ff>No reward given: {rewardRes}</color>");
|
||||
// // maskGo.SetActive(false);
|
||||
// // return;
|
||||
// }
|
||||
|
||||
await UpdateTitle();
|
||||
if (_data.Components[_currentComponentIdx].GetProgressIdx(_data.Components[_currentComponentIdx].Score) <= _data.Components[_currentComponentIdx].GetProgressIdx(_data.Components[_currentComponentIdx].ScoreDisplay))
|
||||
_context.PlayAddScoreFx(_data.Components[_currentComponentIdx].ComponentIndex);
|
||||
// Debug.Log($"<color=#e23f31>SDL: {_component.ScoreDisplay}</color>");
|
||||
_scoreDisplayLocal = _data.Components[_currentComponentIdx].ScoreDisplay;
|
||||
await UpdateTarget();
|
||||
_data.Components[_currentComponentIdx].SyncDisplayScore();
|
||||
_data.SavePlayerPreferenceData();
|
||||
_btnPlay.enabled = true;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(true);
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
animatorBtnPlay.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
maskGo.SetActive(false);
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task HandlePartnerAddScore()
|
||||
{
|
||||
await Awaiters.NextFrame;
|
||||
maskGo.SetActive(true);
|
||||
// Debug.Log($"<color=#c191ff>Handle Partner Add Score Detected.</color>");
|
||||
if (_state != EEventPartnerBuildPanelState.Standby ||
|
||||
_data.Components[_currentComponentIdx].ScorePartnerDisplay >= _data.Components[_currentComponentIdx].ScorePartner)
|
||||
{
|
||||
// Debug.Log( $"<color=#c191ff>Stash. {_state != EEventPartnerBuildPanelState.Standby} {_component.ScorePartnerDisplay >= _component.ScorePartner}</color>")
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.Log($"<color=#c191ff>Pass.</color>");
|
||||
_state = EEventPartnerBuildPanelState.Playing;
|
||||
_btnPlay.enabled = false;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(false);
|
||||
animatorBtnMultiplier.Play("Pressed");
|
||||
animatorBtnPlay.Play("Pressed");
|
||||
_EvStageTrigger = 2;
|
||||
TryGiveRewards();
|
||||
// if (doesGiveRewards)
|
||||
// _component.ResetBotNextScoreTime();
|
||||
await UpdateTitle();
|
||||
if (_data.Components[_currentComponentIdx].GetProgressIdx(_data.Components[_currentComponentIdx].Score) <= _data.Components[_currentComponentIdx].GetProgressIdx(_data.Components[_currentComponentIdx].ScoreDisplay))
|
||||
_context.PlayAddScoreFx(_data.Components[_currentComponentIdx].ComponentIndex);
|
||||
// Debug.Log($"<color=#e23f31>SDL: {_component.ScoreDisplay}</color>");
|
||||
_scoreDisplayLocal = _data.Components[_currentComponentIdx].ScoreDisplay;
|
||||
await UpdateTarget();
|
||||
_data.Components[_currentComponentIdx].SyncDisplayScore();
|
||||
_data.SavePlayerPreferenceData();
|
||||
_btnPlay.enabled = true;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(true);
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
animatorBtnPlay.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
maskGo.SetActive(false);
|
||||
}
|
||||
|
||||
private List<int> spinWeightList, spinPointList;
|
||||
|
||||
[SerializeField]
|
||||
private float _rotationTime,
|
||||
anticipationRotation,
|
||||
anticipationTime,
|
||||
followThroughRotation,
|
||||
followThroughTime,
|
||||
safeAngle;
|
||||
|
||||
[SerializeField] private AnimationCurve easeOutCurve;
|
||||
private int _debugFlag = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Spin the wheel.
|
||||
/// </summary>
|
||||
/// <returns>-1 if insufficient fund, or the cost taken if success.</returns>
|
||||
private async System.Threading.Tasks.Task<int> SpinWheel()
|
||||
{
|
||||
// Debug.Log($"<color=#42b734>Preparing to send build request.</color>");
|
||||
var cost = _btnMultiplier.Multiplier * _tables.TbEventPartnerMain[_data.RedirectId].SpinRequire;
|
||||
var costRes = EventPartnerAct.Ctx.Data.HasEnoughTicket(cost);
|
||||
if (!costRes)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>Insufficient fund.</color>");
|
||||
return -1;
|
||||
}
|
||||
int r = Random.Range(0, spinWeightList[^1]), idx;
|
||||
for (idx = 0; idx < spinWeightList.Count - 1; idx++)
|
||||
if (r < spinWeightList[idx])
|
||||
break;
|
||||
#if UNITY_EDITOR
|
||||
if (_debugFlag != 0)
|
||||
idx = _debugFlag - 1;
|
||||
#endif
|
||||
int scoreToAdd = spinPointList[idx] * _btnMultiplier.Multiplier;
|
||||
_EvPoints = scoreToAdd;
|
||||
var newScore = _data.Components[_currentComponentIdx].ScoreSelf + scoreToAdd;
|
||||
newScore = newScore <= _data.Components[_currentComponentIdx].MaxScore ? newScore : _data.Components[_currentComponentIdx].MaxScore;
|
||||
|
||||
var partnerId = _data.Components[_currentComponentIdx].PartnerId;
|
||||
if (partnerId.EndsWith(EventPartnerBot.RobotIdentifier))
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildRequest = new EventPartnerData.EventBuildBuildRequest
|
||||
{
|
||||
PartnerId = _data.Components[_currentComponentIdx].PartnerId,
|
||||
NewScore = newScore,
|
||||
EventId = _data.EventId
|
||||
};
|
||||
var buildRes = await GContext.container.Resolve<ICustomServerMgr>()
|
||||
.EventPartnerRequest<EventPartnerData.EventBuildBuildResponse>(EventPartnerData.BuildUrl, buildRequest);
|
||||
if (buildRes.State != EventPartnerData.EEventBuildBuildState.Success)
|
||||
{
|
||||
Debug.Log($"<color=#42b734>[EventPartner] BuildRequestFail({buildRes.State}): {buildRes.Message}</color>");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
var ticketRes = EventPartnerAct.Ctx.Data.AddTicket(-cost);
|
||||
if (!ticketRes)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>Insufficient fund.</color>");
|
||||
return -1;
|
||||
}
|
||||
animatorBtnPlay.Play("Pressed");
|
||||
animatorBtnMultiplier.Play("Pressed");
|
||||
animationLight.Play("light_loop");
|
||||
// update local data
|
||||
_data.Components[_currentComponentIdx].AddSelfScore(scoreToAdd);
|
||||
if (partnerId.EndsWith(EventPartnerBot.RobotIdentifier))
|
||||
{
|
||||
_data.Components[_currentComponentIdx].SyncRobotScore();
|
||||
}
|
||||
// _data.AddPartnerTicket(-cost);
|
||||
_textTicketCount.text = _data.TicketCount.ToString();
|
||||
_textTicketCount.color = _data.TicketCount < cost ? Color.red : Color.white;
|
||||
TryGiveRewards();
|
||||
// Debug.Log($"<color=#42b734>Raw Score to add: {spinPointList[idx]}.</color>");
|
||||
_EvPointsPlayer = _data.Components[_currentComponentIdx].ScoreSelf;
|
||||
_evPointsTeammate = _data.Components[_currentComponentIdx].ScorePartner;
|
||||
int i = _data.Components[_currentComponentIdx].LastProgressReceived;
|
||||
i = i >= _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].StagePoint.Count
|
||||
? _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].StagePoint.Count - 1
|
||||
: i;
|
||||
_EvPointsOverflow = _data.Components[_currentComponentIdx].Score - _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].StagePoint[i];
|
||||
_EvStageTrigger = 1;
|
||||
if (_data.Components[_currentComponentIdx].Score > _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].StagePoint[i])
|
||||
_EvPointsPlayer -= _data.Components[_currentComponentIdx].Score - _tables.TbEventPartnerMain[_data.Components[_currentComponentIdx].RedirectID].StagePoint[i];
|
||||
int wheelCount = spinWeightList.Count;
|
||||
float deg = 360.0f / wheelCount;
|
||||
float targetAngle = Random.Range((wheelCount - idx) * deg + safeAngle, (wheelCount - idx) * deg + deg - safeAngle);
|
||||
_data.RecordWheelRotation(targetAngle);
|
||||
_data.SavePlayerPreferenceData();
|
||||
float curAngle = _wheel.rotation.eulerAngles.z;
|
||||
float rotationAngle = curAngle - targetAngle;
|
||||
while (rotationAngle >= 360f * 3 + 180)
|
||||
rotationAngle -= 360f;
|
||||
while (rotationAngle < 360f * 2 + 180)
|
||||
rotationAngle += 360f;
|
||||
// rotationAngle += 360;
|
||||
// anticipationTime = anticipationRotation / rotationSpeed;
|
||||
animationPointer.Play("zhizhen_start");
|
||||
wheelShow.DORotate(Vector3.back * -anticipationRotation, anticipationTime,
|
||||
RotateMode.WorldAxisAdd);
|
||||
await _wheel.DORotate(Vector3.back * -anticipationRotation, anticipationTime,
|
||||
RotateMode.WorldAxisAdd)
|
||||
.AsyncWaitForCompletion();
|
||||
animationPointer.Play("zhizhen_loop");
|
||||
wheelShow.DORotate(
|
||||
Vector3.back * (rotationAngle + anticipationRotation + followThroughRotation),
|
||||
_rotationTime, RotateMode.WorldAxisAdd).SetEase(easeOutCurve);
|
||||
await _wheel
|
||||
.DORotate(Vector3.back * (rotationAngle + anticipationRotation + followThroughRotation),
|
||||
_rotationTime,
|
||||
RotateMode.WorldAxisAdd).SetEase(easeOutCurve).AsyncWaitForCompletion();
|
||||
animationPointer.Play("zhizhen_end");
|
||||
wheelShow.DORotate(Vector3.back * -followThroughRotation, followThroughTime,
|
||||
RotateMode.WorldAxisAdd);
|
||||
await _wheel.DORotate(Vector3.back * -followThroughRotation, followThroughTime,
|
||||
RotateMode.WorldAxisAdd)
|
||||
.AsyncWaitForCompletion();
|
||||
animationLight.Play("light_end");
|
||||
await _wheelPieces[idx].PlayShow();
|
||||
return cost;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Animation duration of score adding in build panel. In seconds.")]
|
||||
private float _animationScoreAddDuration = 1;
|
||||
|
||||
[SerializeField] private float pointAddDelay = 0f, textScoreDelay = 1f, titleEnding = 0.5f;
|
||||
|
||||
private async System.Threading.Tasks.Task UpdateTitle()
|
||||
{
|
||||
maskGo.SetActive(true);
|
||||
int score;
|
||||
if (_data.Components[_currentComponentIdx].ScoreDisplay >= _data.Components[_currentComponentIdx].Score)
|
||||
{
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_data.Components[_currentComponentIdx].ScorePartnerDisplay < _data.Components[_currentComponentIdx].ScorePartner)
|
||||
{
|
||||
_textScorePartnerAdd.text = "+" + (_data.Components[_currentComponentIdx].ScorePartner - _data.Components[_currentComponentIdx].ScorePartnerDisplay);
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(pointAddDelay));
|
||||
_animationPartner.Play("point_add");
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(textScoreDelay - pointAddDelay));
|
||||
score = _data.Components[_currentComponentIdx].ScorePartnerDisplay;
|
||||
DOTween.To(() => score, value => score = value, _data.Components[_currentComponentIdx].ScorePartner, _animationScoreAddDuration)
|
||||
.OnUpdate(() => _textScorePartner.text = score.ToString());
|
||||
}
|
||||
|
||||
if (_data.Components[_currentComponentIdx].ScoreSelfDisplay < _data.Components[_currentComponentIdx].ScoreSelf)
|
||||
{
|
||||
_textScoreSelfAdd.text = "+" + (_data.Components[_currentComponentIdx].ScoreSelf - _data.Components[_currentComponentIdx].ScoreSelfDisplay);
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(pointAddDelay));
|
||||
_animationMe.Play("point_add");
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(textScoreDelay - pointAddDelay));
|
||||
score = _data.Components[_currentComponentIdx].ScoreSelfDisplay;
|
||||
DOTween.To(() => score, value => score = value, _data.Components[_currentComponentIdx].ScoreSelf,
|
||||
_animationScoreAddDuration)
|
||||
.OnUpdate(() => _textScoreSelf.text = score.ToString());
|
||||
}
|
||||
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(titleEnding));
|
||||
}
|
||||
|
||||
private int _EvStageId,
|
||||
_EvStagePoint,
|
||||
_EvPointsPlayer,
|
||||
_evPointsTeammate,
|
||||
_EvRewardList,
|
||||
_EvRewardHook,
|
||||
_EvRewardCash,
|
||||
_EvStageTrigger,
|
||||
_EvPointsOverflow;
|
||||
|
||||
private void TryGiveRewards()
|
||||
{
|
||||
var _component = _data.Components[_currentComponentIdx];
|
||||
int targetProgress = _component.GetProgressIdx(_component.Score);
|
||||
int len = targetProgress - _component.LastProgressReceived;
|
||||
if (len <= 0) return;
|
||||
var slicedDropList = _tables.TbEventPartnerMain[_component.RedirectID].StageReward.GetRange(_component.LastProgressReceived, len);
|
||||
_component.LastProgressReceived = targetProgress;
|
||||
_playerItemData.AddItemByDropList(slicedDropList, false);
|
||||
_data.ToPlayfabData().Save();
|
||||
|
||||
// _data.SaveData();
|
||||
// var request = new EventPartnerData.EventBuildUpdateProgressRequest
|
||||
// {
|
||||
// SlotId = _component.ComponentIndex,
|
||||
// NewProgress = targetProgress
|
||||
// };
|
||||
// _component.GetProgress
|
||||
// return ERewardDistributeState.Given;
|
||||
}
|
||||
|
||||
public enum ERewardDistributeState
|
||||
{
|
||||
Given,
|
||||
NoNeed,
|
||||
Fail
|
||||
}
|
||||
|
||||
private const float TargetSlideTime = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// The auxiliary score for animation usage that starts at old Display Score
|
||||
/// and ends at target actual Score. The component display score is a property
|
||||
/// consists of two parts, and is way too messy to deal with.
|
||||
/// </summary>
|
||||
private int _scoreDisplayLocal;
|
||||
|
||||
private async System.Threading.Tasks.Task UpdateTarget()
|
||||
{
|
||||
var _component = _data.Components[_currentComponentIdx];
|
||||
maskGo.SetActive(true);
|
||||
float newBarFillAmount;
|
||||
var rewardList = _tables.TbEventPartnerMain[_component.RedirectID].StageReward;
|
||||
var stagePoints = _tables.TbEventPartnerMain[_component.RedirectID].StagePoint;
|
||||
int displayProgress = _component.GetProgressIdx(_scoreDisplayLocal),
|
||||
targetProgress = _component.GetProgressIdx(_component.Score);
|
||||
// Debug.Log($"<color=#ffdc7c>Start -> Progress: {displayProgress}, ScoreDisplayLocal: {_scoreDisplayLocal}</color>");
|
||||
//Target reached. End Target update loop.
|
||||
if (_scoreDisplayLocal >= stagePoints[^1] || _component.Score <= _scoreDisplayLocal)
|
||||
{
|
||||
// Debug.Log("<color=#2d7cee>Reached Score.</color>");
|
||||
_btnPlay.enabled = true;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(true);
|
||||
animatorBtnPlay.Play("Normal");
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
int nextProgressScore = stagePoints[displayProgress];
|
||||
if (nextProgressScore > _component.Score) //Next progress target is the score, which is below the max score.
|
||||
{
|
||||
// Debug.Log("<color=#2d7cee>Reach Target, and no reward get.</color>");
|
||||
newBarFillAmount = _component.GetProgress(_component.Score);
|
||||
await _bar.DOFillAmount(newBarFillAmount, _animationScoreAddDuration)
|
||||
.AsyncWaitForCompletion();
|
||||
_scoreDisplayLocal = _component.Score;
|
||||
_btnPlay.enabled = true;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(true);
|
||||
animatorBtnPlay.Play("Normal");
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
int rewardIdx;
|
||||
//...unless next update is reaching the max score.
|
||||
if (nextProgressScore == _component.Score && _component.Score >= _component.MaxScore)
|
||||
{
|
||||
// Debug.Log("<color=#2d7cee>End line reached!</color>");
|
||||
_targetUpdateLoopSubscription?.Dispose();
|
||||
_targetUpdateLoopSubscription = null;
|
||||
rewardIdx = 4;
|
||||
_scoreDisplayLocal = nextProgressScore;
|
||||
newBarFillAmount = 1;
|
||||
await _bar.DOFillAmount(newBarFillAmount, _animationScoreAddDuration).AsyncWaitForCompletion();
|
||||
await PlayRewardShineAnimation(rewardIdx);
|
||||
_textProgress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9", $"{rewardList.Count}/{rewardList.Count}");
|
||||
await SlideTarget(_component.GetProgressIdx(_component.Score));
|
||||
_EvComponentId = _component.ComponentId;
|
||||
_EvStageId = targetProgress;
|
||||
_EvStagePoint = nextProgressScore;
|
||||
_EvPointsOverflow = 0;
|
||||
_EvPointsPlayer = _component.ScoreSelf;
|
||||
_evPointsTeammate = _component.ScorePartner;
|
||||
_EvRewardList = rewardList[^1];
|
||||
if (_component.IsPartnerRobot)
|
||||
{
|
||||
_evTeammateId = "";
|
||||
_evRobotId = EventPartnerBot.Id2Idx(_component.PartnerId).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_evRobotId = "";
|
||||
_evTeammateId = _component.PartnerId;
|
||||
}
|
||||
// Debug.Log($"<color=#ffdc7c>Progress: {rewardList.Count}, ScoreDisplayLocal: {_scoreDisplayLocal}</color>");
|
||||
ShowRewardPopupPanel(rewardList, rewardList.Count); //Will not loop back to this method when PopupPanel is closed...
|
||||
Debug.Log($"<color=#22a6f2>_______________________________________________________________________________</color>");
|
||||
Debug.Log($"<color=#22a6f2>component_id: {_EvComponentId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>teammate_id: {_evTeammateId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>robot_id: {_evRobotId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>stage_id: {_EvStageId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>stage_points: {_EvStagePoint}</color>");
|
||||
Debug.Log($"<color=#22a6f2>stage_trigger: {_EvStageTrigger}</color>");
|
||||
Debug.Log($"<color=#22a6f2>points_overflow: {_EvPointsOverflow}</color>");
|
||||
Debug.Log($"<color=#22a6f2>points_player: {_EvPointsPlayer}</color>");
|
||||
Debug.Log($"<color=#22a6f2>points_teammate: {_evPointsTeammate}</color>");
|
||||
Debug.Log($"<color=#22a6f2>reward_list: {_EvRewardList}</color>");
|
||||
Debug.Log($"<color=#22a6f2>reward_hook: {_EvRewardHook}</color>");
|
||||
Debug.Log($"<color=#22a6f2>reward_cash: {_EvRewardCash}</color>");
|
||||
Debug.Log($"<color=#22a6f2>_______________________________________________________________________________</color>");
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_partners_reward"))
|
||||
{
|
||||
e.AddContent("component_id", _EvComponentId)
|
||||
.AddContent("teammate_id", _evTeammateId)
|
||||
.AddContent("robot_id", _evRobotId)
|
||||
.AddContent("stage_id", _EvStageId)
|
||||
.AddContent("stage_points", _EvStagePoint)
|
||||
.AddContent("stage_trigger", _EvStageTrigger)
|
||||
.AddContent("points_overflow", _EvPointsOverflow)
|
||||
.AddContent("points_player", _EvPointsPlayer)
|
||||
.AddContent("points_teammate", _evPointsTeammate)
|
||||
.AddContent("reward_list", _EvRewardList)
|
||||
.AddContent("reward_hook", _EvRewardHook)
|
||||
.AddContent("reward_cash", _EvRewardCash);
|
||||
}
|
||||
#endif
|
||||
InitByState(true);
|
||||
_btnPlay.enabled = true;
|
||||
_btnMultiplier.ToggleMultiplierButtonFunction(true);
|
||||
animatorBtnPlay.Play("Normal");
|
||||
animatorBtnMultiplier.Play("Normal");
|
||||
_state = EEventPartnerBuildPanelState.Standby;
|
||||
maskGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
//Next progress is a stage mark point.
|
||||
rewardIdx = (int)math.floor(_bar.fillAmount / 0.2f);
|
||||
_scoreDisplayLocal = nextProgressScore;
|
||||
|
||||
|
||||
displayProgress = _component.GetProgressIdx(_scoreDisplayLocal);
|
||||
newBarFillAmount = _component.GetProgress(nextProgressScore);
|
||||
await _bar.DOFillAmount(newBarFillAmount, _animationScoreAddDuration).AsyncWaitForCompletion();
|
||||
await PlayRewardShineAnimation(rewardIdx);
|
||||
await SlideTarget(_component.GetProgressIdx(nextProgressScore));
|
||||
// Debug.Log( $"<color=#ffdc7c>Progress: {displayProgress}, ScoreDisplayLocal: {_scoreDisplayLocal}</color>");
|
||||
ShowRewardPopupPanel(rewardList, displayProgress); //Will loop back to this method when PopupPanel is closed...
|
||||
|
||||
_EvComponentId = _component.ComponentId;
|
||||
_EvStageId = targetProgress;
|
||||
_EvStagePoint = nextProgressScore;
|
||||
_EvPointsOverflow = _component.Score - nextProgressScore;
|
||||
_EvPointsPlayer = _component.ScoreSelf;
|
||||
_evPointsTeammate = _component.ScorePartner;
|
||||
if (_EvStageTrigger == 1)
|
||||
_EvPointsPlayer -= _EvPointsOverflow;
|
||||
else
|
||||
_evPointsTeammate -= _EvPointsOverflow;
|
||||
if (displayProgress >= rewardList.Count)
|
||||
{
|
||||
Debug.Log($"<color=#ffdc7c>Unexpected score add. return</color>");
|
||||
return;
|
||||
}
|
||||
_EvRewardList = rewardList[displayProgress];
|
||||
if (_component.IsPartnerRobot)
|
||||
{
|
||||
_evTeammateId = "";
|
||||
_evRobotId = EventPartnerBot.Id2Idx(_component.PartnerId).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_evRobotId = "";
|
||||
_evTeammateId = _component.PartnerId;
|
||||
}
|
||||
|
||||
Debug.Log($"<color=#22a6f2>_______________________________________________________________________________</color>");
|
||||
Debug.Log($"<color=#22a6f2>component_id: {_EvComponentId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>teammate_id: {_evTeammateId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>robot_id: {_evRobotId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>stage_id: {_EvStageId}</color>");
|
||||
Debug.Log($"<color=#22a6f2>stage_points: {_EvStagePoint}</color>");
|
||||
Debug.Log($"<color=#22a6f2>stage_trigger: {_EvStageTrigger}</color>");
|
||||
Debug.Log($"<color=#22a6f2>points_overflow: {_EvPointsOverflow}</color>");
|
||||
Debug.Log($"<color=#22a6f2>points_player: {_EvPointsPlayer}</color>");
|
||||
Debug.Log($"<color=#22a6f2>points_teammate: {_evPointsTeammate}</color>");
|
||||
Debug.Log($"<color=#22a6f2>reward_list: {_EvRewardList}</color>");
|
||||
Debug.Log($"<color=#22a6f2>reward_hook: {_EvRewardHook}</color>");
|
||||
Debug.Log($"<color=#22a6f2>reward_cash: {_EvRewardCash}</color>");
|
||||
Debug.Log($"<color=#22a6f2>_______________________________________________________________________________</color>");
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_partners_reward"))
|
||||
{
|
||||
e.AddContent("component_id", _EvComponentId)
|
||||
.AddContent("teammate_id", _evTeammateId)
|
||||
.AddContent("robot_id", _evRobotId)
|
||||
.AddContent("stage_id", _EvStageId)
|
||||
.AddContent("stage_points", _EvStagePoint)
|
||||
.AddContent("stage_trigger", _EvStageTrigger)
|
||||
.AddContent("points_overflow", _EvPointsOverflow)
|
||||
.AddContent("points_player", _EvPointsPlayer)
|
||||
.AddContent("points_teammate", _evPointsTeammate)
|
||||
.AddContent("reward_list", _EvRewardList)
|
||||
.AddContent("reward_hook", _EvRewardHook)
|
||||
.AddContent("reward_cash", _EvRewardCash);
|
||||
}
|
||||
#endif
|
||||
_textProgress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9", $"{displayProgress}/{rewardList.Count}");
|
||||
if (_component.IsPartnerRobot)
|
||||
_component.ScheduleBotScoreAction();
|
||||
// _component.UpdateBotScoreGap();
|
||||
// Debug.Log("<color=#2d7cee>End of method, move on to next loop.</color>");
|
||||
maskGo.SetActive(false);
|
||||
}
|
||||
[Tooltip("弹出奖励面板的延迟,从侧边奖励响应与组件升级动画开始播放开始算起,默认值为-1,其效果为紧接着侧边奖励响应动画结束")]
|
||||
[SerializeField] private float jiandaRewardPanelPopupDelay = -1f;
|
||||
|
||||
private async System.Threading.Tasks.Task PlayRewardShineAnimation(int rewardIdx)
|
||||
{
|
||||
var _component = _data.Components[_currentComponentIdx];
|
||||
// Debug.Log($"{System.Threading.Thread.CurrentThread.ManagedThreadId}: Playing reward shine");
|
||||
Animation ani;
|
||||
float clipLength;
|
||||
int componentGrade;
|
||||
if (rewardIdx == rewards.Count - 1)
|
||||
{
|
||||
ani = rewards[rewardIdx].transform.parent.GetComponent<Animation>();
|
||||
ani.Play("campskyscraper_target");
|
||||
clipLength = ani.GetClip("campskyscraper_target").length;
|
||||
componentGrade = _component.GetProgressIdx(_scoreDisplayLocal);
|
||||
_context.UpgradeComponent(_component.ComponentIndex, componentGrade);
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(jiandaRewardPanelPopupDelay < 0 ? clipLength : jiandaRewardPanelPopupDelay));
|
||||
rewards[rewardIdx].SetReceived(true);
|
||||
return;
|
||||
}
|
||||
|
||||
rewards[rewardIdx].SetReceived(true);
|
||||
ani = rewards[rewardIdx].gameObject.GetComponent<Animation>();
|
||||
ani.Play("reward_claim");
|
||||
componentGrade = _component.GetProgressIdx(_scoreDisplayLocal);
|
||||
_context.UpgradeComponent(_component.ComponentIndex, componentGrade);
|
||||
clipLength = ani.GetClip("reward_claim").length;
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(jiandaRewardPanelPopupDelay < 0 ? clipLength : jiandaRewardPanelPopupDelay));
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task SlideTarget(int idx)
|
||||
{
|
||||
/*
|
||||
foreach (var reward in rewards)
|
||||
reward.gameObject.SetActive(true);
|
||||
if (idx <= 2)
|
||||
rewards[3].gameObject.SetActive(false);
|
||||
if (idx <= 1)
|
||||
rewards[2].gameObject.SetActive(false);
|
||||
*/
|
||||
rewards[^1].gameObject.SetActive(true);
|
||||
var cap = idx <= 3 ? idx : 3;
|
||||
for (int i = 0; i < rewards.Count - 1; i++)
|
||||
{
|
||||
rewards[i].gameObject.SetActive(i == cap || i == cap - 1);
|
||||
}
|
||||
|
||||
var rectTrans = targetContentGo.GetComponent<RectTransform>();
|
||||
float delta = _targetPositions[idx] - rectTrans.anchoredPosition.y;
|
||||
if (Mathf.Abs(delta) <= 0.1f)
|
||||
return;
|
||||
float newY = rectTrans.localPosition.y + delta;
|
||||
await rectTrans.DOAnchorPosY(newY, TargetSlideTime).AsyncWaitForCompletion();
|
||||
}
|
||||
|
||||
private void ShowRewardPopupPanel(List<int> rewardList, int displayProgress)
|
||||
{
|
||||
var dropList = _tables.TbDrop[rewardList[displayProgress - 1]].DropList;
|
||||
_EvRewardHook = 0;
|
||||
_EvRewardCash = 0;
|
||||
var dropDataList = new List<ItemData>();
|
||||
for (int i = 0; i < dropList.DropCountList.Count; i++)
|
||||
{
|
||||
var rewardId = dropList.DropIDList[i];
|
||||
var count = dropList.DropCountList[i];
|
||||
if (rewardId == 1001)
|
||||
{
|
||||
_EvRewardHook += count;
|
||||
var itemData = new ItemData(rewardId, count);
|
||||
itemData.curCount = (ulong)_playerItemData.GetItemCount(1001) - (ulong)count;
|
||||
dropDataList.Add(itemData);
|
||||
}
|
||||
else if (rewardId == 1002)
|
||||
{
|
||||
count = GContext.container.Resolve<PlayerItemData>().GetExtraCoinMag(count);
|
||||
_EvRewardCash += count;
|
||||
var itemData = new ItemData(rewardId, count);
|
||||
itemData.curCount = (ulong)_playerItemData.GetItemCount(1002) - (ulong)count;
|
||||
dropDataList.Add(itemData);
|
||||
}
|
||||
}
|
||||
GContext.Publish(new ShowData(dropDataList));
|
||||
GContext.Publish(new ShowData());
|
||||
}
|
||||
|
||||
public void SetStateInactive()
|
||||
{
|
||||
_state = EEventPartnerBuildPanelState.Inactive;
|
||||
}
|
||||
|
||||
private void OnMultiplierChange(EventPartnerMultiplierChange e)
|
||||
{
|
||||
var _component = _data.Components[_currentComponentIdx];
|
||||
var eventPartnerMain = _tables.TbEventPartnerMain[_component.RedirectID];
|
||||
for (int i = 0; i < _wheelPieces.Length; i++)
|
||||
_wheelPieces[i].SetScore(eventPartnerMain.SpinPoint[i] * _btnMultiplier.Multiplier);
|
||||
int cost = eventPartnerMain.SpinRequire * _btnMultiplier.Multiplier;
|
||||
_textPlayCost.text = cost.ToString();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Debug.Log("Dispose!!!!!!!!!!!!!!");
|
||||
fxFinishGo.SetActive(false);
|
||||
_disposables?.Dispose();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnGUI()
|
||||
{
|
||||
var _component = _data.Components[_currentComponentIdx];
|
||||
if (_component == null)
|
||||
return;
|
||||
GUI.Box(new Rect(20, 20, 200, 20), $"Component Index: {_component.ComponentIndex}");
|
||||
GUI.Box(new Rect(20, 40, 400, 20),
|
||||
$"DisplayScore: self {_component.ScoreSelfDisplay}, partner {_component.ScorePartnerDisplay}");
|
||||
GUI.Box(new Rect(20, 60, 400, 20),
|
||||
$"ActualScore: self {_component.ScoreSelf}, partner {_component.ScorePartner}");
|
||||
GUI.Box(new Rect(20, 80, 400, 20),
|
||||
$"Progress: display {_component.GetProgressIdx(_scoreDisplayLocal)}, target {_component.GetProgressIdx(_component.Score)}");
|
||||
GUI.Box(new Rect(20, 100, 400, 20),
|
||||
$"Cheat code: {_debugFlag}, score:" +
|
||||
(_debugFlag == 0 ? "None" : $"{spinPointList[_debugFlag - 1]}"));
|
||||
}
|
||||
#endif
|
||||
private enum EEventPartnerBuildPanelState
|
||||
{
|
||||
Playing,
|
||||
Standby,
|
||||
Finished,
|
||||
Inactive,
|
||||
}
|
||||
|
||||
public void UpdateTicketCount()
|
||||
{
|
||||
var _component = _data.Components[_currentComponentIdx];
|
||||
int cost = _tables.TbEventPartnerMain[_component.RedirectID].SpinRequire * _btnMultiplier.Multiplier;
|
||||
_textTicketCount.text = _data.TicketCount.ToString();
|
||||
_textTicketCount.color = _data.TicketCount < cost ? Color.red : Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
public class EventPartnerPartnerAddScore
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fee4f389ff4feb4aab9a8ad5cd35d00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Assets/Scripts/UI/PartnerFishBowl/EventPartnerCharaSlot.cs
Normal file
110
Assets/Scripts/UI/PartnerFishBowl/EventPartnerCharaSlot.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using cfg;
|
||||
|
||||
public class EventPartnerCharaSlot : MonoBehaviour
|
||||
{
|
||||
private TMP_Text _textScoreAdd;
|
||||
private Button _btn;
|
||||
private Image _iconHead, _bar, _iconGrandPrize;
|
||||
private RewardItemNew _reward;
|
||||
private GameObject _GoHead, _GoEmpty, _redPoint;
|
||||
private PlayerItemData _playerItemData;
|
||||
private EventPartnerData.Component _component;
|
||||
private EventPartnerAct.Context _ctx;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private Tables _tables;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// _textNameHead = transform.Find("head/text_name").GetComponent<TMP_Text>();
|
||||
// _textNameEmpty = transform.Find("empty/text_name").GetComponent<TMP_Text>();
|
||||
_btn = GetComponent<Button>();
|
||||
_iconHead = transform.Find("head/mask/icon_head").GetComponent<Image>();
|
||||
_bar = transform.Find("head/bg_bar/bar").GetComponent<Image>();
|
||||
_reward = transform.Find("head/bg_bar/reward").GetComponent<RewardItemNew>();
|
||||
_GoHead = transform.Find("head").gameObject;
|
||||
_GoEmpty = transform.Find("empty").gameObject;
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_redPoint = transform.Find("head/redpoints").gameObject;
|
||||
_textScoreAdd = transform.Find("head/text_add").GetComponent<TMP_Text>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_btn.onClick.AddListener(() => _ = OnClickBtn());
|
||||
_iconGrandPrize = transform.Find("head/bg_bar/icon_grand_reward").GetComponent<Image>();
|
||||
}
|
||||
|
||||
public void Init(EventPartnerData.Component c)
|
||||
{
|
||||
var ctx = EventPartnerAct.Ctx;
|
||||
_ctx = ctx;
|
||||
_component = c;
|
||||
_eventAggregator = ctx.EventAggregator;
|
||||
// string name = c.GetComponentName();
|
||||
// _textNameEmpty.text = name;
|
||||
// _textNameHead.text = name;
|
||||
_bar.fillAmount = _component.GetPartialProgress(_component.Score);
|
||||
_GoEmpty.SetActive(!_component.IsMatched);
|
||||
_GoHead.SetActive(_component.IsMatched);
|
||||
if (!_component.IsMatched)
|
||||
return;
|
||||
if (!_component.IsPartnerRobot)
|
||||
c.SetComponent(_component.PartnerId);
|
||||
//else has been when adding bot.
|
||||
// Debug.Log($"<color=#22a6f2>[EventPartner]CharaSlot: Set icon {_component.PartnerAvatarUrl} for slot {_component.ComponentIndex}. Robot: {_component.IsPartnerRobot}</color>");
|
||||
GContext.container.Resolve<IUIService>().SetHeadImage(_iconHead, _component.PartnerAvatarUrl);
|
||||
if (_component.DisplayStageProgress <
|
||||
_tables.TbEventPartnerMain[_component.RedirectID].StagePoint.Count - 1)
|
||||
{
|
||||
_reward.SetData( _playerItemData.GetItemDataByDropId(_component.GetNextRewardId(_component.Score))[0]);
|
||||
_reward.text_num.gameObject.SetActive(false);
|
||||
_iconGrandPrize.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// _reward.SetIcon(_tables.TbEventPartnerMain[_component.RedirectID].RewardIcon);
|
||||
_iconGrandPrize.gameObject.SetActive(true);
|
||||
_reward.text_num.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (_component.Score < _component.MaxScore)
|
||||
_redPoint.SetActive(_bar.fillAmount >= 1);
|
||||
else
|
||||
{
|
||||
_reward.SetReceived(_component.LastProgressReceived >= 5);
|
||||
_redPoint.SetActive(_component.LastProgressReceived < 5);
|
||||
}
|
||||
|
||||
if (_component.Score > _component.ScoreDisplay)
|
||||
{
|
||||
int delta = _component.Score - _component.ScoreDisplay;
|
||||
_textScoreAdd.text = "+" + delta.ToString();
|
||||
_textScoreAdd.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_textScoreAdd.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Match()
|
||||
{
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_iconHead, _component.PartnerAvatarUrl);
|
||||
_GoEmpty.SetActive(false);
|
||||
_GoHead.SetActive(true);
|
||||
_bar.fillAmount = 0f;
|
||||
_reward.SetData(_playerItemData.GetItemDataByDropId(_component.GetNextRewardId(_component.Score))[0]);
|
||||
_reward.text_num.gameObject.SetActive(false);
|
||||
_redPoint.SetActive(false);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task OnClickBtn()
|
||||
{
|
||||
if (_component.IsMatched)
|
||||
_ctx.ShowBuildPanel(_component.ComponentIndex);
|
||||
else
|
||||
await UIManager.Instance.ShowUI(UITypes.EventPartnerInvitationPanel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d84b4a5d68d6924ebb3b480bd60a41f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/Scripts/UI/PartnerFishBowl/EventPartnerComponent.cs
Normal file
44
Assets/Scripts/UI/PartnerFishBowl/EventPartnerComponent.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventPartnerComponent : MonoBehaviour
|
||||
{
|
||||
public Image ComponentImage;
|
||||
public GameObject FxLvlUp, FxAddScore;
|
||||
public GameObject[] FxProgress;
|
||||
private EventPartnerAct.Context _context;
|
||||
[Tooltip("加分特效播放时长,一般默认为2")] [SerializeField] private float jiandaAddScoreFxDuration = 2f;
|
||||
[Tooltip("升级特效播放时长,一般默认为2")] [SerializeField] private float jiandaUpgradeFxDuration = 2f;
|
||||
|
||||
public void Init(EventPartnerAct.Context ctx, int targetGrade, string imgUri)
|
||||
{
|
||||
_context = ctx;
|
||||
SetComponent(targetGrade, imgUri);
|
||||
}
|
||||
|
||||
public void SetComponent(int targetGrade, string imgUri)
|
||||
{
|
||||
ComponentImage.sprite = _context.GetSprite(imgUri);
|
||||
for (int i = 0; i < FxProgress.Length; i++)
|
||||
{
|
||||
if (FxProgress[i] == null)
|
||||
continue;
|
||||
FxProgress[i].SetActive(i == targetGrade);
|
||||
}
|
||||
}
|
||||
public async void UpgradeComponent(int targetGrade, string imgUri)
|
||||
{
|
||||
FxLvlUp.SetActive(false);
|
||||
FxLvlUp.SetActive(true);
|
||||
SetComponent(targetGrade, imgUri);
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(jiandaUpgradeFxDuration));
|
||||
FxLvlUp.SetActive(false);
|
||||
}
|
||||
public async void PlayAddScoreFx()
|
||||
{
|
||||
FxAddScore.SetActive(false);
|
||||
FxAddScore.SetActive(true);
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(jiandaAddScoreFxDuration));
|
||||
FxAddScore.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6cab46454af20a4d8ce2fca00dd7569
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1411
Assets/Scripts/UI/PartnerFishBowl/EventPartnerData.cs
Normal file
1411
Assets/Scripts/UI/PartnerFishBowl/EventPartnerData.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerData.cs.meta
Normal file
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ecf1e8996af93d4c9a5399fd7965fa2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
175
Assets/Scripts/UI/PartnerFishBowl/EventPartnerEntryButton.cs
Normal file
175
Assets/Scripts/UI/PartnerFishBowl/EventPartnerEntryButton.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using asap.core;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using GameCore;
|
||||
using game;
|
||||
using static EventPartnerData;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class EventPartnerEntryButton : EventButtonResource
|
||||
{
|
||||
[SerializeField] private TMP_Text _textTimer;
|
||||
[SerializeField] private Button _btn;
|
||||
[SerializeField] CanvasGroup _homeCanvasGroup;
|
||||
[SerializeField] private Image icon;
|
||||
private readonly IUserService _userService = GContext.container.Resolve<IUserService>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Debug.Log($"<color=#e23f31>[EventPartner] Icon Awake</color>");
|
||||
GContext.OnEvent<EventPartnerDataLoaded>().Subscribe(_ => OnDataLoaded()).AddTo(this);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
var _data = GContext.container.Resolve<EventPartnerData>();
|
||||
// _data.LogActivation();
|
||||
|
||||
//var manager = GContext.container.Resolve(Partainer)?
|
||||
|
||||
if (!_data.IsEventActivated)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
_textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
RedPointManager.Instance.SetRedPointState("Home.Fishbowl", _data.DoNeedRedPoint);
|
||||
Observable.Interval(System.TimeSpan.FromSeconds(1.0f)).Subscribe(_ =>
|
||||
{
|
||||
_textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
RedPointManager.Instance.SetRedPointState("Home.Fishbowl", _data.DoNeedRedPoint);
|
||||
if (_data.RemainingTime.TotalSeconds <= 0) gameObject.SetActive(false);
|
||||
}).AddTo(this);
|
||||
// Debug.Log($"<color=#e23f31>icon: {_data.Icon}</color>");
|
||||
CheckResource(new List<string>() { "EventPartnerCommonPrefabs", _data.AddressableLabel, _data.Icon });
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_btn.onClick.AddListener(() => EnterEventPartnerAct());
|
||||
}
|
||||
|
||||
private async void EnterEventPartnerAct()
|
||||
{
|
||||
try
|
||||
{
|
||||
var _data = GContext.container.Resolve<EventPartnerData>();
|
||||
_homeCanvasGroup.blocksRaycasts = false;
|
||||
var isWithinCoolDown = _data.LastDetailRequestFromEntranceButton != null
|
||||
&& ZZTimeHelper.UtcNow() - _data.LastDetailRequestFromEntranceButton <= System.TimeSpan.FromSeconds(15);
|
||||
|
||||
if (!_data.IsWhole || !isWithinCoolDown)
|
||||
{
|
||||
_data.LastDetailRequestFromEntranceButton = ZZTimeHelper.UtcNow();
|
||||
var dataRes = await LoadData();
|
||||
if (!dataRes)
|
||||
{
|
||||
Debug.Log($"<color=red>[EventPartner] LoadData Failed.</color>");
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_107"));
|
||||
_homeCanvasGroup.blocksRaycasts = true;
|
||||
_data.IsLastTimeDetailRequestFromEntranceButtonValid = false;
|
||||
return;
|
||||
}
|
||||
_data.IsLastTimeDetailRequestFromEntranceButtonValid = true;
|
||||
// else open panel.
|
||||
}
|
||||
else if (!_data.IsLastTimeDetailRequestFromEntranceButtonValid)
|
||||
{
|
||||
Debug.Log($"<color=red>[EventPartner] Too frequent.</color>");
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_107"));
|
||||
_homeCanvasGroup.blocksRaycasts = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Load resource and enter event act
|
||||
_data.SubscribeEvent();
|
||||
if (await LoadAssetBundle())
|
||||
GContext.Publish(new UnloadActToNextAct("EventPartnerAct"));
|
||||
else
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, () => GContext.Publish(new UnloadActToNextAct("EventPartnerAct")));
|
||||
}
|
||||
_homeCanvasGroup.blocksRaycasts = true;
|
||||
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.Log($"<color=#22a6f2>[EventPartner] EnterActError: {e.Message}\n{e.StackTrace}</color>");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task<bool> LoadData()
|
||||
{
|
||||
var _data = GContext.container.Resolve<EventPartnerData>();
|
||||
var _playerPreferenceKey = "EventPartnerRecommendCache" + _userService.UserId;
|
||||
//Load Player Preferences
|
||||
var pfString = PlayFabMgr.Instance.GetLocalData(EventPartnerPlayfabData.Key);
|
||||
EventPartnerPlayfabData pfData = EventPartnerPlayfabData.FromString(pfString);
|
||||
Debug.Log($"<color=#2d7cee>[EventPartner] Try get response in load data from entrance:</color>");
|
||||
var detailRequest = new EventBuildDetailRequest() { eventId = _data.EventId };
|
||||
var response = await GContext.container.Resolve<ICustomServerMgr>()
|
||||
.EventPartnerRequest<EventBuildDetailResp>(DetailUrl, detailRequest);
|
||||
if (response == null)
|
||||
{
|
||||
Debug.Log($"<color=red>[EventPartner] No response. </color>");
|
||||
return false;
|
||||
}
|
||||
Debug.Log($"<color=#2d7cee>[EventPartner] Response: {response}</color>");
|
||||
Debug.Log($"<color=#2d7cee>[EventPartner] ResponseState: {response.State}</color>");
|
||||
Debug.Log($"<color=#2d7cee>[EventPartner] ResponseMessage: {response.Message}</color>");
|
||||
switch (response.State)
|
||||
{
|
||||
case EEventBuildState.Failed:
|
||||
Debug.Log($"<color=red>[EventPartner] Load data error from server: {response.Message} </color>");
|
||||
return false;
|
||||
case EEventBuildState.NoActiveEvent:
|
||||
Debug.Log($"<color=red>[EventPartner] Event partner not active in server: {response.Message}, but this is not supposed to happen any more.</color>");
|
||||
return false;
|
||||
case EEventBuildState.Success:
|
||||
_data.ResolveAllDataButEvent(response, _data.Cache, pfData);
|
||||
return true;
|
||||
default:
|
||||
Debug.Log($"<color=red>[EventPartner] Unexpected status: {response.State}./nMessage: {response.Message} </color>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task<bool> LoadAssetBundle()
|
||||
{
|
||||
var _data = GContext.container.Resolve<EventPartnerData>();
|
||||
var loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||||
var isCommentAssetLoaded = await loadResourceService.Load("EventPartnerCommonPrefabs");
|
||||
var isCurrentAssetLoaded = await loadResourceService.Load(_data.AddressableLabel);
|
||||
return isCommentAssetLoaded && isCurrentAssetLoaded;
|
||||
}
|
||||
|
||||
private async void OnDataLoaded()
|
||||
{
|
||||
Debug.Log($"<color=#2d7cee>[EventPartner]On Loaded.</color>");
|
||||
await Awaiters.NextFrame;
|
||||
//gameObject.SetActive(true);
|
||||
var _data = GContext.container.Resolve<EventPartnerData>();
|
||||
CheckResource(new List<string>() { "EventPartnerCommonPrefabs", _data.AddressableLabel, _data.Icon });
|
||||
}
|
||||
|
||||
protected override void OnLoadEventResource()
|
||||
{
|
||||
var _data = GContext.container.Resolve<EventPartnerData>();
|
||||
if (_data == null)
|
||||
{
|
||||
Debug.LogError("EventPartnerEntryButton EventPartnerData 为空");
|
||||
return;
|
||||
}
|
||||
// _data.LogActivation();
|
||||
if (_data.IsEventActivated)
|
||||
{
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, _data.Icon);
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class EventPartnerDataLoaded { }
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f46caebc2afbe54daf84474d7b636d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
|
||||
public class EventPartnerFishbowlInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image rewardIcon;
|
||||
[SerializeField] private TMP_Text text_info, text_tips;
|
||||
[SerializeField] private Button btnClose;
|
||||
private Tables _tables;
|
||||
private FishingEventData _fishingEventData;
|
||||
private IUIService _uiService;
|
||||
private EventPartnerData _data;
|
||||
private void Start()
|
||||
{
|
||||
btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.EventPartnerInfoPopupPanel));
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_data = GContext.container.Resolve<EventPartnerData>();
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
_uiService = GContext.container.Resolve<IUIService>();
|
||||
var item = _tables.TbItem[_fishingEventData.collectingTargetInitTokenID];
|
||||
var itemId = _tables.TbEventPartnerMain[_data.RedirectId].WheelTicket;
|
||||
item = _tables.TbItem[itemId];
|
||||
_uiService.SetImageSprite(rewardIcon, item.Icon);
|
||||
|
||||
string itemName = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
text_info.text = LocalizationMgr.GetFormatTextValue("UI_EventSandDigPanel_4", itemName);
|
||||
text_tips.text = LocalizationMgr.GetFormatTextValue("UI_EventSandDigPanel_7", itemName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17d49b358c39c4e44aea3b662f63535d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
507
Assets/Scripts/UI/PartnerFishBowl/EventPartnerInvitationPanel.cs
Normal file
507
Assets/Scripts/UI/PartnerFishBowl/EventPartnerInvitationPanel.cs
Normal file
@@ -0,0 +1,507 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using game;
|
||||
using GameCore;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using ScrollViewItemInfo = EventPartnerScrollViewItem.ScrollViewItemInfo;
|
||||
using EScrollViewType = EventPartnerScrollViewItem.EScrollViewType;
|
||||
using Random = UnityEngine.Random;
|
||||
using RecommendResponse = EventPartnerData.EventBuildRecommendPlayerResp;
|
||||
using RecommendRequest = EventPartnerData.EventBuildRecommendPlayerRequest;
|
||||
|
||||
public class EventPartnerInvitationPanel : MonoBehaviour, IEnhancedScrollerDelegate
|
||||
{
|
||||
[SerializeField] private EnhancedScroller scrollView;
|
||||
[SerializeField] private Button btnClose, btnAddFriends;
|
||||
[SerializeField] private EventPartnerScrollViewItem scrollViewItemPrefab;
|
||||
[SerializeField] private EventPartnerScrollViewTitle scrollViewTitlePrefab;
|
||||
[SerializeField] private GameObject emptyGo, loadingGo;
|
||||
|
||||
private const string RecommendTitleKey = "UI_EventPartnerFishbowlPanel_30",
|
||||
FriendTitleKey = "UI_EventPartnerFishbowlPanel_31",
|
||||
InvitationTitleKey = "UI_EventPartnerFishbowlPanel_36";
|
||||
private List<ScrollViewItemInfo> _scrollViewInfoList, _recommendList, _friendList, _invitationList;
|
||||
private ICustomServerMgr _customServerMgr;
|
||||
private FriendService _friendService;
|
||||
// private EventPartnerData _eventPartnerData;
|
||||
private IUserService _userService;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
btnAddFriends.onClick.AddListener(OnClickAddFriends);
|
||||
_customServerMgr = GContext.container.Resolve<ICustomServerMgr>();
|
||||
_friendService = GContext.container.Resolve<FriendService>();
|
||||
// _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
_scrollViewInfoList = new List<ScrollViewItemInfo>();
|
||||
_recommendList = new List<ScrollViewItemInfo>();
|
||||
_friendList = new List<ScrollViewItemInfo>();
|
||||
_invitationList = new List<ScrollViewItemInfo>();
|
||||
_userService = GContext.container.Resolve<IUserService>();
|
||||
emptyGo.SetActive(false);
|
||||
loadingGo.SetActive(false);
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerClickInvite>().Subscribe(e => _ = OnInvite(e.Info)).AddTo(this);
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerClickIgnore>().Subscribe(e => OnIgnore(e.Info.PlayfabId)).AddTo(this);
|
||||
InitScrollViewAsync();
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("EventPartnerInvitePopupPanel", curPanelName: gameObject.name);
|
||||
}
|
||||
|
||||
private async void InitScrollViewAsync()
|
||||
{
|
||||
|
||||
await InitScrollView();
|
||||
}
|
||||
private void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.EventPartnerInvitationPanel);
|
||||
}
|
||||
|
||||
private void OnClickAddFriends()
|
||||
{
|
||||
//添加好友
|
||||
GContext.container.Resolve<ClubService>().OpenFishingSocialPanel(1);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task OnInvite(ScrollViewItemInfo invitationInfo)
|
||||
{
|
||||
var _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
if (_eventPartnerData.IsFullyMatched)
|
||||
{
|
||||
Debug.Log("<color=#c191ff>[EventPartner]Cannot invite. Player fully matched.</color>");
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_80"));
|
||||
RemoveItem(invitationInfo.PlayfabId);
|
||||
return;
|
||||
}
|
||||
|
||||
var partnerId = invitationInfo.PlayfabId;
|
||||
int slotId = -1;
|
||||
if (partnerId.EndsWith(EventPartnerBot.RobotIdentifier))
|
||||
{
|
||||
var request = new EventPartnerData.EventBuildPartnerRequest { partnerId = partnerId, eventId = _eventPartnerData.EventId };
|
||||
var response = await _customServerMgr.EventPartnerRequest<EventPartnerData.EventBuildOperationResp>(EventPartnerData.AcceptUrl, request);
|
||||
if (response.State != EventPartnerData.EEventBuildState.Success)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner] Fail to add {partnerId}, {response.State}: {response.ErrorMessage}</color>");
|
||||
return;
|
||||
}
|
||||
if (response.SlotId == null || response.SlotId.Value == -1)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]Fail to add bot {invitationInfo.PlayfabId}</color>");
|
||||
return;
|
||||
}
|
||||
slotId = response.SlotId.Value;
|
||||
EventPartnerBot.AddBot(invitationInfo, slotId);
|
||||
_eventPartnerData.ToPlayfabData().Save();
|
||||
GContext.container.Resolve<IUserService>().SetPlayInfo(partnerId, invitationInfo.DisplayName, invitationInfo.AvatarUrl);
|
||||
_eventPartnerData.Components[slotId].ScheduleBotScoreAction();
|
||||
EventPartnerAct.Ctx.EventAggregator.Publish(new EventPartnerMatchSuccess
|
||||
{
|
||||
NamePartner = invitationInfo.DisplayName,
|
||||
IconPartner = invitationInfo.AvatarUrl,
|
||||
NameComponent = EventPartnerAct.Ctx.Data.Components[slotId].GetComponentName(),
|
||||
SlotId = slotId,
|
||||
PartnerId = invitationInfo.PlayfabId
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = new EventPartnerData.EventBuildPartnerRequest { partnerId = partnerId, eventId = _eventPartnerData.EventId };
|
||||
var response = await _customServerMgr.EventPartnerRequest<EventPartnerData.EventBuildOperationResp>(EventPartnerData.InviteUrl, request);
|
||||
if (response.State != EventPartnerData.EEventBuildState.Success)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]{response.State}: {response.ErrorMessage}</color>");
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_80"));
|
||||
RemoveItem(partnerId);
|
||||
invitationInfo.IsFull = response.State == EventPartnerData.EEventBuildState.Full;
|
||||
}
|
||||
}
|
||||
switch (invitationInfo.Type)
|
||||
{
|
||||
case EScrollViewType.Friend:
|
||||
{
|
||||
int i = 0;
|
||||
while (i < _friendList.Count)
|
||||
{
|
||||
if (_friendList[i].PlayfabId == partnerId)
|
||||
_friendList.RemoveAt(i);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EScrollViewType.Recommendation:
|
||||
{
|
||||
int i = 0;
|
||||
while (i < _recommendList.Count)
|
||||
{
|
||||
if (_recommendList[i].PlayfabId == partnerId)
|
||||
_recommendList.RemoveAt(i);
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < _eventPartnerData.Cache.Recommend.Count)
|
||||
{
|
||||
if (_eventPartnerData.Cache.Recommend[i].PlayfabId == partnerId)
|
||||
_eventPartnerData.Cache.Recommend.RemoveAt(i);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_eventPartnerData.InvitePartners.Contains(partnerId))
|
||||
return;
|
||||
_eventPartnerData.InvitePartners.Add(partnerId);
|
||||
invitationInfo.Type = EScrollViewType.MyInvitation;
|
||||
_invitationList.Add(invitationInfo);
|
||||
_eventPartnerData.Cache.ListInvitation ??= new List<ScrollViewItemInfo>();
|
||||
_eventPartnerData.Cache.ListInvitation.Add(invitationInfo);
|
||||
BuildScrollViewInfoList();
|
||||
_eventPartnerData.SavePlayerPreferenceData();
|
||||
ReloadScrollViewData();
|
||||
_eventPartnerData.AddInvitationCount();
|
||||
}
|
||||
|
||||
private void OnIgnore(string partnerId)
|
||||
{
|
||||
var _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
_eventPartnerData.RefusePartners.Add(partnerId);
|
||||
for (int i = 0; i < _recommendList.Count; i++)
|
||||
{
|
||||
if (_recommendList[i].PlayfabId != partnerId) continue;
|
||||
_recommendList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < _friendList.Count; i++)
|
||||
{
|
||||
if (_friendList[i].PlayfabId != partnerId) continue;
|
||||
_friendList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _eventPartnerData.Cache.Recommend.Count; i++)
|
||||
{
|
||||
if (_eventPartnerData.Cache.Recommend[i].PlayfabId != partnerId) continue;
|
||||
_eventPartnerData.Cache.Recommend.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
BuildScrollViewInfoList();
|
||||
_eventPartnerData.SavePlayerPreferenceData();
|
||||
ReloadScrollViewData();
|
||||
}
|
||||
|
||||
#region ScrollView
|
||||
|
||||
[SerializeField] private float jiandaTitleHeight = 72f, jiandaItemHeight = 150f;
|
||||
|
||||
private async System.Threading.Tasks.Task InitScrollView()
|
||||
{
|
||||
try
|
||||
{
|
||||
loadingGo.SetActive(true);
|
||||
// Debug.Log($"<color=red>[EventPartner]Try get recommend list.</color>");
|
||||
_recommendList = await GetRecommendList();
|
||||
// Debug.Log($"<color=red>[EventPartner]Try get friend list.</color>");
|
||||
_friendList = GetFriendList();
|
||||
// Debug.Log($"<color=red>[EventPartner]Try get invitation list.</color>");
|
||||
_invitationList = GetInvitationList();
|
||||
// Debug.Log($"<color=red>[EventPartner]Build data.</color>");
|
||||
BuildScrollViewInfoList();
|
||||
// Debug.Log($"<color=red>[EventPartner]Set delegate.</color>");
|
||||
scrollView.Delegate = this;
|
||||
// Debug.Log($"<color=red>[EventPartner]Reset.</color>");
|
||||
loadingGo.SetActive(false);
|
||||
ReloadScrollViewData();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[EventPartner]{e.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task<List<ScrollViewItemInfo>> GetRecommendList()
|
||||
{
|
||||
var recommendList = new List<ScrollViewItemInfo>();
|
||||
var _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
var c = _eventPartnerData.Cache;
|
||||
if (c.RecommendListExpireTime > ZZTimeHelper.UtcNow() && c.Recommend is not null)
|
||||
{
|
||||
recommendList.AddRange(c.Recommend.OrderByDescending(info => info.LastLoginTime));
|
||||
return recommendList;
|
||||
}
|
||||
|
||||
if (_eventPartnerData.DoRecommendBot)
|
||||
{
|
||||
recommendList.AddRange((await GetPlayerRecommendList(_eventPartnerData.RecommendCount / 2)).OrderByDescending(info => info.LastLoginTime));
|
||||
var botCount = _eventPartnerData.RecommendCount - recommendList.Count;
|
||||
recommendList.AddRange(GetBotRecommendList(botCount));
|
||||
}
|
||||
else
|
||||
recommendList.AddRange((await GetPlayerRecommendList(_eventPartnerData.RecommendCount)).OrderByDescending(info => info.LastLoginTime));
|
||||
// Update cache
|
||||
c.RecommendListExpireTime = ZZTimeHelper.UtcNow() + TimeSpan.FromSeconds(GContext.container.Resolve<Tables>().TbEventPartnerConfig.FriendRecommendListRefreshTime);
|
||||
c.RecommendListExpireTime = c.RecommendListExpireTime < _eventPartnerData.EndTime
|
||||
? c.RecommendListExpireTime
|
||||
: _eventPartnerData.EndTime;
|
||||
c.Recommend = recommendList;
|
||||
return recommendList;
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task<List<ScrollViewItemInfo>> GetPlayerRecommendList(int count)
|
||||
{
|
||||
var recommendList = new List<ScrollViewItemInfo>();
|
||||
// Either cache is expired or no previous recommend found.
|
||||
var request = new RecommendRequest();
|
||||
// Exclude players that do not reach level limit.
|
||||
// if (EventPartnerData.DebugFlag)
|
||||
// request.MinLevel = 0;
|
||||
// else
|
||||
var _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
request.MinLevel = int.Parse(GContext.container.Resolve<Tables>().TbFishingEvent[_eventPartnerData.EventId].ConditionList[0].Param[0]);
|
||||
var excludeSet = new HashSet<string>();
|
||||
// Exclude players that invites me.
|
||||
// recommendList = oldList.Where(info => info.IsInvitationPending).ToList();
|
||||
if (_eventPartnerData.RequestPartners != null)
|
||||
foreach (var playfabId in _eventPartnerData.RequestPartners)
|
||||
excludeSet.Add(playfabId);
|
||||
// Exclude players that is matched to me.
|
||||
foreach (var component in _eventPartnerData.Components.Where(component => component.PartnerId != ""))
|
||||
excludeSet.Add(component.PartnerId);
|
||||
// Exclude friends
|
||||
foreach (var friend in _friendService.FriendList)
|
||||
excludeSet.Add(friend.playFabId);
|
||||
// Exclude refused ones
|
||||
if (_eventPartnerData.RefusePartners is not null)
|
||||
foreach (var id in _eventPartnerData.RefusePartners)
|
||||
excludeSet.Add(id);
|
||||
// Exclude ones that player already invited
|
||||
if (_eventPartnerData.InvitePartners is not null)
|
||||
foreach (var id in _eventPartnerData.InvitePartners)
|
||||
excludeSet.Add(id);
|
||||
request.Exclude = new List<string>(excludeSet);
|
||||
RecommendResponse recommendResponse;
|
||||
recommendResponse = await _customServerMgr.EventPartnerRequest<RecommendResponse>(EventPartnerData.RecommendUrl, request);
|
||||
if (recommendResponse.State != (int)EventPartnerData.EEventBuildState.Success)
|
||||
{
|
||||
Debug.Log($"<color=red>Recommend Request failed: {recommendResponse.State}</color>");
|
||||
return recommendList;
|
||||
}
|
||||
foreach (var info in recommendResponse.Players)
|
||||
GContext.container.Resolve<IUserService>().SetPlayInfo(info.PlayFabId, info.DisplayName, info.AvatarUrl);
|
||||
|
||||
recommendList.AddRange(recommendResponse.Players.Select(info => new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Recommendation,
|
||||
AvatarUrl = info.AvatarUrl,
|
||||
DisplayName = info.DisplayName,
|
||||
PlayfabId = info.PlayFabId,
|
||||
Level = info.Level,
|
||||
LastLoginTime = info.lastLoginTime.Value
|
||||
}).Take(count));
|
||||
_eventPartnerData.SavePlayerPreferenceData();
|
||||
return recommendList;
|
||||
}
|
||||
|
||||
private HashSet<ScrollViewItemInfo> GetBotRecommendList(int count)
|
||||
{
|
||||
var botTable = GContext.container.Resolve<Tables>().TbRobot;
|
||||
var recommendList = new HashSet<ScrollViewItemInfo>();
|
||||
var _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
var partnerIdSet = _eventPartnerData.Components.Where(c => c.IsMatched)
|
||||
.Select(c => c.PartnerId).ToHashSet();
|
||||
while (recommendList.Count < count)
|
||||
{
|
||||
var randomBot = botTable.DataList[Random.Range(0, botTable.DataList.Count)];
|
||||
if (partnerIdSet.Contains(EventPartnerBot.Idx2Id(randomBot.ID)))
|
||||
continue;
|
||||
recommendList.Add(new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Recommendation,
|
||||
AvatarUrl = randomBot.Avatar,
|
||||
DisplayName = randomBot.Name,
|
||||
PlayfabId = EventPartnerBot.Idx2Id(randomBot.ID),
|
||||
Level = Random.Range(60, 120),
|
||||
});
|
||||
// Debug.Log($"<color=#ffc700>Robot: No.{randomBot.ID} {randomBot.Name}</color>");
|
||||
}
|
||||
|
||||
return recommendList;
|
||||
}
|
||||
|
||||
private List<ScrollViewItemInfo> GetFriendList()
|
||||
{
|
||||
var friendList = _friendService.FriendList;
|
||||
var _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
var pendingSet = _eventPartnerData.InvitePartners;
|
||||
var newList = new List<ScrollViewItemInfo>();
|
||||
// Debug.Log($"<color=#ffc700>[EventPartner] DataHash from null stuff: {_eventPartnerData.GetHashCode()}</color>");
|
||||
foreach (var info in (from friend in friendList
|
||||
where friend.playFabId != _userService.UserId &&
|
||||
!_eventPartnerData.RequestPartners.Contains(friend.playFabId) &&
|
||||
!_eventPartnerData.RefusePartners.Contains(friend.playFabId) &&
|
||||
!pendingSet.Contains(friend.playFabId) &&
|
||||
_eventPartnerData.Components.All(c => c.PartnerId != friend.playFabId)
|
||||
select new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Friend,
|
||||
AvatarUrl = friend.avatarUrl,
|
||||
DisplayName = friend.displayName,
|
||||
PlayfabId = friend.playFabId,
|
||||
Level = friend.value / LeadboardData.LV_MODELING,
|
||||
LastLoginTime = friend.LastLogin.Value
|
||||
}).OrderByDescending(info => info.LastLoginTime))
|
||||
{
|
||||
// if (info.IsInvitationPending)
|
||||
newList.Add(info);
|
||||
// else
|
||||
// newList.Insert(0, info);
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
private List<ScrollViewItemInfo> GetInvitationList()
|
||||
{
|
||||
var res = new List<ScrollViewItemInfo>();
|
||||
var _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
if (_eventPartnerData.Cache.ListInvitation is null)
|
||||
return res;
|
||||
_eventPartnerData.Cache.ListInvitation = _eventPartnerData.Cache.ListInvitation
|
||||
.Where(info => _eventPartnerData.InvitePartners.Contains(info.PlayfabId))
|
||||
.ToList();
|
||||
foreach (var info in _eventPartnerData.Cache.ListInvitation)
|
||||
{
|
||||
res.Add(info);
|
||||
}
|
||||
// foreach (var info in _eventPartnerData.Cache.ListInvitation)
|
||||
// {
|
||||
// if (_eventPartnerData.InvitePartners.Contains(info.PlayfabId))
|
||||
// res.Add(info);
|
||||
// else
|
||||
// _eventPartnerData.Cache.ListInvitation.Remove(info);
|
||||
// }
|
||||
return res;
|
||||
}
|
||||
|
||||
public int GetNumberOfCells(EnhancedScroller scroller)
|
||||
{
|
||||
return _scrollViewInfoList.Count;
|
||||
}
|
||||
|
||||
public float GetCellViewSize(EnhancedScroller scroller, int dataIndex)
|
||||
{
|
||||
switch (_scrollViewInfoList[dataIndex].Type)
|
||||
{
|
||||
case EScrollViewType.Title:
|
||||
return jiandaTitleHeight;
|
||||
default:
|
||||
return jiandaItemHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex,
|
||||
int cellIndex)
|
||||
{
|
||||
var info = _scrollViewInfoList[dataIndex];
|
||||
switch (info.Type)
|
||||
{
|
||||
case EScrollViewType.Title:
|
||||
if (scroller.GetCellView(scrollViewTitlePrefab) is not EventPartnerScrollViewTitle cellViewTitle)
|
||||
{
|
||||
Debug.Log("<color=red>[EventPartner] Cell view as title is null.</color>");
|
||||
return null;
|
||||
}
|
||||
cellViewTitle.textTitle.text = info.Title;
|
||||
return cellViewTitle;
|
||||
case EScrollViewType.Recommendation:
|
||||
case EScrollViewType.Friend:
|
||||
case EScrollViewType.MyInvitation:
|
||||
if (scroller.GetCellView(scrollViewItemPrefab) is not EventPartnerScrollViewItem cellViewItem)
|
||||
{
|
||||
Debug.Log("<color=red>[EventPartner] Cell view as item is null.</color>");
|
||||
return null;
|
||||
}
|
||||
cellViewItem.Init(info);
|
||||
return cellViewItem;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveItem(string id)
|
||||
{
|
||||
if (_recommendList is not null)
|
||||
for (int i = 0; i < _recommendList.Count; i++)
|
||||
{
|
||||
if (_recommendList[i].PlayfabId == id)
|
||||
_recommendList.RemoveAt(i);
|
||||
}
|
||||
if (_friendList is not null)
|
||||
for (int i = 0; i < _friendList.Count; i++)
|
||||
{
|
||||
if (_friendList[i].PlayfabId == id)
|
||||
_friendList.RemoveAt(i);
|
||||
}
|
||||
BuildScrollViewInfoList();
|
||||
ReloadScrollViewData();
|
||||
}
|
||||
|
||||
private void BuildScrollViewInfoList()
|
||||
{
|
||||
_scrollViewInfoList.Clear();
|
||||
if (_recommendList is not null && _recommendList.Count > 0)
|
||||
{
|
||||
_scrollViewInfoList.Add(new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Title,
|
||||
Title = LocalizationMgr.GetText(RecommendTitleKey)
|
||||
});
|
||||
// Debug.Log("<color=#c191ff>[EventPartner]Build Title.</color>");
|
||||
foreach (var info in _recommendList)
|
||||
{
|
||||
_scrollViewInfoList.Add(info);
|
||||
// Debug.Log($"<color=#c191ff>[EventPartner]Build {info.DisplayName}: {info.LastLoginTime}</color>");
|
||||
}
|
||||
}
|
||||
|
||||
if (_friendList is not null && _friendList.Count > 0)
|
||||
{
|
||||
_scrollViewInfoList.Add(new ScrollViewItemInfo
|
||||
{ Type = EScrollViewType.Title, Title = LocalizationMgr.GetText(FriendTitleKey) });
|
||||
// Debug.Log("<color=#c191ff>[EventPartner]Build Title.</color>");
|
||||
foreach (var info in _friendList)
|
||||
{
|
||||
_scrollViewInfoList.Add(info);
|
||||
// Debug.Log($"<color=#c191ff>[EventPartner]Build {info.DisplayName}: {info.LastLoginTime}</color>");
|
||||
}
|
||||
}
|
||||
|
||||
if (_invitationList is not null && _invitationList.Count > 0)
|
||||
{
|
||||
_scrollViewInfoList.Add(new ScrollViewItemInfo
|
||||
{ Type = EScrollViewType.Title, Title = LocalizationMgr.GetText(InvitationTitleKey) });
|
||||
// Debug.Log("<color=#c191ff>[EventPartner]Build Title.</color>");
|
||||
foreach (var info in _invitationList)
|
||||
{
|
||||
_scrollViewInfoList.Add(info);
|
||||
// Debug.Log($"<color=#c191ff>[EventPartner]Build {info.DisplayName}: {info.LastLoginTime}</color>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReloadScrollViewData()
|
||||
{
|
||||
scrollView.ReloadData();
|
||||
if (_scrollViewInfoList.Count <= 1)
|
||||
{
|
||||
emptyGo.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2531c0167218b1f45ad632e68bc03ad4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
266
Assets/Scripts/UI/PartnerFishBowl/EventPartnerInvitedPanel.cs
Normal file
266
Assets/Scripts/UI/PartnerFishBowl/EventPartnerInvitedPanel.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using UnityEngine;
|
||||
using ScrollViewItemInfo = EventPartnerScrollViewItem.ScrollViewItemInfo;
|
||||
using EScrollViewType = EventPartnerScrollViewItem.EScrollViewType;
|
||||
using asap.core;
|
||||
using Castle.Core.Internal;
|
||||
using game;
|
||||
using GameCore;
|
||||
using UniRx;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventPartnerInvitedPanel : MonoBehaviour, IEnhancedScrollerDelegate
|
||||
{
|
||||
private readonly ICustomServerMgr _customServerMgr = GContext.container.Resolve<ICustomServerMgr>();
|
||||
private readonly EventPartnerData _eventPartnerData = GContext.container.Resolve<EventPartnerData>();
|
||||
private readonly IUserService _userService = GContext.container.Resolve<IUserService>();
|
||||
[SerializeField] private Button btnClose;
|
||||
private readonly string PlayerFullKey = "UI_ToastPanel_80", PartnerFullKey = "UI_ToastPanel_99";
|
||||
|
||||
private async void Start()
|
||||
{
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
await InitScrollView();
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerClickAccept>()
|
||||
.Subscribe(e => _ = OnAccept(e.Info)).AddTo(this);
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerClickIgnore>()
|
||||
.Subscribe(e => _ = OnIgnore(e.Info.PlayfabId)).AddTo(this);
|
||||
}
|
||||
private void HideBtn()
|
||||
{
|
||||
EventPartnerAct.Ctx.EventAggregator.Publish(new EventPartnerHideApplicationBtn());
|
||||
}
|
||||
|
||||
private void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.EventPartnerInvitedPanel);
|
||||
}
|
||||
|
||||
#region ScrollView
|
||||
|
||||
[SerializeField] private EnhancedScroller scrollView;
|
||||
[SerializeField] private float jiandaItemHeight = 150f;
|
||||
[SerializeField] private EventPartnerScrollViewItem scrollViewItemPrefab;
|
||||
private List<ScrollViewItemInfo> _itemInfos = new List<ScrollViewItemInfo>();
|
||||
|
||||
private async System.Threading.Tasks.Task InitScrollView()
|
||||
{
|
||||
await RequestItemInfo();
|
||||
var invitationList = _eventPartnerData.RequestPartners.ToList();
|
||||
// foreach (Transform child in scrollView.transform)
|
||||
// {
|
||||
// Destroy(child.gameObject);
|
||||
// }
|
||||
|
||||
scrollView.Delegate = this;
|
||||
scrollView.ReloadData();
|
||||
}
|
||||
|
||||
public int GetNumberOfCells(EnhancedScroller scroller)
|
||||
{
|
||||
return _itemInfos.Count;
|
||||
}
|
||||
|
||||
public float GetCellViewSize(EnhancedScroller scroller, int dataIndex)
|
||||
{
|
||||
return jiandaItemHeight;
|
||||
}
|
||||
|
||||
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
|
||||
{
|
||||
var info = _itemInfos[dataIndex];
|
||||
if (scroller.GetCellView(scrollViewItemPrefab) is not EventPartnerScrollViewItem cellView)
|
||||
{
|
||||
Debug.Log("<color=red>[EventPartner] Cell view is null.</color>");
|
||||
return null;
|
||||
}
|
||||
|
||||
cellView.Init(info);
|
||||
return cellView;
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task OnAccept(ScrollViewItemInfo info)
|
||||
{
|
||||
if (_eventPartnerData.IsFullyMatched)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]Cannot accept. Fully matched.</color>");
|
||||
ToastPanel.Show(LocalizationMgr.GetText(PlayerFullKey));
|
||||
return;
|
||||
}
|
||||
var request = new EventPartnerData.EventBuildPartnerRequest { partnerId = info.PlayfabId, eventId = _eventPartnerData.EventId};
|
||||
try
|
||||
{
|
||||
var response = await _customServerMgr.EventPartnerRequest<EventPartnerData.EventBuildOperationResp>(EventPartnerData.AcceptUrl, request);
|
||||
if (response.State != EventPartnerData.EEventBuildState.Success)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]{response.State}: {response.ErrorMessage}</color>");
|
||||
ToastPanel.Show(LocalizationMgr.GetText(PartnerFullKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
var idx = response.SlotId ?? throw new Exception($"Null slot id for {info.DisplayName}");
|
||||
_eventPartnerData.Components[idx].SetComponent(info);
|
||||
_ = EventPartnerAct.Ctx.ShowMainPanel(true, info.DisplayName, info.AvatarUrl, _eventPartnerData.Components[idx].GetComponentName());
|
||||
}
|
||||
for (int i = 0; i < _itemInfos.Count; i++)
|
||||
{
|
||||
if (_itemInfos[i].PlayfabId != info.PlayfabId)
|
||||
continue;
|
||||
_itemInfos.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
_eventPartnerData.Cache.ListInvitedBy = _eventPartnerData.Cache.ListInvitedBy.Where(i => i.PlayfabId != info.PlayfabId).ToList();
|
||||
_eventPartnerData.RequestPartners.Remove(info.PlayfabId);
|
||||
_eventPartnerData.SavePlayerPreferenceData();
|
||||
scrollView.ReloadData();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]{e.Message}</color>");
|
||||
}
|
||||
|
||||
if (_itemInfos.Count <= 0 || _eventPartnerData.IsFullyMatched)
|
||||
{
|
||||
OnClickClose();
|
||||
HideBtn();
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task OnIgnore(string partnerId)
|
||||
{
|
||||
var request = new EventPartnerData.EventBuildPartnerRequest { partnerId = partnerId , eventId = _eventPartnerData.EventId};
|
||||
try
|
||||
{
|
||||
var response = await _customServerMgr
|
||||
.EventPartnerRequest<EventPartnerData.EventBuildOperationResp>(
|
||||
EventPartnerData.IgnoreUrl, request);
|
||||
if (response.State != EventPartnerData.EEventBuildState.Success)
|
||||
Debug.Log(
|
||||
$"<color=#c191ff>[EventPartner]{response.State}: {response.ErrorMessage}</color>");
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _itemInfos.Count; i++)
|
||||
{
|
||||
if (_itemInfos[i].PlayfabId != partnerId)
|
||||
continue;
|
||||
_itemInfos.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
|
||||
_eventPartnerData.Cache.ListInvitedBy = _eventPartnerData.Cache.ListInvitedBy.Where(info => info.PlayfabId != partnerId).ToList();
|
||||
_eventPartnerData.RequestPartners.Remove(partnerId);
|
||||
_eventPartnerData.SavePlayerPreferenceData();
|
||||
scrollView.ReloadData();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]{e.Message}</color>");
|
||||
}
|
||||
|
||||
if (_itemInfos.Count <= 0)
|
||||
{
|
||||
OnClickClose();
|
||||
HideBtn();
|
||||
}
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task RequestItemInfo()
|
||||
{
|
||||
var originSet = new HashSet<string>();
|
||||
foreach (var partner in _eventPartnerData.RequestPartners)
|
||||
{
|
||||
originSet.Add(partner);
|
||||
}
|
||||
|
||||
// Find in cache
|
||||
if (_eventPartnerData.Cache?.ListInvitedBy is { Count: > 0 })
|
||||
{
|
||||
foreach (var info in _eventPartnerData.Cache.ListInvitedBy.Where(info =>
|
||||
originSet.Contains(info.PlayfabId)))
|
||||
{
|
||||
originSet.Remove(info.PlayfabId);
|
||||
_itemInfos.Add(info);
|
||||
}
|
||||
}
|
||||
|
||||
if (originSet.IsNullOrEmpty())
|
||||
return;
|
||||
|
||||
// Find in friendList
|
||||
var friendDictionary = GContext.container.Resolve<FriendService>().FriendList
|
||||
.ToDictionary(f => f.playFabId);
|
||||
if (!friendDictionary.IsNullOrEmpty())
|
||||
{
|
||||
var i = originSet.Intersect(friendDictionary.Keys);
|
||||
_itemInfos.AddRange(i.Select(s => new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Partner2Accept,
|
||||
PlayfabId = friendDictionary[s].playFabId,
|
||||
AvatarUrl = friendDictionary[s].avatarUrl,
|
||||
DisplayName = friendDictionary[s].displayName,
|
||||
Level = friendDictionary[s].value / LeadboardData.LV_MODELING
|
||||
}));
|
||||
originSet.RemoveWhere(friendDictionary.ContainsKey);
|
||||
}
|
||||
|
||||
if (originSet.IsNullOrEmpty())
|
||||
return;
|
||||
|
||||
// Find in server cache
|
||||
var request = new EventPartnerData.EventBuildRecentPlayerInfoRequest();
|
||||
request.playerPrefabs = originSet.ToArray();
|
||||
var resp = await _customServerMgr
|
||||
.EventPartnerRequest<EventPartnerData.EventBuildRecentPlayerInfoResponse>(
|
||||
EventPartnerData.MatchRecentPlayerInfoUrl, request);
|
||||
if (resp.State == EventPartnerData.EEventBuildState.Success && !resp.playerInfos.IsNullOrEmpty())
|
||||
{
|
||||
originSet = resp.leftOvers.ToHashSet();
|
||||
_itemInfos.AddRange(resp.playerInfos.Select(p => new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Partner2Accept, PlayfabId = p.PlayFabId,
|
||||
AvatarUrl = p.AvatarUrl,
|
||||
DisplayName = p.DisplayName, Level = p.Level
|
||||
}));
|
||||
if (originSet.IsNullOrEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
// Find in server database.
|
||||
var displayInfoRequest = new EventPartnerData.EventBuildPlayerDisplayInfoRequest();
|
||||
displayInfoRequest.PlayfabIds = originSet.ToArray();
|
||||
var res = await _customServerMgr
|
||||
.EventPartnerRequest<EventPartnerData.EventBuildPlayerDisplayInfoResp>(
|
||||
EventPartnerData.PlayerDisplayInfoUrl, displayInfoRequest);
|
||||
if (res.State != EventPartnerData.EEventBuildState.Success || res.PlayerInfos.IsNullOrEmpty())
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]Server response in invite panel info: {res.Message}</color>");
|
||||
|
||||
foreach (var info in res.PlayerInfos)
|
||||
{
|
||||
originSet.Remove(info.PlayFabId);
|
||||
_itemInfos.Add(new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Partner2Accept, PlayfabId = info.PlayFabId,
|
||||
AvatarUrl = info.AvatarUrl, DisplayName = info.DisplayName, Level = info.Level
|
||||
});
|
||||
}
|
||||
|
||||
if (originSet.IsNullOrEmpty())
|
||||
return;
|
||||
// Show default
|
||||
_itemInfos.AddRange(originSet.Select(p =>
|
||||
new ScrollViewItemInfo
|
||||
{
|
||||
Type = EScrollViewType.Partner2Accept,
|
||||
PlayfabId = p,
|
||||
AvatarUrl = "",
|
||||
DisplayName = _userService.GetDefaultName(p),
|
||||
Level = 60
|
||||
}));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5562b89a3829e0642aeb4b5abe804b5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
215
Assets/Scripts/UI/PartnerFishBowl/EventPartnerMainPanel.cs
Normal file
215
Assets/Scripts/UI/PartnerFishBowl/EventPartnerMainPanel.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
using cfg;
|
||||
using asap.core;
|
||||
using Castle.Core.Internal;
|
||||
using game;
|
||||
using UnityEngine.Assertions;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EventPartnerMainPanel : MonoBehaviour
|
||||
{
|
||||
#region UI
|
||||
|
||||
[SerializeField] private TMP_Text _textTimer, _textAreaInfo, _textProgress, _textTicketCount;
|
||||
[SerializeField] private Image[] _targetBars;
|
||||
[SerializeField] private RewardItemNew[] _rewardItems;
|
||||
[SerializeField] private Image _iconTicket;
|
||||
[SerializeField] private EventPartnerCharaSlot[] _characters;
|
||||
[SerializeField] private GameObject finishedGo, ticketGo;
|
||||
[SerializeField] private Button btnInfo, btnTicket, btnApplication;
|
||||
[SerializeField] private EventPartnerMainPanelMatchTip matchTip;
|
||||
[SerializeField] private EventPartnerTips tips;
|
||||
private Image _activeBar;
|
||||
private PlayerItemData _playerItemData;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Config
|
||||
|
||||
private EventPartnerData _data;
|
||||
private Tables _tables;
|
||||
private TbEventPartnerMain _tableMain;
|
||||
|
||||
#endregion
|
||||
|
||||
private void Start()
|
||||
{
|
||||
btnInfo.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventPartnerInfoPopupPanel));
|
||||
btnTicket.onClick.AddListener(tips.ShowMainTip);
|
||||
btnApplication.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventPartnerInvitedPanel));
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerMatchSuccess>().Subscribe(OnNewMatch).AddTo(this);
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerPartnerAddScore>().Subscribe(OnScoreAdd).AddTo(this);
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerOnInvited>().Subscribe(_ => OnInvited()).AddTo(this);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f)).Subscribe(_ => _textTimer.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(_data.RemainingTime))).AddTo(this);
|
||||
EventPartnerAct.Ctx.EventAggregator.GetEvent<EventPartnerHideApplicationBtn>().Subscribe(e => btnApplication.transform.parent.gameObject.SetActive(false)).AddTo(this);
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.B))
|
||||
{
|
||||
Debug.Log("Bot recommend.");
|
||||
_data.ActivateRobotRecommend();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Init()
|
||||
{
|
||||
var ctx = EventPartnerAct.Ctx;
|
||||
_tables = ctx.Tables;
|
||||
_tableMain = _tables.TbEventPartnerMain;
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_data = ctx.Data;
|
||||
// Debug.Log($"[EventPartner] Data in main panel: {_data.GetHashCode()}");
|
||||
for (int i = 0; i < _characters.Length; i++)
|
||||
_characters[i].Init(_data.Components[i]);
|
||||
|
||||
_textTimer.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(_data.RemainingTime));
|
||||
InitializeTarget();
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_iconTicket, _tables.TbItem[_tableMain[_data.RedirectId].WheelTicket].Icon);
|
||||
_textTicketCount.text = _data.TicketCount.ToString();
|
||||
finishedGo.SetActive(_data.IsBuildingCompleted);
|
||||
ticketGo.SetActive(!_data.IsBuildingCompleted);
|
||||
if (_data.IsBuildingCompleted && !_data.IsBuildingRewardCollected)
|
||||
{
|
||||
int dropId = _tableMain[_data.RedirectId].Reward;
|
||||
// SendCheck();
|
||||
_playerItemData.AddItemByDrop(dropId, false);
|
||||
GContext.Publish(new ShowData(_playerItemData.GetItemDataByDropId(dropId)));
|
||||
GContext.Publish(new ShowData());
|
||||
int _EvStageId = 99, _EvRewardList = dropId, _EvRewardHook = 0, _EvRewardCash = 0;
|
||||
var rewardIdList = _tables.TbDrop[dropId].DropList.DropIDList;
|
||||
for (int i = 0; i < rewardIdList.Count; i++)
|
||||
{
|
||||
if (rewardIdList[i] == 1001)
|
||||
_EvRewardHook = _tables.TbDrop[dropId].DropList.DropCountList[i];
|
||||
if (rewardIdList[i] == 1002)
|
||||
_EvRewardCash = _tables.TbDrop[dropId].DropList.DropCountList[i];
|
||||
}
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_partners_reward"))
|
||||
{
|
||||
e.AddContent("stage_id", _EvStageId)
|
||||
.AddContent("reward_list", _EvRewardList)
|
||||
.AddContent("reward_hook", _EvRewardHook)
|
||||
.AddContent("reward_cash", _EvRewardCash);
|
||||
}
|
||||
#endif
|
||||
_data.IsBuildingRewardCollected = true;
|
||||
_data.SavePlayerPreferenceData();
|
||||
_data.ToPlayfabData().Save();
|
||||
}
|
||||
btnApplication.transform.parent.gameObject.SetActive(!ctx.Data.RequestPartners.IsNullOrEmpty() && !ctx.Data.IsFullyMatched);
|
||||
GContext.OnEvent<EventPartnerTicketChangedEvent>().Subscribe(_ => UpdateTicketCount()).AddTo(this);
|
||||
}
|
||||
|
||||
private void UpdateTicketCount()
|
||||
{
|
||||
_textTicketCount.text = _data.TicketCount.ToString();
|
||||
_textTicketCount.color = _data.TicketCount < 1 ? Color.red : Color.white;
|
||||
}
|
||||
|
||||
// private async void SendCheck()
|
||||
// {
|
||||
// var res = await GContext.container.Resolve<ICustomServerMgr>().EventPartnerRequest<EventPartnerData.EventBuildRewardStatusResp>(EventPartnerData.SetRewardCollectedUrl, null);
|
||||
// Debug.Log($"<color=#c191ff>full reward res: {res.State}, {res.Message}, {res.IsRewardCollected}</color>");
|
||||
// }
|
||||
|
||||
private void InitializeTarget()
|
||||
{
|
||||
var d = _tables.TbDrop[_tableMain[_data.RedirectId].Reward];
|
||||
int dropTypeCount = d.DropList.DropIDList.Count;
|
||||
Assert.IsTrue(dropTypeCount is > 0 and <= 3,
|
||||
$"Drop count {dropTypeCount} is not within [0, 3].");
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
_targetBars[i].gameObject.SetActive(3 - dropTypeCount == i);
|
||||
if (3 - dropTypeCount == i)
|
||||
_activeBar = _targetBars[i];
|
||||
_rewardItems[i].gameObject.SetActive(i < dropTypeCount);
|
||||
}
|
||||
|
||||
var itemList = _playerItemData.GetItemDataByDropId(d.ID);
|
||||
for (int i = 0; i < dropTypeCount; i++)
|
||||
_rewardItems[i].SetData(itemList[i]);
|
||||
int amount = _data.Components.Count(t => t.IsFinished);
|
||||
_activeBar.fillAmount = (float)amount / _data.Components.Count;
|
||||
_textProgress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9",
|
||||
$"{amount}/{_data.Components.Count}");
|
||||
}
|
||||
|
||||
public void SetMatchTip(string namePartner, string iconPartner, string nameComponent,
|
||||
bool doShowPanelTips)
|
||||
{
|
||||
if (!doShowPanelTips)
|
||||
{
|
||||
matchTip.gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
matchTip.Show(namePartner, iconPartner, nameComponent);
|
||||
matchTip.gameObject.SetActive(false);
|
||||
matchTip.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private async void OnNewMatch(EventPartnerMatchSuccess e)
|
||||
{
|
||||
if (e.PartnerId.EndsWith(EventPartnerBot.RobotIdentifier))
|
||||
{
|
||||
int delay = Random.Range( _tables.TbEventPartnerConfig.RobotAgreeTime[0],
|
||||
_tables.TbEventPartnerConfig.RobotAgreeTime[1]);
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]Delay: {delay} seconds.</color>");
|
||||
await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(delay));
|
||||
}
|
||||
// Init();
|
||||
SetMatchTip(e.NamePartner, e.IconPartner, e.NameComponent, true);
|
||||
_characters[e.SlotId].Init(_data.Components[e.SlotId]);
|
||||
}
|
||||
|
||||
private async void OnInvited()
|
||||
{
|
||||
await Awaiters.NextFrame;
|
||||
btnApplication.transform.parent.gameObject.SetActive(true);
|
||||
}
|
||||
// private async void OnAccepted(EventPartnerOnAccepted e)
|
||||
// {
|
||||
// await Awaiters.NextFrame;
|
||||
// _characters[e.SlotId].Init(_data.Components[e.SlotId]);
|
||||
// }
|
||||
|
||||
private async void OnScoreAdd(EventPartnerPartnerAddScore _)
|
||||
{
|
||||
await Awaiters.NextFrame;
|
||||
for (int i = 0; i < _data.Components.Count; i++)
|
||||
_characters[i].Init(_data.Components[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public class EventPartnerMatchSuccess
|
||||
{
|
||||
public string NamePartner;
|
||||
public string IconPartner;
|
||||
public string NameComponent;
|
||||
public int SlotId;
|
||||
public string PartnerId;
|
||||
}
|
||||
|
||||
public class EventPartnerOnInvited { }
|
||||
public class EventPartnerHideApplicationBtn { }
|
||||
// public class EventPartnerOnAccepted
|
||||
// {
|
||||
// public int SlotId;
|
||||
// public string PartnerId;
|
||||
// public EventPartnerOnAccepted(EventPartnerData.EventBuildPartnerEvt e)
|
||||
// {
|
||||
// SlotId = e.slotId;
|
||||
// PartnerId = e.partnerId;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6839c31148aca7a478eb3e215d7a7c1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventPartnerMainPanelMatchTip : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text text;
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private Image iconHead;
|
||||
public void Show(string namePartner,string iconPartner, string nameComponent)
|
||||
{
|
||||
text.text = LocalizationMgr.GetFormatTextValue("UI_EventPartnerFishbowlPanel_25", namePartner, nameComponent);
|
||||
GContext.container.Resolve<IUIService>().SetHeadImage(iconHead, iconPartner);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3cd7735044abf1e40a942d6d4ceb61f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventPartnerMultiplierController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text _textMultiplier, _textMultiplierMax;
|
||||
[SerializeField] private Button _btnMultiplier;
|
||||
[SerializeField] private GameObject _goNormal, _goMax;
|
||||
[SerializeField] private Animator btnAnimation;
|
||||
private int _idx, _redirectId, largeIdx;
|
||||
private Tables _tables;
|
||||
private List<int> _multiplierList;
|
||||
private PlayerItemData _playerItemData;
|
||||
private IEventAggregator _eventAggregator;
|
||||
public int Multiplier => _multiplierList[_idx];
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_btnMultiplier.onClick.AddListener(CycleMultiplierToNext);
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
public void Init(int redirectId, IEventAggregator eventAggregator)
|
||||
{
|
||||
// Debug.Log("Btn init:");
|
||||
// Debug.Log(eventAggregator.GetHashCode());
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_redirectId = redirectId;
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_multiplierList = _tables.TbEventPartnerMain[_redirectId].SpinMag;
|
||||
SwitchToNextMax();
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
[SerializeField] private float btnReactTime = 0.05f;
|
||||
public async void CycleMultiplierToNext()
|
||||
{
|
||||
_idx++;
|
||||
int currentMaxMultiplier = GetCurrentMaxMultiplier();
|
||||
btnAnimation.Play("Pressed");
|
||||
ToggleMultiplierButtonFunction(false);
|
||||
if (_idx >= _multiplierList.Count || Multiplier > currentMaxMultiplier)
|
||||
{
|
||||
_idx = 0;
|
||||
ToggleButtons(largeIdx != 0);
|
||||
}
|
||||
else if (Multiplier == currentMaxMultiplier)
|
||||
{
|
||||
ToggleButtons(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleButtons(true);
|
||||
}
|
||||
_eventAggregator.Publish(new EventPartnerMultiplierChange());
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(btnReactTime));
|
||||
btnAnimation.Play("Normal");
|
||||
ToggleMultiplierButtonFunction(true);
|
||||
}
|
||||
public void ToggleMultiplierButtonFunction(bool doEnable)
|
||||
{
|
||||
_btnMultiplier.enabled = doEnable;
|
||||
}
|
||||
|
||||
public void SwitchToNextMax()
|
||||
{
|
||||
GetCurrentMaxMultiplier();
|
||||
_idx = largeIdx;
|
||||
_textMultiplier.text = $"x{_multiplierList[_idx]}";
|
||||
_textMultiplierMax.text = $"x{_multiplierList[_idx]}";
|
||||
ToggleMultiplierButtonFunction(true);
|
||||
_goNormal.SetActive(false);
|
||||
_goMax.SetActive(true);
|
||||
}
|
||||
|
||||
private int GetCurrentMaxMultiplier()
|
||||
{
|
||||
int ans = _multiplierList[0];
|
||||
largeIdx = 0;
|
||||
for (int i = 0; i < _multiplierList.Count; i++ )
|
||||
if (_multiplierList[i] * _tables.TbEventPartnerMain[_redirectId].SpinRequire
|
||||
<= GContext.container.Resolve<EventPartnerData>().TicketCount)
|
||||
{
|
||||
ans = _multiplierList[i];
|
||||
largeIdx = i;
|
||||
}
|
||||
// Debug.Log($"<color=red>Multiplier: {ans}</color>");
|
||||
return ans;
|
||||
}
|
||||
private void ToggleButtons(bool doShowNormal)
|
||||
{
|
||||
if (doShowNormal)
|
||||
{
|
||||
_goNormal.SetActive(true);
|
||||
_goMax.SetActive(false);
|
||||
_textMultiplier.text = $"x{Multiplier}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_goNormal.SetActive(false);
|
||||
_goMax.SetActive(true);
|
||||
_textMultiplierMax.text = $"x{Multiplier}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct EventPartnerMultiplierChange { }
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f721c01e5b6e54c45b2ff91397343e8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
235
Assets/Scripts/UI/PartnerFishBowl/EventPartnerPanel.cs
Normal file
235
Assets/Scripts/UI/PartnerFishBowl/EventPartnerPanel.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using game;
|
||||
using asap.core;
|
||||
using UnityEngine.UI;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using UniRx;
|
||||
using System.Collections.Generic;
|
||||
using Castle.Core.Internal;
|
||||
using GameCore;
|
||||
|
||||
public class EventPartnerPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button btnClose, btnConfirm;
|
||||
[SerializeField] private EventPartnerMainPanel mainPanel;
|
||||
[SerializeField] private EventPartnerBuildPanel buildPanel;
|
||||
[SerializeField] private EPanel curPanel;
|
||||
[SerializeField] private GameObject background;
|
||||
[SerializeField] private float zoomTime;
|
||||
[SerializeField] private float zoomScale;
|
||||
[SerializeField] private EventPartnerComponent[] components;
|
||||
[SerializeField] private CanvasGroup mask;
|
||||
[SerializeField] private Animation uiAnimation;
|
||||
[SerializeField] private EventPartnerTips tips;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private EventPartnerData _data;
|
||||
private Tables _tables;
|
||||
private EventPartnerAct.Context _context;
|
||||
private IDisposable _robotAddScoreSubscription;
|
||||
private List<Tween> _tweenList;
|
||||
private List<Vector3> _posList;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_posList = new List<Vector3>();
|
||||
foreach (var component in components)
|
||||
{
|
||||
_posList.Add(component.transform.localPosition);
|
||||
// Debug.Log($"<color=#80c342>init pos: {_posList[^1]}</color>");
|
||||
}
|
||||
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
btnConfirm.onClick.AddListener(OnClickClose);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("EventPartnerJurassicbuildingPanel", curPanelName: gameObject.name);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_robotAddScoreSubscription?.Dispose();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_context = EventPartnerAct.Ctx;
|
||||
_eventAggregator = _context.EventAggregator;
|
||||
_tables = _context.Tables;
|
||||
_data = _context.Data;
|
||||
// Debug.Log($"[EventPartner] Data in panel: {_data.GetHashCode()}");
|
||||
for (int i = 0; i < _data.Components.Count; i++)
|
||||
{
|
||||
var c = _data.Components[i];
|
||||
SetComponent(i, c.GetProgressIdx(c.ScoreDisplay), isInit: true);
|
||||
var now = ZZTimeHelper.UtcNow();
|
||||
if (!c.IsMatched || !c.IsPartnerRobot || c.BotActionQueue.IsNullOrEmpty() || now < c.BotActionQueue.Peek().Time)
|
||||
continue;
|
||||
if (c.Score >= c.MaxScore)
|
||||
{
|
||||
c.BotActionQueue.Clear();
|
||||
continue;
|
||||
}
|
||||
while (!c.BotActionQueue.IsNullOrEmpty() && now >= c.BotActionQueue.Peek().Time)
|
||||
{
|
||||
c.AddRobotScore();
|
||||
}
|
||||
c.SyncRobotScore();
|
||||
}
|
||||
|
||||
mask.alpha = 0;
|
||||
// TODO: Optimize to timed task instead of constant looking up.
|
||||
_robotAddScoreSubscription ??= Observable.Interval(System.TimeSpan.FromSeconds(2.0f))
|
||||
.Subscribe(x =>
|
||||
{
|
||||
// Debug.Log($"<color=#c191ff>{x} minute:</color>");
|
||||
foreach (var c in _data.Components.Where(c => c.IsMatched && c.IsPartnerRobot))
|
||||
{
|
||||
if (!c.BotActionQueue.TryPeek(out var action) || ZZTimeHelper.UtcNow() < action.Time)
|
||||
continue;
|
||||
if (c.Score >= c.MaxScore)
|
||||
{
|
||||
c.BotActionQueue.Clear();
|
||||
continue;
|
||||
}
|
||||
c.AddRobotScore();
|
||||
c.SyncRobotScore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowMainPanel()
|
||||
{
|
||||
curPanel = EPanel.Main;
|
||||
mainPanel.gameObject.SetActive(true);
|
||||
buildPanel.gameObject.SetActive(false);
|
||||
mainPanel.Init();
|
||||
}
|
||||
|
||||
public void ShowBuildPanel(EventPartnerAct.Context ctx)
|
||||
{
|
||||
curPanel = EPanel.Build;
|
||||
mainPanel.gameObject.SetActive(false);
|
||||
buildPanel.gameObject.SetActive(true);
|
||||
buildPanel.Init();
|
||||
}
|
||||
|
||||
private void OnClickClose()
|
||||
{
|
||||
// Debug.Log("<color=red>Click click click!</color>");
|
||||
if (curPanel == EPanel.Main)
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
else
|
||||
{
|
||||
buildPanel.SetStateInactive();
|
||||
_ = _context.ShowMainPanel();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetComponent(int componentIdx, int targetGrade, bool isUpgrade = false,
|
||||
bool isInit = false)
|
||||
{
|
||||
var component = components[componentIdx];
|
||||
var componentId = _data.Components[componentIdx].ComponentId;
|
||||
var resourceList = _tables.TbEventPartnerComponent[componentId].ResourceList;
|
||||
var resource = resourceList[targetGrade];
|
||||
// Debug.Log($"<color=#c9a26d>Id: {componentId}, Index: {componentIdx}, resource: {resource}.</color>");
|
||||
if (isInit)
|
||||
component.Init(_context, targetGrade, resource);
|
||||
else if (isUpgrade)
|
||||
component.UpgradeComponent(targetGrade, resource);
|
||||
else
|
||||
component.SetComponent(targetGrade, resource);
|
||||
}
|
||||
|
||||
public void PlayAddScoreFx(int componentIdx)
|
||||
{
|
||||
components[componentIdx].PlayAddScoreFx();
|
||||
}
|
||||
|
||||
public void ZoomIn(int componentIdx)
|
||||
{
|
||||
for (int i = 0; i < _data.Components.Count; i++)
|
||||
{
|
||||
components[i].gameObject.SetActive(i == componentIdx);
|
||||
}
|
||||
|
||||
var pos = _posList[componentIdx];
|
||||
// Debug.Log($"<color=#80c342>before pos: {pos}</color>");
|
||||
// Debug.Log($"<color=#80c342>before l : {_posList[componentIdx]}</color>");
|
||||
pos *= zoomScale;
|
||||
// Debug.Log($"<color=#80c342>after pos: {pos}</color>");
|
||||
// Debug.Log($"<color=#80c342>after l : {_posList[componentIdx]}</color>");
|
||||
if (_tweenList is { Count: > 0 })
|
||||
foreach (var tween in _tweenList)
|
||||
tween.Kill();
|
||||
_tweenList = new List<Tween>
|
||||
{
|
||||
background.transform.DOLocalMove(-pos, zoomTime),
|
||||
background.transform.DOScale(zoomScale, zoomTime),
|
||||
mask.DOFadeAlpha(1.0f, zoomTime)
|
||||
};
|
||||
}
|
||||
|
||||
public void ZoomOut()
|
||||
{
|
||||
for (int i = 0; i < _data.Components.Count; i++)
|
||||
{
|
||||
components[i].gameObject.SetActive(true);
|
||||
}
|
||||
// Debug.Log($"<color=#80c342>Before ZoomOut{transform.position}</color>");
|
||||
if (_tweenList is { Count: > 0 })
|
||||
foreach (var tween in _tweenList)
|
||||
tween.Kill();
|
||||
_tweenList = new List<Tween>
|
||||
{
|
||||
background.transform.DOLocalMove(Vector3.zero, zoomTime),
|
||||
background.transform.DOScale(1, zoomTime),
|
||||
mask.DOFadeAlpha(0.0f, zoomTime)
|
||||
};
|
||||
}
|
||||
|
||||
public void PlayUiAnimation()
|
||||
{
|
||||
uiAnimation.Play("fishbowl_show");
|
||||
}
|
||||
|
||||
public void ShowMatchTip(string namePartner, string iconPartner, string nameComponent,
|
||||
bool doShowPanelTips)
|
||||
{
|
||||
mainPanel.SetMatchTip(namePartner, iconPartner, nameComponent, doShowPanelTips);
|
||||
}
|
||||
}
|
||||
|
||||
public enum EPanel
|
||||
{
|
||||
Main,
|
||||
Build,
|
||||
Info,
|
||||
Match,
|
||||
MatchPopup
|
||||
}
|
||||
|
||||
/*public class EventPartnerSwitchPanel
|
||||
{
|
||||
public EPanel panelType;
|
||||
public int ComponentIndex;
|
||||
public EventPartnerSwitchPanel (EPanel e, int c = 0)
|
||||
{
|
||||
panelType = e;
|
||||
ComponentIndex = c;
|
||||
}
|
||||
}*/
|
||||
public class EventPartnerComponentUpgrade
|
||||
{
|
||||
public int ComponentIndex, Grade;
|
||||
|
||||
public EventPartnerComponentUpgrade(int componentIndex, int grade)
|
||||
{
|
||||
ComponentIndex = componentIndex;
|
||||
Grade = grade;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerPanel.cs.meta
Normal file
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3af8adf6f5f7d542854573da2a69758
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/Scripts/UI/PartnerFishBowl/EventPartnerRewardTip.cs
Normal file
61
Assets/Scripts/UI/PartnerFishBowl/EventPartnerRewardTip.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventPartnerRewardTip : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject rewardEmptyGo1, rewardEmptyGo2;
|
||||
[SerializeField] private GameObject[] rewardGos;
|
||||
[SerializeField] private RewardItemNew[] rewards;
|
||||
[SerializeField] private TMP_Text textTarget, textOwned;
|
||||
[SerializeField] private Button btnClose;
|
||||
[SerializeField] private GameObject tipGo;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
tipGo.SetActive(false);
|
||||
btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.EventPartnerTip));
|
||||
}
|
||||
/// <summary>
|
||||
/// Init this tip.
|
||||
/// </summary>
|
||||
/// <param name="items">Items to be shown in this tip.</param>
|
||||
/// <param name="score">Current Score.</param>
|
||||
/// <param name="targetScore">Target Score.</param>
|
||||
/// <param name="btnTransform">The position where this tip shows up.</param>
|
||||
public void Init(List<ItemData> items, int score = 0, int targetScore = 0, Transform btnTransform = null)
|
||||
{
|
||||
if (items.Count == 1)
|
||||
{
|
||||
rewardEmptyGo1.SetActive(true);
|
||||
rewardEmptyGo2.SetActive(true);
|
||||
rewardGos[0].SetActive(true) ;
|
||||
for (int i = 1; i < rewardGos.Length; i++)
|
||||
{
|
||||
rewardGos[i].SetActive(false);
|
||||
}
|
||||
rewards[0].SetData(items[0]);
|
||||
}
|
||||
else if (items.Count > 1)
|
||||
{
|
||||
rewardEmptyGo1.SetActive(false);
|
||||
rewardEmptyGo2.SetActive(false);
|
||||
for (int i = 0; i < rewardGos.Length; i++)
|
||||
{
|
||||
rewardGos[i].SetActive(i < items.Count);
|
||||
if (i < items.Count)
|
||||
rewards[i].SetData(items[i]);
|
||||
}
|
||||
}
|
||||
// textPoint.text = LocalizationMgr.GetFormatTextValue("UI_EventPartnerFishbowlPanel_7", score, targetScore);
|
||||
if (textOwned)
|
||||
textOwned.text = LocalizationMgr.GetFormatTextValue("UI_item_tips_1", score);
|
||||
if (textTarget)
|
||||
textTarget.text = LocalizationMgr.GetFormatTextValue("UI_EventRankPopupPanel_16", targetScore);
|
||||
if (btnTransform)
|
||||
tipGo.transform.position = btnTransform.position;
|
||||
tipGo.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a00c279936194de419c1ebbf46d3c70e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
139
Assets/Scripts/UI/PartnerFishBowl/EventPartnerScrollViewItem.cs
Normal file
139
Assets/Scripts/UI/PartnerFishBowl/EventPartnerScrollViewItem.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
|
||||
public class EventPartnerScrollViewItem : EnhancedScrollerCellView
|
||||
{
|
||||
public TMP_Text textName, textLvl, textBtnYes, textState, textTime;
|
||||
public Head avatar;
|
||||
public Button btnNo, btnYes;
|
||||
public GameObject iconLoadingGo, btnGrayGo, timeGo;
|
||||
private string _playfabId;
|
||||
|
||||
private const string AcceptKey = "UI_EventPartnerFishbowlPanel_18", InviteKey = "UI_EventPartnerFishbowlPanel_17";
|
||||
|
||||
private ScrollViewItemInfo _info;
|
||||
private bool _isNew = true;
|
||||
|
||||
public void Init(ScrollViewItemInfo info)
|
||||
{
|
||||
if (info.Type == EScrollViewType.Title)
|
||||
{
|
||||
Debug.Log( "<color=red>[EventPartner] An item scrollViewCell is initiated with title info.</color>");
|
||||
return;
|
||||
}
|
||||
|
||||
_info = info;
|
||||
_playfabId = info.PlayfabId;
|
||||
textName.text = info.DisplayName;
|
||||
avatar.SetData(info.AvatarUrl);
|
||||
textLvl.text = info.Level.ToString();
|
||||
|
||||
btnNo.transform.parent.gameObject.SetActive(info.Type != EScrollViewType.Friend && info.Type != EScrollViewType.MyInvitation);
|
||||
textBtnYes.text = LocalizationMgr.GetText(info.Type == EScrollViewType.Partner2Accept ? AcceptKey : InviteKey);
|
||||
if (info.Type == EScrollViewType.MyInvitation)
|
||||
{
|
||||
btnYes.transform.parent.gameObject.SetActive(false);
|
||||
btnGrayGo.SetActive(true);
|
||||
}
|
||||
else //(info.Type == EScrollViewType.Partner2Accept)
|
||||
{
|
||||
btnYes.transform.parent.gameObject.SetActive(true);
|
||||
btnGrayGo.SetActive(false);
|
||||
}
|
||||
// btnYes.gameObject.SetActive(info.Type == EScrollViewType.Partner2Accept || !info.IsInvitationPending);
|
||||
// Debug.Log($"<color=#c191ff>[EventPartner]{info.DisplayName}: {info.Type != EScrollViewType.Partner2Accept && info.IsInvitationPending}</color>");
|
||||
// btnGrayGo.SetActive(info.Type != EScrollViewType.Partner2Accept && info.IsInvitationPending);
|
||||
if (info.LastLoginTime.HasValue)
|
||||
textTime.text = ConvertTools.ConvertActiveTime(ZZTimeHelper.UtcNow() - info.LastLoginTime.Value);
|
||||
else
|
||||
{
|
||||
textTime.text = "";
|
||||
Debug.Log($"<color=#c191ff>[EventPartner]Fail to get last login time.</color>");
|
||||
}
|
||||
timeGo.SetActive(info.Type == EScrollViewType.Friend && textTime.text != "");
|
||||
textState.gameObject.SetActive(info.Type == EScrollViewType.MyInvitation && info.IsFull);
|
||||
if (!_isNew)
|
||||
return;
|
||||
_isNew = false;
|
||||
btnNo.onClick.AddListener(OnClickIgnore);
|
||||
btnYes.onClick.AddListener(info.Type == EScrollViewType.Partner2Accept ? OnClickAccept : OnClickInvite);
|
||||
}
|
||||
|
||||
private void OnClickInvite()
|
||||
{
|
||||
EventPartnerAct.Ctx.EventAggregator.Publish(new EventPartnerClickInvite { Info = _info });
|
||||
}
|
||||
|
||||
private void OnClickAccept()
|
||||
{
|
||||
EventPartnerAct.Ctx.EventAggregator.Publish(new EventPartnerClickAccept { Info = _info });
|
||||
}
|
||||
|
||||
private void OnClickIgnore()
|
||||
{
|
||||
EventPartnerAct.Ctx.EventAggregator.Publish(new EventPartnerClickIgnore { Info = _info });
|
||||
}
|
||||
|
||||
public class ScrollViewItemInfo : IEquatable<ScrollViewItemInfo>
|
||||
{
|
||||
public EScrollViewType Type;
|
||||
public string PlayfabId;
|
||||
public string AvatarUrl;
|
||||
public string DisplayName;
|
||||
public int Level;
|
||||
public bool IsFull = false;
|
||||
public string Title;
|
||||
public DateTime? LastLoginTime;
|
||||
#region EQ override
|
||||
|
||||
public bool Equals(ScrollViewItemInfo other)
|
||||
{
|
||||
return Type == other.Type && PlayfabId == other.PlayfabId && Title == other.Title;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is ScrollViewItemInfo other && Equals(other);
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine((int)Type, PlayfabId, AvatarUrl, DisplayName, Level,
|
||||
Title, LastLoginTime);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public enum EScrollViewType
|
||||
{
|
||||
Title,
|
||||
Recommendation,
|
||||
Friend,
|
||||
Partner2Accept,
|
||||
MyInvitation
|
||||
}
|
||||
}
|
||||
|
||||
public class EventPartnerRemoveScrollViewItem
|
||||
{
|
||||
public EventPartnerScrollViewItem.ScrollViewItemInfo Info;
|
||||
}
|
||||
|
||||
public class EventPartnerClickAccept
|
||||
{
|
||||
public EventPartnerScrollViewItem.ScrollViewItemInfo Info;
|
||||
}
|
||||
|
||||
public class EventPartnerClickInvite
|
||||
{
|
||||
public EventPartnerScrollViewItem.ScrollViewItemInfo Info;
|
||||
}
|
||||
|
||||
public class EventPartnerClickIgnore
|
||||
{
|
||||
public EventPartnerScrollViewItem.ScrollViewItemInfo Info;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0270f40a0b9554449b2f3ddc4e2c96e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventPartnerScrollViewTitle : EnhancedScrollerCellView
|
||||
{
|
||||
public TMP_Text textTitle;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e63f8379eb94c544ac9b0b317d5301f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Scripts/UI/PartnerFishBowl/EventPartnerTips.cs
Normal file
39
Assets/Scripts/UI/PartnerFishBowl/EventPartnerTips.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Design;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventPartnerTips : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button btnClose;
|
||||
[SerializeField] private GameObject mainTip, buildBtnTip, buildTip;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btnClose.onClick.AddListener(() => gameObject.SetActive(false));
|
||||
}
|
||||
|
||||
public void ShowMainTip()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
mainTip.SetActive(true);
|
||||
buildBtnTip.SetActive(false);
|
||||
buildTip.SetActive(false);
|
||||
}
|
||||
public void ShowBuildBtnTip()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
mainTip.SetActive(false);
|
||||
buildBtnTip.SetActive(true);
|
||||
buildTip.SetActive(false);
|
||||
}
|
||||
public void ShowBuildTip()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
mainTip.SetActive(false);
|
||||
buildBtnTip.SetActive(false);
|
||||
buildTip.SetActive(true);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerTips.cs.meta
Normal file
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerTips.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdf33627f159aa74683017ff5a99fee4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Scripts/UI/PartnerFishBowl/EventPartnerWheel.cs
Normal file
18
Assets/Scripts/UI/PartnerFishBowl/EventPartnerWheel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventPartnerWheel : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerWheel.cs.meta
Normal file
11
Assets/Scripts/UI/PartnerFishBowl/EventPartnerWheel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afb4b3650a50b714f9e718372017f946
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/Scripts/UI/PartnerFishBowl/EventPartnerWheelPiece.cs
Normal file
41
Assets/Scripts/UI/PartnerFishBowl/EventPartnerWheelPiece.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventPartnerWheelPiece : MonoBehaviour
|
||||
{
|
||||
private Image _imgBg, _imgBgShow;
|
||||
private TMP_Text _textScore, _textScoreShow;
|
||||
[SerializeField] private Animation animationShow;
|
||||
private void Awake()
|
||||
{
|
||||
_imgBg = transform.Find("bg").GetComponent<Image>();
|
||||
_textScore = transform.Find("text_beilv").GetComponent<TMP_Text>();
|
||||
_imgBgShow = animationShow.transform.Find("bg").GetComponent<Image>();
|
||||
_textScoreShow = animationShow.transform.Find("text_beilv").GetComponent<TMP_Text>();
|
||||
}
|
||||
public void Init(string bgUrl, int score, EventPartnerAct.Context ctx)
|
||||
{
|
||||
// Debug.Log(bgUrl);
|
||||
// Debug.Log(score);
|
||||
// GContext.container.Resolve<IUIService>().SetImageSprite(_imgBg, bgUrl);
|
||||
_imgBg.sprite = ctx.GetSprite(bgUrl);
|
||||
_textScore.text = score.ToString();
|
||||
_imgBgShow.sprite = ctx.GetSprite(bgUrl);
|
||||
_textScoreShow.text = score.ToString();
|
||||
animationShow.Rewind();
|
||||
}
|
||||
|
||||
public void SetScore(int score)
|
||||
{
|
||||
_textScore.text = score.ToString();
|
||||
_textScoreShow.text = score.ToString();
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task PlayShow()
|
||||
{
|
||||
animationShow.Play("turntable_reward");
|
||||
// float time = animationShow["turntable_reward"].length;
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(48f / 60f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 814425847a12ca545b037eff8d650798
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user