备份CatanBuilding瘦身独立工程
This commit is contained in:
78
Assets/Scripts/Aquarium/UI/AquariumBtnGift.cs
Normal file
78
Assets/Scripts/Aquarium/UI/AquariumBtnGift.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumBtnGift : MonoBehaviour
|
||||
{
|
||||
Button btn_enter;
|
||||
TMP_Text text_time;
|
||||
TriggerPackData triggerPackData;
|
||||
TriggerPackBuyData triggerPack;
|
||||
private void Awake()
|
||||
{
|
||||
triggerPackData = GContext.container.Resolve<TriggerPackData>();
|
||||
btn_enter = GetComponent<Button>();
|
||||
text_time = transform.Find("text_time").GetComponent<TMP_Text>();
|
||||
var triggerPackDic = triggerPackData.GetTriggerPackList(6);
|
||||
if (triggerPackDic.Count <= 0)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
triggerPack = triggerPackDic[0];
|
||||
TimeSpan now = triggerPackData.GetCurTriggerPackEndTime(triggerPack);
|
||||
if (now.TotalSeconds < 0)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (triggerPack != null)
|
||||
{
|
||||
SetEndTime();
|
||||
}
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_enter.onClick.AddListener(OnClick);
|
||||
}
|
||||
async void OnClick()
|
||||
{
|
||||
btn_enter.enabled = false;
|
||||
await UIManager.Instance.ShowUILoad(UITypes.AquariumGiftPopupPanel);
|
||||
btn_enter.enabled = true;
|
||||
}
|
||||
|
||||
void SetEndTime()
|
||||
{
|
||||
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime endTime = GlobalUtils.TryParseDateTime(triggerPack.time, curTime);
|
||||
TimeSpan now = endTime - curTime;
|
||||
double seconds = now.TotalSeconds;
|
||||
if (seconds < 1)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AttachTimer((float)seconds,
|
||||
() => { gameObject.SetActive(false); },
|
||||
(elapsed) =>
|
||||
{
|
||||
if (triggerPack.index > 0)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}, useRealTime: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumBtnGift.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumBtnGift.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f643b7e30fa9b9418a3bf5d9a4f423c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/Aquarium/UI/AquariumCardWeight.cs
Normal file
14
Assets/Scripts/Aquarium/UI/AquariumCardWeight.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumCardWeight : MonoBehaviour
|
||||
{
|
||||
public Image icon;
|
||||
public TMP_Text text_level;
|
||||
private void Reset()
|
||||
{
|
||||
icon = transform.Find("icon").GetComponent<Image>();
|
||||
text_level = transform.Find("text_level").GetComponent<TMP_Text>();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumCardWeight.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumCardWeight.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d170e163d7f296945b780b5edae26151
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
149
Assets/Scripts/Aquarium/UI/AquariumCloudPanel.cs
Normal file
149
Assets/Scripts/Aquarium/UI/AquariumCloudPanel.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using cfg;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class AquariumCloudPanel : MonoBehaviour
|
||||
{
|
||||
Animation ani;
|
||||
IDisposable disposable;
|
||||
Image image_map;
|
||||
TMP_Text text_map;
|
||||
TMP_Text text_level;
|
||||
AquariumManagerData data;
|
||||
int type = 0;
|
||||
|
||||
AudioClip doorvault_gear;
|
||||
Sound sound_doorvault_gear;
|
||||
private void Awake()
|
||||
{
|
||||
ani = GetComponent<Animation>();
|
||||
disposable = GContext.OnEvent<EndTransition>().Subscribe(EndTransition);
|
||||
image_map = transform.Find("RandomMapPanel/Item/img_map").GetComponent<Image>();
|
||||
text_map = transform.Find("RandomMapPanel/result/text_map").GetComponent<TMP_Text>();
|
||||
text_level = transform.Find("RandomMapPanel/result/fishcard/text_level").GetComponent<TMP_Text>();
|
||||
|
||||
type = FishingAquariumAct.CloudType;
|
||||
StartCoroutine(OnStart());
|
||||
Synchrodata();
|
||||
}
|
||||
void Synchrodata()
|
||||
{
|
||||
//从服务器拿数据
|
||||
string dataStr = PlayFabMgr.Instance.GetLocalData(AquariumManager.AquariumEventDataKey);
|
||||
if (!string.IsNullOrEmpty(dataStr))
|
||||
{
|
||||
data = Newtonsoft.Json.JsonConvert.DeserializeObject<AquariumManagerData>(dataStr);
|
||||
if (data != null)
|
||||
{
|
||||
Tables _tables = GContext.container.Resolve<Tables>();
|
||||
var mapData = _tables.TbMapData.DataMap[data.mapId];
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(image_map, mapData.Bg);
|
||||
text_map.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
string levelLV = LocalizationMgr.GetText("UI_FishingMapPanel_101006");
|
||||
int fishCardLevel = GContext.container.Resolve<PlayerFishData>().GetFishLevelByMap(data.mapId);
|
||||
text_level.text = levelLV + fishCardLevel.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
IEnumerator OnStart()
|
||||
{
|
||||
string cloud_in = "aquarium_cloud_in_2";
|
||||
float time = 0.75f;
|
||||
switch (type)
|
||||
{
|
||||
case 2:
|
||||
cloud_in = "aquarium_cloud_in_3";
|
||||
time = 1.25f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (disposable != null)
|
||||
{
|
||||
ani.Play(cloud_in);
|
||||
|
||||
}
|
||||
yield return new WaitForSeconds(time);//入场动画播完
|
||||
PlayRodAudio("audio_ui_aquarium_doorvault_gear");
|
||||
if (disposable != null)
|
||||
{
|
||||
ani.Play("aquarium_cloud_loop_2");
|
||||
}
|
||||
}
|
||||
|
||||
void StopRodAudio()
|
||||
{
|
||||
if (doorvault_gear)
|
||||
{
|
||||
Addressables.Release(doorvault_gear);
|
||||
doorvault_gear = null;
|
||||
}
|
||||
if (sound_doorvault_gear)
|
||||
{
|
||||
sound_doorvault_gear.audioSource.Stop();
|
||||
sound_doorvault_gear.ReturnPool();
|
||||
sound_doorvault_gear = null;
|
||||
}
|
||||
}
|
||||
async void PlayRodAudio(string audioName)
|
||||
{
|
||||
StopRodAudio();
|
||||
doorvault_gear = await Addressables.LoadAssetAsync<AudioClip>(audioName).Task;
|
||||
if (disposable == null)
|
||||
{
|
||||
if (doorvault_gear)
|
||||
{
|
||||
Addressables.Release(doorvault_gear);
|
||||
doorvault_gear = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
sound_doorvault_gear = GContext.container.Resolve<ISoundService>().GetNewUISound(doorvault_gear);
|
||||
sound_doorvault_gear.audioSource.Play();
|
||||
sound_doorvault_gear.audioSource.loop = true;
|
||||
}
|
||||
public void EndTransition(EndTransition endTransition)
|
||||
{
|
||||
StartCoroutine(End());
|
||||
StopRodAudio();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
IEnumerator End()
|
||||
{
|
||||
string cloud_out = "aquarium_cloud_out_2";
|
||||
float time = 1.25f;
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
case 5:
|
||||
cloud_out = "aquarium_cloud_out_3";
|
||||
time = 0.866f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
image_map.gameObject.SetActive(false);
|
||||
ani.Play(cloud_out);
|
||||
Dispose();
|
||||
yield return new WaitForSeconds(time);//退场动画播完
|
||||
UIManager.Instance.DestroyUI(UITypes.AquariumCloudPanel);
|
||||
}
|
||||
void Dispose()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumCloudPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumCloudPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b23b723950eb39646945ef78c6ba02d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/Scripts/Aquarium/UI/AquariumDetectEgg.cs
Normal file
60
Assets/Scripts/Aquarium/UI/AquariumDetectEgg.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumDetectEgg : MonoBehaviour
|
||||
{
|
||||
RectTransform Content;
|
||||
GameObject icon_item;
|
||||
int allCount = 5;
|
||||
float height;
|
||||
int maIndex = 2;
|
||||
int curAllCount;
|
||||
IUIService uIService;
|
||||
private void Init()
|
||||
{
|
||||
uIService = GContext.container.Resolve<IUIService>();
|
||||
Content = transform.Find("Viewport/Content").GetComponent<RectTransform>();
|
||||
icon_item = transform.Find("Viewport/Content/Item").gameObject;
|
||||
height = icon_item.GetComponent<RectTransform>().rect.height;
|
||||
icon_item.SetActive(false);
|
||||
}
|
||||
public void SetIcon(List<string> iconNameList, string curIcon, int index)
|
||||
{
|
||||
Init();
|
||||
curAllCount = 0;
|
||||
//List<string> 得到一个新的随机顺序的列表
|
||||
string str;
|
||||
string curStr = curIcon;
|
||||
allCount += index;
|
||||
for (int i = 0; i < allCount + maIndex; i++)
|
||||
{
|
||||
str = iconNameList[Random.Range(0, iconNameList.Count)];
|
||||
SetMapBg(str);
|
||||
}
|
||||
SetMapBg(curStr);
|
||||
SetMapBg(iconNameList[Random.Range(0, iconNameList.Count)]);
|
||||
}
|
||||
void SetMapBg(string bg)
|
||||
{
|
||||
GameObject go = Instantiate(icon_item, Content);
|
||||
Image image = go.transform.GetChild(0).GetComponent<Image>();
|
||||
go.SetActive(true);
|
||||
uIService.SetImageSprite(image, bg);
|
||||
curAllCount++;
|
||||
}
|
||||
public void Play()
|
||||
{
|
||||
var sequence = DOTween.Sequence();
|
||||
sequence.Append(Content.DOAnchorPosY(allCount * height, 0.08f * allCount).SetLoops(2, LoopType.Restart).SetEase(Ease.Linear));
|
||||
|
||||
//跑马灯动画
|
||||
float index2 = allCount + maIndex + Random.Range(-0.5f, 0.5f);
|
||||
sequence.Append(Content.DOAnchorPosY(index2 * height, 0.2f).SetEase(Ease.Linear));
|
||||
sequence.Append(Content.DOAnchorPosY((allCount + maIndex) * height, 0.2f).SetEase(Ease.InSine));
|
||||
sequence.Play();
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumDetectEgg.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumDetectEgg.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8158707274832642816f337e0982f45
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
275
Assets/Scripts/Aquarium/UI/AquariumDetectPanel.cs
Normal file
275
Assets/Scripts/Aquarium/UI/AquariumDetectPanel.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumDetectPanel : BasePanel
|
||||
{
|
||||
AquariumManager AM;
|
||||
Animation anim;
|
||||
Button btn_close;
|
||||
Button btn_enter;
|
||||
Button btn_enter_gray;
|
||||
TMP_Text text_info;
|
||||
TMP_Text text_time;
|
||||
Button btn_event;
|
||||
GameObject event_redpoint;
|
||||
Button btn_slot;
|
||||
TMP_Text text_num_slot;
|
||||
GameObject slot_redpoint;
|
||||
GameObject slot_tips;
|
||||
TMP_Text text_title_tips;
|
||||
TMP_Text text_title_info;
|
||||
Button btn_questionmark;
|
||||
|
||||
AquariumRandomMapPanel randomMapPanel;
|
||||
int maxSlot = 6;
|
||||
DateTime refreshTime;
|
||||
bool isCutTo = false;
|
||||
|
||||
AudioClip doorvault_gear;
|
||||
Sound sound_doorvault_gear;
|
||||
AudioClip searchingroll_single;
|
||||
Sound sound_searchingroll_single;
|
||||
string audioName;
|
||||
int refreshTimeInt;
|
||||
private void Awake()
|
||||
{
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
anim = GetComponent<Animation>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_enter = transform.Find("root_main/btn_enter/btn_green").GetComponent<Button>();
|
||||
btn_enter_gray = transform.Find("root_main/btn_enter_gray/btn_green").GetComponent<Button>();
|
||||
text_info = transform.Find("root_main/btn_enter_gray/text_info").GetComponent<TMP_Text>();
|
||||
text_time = transform.Find("root_main/text_time").GetComponent<TMP_Text>();
|
||||
btn_event = transform.Find("root_main/btn_event").GetComponent<Button>();
|
||||
event_redpoint = transform.Find("root_main/btn_event/redpoint").gameObject;
|
||||
btn_slot = transform.Find("root_main/btn_slot").GetComponent<Button>();
|
||||
text_num_slot = transform.Find("root_main/btn_slot/text_num").GetComponent<TMP_Text>();
|
||||
slot_redpoint = transform.Find("root_main/btn_slot/redpoint").gameObject;
|
||||
slot_tips = transform.Find("root_main/slot_tips").gameObject;
|
||||
text_title_tips = transform.Find("root_main/slot_tips/text_title").GetComponent<TMP_Text>();
|
||||
text_title_info = transform.Find("root_main/slot_tips/text_info").GetComponent<TMP_Text>();
|
||||
btn_questionmark = transform.Find("root_main/title/btn_questionmark").GetComponent<Button>();
|
||||
|
||||
randomMapPanel = transform.Find("RandomMapPanel").GetComponent<AquariumRandomMapPanel>();
|
||||
event_redpoint.SetActive(false);
|
||||
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("AquariumDetectPanel");
|
||||
|
||||
//randomMapPanel.gameObject.SetActive(false);
|
||||
base.Start();
|
||||
btn_event.onClick.AddListener(OnClickEvent);
|
||||
btn_enter.onClick.AddListener(OnClickMaching);
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_questionmark.onClick.AddListener(async () =>
|
||||
await UIManager.Instance.ShowUI(UITypes.AquariumInfoPopupPanel));
|
||||
btn_slot.onClick.AddListener(() => slot_tips.SetActive(!slot_tips.activeSelf));
|
||||
int Slot = GContext.container.Resolve<PlayerData>().benefitsAquariumLimit;
|
||||
text_num_slot.text = $"{Slot}/{maxSlot}";
|
||||
text_title_tips.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_2", $"{Slot}/{maxSlot}");
|
||||
if (Slot == maxSlot)
|
||||
{
|
||||
text_title_info.text = LocalizationMgr.GetText("UI_AquariumPanel_4");
|
||||
}
|
||||
else
|
||||
{
|
||||
int level = GContext.container.Resolve<PlayerData>().benefitsLevel[6];
|
||||
var Benefits = GContext.container.Resolve<Tables>().TBBenefits.GetOrDefault(7);
|
||||
if (Benefits == null || level + 1 >= Benefits.AccountLevel.Count)
|
||||
{
|
||||
Debug.LogError("No account data AquariumLimit up");
|
||||
}
|
||||
else
|
||||
{
|
||||
text_title_info.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_3", Benefits.AccountLevel[level + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
var nowTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
refreshTime = nowTime.Date.AddDays(1);
|
||||
if (nowTime.Date.DayOfYear != AM.data.refreshDay)
|
||||
{
|
||||
AM.data.refreshCount = 0;
|
||||
AM.data.adCount = 0;
|
||||
AM.data.refreshDay = nowTime.Date.DayOfYear;
|
||||
}
|
||||
|
||||
refreshTimeInt = GContext.container.Resolve<Tables>().TbAquariumConfig.RefreshTime;
|
||||
bool isRefresh = AM.data.refreshCount < refreshTimeInt;
|
||||
if (!isRefresh)
|
||||
{
|
||||
ShowInfo();
|
||||
}
|
||||
btn_enter.transform.parent.gameObject.SetActive(isRefresh);
|
||||
btn_enter_gray.transform.parent.gameObject.SetActive(!isRefresh);
|
||||
text_time.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_44", refreshTimeInt - AM.data.refreshCount, refreshTimeInt);
|
||||
}
|
||||
|
||||
void ShowInfo()
|
||||
{
|
||||
//剩余时间
|
||||
TimeSpan duration = refreshTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
string textValue = LocalizationMgr.GetText("UI_AquariumPanel_7");
|
||||
text_info.text = string.Format(textValue, ConvertTools.ConvertTime2(duration));
|
||||
var timer = Observable.Interval(TimeSpan.FromSeconds(1))
|
||||
.TakeWhile(seconds => seconds <= duration.TotalSeconds)
|
||||
.Subscribe(seconds => text_info.text =
|
||||
string.Format(textValue, ConvertTools.ConvertTime2(duration.Subtract(TimeSpan.FromSeconds(seconds))))
|
||||
, Refresh)
|
||||
.AddTo(disposables);
|
||||
}
|
||||
void Refresh()
|
||||
{
|
||||
AM.data.adCount = 0;
|
||||
AM.data.refreshCount = 0;
|
||||
AM.data.refreshDay = ZZTimeHelper.UtcNow().UtcNowOffset().Date.DayOfYear;
|
||||
text_time.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_44", refreshTimeInt, refreshTimeInt);
|
||||
btn_enter.transform.parent.gameObject.SetActive(true);
|
||||
btn_enter_gray.transform.parent.gameObject.SetActive(false);
|
||||
}
|
||||
void OnClickEvent()
|
||||
{
|
||||
_ = UIManager.Instance.ShowUI(UITypes.EventReportPopupPanel);
|
||||
}
|
||||
|
||||
async void GetSearchingrollSingle()
|
||||
{
|
||||
searchingroll_single = await Addressables.LoadAssetAsync<AudioClip>("audio_ui_aquarium_doorvault_searchingroll_single").Task;
|
||||
if (searchingroll_single != null && this != null)
|
||||
{
|
||||
sound_searchingroll_single = GContext.container.Resolve<ISoundService>().GetNewUISound(searchingroll_single);
|
||||
}
|
||||
}
|
||||
|
||||
IDisposable enterMap;
|
||||
void OnClickMaching()
|
||||
{
|
||||
StartCoroutine(StartClickMaching());
|
||||
}
|
||||
IEnumerator StartClickMaching()
|
||||
{
|
||||
//randomMapPanel.gameObject.SetActive(true);
|
||||
anim.Play("match_map_start");
|
||||
yield return new WaitForSeconds(1);
|
||||
PlayRodAudio("audio_ui_fishingduel_matchingloop");
|
||||
randomMapPanel.SetMap();
|
||||
enterMap = FishingAquariumAct.eventAggregator.GetEvent<EnterMaped>().Subscribe(EnterMaped);
|
||||
randomMapPanel.InitEgg();
|
||||
FishingAquariumAct.eventAggregator.Publish(new AquariumEnterMapScene());
|
||||
yield return new WaitForSeconds(3);
|
||||
StopRodAudio();
|
||||
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
|
||||
anim.Play("match_egg_start");
|
||||
GetSearchingrollSingle();
|
||||
yield return new WaitForSeconds(1);
|
||||
PlayRodAudio("audio_ui_aquarium_doorvault_searchingroll_loop");
|
||||
randomMapPanel.PlayEgg();
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
StopRodAudio();
|
||||
for (int i = 1; i < AM.Slot; i++)
|
||||
{
|
||||
yield return new WaitForSeconds(0.16f);
|
||||
if (sound_searchingroll_single != null)
|
||||
{
|
||||
sound_searchingroll_single.audioSource.Play();
|
||||
}
|
||||
}
|
||||
anim.Play("aquarium_cloud_in");
|
||||
yield return new WaitForSeconds(3.5f);
|
||||
PlayRodAudio("audio_ui_aquarium_doorvault_gear");
|
||||
anim.Play("aquarium_cloud_loop");
|
||||
randomMapPanel.HideMap();
|
||||
yield return new WaitForSeconds(1f);
|
||||
OnClose();
|
||||
}
|
||||
void StopRodAudio()
|
||||
{
|
||||
if (doorvault_gear)
|
||||
{
|
||||
Addressables.Release(doorvault_gear);
|
||||
doorvault_gear = null;
|
||||
}
|
||||
if (sound_doorvault_gear)
|
||||
{
|
||||
sound_doorvault_gear.audioSource.Stop();
|
||||
sound_doorvault_gear.ReturnPool();
|
||||
sound_doorvault_gear = null;
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
this.audioName = "";
|
||||
StopRodAudio();
|
||||
|
||||
if (searchingroll_single)
|
||||
{
|
||||
Addressables.Release(searchingroll_single);
|
||||
searchingroll_single = null;
|
||||
}
|
||||
if (sound_searchingroll_single)
|
||||
{
|
||||
sound_searchingroll_single.audioSource.Stop();
|
||||
sound_searchingroll_single.ReturnPool();
|
||||
sound_searchingroll_single = null;
|
||||
}
|
||||
}
|
||||
async void PlayRodAudio(string audioName)
|
||||
{
|
||||
this.audioName = audioName;
|
||||
StopRodAudio();
|
||||
var local_doorvault_gear = await Addressables.LoadAssetAsync<AudioClip>(audioName).Task;
|
||||
if (local_doorvault_gear == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.audioName != audioName)
|
||||
{
|
||||
Addressables.Release(local_doorvault_gear);
|
||||
return;
|
||||
}
|
||||
doorvault_gear = local_doorvault_gear;
|
||||
sound_doorvault_gear = GContext.container.Resolve<ISoundService>().GetNewUISound(doorvault_gear);
|
||||
sound_doorvault_gear.audioSource.Play();
|
||||
sound_doorvault_gear.audioSource.loop = true;
|
||||
}
|
||||
void EnterMaped(EnterMaped enterMaped)
|
||||
{
|
||||
enterMap?.Dispose();
|
||||
enterMap = null;
|
||||
OnClose();
|
||||
}
|
||||
|
||||
async void OnClose()
|
||||
{
|
||||
if (isCutTo)
|
||||
{
|
||||
StopRodAudio();
|
||||
anim.Play("aquarium_cloud_out");
|
||||
FishingAquariumAct.eventAggregator.Publish(new AquariumEnterMapScene() { isShowUI = true });
|
||||
await Awaiters.Seconds(2.0f);
|
||||
UIManager.Instance.DestroyUI(UITypes.AquariumDetectPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
isCutTo = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickClose()
|
||||
{
|
||||
FishingAquariumAct.CloudType = 2;
|
||||
GContext.Publish(new UnloadActToNextAct(transitionPanel: UITypes.AquariumCloudPanel, time: 1.25f));
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumDetectPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumDetectPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9530c5e1797998d4e8eae671d2b7baf3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
88
Assets/Scripts/Aquarium/UI/AquariumEggTips.cs
Normal file
88
Assets/Scripts/Aquarium/UI/AquariumEggTips.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumEggTips : MonoBehaviour, IAquariumTips
|
||||
{
|
||||
public Image icon;
|
||||
public TMP_Text text_name;
|
||||
public Image bar;
|
||||
public TMP_Text text_time;
|
||||
public Button btn_speedup;
|
||||
public GameObject[] card_info;
|
||||
AquariumSlotData slotData;
|
||||
AquariumSlot aquariumSlot;
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
gameObject.SetActive(value);
|
||||
}
|
||||
public void SetData(AquariumSlot aquariumSlot)
|
||||
{
|
||||
this.aquariumSlot = aquariumSlot;
|
||||
this.slotData = aquariumSlot.slotData;
|
||||
|
||||
for (int i = 0; i < card_info.Length; i++)
|
||||
{
|
||||
card_info[i].SetActive(false);
|
||||
}
|
||||
|
||||
UpdateBar(ZZTimeHelper.UtcNow());
|
||||
|
||||
AquariumEgg aquariumEgg = GContext.container.Resolve<Tables>().TbAquariumEgg.GetOrDefault(slotData.eggId);
|
||||
|
||||
if (aquariumEgg != null)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetText(aquariumEgg.Name_l10n_key);
|
||||
var quantity = aquariumEgg.HatchFishQuantity;
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, aquariumEgg.Icon);
|
||||
|
||||
List<int> hatchFishQuality = aquariumEgg.HatchFishQuality;
|
||||
bool showNum = false;
|
||||
int max = 1;
|
||||
int min = hatchFishQuality[0];
|
||||
if (hatchFishQuality.Count > 1)
|
||||
{
|
||||
showNum = true;
|
||||
max = hatchFishQuality[^1];
|
||||
}
|
||||
int index = 0;
|
||||
TMP_Text text_fish_num;
|
||||
for (int i = 0; i < hatchFishQuality.Count; i++)
|
||||
{
|
||||
index = hatchFishQuality[i] - 1;
|
||||
if (index < card_info.Length)
|
||||
{
|
||||
card_info[index].SetActive(true);
|
||||
text_fish_num = card_info[index].transform.Find("text_fish_num").GetComponent<TMP_Text>();
|
||||
if (showNum)
|
||||
{
|
||||
text_fish_num.text = $"{min}~{max}";
|
||||
}
|
||||
else
|
||||
{
|
||||
text_fish_num.text = min.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateBar(DateTime dateTime)
|
||||
{
|
||||
float time = (float)(dateTime - slotData.startTime).TotalHours + slotData.accelerationHatch;
|
||||
bar.fillAmount = time / slotData.hatchTime;
|
||||
int timeRemaining = (int)((slotData.hatchTime - time) * 3600);
|
||||
if (timeRemaining <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
||||
text_time.text = ConvertTools.ConvertTime2(timeSpan);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumEggTips.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumEggTips.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55501fec551954c42a9d89432530e7da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
200
Assets/Scripts/Aquarium/UI/AquariumFishTips.cs
Normal file
200
Assets/Scripts/Aquarium/UI/AquariumFishTips.cs
Normal file
@@ -0,0 +1,200 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using GameCore;
|
||||
|
||||
public class AquariumFishTips : MonoBehaviour, IAquariumTips
|
||||
{
|
||||
public Image icon;
|
||||
public Image tag_fish;
|
||||
public TMP_Text text_name;
|
||||
public Image bar;
|
||||
public Image bar_hurt;
|
||||
public TMP_Text text_time;
|
||||
public GameObject recoverting;
|
||||
public TMP_Text text_time2;
|
||||
public GameObject killed;
|
||||
public GameObject sold;
|
||||
public TMP_Text text_killed;
|
||||
public GameObject text_max;
|
||||
public Button btn_speedup;
|
||||
public Button btn_sell;
|
||||
public TMP_Text text_cash;
|
||||
public GameObject mutated;
|
||||
public TMP_Text fishcard;
|
||||
AquariumSlotData slotData;
|
||||
Item item;
|
||||
FishData fishData;
|
||||
AquariumSlot aquariumSlot;
|
||||
AquariumFish aquariumFish;
|
||||
AquariumManager AM;
|
||||
Tables _tables;
|
||||
|
||||
DateTime StartTime;
|
||||
float injuryH;
|
||||
float allRewardCount;
|
||||
float baseRewardCount;
|
||||
float WeightIncEvent;
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
gameObject.SetActive(value);
|
||||
}
|
||||
public void SetData(AquariumSlot aquariumSlot)
|
||||
{
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
this.aquariumSlot = aquariumSlot;
|
||||
this.slotData = aquariumSlot.slotData;
|
||||
item = _tables.TbItem.GetOrDefault(slotData.fishItemID);
|
||||
fishData = _tables.TbFishData.GetOrDefault(item.RedirectID);
|
||||
aquariumFish = _tables.TbAquariumFish.GetOrDefault(slotData.aquariumFishID);
|
||||
StartTime = slotData.FishHatchTime();
|
||||
injuryH = slotData.injuryGrowthTime;
|
||||
mutated.SetActive(slotData.mutants > 0);
|
||||
text_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(tag_fish, "icon_fish_rate_tag_" + item.Quality);
|
||||
PlayerFishData.SetFishIcon(icon, item);//鱼头像
|
||||
|
||||
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||||
var weights = GContext.container.Resolve<AquariumManager>().GetWeightMag();
|
||||
float weight = weights[slotData.aquariumFishID - 1];
|
||||
fishcard.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_40", weight.ToPercentageString());
|
||||
WeightIncEvent = (1 + weight) * (1 + playerData.benefitsCashMag) * (1 + playerData.benefitsAquariumCashMag);
|
||||
|
||||
baseRewardCount = slotData.allCash;
|
||||
allRewardCount = 0;
|
||||
int fishQ = slotData.fishMQ;
|
||||
for (int i = 0; i < fishQ; i++)
|
||||
{
|
||||
if (slotData.mutants > i)
|
||||
{
|
||||
allRewardCount += baseRewardCount * WeightIncEvent * (1 + aquariumFish.MutantGrowthExtraSoldReward) * (1 + aquariumFish.MutantExtraSoldReward);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRewardCount += baseRewardCount * WeightIncEvent * (1 + aquariumFish.GrowthExtraSoldReward);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateBar(ZZTimeHelper.UtcNow());
|
||||
}
|
||||
|
||||
|
||||
public bool UpdateBar(DateTime dateTime)
|
||||
{
|
||||
//正常的成长进度 自然时间+加速成长 - 全部恢复时间
|
||||
float normalH = (float)(dateTime - StartTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
||||
|
||||
//受伤时的成长进度加上本次恢复时间大于正常的成长进度
|
||||
bar_hurt.gameObject.SetActive(false);
|
||||
text_time.gameObject.SetActive(true);
|
||||
recoverting.gameObject.SetActive(false);
|
||||
text_max.gameObject.SetActive(false);
|
||||
btn_speedup.gameObject.SetActive(true);
|
||||
btn_sell.gameObject.SetActive(false);
|
||||
killed.SetActive(false);
|
||||
sold.SetActive(false);
|
||||
float timeProgress = 1;
|
||||
|
||||
if (aquariumSlot.slotState == 5)
|
||||
{
|
||||
bar.transform.parent.gameObject.SetActive(false);
|
||||
killed.SetActive(true);
|
||||
btn_speedup.gameObject.SetActive(false);
|
||||
text_time.gameObject.SetActive(false);
|
||||
AquariumResultData aquariumResultDatas = AM.data.aquariumResultDatas[slotData.index];
|
||||
text_killed.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_42", aquariumResultDatas.displayName);
|
||||
text_cash.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_26", $"{0}/{ConvertTools.GetNumberString2((int)allRewardCount)}");
|
||||
return false;
|
||||
}
|
||||
else if (aquariumSlot.slotState == 4)
|
||||
{
|
||||
bar.transform.parent.gameObject.SetActive(false);
|
||||
sold.SetActive(true);
|
||||
btn_speedup.gameObject.SetActive(false);
|
||||
text_time.gameObject.SetActive(false);
|
||||
text_cash.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_26", $"{ConvertTools.GetNumberString2(slotData.cash)}/{ConvertTools.GetNumberString2((int)allRewardCount)}");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
bar.transform.parent.gameObject.SetActive(true);
|
||||
timeProgress = normalH / slotData.growthTime;
|
||||
bar.fillAmount = 1;
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
text_time.gameObject.SetActive(false);
|
||||
recoverting.gameObject.SetActive(true);
|
||||
bar_hurt.gameObject.SetActive(true);
|
||||
bar_hurt.fillAmount = (injuryH - normalH) / slotData.recoveryTime;
|
||||
|
||||
int timeRemaining = (int)((injuryH - normalH) * 3600);
|
||||
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
||||
text_time2.text = ConvertTools.ConvertTime2(timeSpan);
|
||||
|
||||
if (injuryH / slotData.growthTime > 1)
|
||||
{
|
||||
timeProgress = 1 - ((injuryH - normalH) / slotData.growthTime);
|
||||
}
|
||||
bar.fillAmount = 0;
|
||||
}
|
||||
else if (normalH >= slotData.growthTime)
|
||||
{
|
||||
text_time.gameObject.SetActive(false);
|
||||
text_max.gameObject.SetActive(true);
|
||||
btn_speedup.gameObject.SetActive(false);
|
||||
btn_sell.gameObject.SetActive(true);
|
||||
timeProgress = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bar.fillAmount = normalH / slotData.growthTime;
|
||||
}
|
||||
|
||||
if (timeProgress < 1)
|
||||
{
|
||||
int timeRemaining = (int)(slotData.growthTime * (1 - timeProgress) * 3600);
|
||||
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
||||
text_time.text = ConvertTools.ConvertTime2(timeSpan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float rewardProgress = timeProgress;// normalH / slotData.growthTime;
|
||||
if (rewardProgress > 1)
|
||||
{
|
||||
rewardProgress = 1;
|
||||
}
|
||||
|
||||
//金币显示
|
||||
int fishQ = slotData.fishMQ;
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
fishQ -= GContext.container.Resolve<AquariumManager>().data.aquariumHurtDatas[slotData.index].fishLQ;
|
||||
if (fishQ <= 0)
|
||||
{
|
||||
fishQ = 1;
|
||||
}
|
||||
}
|
||||
float rewardCount = 0;
|
||||
for (int i = 0; i < fishQ; i++)
|
||||
{
|
||||
if (slotData.mutants > i)
|
||||
{
|
||||
rewardCount += baseRewardCount * (1 + aquariumFish.MutantExtraSoldReward) * (1 + aquariumFish.MutantGrowthExtraSoldReward * rewardProgress) * WeightIncEvent;
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardCount += baseRewardCount * (1 + aquariumFish.GrowthExtraSoldReward * rewardProgress) * WeightIncEvent;
|
||||
}
|
||||
}
|
||||
|
||||
text_cash.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_26", $"{ConvertTools.GetNumberString2((int)(rewardCount))}/{ConvertTools.GetNumberString2((int)allRewardCount)}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumFishTips.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumFishTips.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: daa217149732d6b40b4a1bfaaad0537d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Aquarium/UI/AquariumInfoPopupPanel.cs
Normal file
16
Assets/Scripts/Aquarium/UI/AquariumInfoPopupPanel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
private Button btnClose;
|
||||
private void Awake()
|
||||
{
|
||||
btnClose = transform.Find("btn_close").GetComponent<Button>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
btnClose.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.AquariumInfoPopupPanel));
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumInfoPopupPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumInfoPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a72a012b9cb7fc4abffc4d9e52d0ea7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
429
Assets/Scripts/Aquarium/UI/AquariumPanel.cs
Normal file
429
Assets/Scripts/Aquarium/UI/AquariumPanel.cs
Normal file
@@ -0,0 +1,429 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumPanel : BasePanel
|
||||
{
|
||||
Button btn_close;
|
||||
Button btn_event;
|
||||
Button btn_progress;
|
||||
Button btn_fishcard;
|
||||
TMP_Text text_level;
|
||||
Button btn_questionmark;
|
||||
Button btn_sell;
|
||||
Button btn_speedup;
|
||||
Head head;
|
||||
TMP_Text text_name;
|
||||
TMP_Text text_title;
|
||||
Button btn_close_tips;
|
||||
GameObject redpoint;
|
||||
AquariumManager AM;
|
||||
Tables tables;
|
||||
AquariumSlot[] aquariumSlot;
|
||||
bool updateBar = true;
|
||||
IUIService uIService;
|
||||
IAquariumTips aquariumTips;
|
||||
AquariumEggTips aquariumEggTips;
|
||||
AquariumFishTips aquariumFishTips;
|
||||
|
||||
AquariumSlot curAquariumSlot;
|
||||
|
||||
FishingAquariumAct fishingAquariumAct;
|
||||
|
||||
UIDrag moveCameraPanel;
|
||||
bool canDragMove = false;
|
||||
public bool CanDragMove => canDragMove;
|
||||
MapData mapData;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GContext.OnEvent<GetUIAsyncEvent>().Subscribe(GetUIAsyncEvent).AddTo(disposables);
|
||||
|
||||
GContext.OnEvent<ChangeMapDataAsyncEvent>().Subscribe(e =>
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.FishcardBenefitPopupPanel);
|
||||
GContext.container.Resolve<PlayerData>().SetCurrentMapId(e.mapID);
|
||||
OnClickClose();
|
||||
e.source?.SetResult(false);
|
||||
}).AddTo(disposables);
|
||||
transform.SetAsFirstSibling();
|
||||
reportService = GContext.container.Resolve<IReportService>();
|
||||
eventReport = transform.Find("root/Event_report").GetComponent<EventReport>();
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
uIService = GContext.container.Resolve<IUIService>();
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
text_name = transform.Find("root/title/bg/text_name").GetComponent<TMP_Text>();
|
||||
head = transform.Find("root/title/btn_head").GetComponent<Head>();
|
||||
btn_event = transform.Find("root/btn_event").GetComponent<Button>();
|
||||
btn_progress = transform.Find("root/btn_progress").GetComponent<Button>();
|
||||
btn_fishcard = transform.Find("root/btn_fishcard").GetComponent<Button>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_questionmark = transform.Find("root/title/btn_questionmark").GetComponent<Button>();
|
||||
text_level = transform.Find("root/btn_fishcard/text_level").GetComponent<TMP_Text>();
|
||||
aquariumSlot = transform.Find("root/partner").GetComponentsInChildren<AquariumSlot>();
|
||||
text_title = transform.Find("root/title/text_title").GetComponent<TMP_Text>();
|
||||
moveCameraPanel = transform.Find("moveCameraPanel").GetComponent<UIDrag>();
|
||||
redpoint = transform.Find("root/btn_fishcard/redpoint").gameObject;
|
||||
btn_sell = transform.Find("btn_2/btn_sell").GetComponent<Button>();
|
||||
btn_speedup = transform.Find("btn_2/btn_speedup").GetComponent<Button>();
|
||||
|
||||
aquariumEggTips = transform.Find("egg_tips").GetComponent<AquariumEggTips>();
|
||||
aquariumFishTips = transform.Find("fish_tips").GetComponent<AquariumFishTips>();
|
||||
btn_close_tips = transform.Find("btn_close_tips").GetComponent<Button>();
|
||||
SetMoveCameraPanel();
|
||||
}
|
||||
void SetMoveCameraPanel()
|
||||
{
|
||||
moveCameraPanel.OnPointerDownCall = () =>
|
||||
{
|
||||
canDragMove = true;
|
||||
};
|
||||
moveCameraPanel.OnPointerUpCall = () =>
|
||||
{
|
||||
canDragMove = false;
|
||||
};
|
||||
//moveCameraPanel.OnDragCall = (eventData) =>
|
||||
//{
|
||||
// Debug.Log(" Pointer OnDragCall");
|
||||
//};
|
||||
}
|
||||
void GetUIAsyncEvent(GetUIAsyncEvent data)
|
||||
{
|
||||
if (data.uIType == UITypes.FishingMapPanel.Name && !data.show)
|
||||
{
|
||||
SetRed();
|
||||
string levelLV = LocalizationMgr.GetText("UI_FishingMapPanel_101006");
|
||||
int fishCardLevel = GContext.container.Resolve<PlayerFishData>().GetFishLevelByMap(AM.MapId);
|
||||
text_level.text = levelLV + fishCardLevel.ToString();
|
||||
}
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
var fishingData = GContext.container.Resolve<FishingData>();
|
||||
|
||||
fishingData.MapId = AM.MapId;
|
||||
|
||||
updateBar = true;
|
||||
base.Start();
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("AquariumPanel");
|
||||
aquariumEggTips.btn_speedup.onClick.AddListener(OnClickSpeedup);
|
||||
aquariumFishTips.btn_speedup.onClick.AddListener(OnClickSpeedup);
|
||||
btn_speedup.onClick.AddListener(OnClickSpeedup);
|
||||
aquariumFishTips.btn_sell.onClick.AddListener(ShowFishSellingPopupPanel);
|
||||
btn_close_tips.onClick.AddListener(CloseTips);
|
||||
|
||||
btn_event.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventReportPopupPanel));
|
||||
btn_fishcard.onClick.AddListener(async () =>
|
||||
await UIManager.Instance.ShowUI(UITypes.FishcardBenefitPopupPanel));
|
||||
btn_sell.onClick.AddListener(ShowFishSellingPopupPanel);
|
||||
btn_progress.onClick.AddListener(OnClickProgress);
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_questionmark.onClick.AddListener(async () =>
|
||||
await UIManager.Instance.ShowUI(UITypes.AquariumInfoPopupPanel));
|
||||
text_name.text = GContext.container.Resolve<IUserService>().DisplayName;
|
||||
head.SetData(GContext.container.Resolve<IUserService>().AvatarUrl);
|
||||
|
||||
mapData = tables.TbMapData.GetOrDefault(AM.MapId);
|
||||
text_title.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
|
||||
string levelLV = LocalizationMgr.GetText("UI_FishingMapPanel_101006");
|
||||
int fishCardLevel = GContext.container.Resolve<PlayerFishData>().GetFishLevelByMap(AM.MapId);
|
||||
text_level.text = levelLV + fishCardLevel.ToString();
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow();
|
||||
Item item;
|
||||
AquariumEgg aquariumEgg;
|
||||
bool isShowSell = false;
|
||||
bool isShowSpeedup = false;
|
||||
for (int i = 0; i < aquariumSlot.Length; i++)
|
||||
{
|
||||
if (i < AM.Slot)
|
||||
{
|
||||
AquariumSlotData slotData = AM.data.slotDatas[i];
|
||||
if (slotData.startTime.AddHours(slotData.hatchTime - slotData.accelerationHatch) > dateTime)
|
||||
{
|
||||
aquariumEgg = tables.TbAquariumEgg.GetOrDefault(slotData.eggId);
|
||||
//还没孵化
|
||||
uIService.SetImageSprite(aquariumSlot[i].icon_egg, aquariumEgg.Icon);
|
||||
}
|
||||
|
||||
item = tables.TbItem.GetOrDefault(slotData.fishItemID);
|
||||
PlayerFishData.SetFishIcon(aquariumSlot[i].icon_fish, item);//鱼头像
|
||||
uIService.SetImageSprite(aquariumSlot[i].icon_rate, "icon_fish_rate_tag_" + item.Quality);
|
||||
aquariumSlot[i].InitSlot(i, slotData, OnClickSlot, OnFishStateChange);
|
||||
if (aquariumSlot[i].slotState == 2 || aquariumSlot[i].slotState == 3)
|
||||
{
|
||||
isShowSell = true;
|
||||
}
|
||||
if (aquariumSlot[i].slotState < 3)
|
||||
{
|
||||
isShowSpeedup = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aquariumSlot[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
btn_sell.gameObject.SetActive(isShowSell);
|
||||
btn_speedup.gameObject.SetActive(isShowSpeedup);
|
||||
AM.CheckInHome();
|
||||
NextReport();
|
||||
SetRed();
|
||||
}
|
||||
void SetRed()
|
||||
{
|
||||
bool isRedPoint = GContext.container.Resolve<PlayerFishData>().GetMapRed(mapData.FishList);
|
||||
redpoint.SetActive(isRedPoint);
|
||||
}
|
||||
public void OnUpdate(DateTime dateTime)
|
||||
{
|
||||
if (!updateBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < AM.Slot; i++)
|
||||
{
|
||||
aquariumSlot[i].UpdateBar(dateTime);
|
||||
}
|
||||
if (aquariumTips != null && curAquariumSlot != null && curAquariumSlot.slotState < 3)
|
||||
{
|
||||
aquariumTips.UpdateBar(dateTime);
|
||||
}
|
||||
}
|
||||
public void Init(FishingAquariumAct fishingAquariumAct)
|
||||
{
|
||||
this.fishingAquariumAct = fishingAquariumAct;
|
||||
}
|
||||
|
||||
async void ShowFishSellingPopupPanel()
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.FishSellingPopupPanel);
|
||||
FishSellingPopupPanel fishSellingPopupPanel = go.GetComponent<FishSellingPopupPanel>();
|
||||
fishSellingPopupPanel.Init(OnSellFish);
|
||||
aquariumFishTips.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
async void OnSellFish()
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.AquariumReportPopupPanel);
|
||||
AquariumReportPopupPanel aquariumReportPopupPanel = go.GetComponent<AquariumReportPopupPanel>();
|
||||
aquariumReportPopupPanel.InitData(fishingAquariumAct);
|
||||
OnFishStateChange();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鱼当前状态倒计时结束
|
||||
/// 售卖鱼刷新
|
||||
/// </summary>
|
||||
void OnFishStateChange()
|
||||
{
|
||||
bool isShowSell = false;
|
||||
bool isShowSpeedup = false;
|
||||
List<int> addFish = new List<int>();
|
||||
List<int> removeFish = new List<int>();
|
||||
for (int i = 0; i < AM.Slot; i++)
|
||||
{
|
||||
if (aquariumSlot[i].slotState > 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int oldState = aquariumSlot[i].slotState;
|
||||
aquariumSlot[i].SetState();
|
||||
if (oldState != aquariumSlot[i].slotState)
|
||||
{
|
||||
if (oldState == 1 && (aquariumSlot[i].slotState == 2 || aquariumSlot[i].slotState == 3))
|
||||
{
|
||||
//添加鱼
|
||||
addFish.Add(i);
|
||||
}
|
||||
else if (aquariumSlot[i].slotState == 4)
|
||||
{
|
||||
//删除鱼
|
||||
removeFish.Add(i);
|
||||
}
|
||||
}
|
||||
if (aquariumSlot[i].slotState == 2 || aquariumSlot[i].slotState == 3)
|
||||
{
|
||||
isShowSell = true;
|
||||
}
|
||||
if (aquariumSlot[i].slotState < 3)
|
||||
{
|
||||
isShowSpeedup = true;
|
||||
}
|
||||
}
|
||||
btn_sell.gameObject.SetActive(isShowSell);
|
||||
btn_speedup.gameObject.SetActive(isShowSpeedup);
|
||||
//修改显示的鱼
|
||||
if (removeFish.Count > 0 || addFish.Count > 0)
|
||||
{
|
||||
if (aquariumTips != null && curAquariumSlot != null)
|
||||
{
|
||||
bool isShow = aquariumTips.UpdateBar(ZZTimeHelper.UtcNow());
|
||||
if (!isShow)
|
||||
{
|
||||
CloseTips();
|
||||
}
|
||||
}
|
||||
ChangeFishEvent changeFishEvent = new ChangeFishEvent();
|
||||
changeFishEvent.addFish = addFish;
|
||||
changeFishEvent.removeFish = removeFish;
|
||||
FishingAquariumAct.eventAggregator.Publish(changeFishEvent);
|
||||
}
|
||||
}
|
||||
void CloseTips()
|
||||
{
|
||||
if (curAquariumSlot != null && aquariumTips != null)
|
||||
{
|
||||
curAquariumSlot.selected.SetActive(false);
|
||||
aquariumTips.SetActive(false);
|
||||
btn_close_tips.gameObject.SetActive(false);
|
||||
curAquariumSlot = null;
|
||||
aquariumTips = null;
|
||||
}
|
||||
fishingAquariumAct.StopFollowFishCamera();
|
||||
}
|
||||
|
||||
public void OnClickFish(int index)
|
||||
{
|
||||
if (index < aquariumSlot.Length)
|
||||
{
|
||||
OnClickSlot(aquariumSlot[index]);
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickSlot(AquariumSlot aquariumSlot)
|
||||
{
|
||||
if (curAquariumSlot != null && aquariumTips != null)
|
||||
{
|
||||
if (curAquariumSlot == aquariumSlot)
|
||||
{
|
||||
CloseTips();
|
||||
return;
|
||||
}
|
||||
curAquariumSlot.selected.SetActive(false);
|
||||
aquariumTips.SetActive(false);
|
||||
}
|
||||
curAquariumSlot = aquariumSlot;
|
||||
curAquariumSlot.selected.SetActive(true);
|
||||
AquariumSlotData slotData = aquariumSlot.slotData;
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow();
|
||||
bool isEgg = false;
|
||||
if (slotData.FishHatchTime() > dateTime)
|
||||
{
|
||||
//还没孵化
|
||||
isEgg = true;
|
||||
aquariumTips = aquariumEggTips;
|
||||
}
|
||||
else
|
||||
{
|
||||
//已经孵化
|
||||
aquariumTips = aquariumFishTips;
|
||||
}
|
||||
if (curAquariumSlot.slotState < 4)
|
||||
{
|
||||
fishingAquariumAct.FollowFishCamera(slotData, isEgg);
|
||||
}
|
||||
aquariumTips.SetActive(true);
|
||||
aquariumTips.SetData(curAquariumSlot);
|
||||
btn_close_tips.gameObject.SetActive(true);
|
||||
}
|
||||
async void OnClickSpeedup()
|
||||
{
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow();
|
||||
|
||||
if (aquariumTips != null && curAquariumSlot != null && curAquariumSlot.slotState < 3)
|
||||
{
|
||||
bool isShow = aquariumTips.UpdateBar(dateTime);
|
||||
if (!isShow)
|
||||
{
|
||||
CloseTips();
|
||||
return;
|
||||
}
|
||||
}
|
||||
var go = await UIManager.Instance.ShowUI(UITypes.SpeedupPopupPanel);
|
||||
if (go != null)
|
||||
{
|
||||
//判断是否置灰
|
||||
bool isAd = AM.data.adCount < tables.TbAquariumConfig.AdMaxTime;
|
||||
SpeedupPopupPanel speedupPopupPanel = go.GetComponent<SpeedupPopupPanel>();
|
||||
string adContent = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_44", tables.TbAquariumConfig.AdMaxTime - AM.data.adCount, tables.TbAquariumConfig.AdMaxTime);
|
||||
if (isAd)
|
||||
{
|
||||
speedupPopupPanel.SetData(OnAdsSucceed, StartSpeedUp, adContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
speedupPopupPanel.SetData(null, null, adContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
void StartSpeedUp(bool isGuide)
|
||||
{
|
||||
updateBar = false;
|
||||
//加速成功
|
||||
AM.Speedup(isGuide);
|
||||
}
|
||||
void OnAdsSucceed()
|
||||
{
|
||||
updateBar = true;
|
||||
if (aquariumTips != null && curAquariumSlot != null && curAquariumSlot.slotState < 3)
|
||||
{
|
||||
bool isShow = aquariumTips.UpdateBar(ZZTimeHelper.UtcNow());
|
||||
if (!isShow)
|
||||
{
|
||||
CloseTips();
|
||||
}
|
||||
}
|
||||
OnFishStateChange();
|
||||
}
|
||||
|
||||
async void OnClickProgress()
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.PlayerGradePanel);
|
||||
GContext.Publish(new HideHomePanelEvent());
|
||||
GContext.Publish(new ChangeTabEvent() { index = 1 });
|
||||
}
|
||||
void OnClickClose()
|
||||
{
|
||||
FishingAquariumAct.CloudType = 4;
|
||||
GContext.Publish(new UnloadActToNextAct(transitionPanel: UITypes.AquariumCloudPanel, time: 0.75f));
|
||||
}
|
||||
|
||||
EventReport eventReport;
|
||||
IReportService reportService;
|
||||
bool isEnable = true;
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
isEnable = false;
|
||||
}
|
||||
|
||||
async void PlayEventReport(ReportData reportEvent)
|
||||
{
|
||||
eventReport.gameObject.SetActive(true);
|
||||
eventReport.SetData(reportEvent.playFabId, reportEvent.content, reportEvent.type);
|
||||
await Awaiters.Seconds(4f);
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
eventReport.gameObject.SetActive(false);
|
||||
|
||||
NextReport();
|
||||
}
|
||||
void NextReport()
|
||||
{
|
||||
var data = reportService.GetAquariumReportData();
|
||||
if (data != null)
|
||||
{
|
||||
PlayEventReport(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c600010492ee4164d904cb466cc1daf6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
139
Assets/Scripts/Aquarium/UI/AquariumRandomMapPanel.cs
Normal file
139
Assets/Scripts/Aquarium/UI/AquariumRandomMapPanel.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumRandomMapPanel : MonoBehaviour
|
||||
{
|
||||
AquariumManager AM;
|
||||
RectTransform Content;
|
||||
GameObject img_map;
|
||||
int allCount = 5;
|
||||
float height;
|
||||
int maIndex = 2;
|
||||
IUIService uIService;
|
||||
|
||||
GameObject result;
|
||||
TMP_Text text_map;
|
||||
TMP_Text text_level;
|
||||
AquariumDetectEgg[] aquariumDetectEggs;
|
||||
Transform eggRoot;
|
||||
Tables _tables;
|
||||
Transform door;
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
uIService = GContext.container.Resolve<IUIService>();
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
Content = transform.Find("Viewport/Content").GetComponent<RectTransform>();
|
||||
img_map = transform.Find("Viewport/Content/Item").gameObject;
|
||||
height = img_map.GetComponent<RectTransform>().rect.height;
|
||||
img_map.SetActive(false);
|
||||
result = transform.Find("result").gameObject;
|
||||
text_map = transform.Find("result/text_map").GetComponent<TMP_Text>();
|
||||
text_level = transform.Find("result/fishcard/text_level").GetComponent<TMP_Text>();
|
||||
eggRoot = transform.Find("eggRoot");
|
||||
aquariumDetectEggs = eggRoot.GetComponentsInChildren<AquariumDetectEgg>();
|
||||
//eggRoot.gameObject.SetActive(false);
|
||||
door = transform.Find("door");
|
||||
}
|
||||
//private void Start()
|
||||
//{
|
||||
// result.SetActive(false);
|
||||
//}
|
||||
public void SetMap()
|
||||
{
|
||||
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||||
AM.GetRandmMap();
|
||||
var lastMapID = playerData.lastMapId;
|
||||
List<MapData> mapDatas = _tables.TbMapData.DataList;
|
||||
List<int> indexs = new List<int>();
|
||||
for (int i = 0; i < mapDatas.Count; i++)
|
||||
{
|
||||
if (mapDatas[i].ID <= lastMapID)
|
||||
{
|
||||
indexs.Add(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (indexs.Count < allCount)
|
||||
{
|
||||
indexs.AddRange(indexs);
|
||||
}
|
||||
List<int> newIDs = new List<int>();
|
||||
for (int i = 0; i < allCount; i++)
|
||||
{
|
||||
int mapIDIndex = indexs[Random.Range(0, indexs.Count)];
|
||||
newIDs.Add(mapIDIndex);
|
||||
indexs.Remove(mapIDIndex);
|
||||
}
|
||||
newIDs.AddRange(newIDs);
|
||||
for (int i = 0; i < allCount + maIndex; i++)
|
||||
{
|
||||
SetMapBg(mapDatas[newIDs[i]].Bg);
|
||||
}
|
||||
var mapData = _tables.TbMapData.DataMap[AM.MapId];
|
||||
SetMapBg(mapData.Bg);
|
||||
SetMapBg(mapDatas[newIDs[0]].Bg);
|
||||
text_map.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
string levelLV = LocalizationMgr.GetText("UI_FishingMapPanel_101006");
|
||||
int fishCardLevel = GContext.container.Resolve<PlayerFishData>().GetFishLevelByMap(AM.MapId);
|
||||
text_level.text = levelLV + fishCardLevel.ToString();
|
||||
var sequence = DOTween.Sequence();
|
||||
sequence.Append(door.DOLocalMoveX(900, 0.5f).SetEase(Ease.Linear));
|
||||
sequence.Append(Content.DOAnchorPosY(allCount * height, 0.8f).SetLoops(2, LoopType.Restart).SetEase(Ease.Linear));
|
||||
//跑马灯动画
|
||||
float index2 = allCount + maIndex + Random.Range(-0.5f, 0.5f);
|
||||
sequence.Append(Content.DOAnchorPosY(index2 * height, 0.2f).SetEase(Ease.Linear));
|
||||
sequence.Append(Content.DOAnchorPosY((allCount + maIndex) * height, 0.2f).SetEase(Ease.InSine));
|
||||
sequence.Play();
|
||||
}
|
||||
void SetMapBg(string bg)
|
||||
{
|
||||
GameObject go = Instantiate(img_map, Content);
|
||||
Image image = go.transform.GetChild(0).GetComponent<Image>();
|
||||
go.SetActive(true);
|
||||
uIService.SetImageSprite(image, bg);
|
||||
}
|
||||
|
||||
public void InitEgg()
|
||||
{
|
||||
//开始随机蛋蛋
|
||||
for (int i = 0; i < aquariumDetectEggs.Length; i++)
|
||||
{
|
||||
if (i < AM.Slot)
|
||||
{
|
||||
AquariumEgg aquariumEgg = _tables.TbAquariumEgg.GetOrDefault(AM.data.slotDatas[i].eggId);
|
||||
aquariumDetectEggs[i].SetIcon(AM.eggNames, aquariumEgg.Icon, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
aquariumDetectEggs[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayEgg()
|
||||
{
|
||||
//开始随机蛋蛋
|
||||
for (int i = 0; i < aquariumDetectEggs.Length; i++)
|
||||
{
|
||||
if (i < AM.Slot)
|
||||
{
|
||||
AquariumEgg aquariumEgg = _tables.TbAquariumEgg.GetOrDefault(AM.data.slotDatas[i].eggId);
|
||||
aquariumDetectEggs[i].Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void HideMap()
|
||||
{
|
||||
Content.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumRandomMapPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumRandomMapPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 311a4753f6d60b34c9b7c383888d32e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Scripts/Aquarium/UI/AquariumReportFishItem.cs
Normal file
38
Assets/Scripts/Aquarium/UI/AquariumReportFishItem.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumReportFishItem : MonoBehaviour
|
||||
{
|
||||
[Header("Fish Info")]
|
||||
public Transform mask_bg;
|
||||
public Image fish_icon;
|
||||
public Image icon_rate;
|
||||
public Image icon_egg;
|
||||
|
||||
[Header("Cash Info")]
|
||||
public GameObject fish_info;
|
||||
public TMP_Text text_cash;
|
||||
public TMP_Text text_fish_name;
|
||||
|
||||
[Header("Player Info")]
|
||||
public GameObject player_info;
|
||||
public TMP_Text text_player_name;
|
||||
public Head text_player_head;
|
||||
|
||||
public int index;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
mask_bg = transform.Find("mask_bg2").GetComponent<Transform>();
|
||||
fish_icon = transform.Find("mask_bg2/icon_fish").GetComponent<Image>();
|
||||
icon_rate = transform.Find("mask_bg2/icon_rate").GetComponent<Image>();
|
||||
icon_egg = transform.Find("mask_bg2/icon_egg").GetComponent<Image>();
|
||||
fish_info = transform.Find("fish_info").gameObject;
|
||||
text_cash = transform.Find("fish_info/text_cash").GetComponent<TMP_Text>();
|
||||
text_fish_name = transform.Find("fish_info/text_name").GetComponent<TMP_Text>();
|
||||
player_info = transform.Find("player_info").gameObject;
|
||||
text_player_name = transform.Find("player_info/text_name").GetComponent<TMP_Text>();
|
||||
text_player_head = transform.Find("player_info/text_name/btn_head").GetComponent<Head>();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumReportFishItem.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumReportFishItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb99e1bb5ebd3b6499e45982aaf53e8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
372
Assets/Scripts/Aquarium/UI/AquariumReportPopupPanel.cs
Normal file
372
Assets/Scripts/Aquarium/UI/AquariumReportPopupPanel.cs
Normal file
@@ -0,0 +1,372 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
|
||||
public class AquariumReportPopupPanel : MonoBehaviour
|
||||
{
|
||||
public Button btn_next;
|
||||
public GameObject receive;
|
||||
public GameObject photo;
|
||||
|
||||
public TMP_Text text_gold;
|
||||
public TMP_Text text_energy;
|
||||
public TMP_Text txt_diamond;
|
||||
public TMP_Text text_num;
|
||||
public GameObject[] _lights;
|
||||
public float showTime = 0.3f;
|
||||
public Transform reward_show;
|
||||
public RawImage icon;
|
||||
public Image tag_fish;
|
||||
public TMP_Text text_fish_name;
|
||||
|
||||
public Transform fishIconRT;
|
||||
public RawImage rawImage;
|
||||
RenderTexture rt;
|
||||
Camera rtCamera;
|
||||
Transform avatarCapture;
|
||||
int fieldOfView = 60;
|
||||
//鱼距离相机的位置
|
||||
int fishPosZ = 20;
|
||||
public GameObject mutated;
|
||||
|
||||
List<AquariumSlotData> aquariumSlotDatas;
|
||||
AquariumSlotData curData;
|
||||
int curIndex;
|
||||
int allCount;
|
||||
int Energy;
|
||||
int curDiamond;
|
||||
ulong Gold;
|
||||
bool isClose;
|
||||
bool isClickClose;
|
||||
IDisposable disposable;
|
||||
private Tables _tables;
|
||||
Item item;
|
||||
AquariumManager AM;
|
||||
Vector3 startPosition;
|
||||
FishingAquariumAct aquariumAct;
|
||||
Item fishItem;
|
||||
bool isEnable = true;
|
||||
public SpriteRenderer bg_photo;
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
item = _tables.TbItem.GetOrDefault(1002);
|
||||
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
aquariumSlotDatas = AM.sellList;
|
||||
|
||||
Energy = GContext.container.Resolve<PlayerData>().Energy;
|
||||
Gold = GContext.container.Resolve<PlayerData>().gold;
|
||||
curDiamond = GContext.container.Resolve<PlayerData>().diamond;
|
||||
ShowItemCount();
|
||||
text_energy.text = ConvertTools.GetNumberString2(Energy);
|
||||
text_gold.text = ConvertTools.GetNumberString2(Gold);
|
||||
txt_diamond.text = ConvertTools.GetNumberString2(curDiamond);
|
||||
allCount = aquariumSlotDatas.Count;
|
||||
|
||||
avatarCapture = fishIconRT.Find("avatarCapture");
|
||||
rtCamera = fishIconRT.Find("Camera").GetComponent<Camera>();
|
||||
startPosition = avatarCapture.localPosition;
|
||||
curIndex = 0;
|
||||
disposable = GContext.OnEvent<ResAddEvent>().Subscribe(x =>
|
||||
{
|
||||
NumPlay(x.id);
|
||||
});
|
||||
}
|
||||
|
||||
public void InitData(FishingAquariumAct aquariumAct)
|
||||
{
|
||||
this.aquariumAct = aquariumAct;
|
||||
SetRT();
|
||||
SetData();
|
||||
}
|
||||
|
||||
void SetRT()
|
||||
{
|
||||
fishIconRT.transform.position = Vector3.back * 30;
|
||||
RectTransform raw = rawImage.GetComponent<RectTransform>();
|
||||
rt = new RenderTexture((int)raw.rect.width, (int)raw.rect.height, 24, RenderTextureFormat.ARGB32);
|
||||
|
||||
rtCamera.fieldOfView = fieldOfView;
|
||||
rtCamera.enabled = true;
|
||||
rtCamera.targetTexture = rt;
|
||||
rawImage.texture = rt;
|
||||
rtCamera.Render();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var mapData = _tables.TbMapData.DataMap[AM.MapId];
|
||||
|
||||
string prefabName = mapData.AquariumPrefab;
|
||||
Transform bg = photo.transform.Find($"bg_{prefabName}");
|
||||
if (bg != null)
|
||||
{
|
||||
bg_photo.sprite = bg.GetComponent<Image>().sprite;
|
||||
}
|
||||
btn_next.onClick.AddListener(OnClickNext);
|
||||
}
|
||||
async void ShowFish()
|
||||
{
|
||||
GameObject fishGo = await aquariumAct.LoadFish(curData.index, avatarCapture);
|
||||
if (fishGo != null)
|
||||
{
|
||||
var fishData = _tables.TbFishData.GetOrDefault(fishItem.RedirectID);
|
||||
|
||||
var TankPosition = fishData.TankPosition;
|
||||
Vector3 pos = new Vector3(TankPosition[0], TankPosition[1], TankPosition[2] + fishPosZ);
|
||||
Transform avatar = avatarCapture;
|
||||
pos += startPosition;
|
||||
avatar.localPosition = pos;
|
||||
//fish.transform.localPosition = pos;
|
||||
}
|
||||
}
|
||||
|
||||
async void SetData()
|
||||
{
|
||||
isClose = false;
|
||||
isClickClose = false;
|
||||
curData = aquariumSlotDatas[curIndex];
|
||||
mutated.SetActive(curData.mutants > 0);
|
||||
photo.SetActive(false);
|
||||
fishItem = _tables.TbItem.GetOrDefault(curData.fishItemID);
|
||||
ShowFish();
|
||||
photo.SetActive(true);
|
||||
text_fish_name.text = LocalizationMgr.GetText(fishItem.Name_l10n_key);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(tag_fish, "icon_fish_rate_tag_" + fishItem.Quality);
|
||||
|
||||
int audioName = curIndex % 4 + 1;
|
||||
GContext.Publish(new EventUISound($"audio_ui_getreward_{audioName}"));
|
||||
float showCount = curData.allCash;
|
||||
ItemShow itemShow = GContext.container.Resolve<Tables>().TbItemShow.GetOrDefault(1002);
|
||||
int light_index = 1;
|
||||
if (itemShow != null)
|
||||
{
|
||||
light_index = 0;
|
||||
showCount = (showCount / GContext.container.Resolve<PlayerItemData>().ExtraCoinMag());
|
||||
for (int i = itemShow.Count.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (showCount > itemShow.Count[i])
|
||||
{
|
||||
light_index = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (light_index >= _lights.Length)
|
||||
{
|
||||
light_index = _lights.Length - 1;
|
||||
}
|
||||
for (int i = 0; i < _lights.Length; i++)
|
||||
{
|
||||
_lights[i].SetActive(i == light_index);
|
||||
}
|
||||
curIndex++;
|
||||
receive.SetActive(false);
|
||||
receive.SetActive(true);
|
||||
var progress = 0f;
|
||||
//text_num.text = ConvertTools.GetNumberString2(curData.cash);
|
||||
int cash = curData.cash;
|
||||
DOTween.Kill("AddCash");
|
||||
await Awaiters.Seconds(showTime);
|
||||
|
||||
DOTween.To(() => progress, x => progress = x, 1f, 0.8f).OnUpdate(() =>
|
||||
{
|
||||
text_num.text = ConvertTools.GetNumberString2((int)(cash * progress));
|
||||
}).SetId("AddCash");
|
||||
await Awaiters.Seconds(0.5f);
|
||||
await ParticleAttractor(showCount);
|
||||
isClose = true;
|
||||
if (isClickClose)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
void NumPlay(int id)
|
||||
{
|
||||
if (id != 1002)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GoldAddAnim(curData.cash);
|
||||
}
|
||||
void GoldAddAnim(float add)
|
||||
{
|
||||
DOTween.Kill("report_text_gold");
|
||||
text_gold.text = ConvertTools.GetNumberString2(Gold);
|
||||
float progress = 0;
|
||||
ulong glod = Gold;
|
||||
DOTween.To(() => progress, x => progress = x, 1, 0.4f).OnUpdate(() =>
|
||||
{
|
||||
Gold = glod + (ulong)(add * progress);
|
||||
text_gold.text = ConvertTools.GetNumberString2(Gold);
|
||||
}).SetDelay(0.5f).SetId("report_text_gold");
|
||||
}
|
||||
|
||||
void ShowItemCount()
|
||||
{
|
||||
if (aquariumSlotDatas != null)
|
||||
{
|
||||
for (int i = 0; i < aquariumSlotDatas.Count; i++)
|
||||
{
|
||||
ulong curGold = (ulong)aquariumSlotDatas[i].cash;
|
||||
if (Gold > curGold)
|
||||
{
|
||||
Gold -= curGold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
isClickClose = false;
|
||||
isClose = false;
|
||||
receive.SetActive(false);
|
||||
UIManager.Instance.DestroyUI(UITypes.AquariumReportPopupPanel);
|
||||
if (AM.data.isHome)
|
||||
{
|
||||
FishingAquariumAct.eventAggregator.Publish(new AquariumEnterMapScene());
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickNext()
|
||||
{
|
||||
if (curIndex >= allCount)
|
||||
{
|
||||
receive.SetActive(false);
|
||||
if (isClose)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
isClickClose = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
SetData();
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task ParticleAttractor(float showCount)
|
||||
{
|
||||
//1001 1002 另外一种配法
|
||||
//ItemShow itemShow = _tables.TbItemShow.GetOrDefault(item.ID);
|
||||
//string fxName = itemShow.Fx[0];
|
||||
//for (int i = itemShow.Count.Count - 1; i >= 0; i--)
|
||||
//{
|
||||
// if (showCount > itemShow.Count[i])
|
||||
// {
|
||||
// fxName = itemShow.Fx[i + 1];
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
string fxName = "fx_ui_reward_common_money_01";// item.Fx;
|
||||
if (fishItem.Quality > 3)
|
||||
{
|
||||
fxName = "fx_ui_reward_common_money_02";
|
||||
}
|
||||
|
||||
Transform fxP = reward_show.Find(fxName);
|
||||
|
||||
if (fxP == null)
|
||||
{
|
||||
GContext.Publish(new ResAddEvent(item.ID, item.Type, item.SubType));
|
||||
return;
|
||||
}
|
||||
GameObject fx = Instantiate(fxP.gameObject, reward_show);
|
||||
ParticleSystem particleSystem = fx.transform.Find("Scale/quan03").GetComponent<ParticleSystem>();
|
||||
if (particleSystem != null)
|
||||
{
|
||||
reward_show.gameObject.SetActive(true);
|
||||
//fx.transform.position = transform.position;
|
||||
ParticleAttractorData particleAttractorData = new ParticleAttractorData()
|
||||
{
|
||||
Type = item.Type,
|
||||
SubType = item.SubType,
|
||||
Priority = -1,
|
||||
};
|
||||
GContext.Publish(particleAttractorData);
|
||||
if (particleAttractorData.Priority > -1 && particleAttractorData.uIParticleAttractorCenter != null)
|
||||
{
|
||||
var particleRenderer = particleSystem.GetComponent<ParticleSystemRenderer>();
|
||||
var sprite = icon.texture;
|
||||
|
||||
var uIParticleAttractorCenter = particleAttractorData.uIParticleAttractorCenter;
|
||||
//多个粒子飞向同一个target时,隐藏前一个粒子
|
||||
var particleAttractor = uIParticleAttractorCenter.GetUIParticleAttractor();
|
||||
particleAttractor?.Clear();
|
||||
particleAttractor.particleSystem = null;
|
||||
//particleAttractor.enabled = false;
|
||||
Texture texture = sprite;// await GContext.container.Resolve<IUIService>().GetTexture(item.Icon, "RewardPopupPanel");
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//_TextureSample0
|
||||
particleRenderer.material.SetTexture("_TextureSample0", texture);
|
||||
//particleRenderer.material.SetTextureScale("_TextureSample0", new Vector2(sprite.textureRect.width / texture.width, sprite.textureRect.height / texture.height));
|
||||
//particleRenderer.material.SetTextureOffset("_TextureSample0", new Vector2(sprite.textureRect.x / texture.width, sprite.textureRect.y / texture.height));
|
||||
particleSystem.Clear();
|
||||
|
||||
var main = particleSystem.main;
|
||||
int maxCount = main.maxParticles;
|
||||
if (showCount < maxCount)
|
||||
{
|
||||
int addCount = (int)showCount;
|
||||
main.maxParticles = addCount;
|
||||
//var emission = particleSystem.emission;
|
||||
//emission.rateOverTime = 0;
|
||||
//emission.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0.0f, addCount) });
|
||||
}
|
||||
fx.SetActive(true);
|
||||
if (particleAttractor != null)
|
||||
{
|
||||
particleAttractor.particleSystem = particleSystem;
|
||||
particleAttractor.enabled = true;
|
||||
}
|
||||
await Awaiters.Seconds(0.2f);
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GContext.Publish(new ResAddEvent(item.ID, item.Type, item.SubType));
|
||||
await Awaiters.Seconds(1.8f);
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (particleAttractor != null && particleAttractor.particleSystem == particleSystem)
|
||||
{
|
||||
particleAttractor.Clear();
|
||||
particleAttractor.enabled = false;
|
||||
particleAttractor = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Destroy(fx);
|
||||
return;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
isEnable = false;
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
rtCamera.targetTexture = null;
|
||||
if (rt != null)
|
||||
{
|
||||
rt.Release();
|
||||
Destroy(rt);
|
||||
rt = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumReportPopupPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumReportPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 677c3f4971f9f104e88f80a951ef4b22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
78
Assets/Scripts/Aquarium/UI/AquariumReportPopupPanelOld.cs
Normal file
78
Assets/Scripts/Aquarium/UI/AquariumReportPopupPanelOld.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumReportPopupPanelOld : MonoBehaviour
|
||||
{
|
||||
Button btn_confirm;
|
||||
TMP_Text text_num;
|
||||
AquariumManager AM;
|
||||
GameObject fishItemPrefab;
|
||||
Transform fish_info_root;
|
||||
Tables tables;
|
||||
private void Awake()
|
||||
{
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
text_num = transform.Find("root/bg_reward/text_num").GetComponent<TMP_Text>();
|
||||
btn_confirm = transform.Find("root/btn_confirm/btn_green").GetComponent<Button>();
|
||||
fish_info_root = transform.Find("root/fish_info1");
|
||||
fishItemPrefab = transform.Find("root/fish_info1/fish").gameObject;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_confirm.onClick.AddListener(OnClickConfirm);
|
||||
int allCash = 0;
|
||||
AquariumReportFishItem fishItem = null;
|
||||
Item item = null;
|
||||
MapData mapData = tables.TbMapData.GetOrDefault(AM.data.mapId);
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
|
||||
List<AquariumResultData> aquariumReportDatas = AM.data.aquariumResultDatas;
|
||||
for (int i = 0; i < AM.data.slot; i++)
|
||||
{
|
||||
fishItem = Instantiate(fishItemPrefab, fish_info_root).GetComponent<AquariumReportFishItem>();
|
||||
fishItem.gameObject.SetActive(true);
|
||||
fishItem.index = i;
|
||||
|
||||
AquariumResultData aquariumSettlementData = aquariumReportDatas[i];
|
||||
AquariumSlotData slotData = AM.data.slotDatas[i];
|
||||
item = tables.TbItem.GetOrDefault(slotData.fishItemID);
|
||||
PlayerFishData.SetFishIcon(fishItem.fish_icon, item);//鱼头像
|
||||
uiService.SetImageSprite(fishItem.icon_rate, "icon_fish_rate_tag_" + item.Quality);
|
||||
var bgbg = fishItem.mask_bg.Find(mapData.AquariumBg);
|
||||
bgbg.gameObject.SetActive(true);
|
||||
AquariumEgg aquariumEgg = GContext.container.Resolve<Tables>().TbAquariumEgg.GetOrDefault(slotData.eggId);
|
||||
if (aquariumEgg != null)
|
||||
{
|
||||
uiService.SetImageSprite(fishItem.icon_egg, aquariumEgg.Icon);
|
||||
}
|
||||
|
||||
fishItem.fish_info.SetActive(slotData.cash > 0);
|
||||
fishItem.player_info.SetActive(slotData.cash <= 0);
|
||||
|
||||
if (slotData.cash > 0)
|
||||
{
|
||||
fishItem.text_fish_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
fishItem.text_cash.text = ConvertTools.GetNumberString2(slotData.cash);
|
||||
allCash += slotData.cash;
|
||||
}
|
||||
else if (slotData.cash <= 0)
|
||||
{
|
||||
fishItem.text_player_name.text = aquariumSettlementData.displayName;
|
||||
fishItem.text_player_head.SetData(aquariumSettlementData.avatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
text_num.text = ConvertTools.GetNumberString2(allCash);
|
||||
}
|
||||
void OnClickConfirm()
|
||||
{
|
||||
FishingAquariumAct.eventAggregator.Publish(new AquariumEnterMapScene());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c52c227bae65bc45884f488664a7156
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
255
Assets/Scripts/Aquarium/UI/AquariumSlot.cs
Normal file
255
Assets/Scripts/Aquarium/UI/AquariumSlot.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumSlot : MonoBehaviour
|
||||
{
|
||||
public Button btn_click;
|
||||
public Image icon_egg;
|
||||
public GameObject mask_fish;
|
||||
public Image icon_fish;
|
||||
public Image icon_rate;
|
||||
public GameObject selected;
|
||||
public GameObject done;
|
||||
public GameObject icon_hurt;
|
||||
public GameObject icon_killed;
|
||||
public GameObject icon_sold;
|
||||
public GameObject redpoint;
|
||||
public AquariumSlotData slotData;
|
||||
public Image bar;
|
||||
public Image bar_hurt;
|
||||
Action<AquariumSlot> onClick;
|
||||
Action onFishStateChange;
|
||||
public int index;
|
||||
/// <summary>
|
||||
/// 1 == egg 2 == fish 3 == done 4 == sell 5 == lose
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
public int slotState = 0;
|
||||
AquariumManager AM;
|
||||
//private void Reset()
|
||||
//{
|
||||
// btn_click = GetComponent<Button>();
|
||||
// icon_egg = transform.Find("icon_egg").GetComponent<Image>();
|
||||
// mask_fish = transform.Find("mask_fish").gameObject;
|
||||
// icon_fish = transform.Find("mask_fish/icon_fish").GetComponent<Image>();
|
||||
// icon_rate = transform.Find("mask_fish/icon_rate").GetComponent<Image>();
|
||||
// selected = transform.Find("selected").gameObject;
|
||||
// done = transform.Find("mask_fish/done").gameObject;
|
||||
// icon_hurt = transform.Find("icon_hurt").gameObject;
|
||||
// icon_killed = transform.Find("icon_killed").gameObject;
|
||||
// icon_sold = transform.Find("icon_sold").gameObject;
|
||||
// redpoint = transform.Find("redpoint").gameObject;
|
||||
// bar = transform.Find("bg_bar/bar").GetComponent<Image>();
|
||||
// bar_hurt = transform.Find("bg_bar/bar_hurt").GetComponent<Image>();
|
||||
//}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
redpoint.SetActive(false);
|
||||
btn_click.onClick.AddListener(OnClick);
|
||||
}
|
||||
void OnClick()
|
||||
{
|
||||
//if (slotState == 4)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
onClick?.Invoke(this);
|
||||
}
|
||||
public void InitSlot(int index, AquariumSlotData slotData, Action<AquariumSlot> onClick, Action onFishStateChange)
|
||||
{
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
this.index = index;
|
||||
this.slotData = slotData;
|
||||
this.onClick = onClick;
|
||||
this.onFishStateChange = onFishStateChange;
|
||||
SetState();
|
||||
InitBar();
|
||||
}
|
||||
public void SetState()
|
||||
{
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow();
|
||||
var HatchTime = slotData.FishHatchTime();
|
||||
var FishGrowthTime = slotData.FishGrowthTime();
|
||||
bool isHatch = HatchTime < dateTime;
|
||||
TimeSpan offsetTime = new TimeSpan();
|
||||
bool isUpdate = false;
|
||||
done.gameObject.SetActive(false);
|
||||
icon_hurt.gameObject.SetActive(false);
|
||||
bar_hurt.gameObject.SetActive(false);
|
||||
icon_killed.gameObject.SetActive(false);
|
||||
bar.gameObject.SetActive(true);
|
||||
redpoint.SetActive(false);
|
||||
if (isHatch)
|
||||
{
|
||||
//鱼鱼
|
||||
slotState = 2;
|
||||
icon_egg.gameObject.SetActive(false);
|
||||
mask_fish.gameObject.SetActive(true);
|
||||
|
||||
bool growth = FishGrowthTime < dateTime;
|
||||
|
||||
List<AquariumResultData> aquariumReportDatas = AM.data.aquariumResultDatas;
|
||||
|
||||
//售卖或者丢失
|
||||
if (slotData.IsResult())
|
||||
{
|
||||
slotState = 4;
|
||||
//btn_click.enabled = false;
|
||||
done.gameObject.SetActive(true);
|
||||
icon_sold.gameObject.SetActive(true);
|
||||
bar.gameObject.SetActive(false);
|
||||
}
|
||||
else if (aquariumReportDatas[slotData.index].IsResult())
|
||||
{
|
||||
slotState = 5;
|
||||
icon_killed.gameObject.SetActive(true);
|
||||
done.gameObject.SetActive(true);
|
||||
bar.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//检查是否受伤
|
||||
//正常的成长时间 自然时间+加速成长-总恢复时间
|
||||
float normalH = (float)(dateTime - HatchTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
||||
|
||||
float injuryH = slotData.injuryGrowthTime;
|
||||
|
||||
//受伤时的成长进度大于正常的成长进度=还没恢复
|
||||
isUpdate = true;
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
bar.gameObject.SetActive(false);
|
||||
bar_hurt.gameObject.SetActive(true);
|
||||
icon_hurt.gameObject.SetActive(true);
|
||||
offsetTime = dateTime.AddHours(injuryH - normalH) - dateTime;
|
||||
}
|
||||
else if (growth)
|
||||
{
|
||||
//成熟并且没有受伤
|
||||
slotState = 3;
|
||||
isUpdate = false;
|
||||
redpoint.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
bar_hurt.gameObject.SetActive(false);
|
||||
icon_hurt.gameObject.SetActive(false);
|
||||
offsetTime = FishGrowthTime - dateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isUpdate = true;
|
||||
offsetTime = HatchTime - dateTime;
|
||||
//蛋蛋
|
||||
slotState = 1;
|
||||
icon_egg.gameObject.SetActive(true);
|
||||
mask_fish.gameObject.SetActive(false);
|
||||
done.gameObject.SetActive(false);
|
||||
}
|
||||
if (isUpdate)
|
||||
{
|
||||
StartCoroutine(UpdateTime((float)offsetTime.TotalSeconds));
|
||||
}
|
||||
}
|
||||
|
||||
void InitBar()
|
||||
{
|
||||
if (slotState == 5)
|
||||
{
|
||||
bar.fillAmount = 0;
|
||||
return;
|
||||
}
|
||||
if (slotState == 4)
|
||||
{
|
||||
bar.fillAmount = 0;
|
||||
return;
|
||||
}
|
||||
DateTime dateTime = ZZTimeHelper.UtcNow();
|
||||
|
||||
if (slotState == 1)
|
||||
{
|
||||
float time = (float)(dateTime - slotData.startTime).TotalHours + slotData.accelerationHatch;
|
||||
bar.fillAmount = time / slotData.hatchTime;
|
||||
return;
|
||||
}
|
||||
var StartTime = slotData.FishHatchTime();
|
||||
//正常的成长进度 自然时间+加速成长 - 全部恢复时间
|
||||
float normalH = (float)(dateTime - StartTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
||||
//受伤时的成长进度
|
||||
float injuryH = slotData.injuryGrowthTime;
|
||||
|
||||
//受伤时的成长进度大于正常的成长进度
|
||||
float timeProgress = 1;
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
bar_hurt.fillAmount = (injuryH - normalH) / slotData.growthTime;
|
||||
timeProgress = 0;// injuryH / slotData.growthTime;
|
||||
}
|
||||
else if (normalH < slotData.growthTime)
|
||||
{
|
||||
timeProgress = normalH / slotData.growthTime;
|
||||
}
|
||||
bar.fillAmount = timeProgress;
|
||||
}
|
||||
|
||||
public void UpdateBar(DateTime dateTime)
|
||||
{
|
||||
if (slotState == 5)
|
||||
{
|
||||
bar.fillAmount = 0;
|
||||
return;
|
||||
}
|
||||
if (slotState == 4)
|
||||
{
|
||||
//bar.DOFillAmount(1, 0.9f);
|
||||
bar.fillAmount = 0;
|
||||
return;
|
||||
}
|
||||
if (slotState == 1)
|
||||
{
|
||||
float time = (float)(dateTime - slotData.startTime).TotalHours + slotData.accelerationHatch;
|
||||
var fillAmount = time / slotData.hatchTime;
|
||||
bar.DOFillAmount(fillAmount, 0.9f);
|
||||
return;
|
||||
}
|
||||
var StartTime = slotData.FishHatchTime();
|
||||
//正常的成长进度 自然时间+加速成长 - 全部恢复时间
|
||||
float normalH = (float)(dateTime - StartTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
||||
//受伤时的成长进度
|
||||
float injuryH = slotData.injuryGrowthTime;
|
||||
|
||||
//受伤时的成长进度大于正常的成长进度
|
||||
float timeProgress = 1;
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
var fillAmount = (injuryH - normalH) / slotData.recoveryTime;
|
||||
bar_hurt.DOFillAmount(fillAmount, 0.9f);
|
||||
//timeProgress = injuryH / slotData.growthTime;
|
||||
bar.fillAmount = 0;
|
||||
}
|
||||
else if (normalH < slotData.growthTime)
|
||||
{
|
||||
timeProgress = normalH / slotData.growthTime;
|
||||
bar.DOFillAmount(timeProgress, 0.9f);
|
||||
}
|
||||
else
|
||||
{
|
||||
bar.DOFillAmount(timeProgress, 0.9f);
|
||||
}
|
||||
}
|
||||
IEnumerator UpdateTime(float s)
|
||||
{
|
||||
yield return new WaitForSeconds(s);
|
||||
//发送事件,状态修改
|
||||
onFishStateChange?.Invoke();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumSlot.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumSlot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fbf14b1ce2402a4981f9ff90a46787d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/Scripts/Aquarium/UI/AquariumUpdatePopupPanel.cs
Normal file
93
Assets/Scripts/Aquarium/UI/AquariumUpdatePopupPanel.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumUpdatePopupPanel : MonoBehaviour
|
||||
{
|
||||
Transform map;
|
||||
RewardItemNew[] rewards;
|
||||
Button btn_sure;
|
||||
bool isShowBox;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btn_sure = transform.Find("root/bg/btn_sure/btn_green").GetComponent<Button>();
|
||||
map = transform.Find("root/bg/rewards");
|
||||
rewards = map.GetComponentsInChildren<RewardItemNew>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
OpenBox();
|
||||
btn_sure.onClick.AddListener(OnBtnSure);
|
||||
}
|
||||
void OnBtnSure()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.AquariumUpdatePopupPanel);
|
||||
}
|
||||
void OpenBox()
|
||||
{
|
||||
var _dataProvider = GContext.container.Resolve<FishingBoxDataProvier>();
|
||||
Dictionary<int, int> FishingBoxs = _dataProvider.Data.FishingBoxs;
|
||||
isShowBox = false;
|
||||
int index = 0;
|
||||
|
||||
foreach (var box in FishingBoxs)
|
||||
{
|
||||
var boxCount = box.Value;
|
||||
if (boxCount > 0)
|
||||
{
|
||||
int id = box.Key;
|
||||
|
||||
isShowBox = true;
|
||||
rewards[index].SetData(new ItemData(id, boxCount));
|
||||
}
|
||||
rewards[index].gameObject.SetActive(boxCount > 0);
|
||||
index++;
|
||||
if (index >= 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
map.gameObject.SetActive(isShowBox);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
if (isShowBox)
|
||||
{
|
||||
var _dataProvider = GContext.container.Resolve<FishingBoxDataProvier>();
|
||||
Dictionary<int, int> FishingBoxs = _dataProvider.Data.FishingBoxs;
|
||||
var FishingNewBoxs = _dataProvider.Data.FishingNewBoxs;
|
||||
int index = 0;
|
||||
|
||||
foreach (var box in FishingBoxs)
|
||||
{
|
||||
var boxCount = box.Value;
|
||||
if (boxCount > 0)
|
||||
{
|
||||
int id = box.Key;
|
||||
if (FishingNewBoxs.ContainsKey(id))
|
||||
{
|
||||
FishingNewBoxs[id] += boxCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
FishingNewBoxs.Add(id, boxCount);
|
||||
}
|
||||
}
|
||||
index++;
|
||||
if (index >= 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_dataProvider.Data.FishingBoxs.Clear();
|
||||
_dataProvider.Data.Save();
|
||||
GContext.Publish(new ShowData(null, RewardType.FishBoxOpen, 1));
|
||||
}
|
||||
GContext.Publish(new FaceUICloseEvent());
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/AquariumUpdatePopupPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/AquariumUpdatePopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93eaf9df0cfde5046bbc6894e930afbd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
145
Assets/Scripts/Aquarium/UI/EventFishHuntingAim.cs
Normal file
145
Assets/Scripts/Aquarium/UI/EventFishHuntingAim.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventFishHuntingAim : MonoBehaviour
|
||||
{
|
||||
LayerMask layerMask;
|
||||
GameObject target;
|
||||
FishMovement fish;
|
||||
[HideInInspector]
|
||||
public EventFishHuntingPanel eventFishHuntingPanel;
|
||||
public Animator animator;
|
||||
public bool isFinish;
|
||||
public float AimTime => crossbow.AimTime;
|
||||
Vector3 screenPosition;
|
||||
cfg.Crossbow crossbow;
|
||||
float shakeTime = 0;
|
||||
float rotate = 0;
|
||||
Vector3 currentPos;
|
||||
Vector3 newPos;
|
||||
float time;
|
||||
//CrossbowCameraMove crossbowCameraMove;
|
||||
private void Awake()
|
||||
{
|
||||
crossbow = GContext.container.Resolve<Tables>().TbCrossbow.DataList[0];
|
||||
layerMask = LayerMask.NameToLayer("fish");
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
animator.SetInteger("AimIndex", crossbow.AimIndex);
|
||||
Time.timeScale = crossbow.TimescaleRate;
|
||||
transform.localPosition = Vector3.zero;
|
||||
shakeTime = 0;
|
||||
rotate = 1;
|
||||
}
|
||||
|
||||
|
||||
void Shake()
|
||||
{
|
||||
float timeRotate = shakeTime / crossbow.AimTime;
|
||||
shakeTime += Time.deltaTime;
|
||||
List<float> shakeSpeed = crossbow.ShakeSpeed;
|
||||
float speed = shakeSpeed[0] - (shakeSpeed[0] - shakeSpeed[1]) * timeRotate;
|
||||
|
||||
if (rotate >= 1)
|
||||
{
|
||||
rotate = 0;
|
||||
var ShakeRandRange = crossbow.ShakeRandRange;
|
||||
float shakeRand1 = ShakeRandRange[0][0] - (ShakeRandRange[0][0] - ShakeRandRange[1][0]) * timeRotate;
|
||||
float shakeRand2 = ShakeRandRange[0][1] - (ShakeRandRange[0][1] - ShakeRandRange[1][1]) * timeRotate;
|
||||
//抖动相机
|
||||
float x = UnityEngine.Random.Range(shakeRand1, shakeRand2);
|
||||
float y = UnityEngine.Random.Range(shakeRand1, shakeRand2);
|
||||
currentPos = transform.localPosition;
|
||||
|
||||
bool directionX = UnityEngine.Random.Range(0, 2) == 0;
|
||||
bool directionY = UnityEngine.Random.Range(0, 2) == 0;
|
||||
if (!directionX)
|
||||
{
|
||||
x = -x;
|
||||
}
|
||||
if (!directionY)
|
||||
{
|
||||
y = -y;
|
||||
}
|
||||
newPos = new Vector3(x, y, 0);
|
||||
float dis = Vector3.Distance(currentPos, newPos);
|
||||
time = dis / speed;
|
||||
}
|
||||
rotate += Time.deltaTime / time;
|
||||
transform.localPosition = Vector3.Lerp(currentPos, newPos, rotate);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (shakeTime < crossbow.AimTime)
|
||||
{
|
||||
Shake();
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
//if (isGuide)
|
||||
//{
|
||||
// OnGuide();
|
||||
// return;
|
||||
//}
|
||||
if (isFinish || eventFishHuntingPanel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
target = SelectTarget();
|
||||
if (target != null)
|
||||
{
|
||||
fish = target.GetComponentInParent<FishMovement>();
|
||||
}
|
||||
else
|
||||
{
|
||||
fish = null;
|
||||
}
|
||||
eventFishHuntingPanel.ChangeTarget(fish);
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
eventFishHuntingPanel.OnUpAim();
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject SelectTarget()
|
||||
{
|
||||
screenPosition = UIManager.Instance.UICanvas.worldCamera.WorldToScreenPoint(transform.position);
|
||||
|
||||
var ray = Camera.main.ScreenPointToRay(screenPosition);
|
||||
if (Physics.Raycast(ray, out var hit))
|
||||
{
|
||||
if (hit.collider.gameObject.layer == layerMask)
|
||||
{
|
||||
return hit.collider.gameObject;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Trigger(string value)
|
||||
{
|
||||
if (gameObject.activeSelf)
|
||||
{
|
||||
animator.SetTrigger(value);
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
Time.timeScale = 1;
|
||||
transform.DOKill();
|
||||
}
|
||||
//void OnGuide()
|
||||
//{
|
||||
// Quaternion rotation = Quaternion.LookRotation(target.transform.position - transform.position);
|
||||
// rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2);
|
||||
// crossbowCameraMove.transform.eulerAngles = new Vector3(rotation.eulerAngles.x, rotation.eulerAngles.y, 0);
|
||||
//}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/EventFishHuntingAim.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/EventFishHuntingAim.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51cb394c2e623d545ae7b418b4b3ae19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
406
Assets/Scripts/Aquarium/UI/EventFishHuntingPanel.cs
Normal file
406
Assets/Scripts/Aquarium/UI/EventFishHuntingPanel.cs
Normal file
@@ -0,0 +1,406 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
public class EventFishHuntingPanel : MonoBehaviour
|
||||
{
|
||||
Tables _tables;
|
||||
Head head;
|
||||
Button switchbtn;
|
||||
GameObject exchange;
|
||||
GameObject title;
|
||||
Button btn_aim;
|
||||
|
||||
TMP_Text text_name;
|
||||
|
||||
GameObject fish_info;
|
||||
Image tag_fish;
|
||||
TMP_Text text_fish_name;
|
||||
GameObject mutated;
|
||||
|
||||
GameObject mutated_settlement;
|
||||
GameObject root_settlement;
|
||||
GameObject kill;
|
||||
GameObject hurt;
|
||||
Button btn_close;
|
||||
Transform photo;
|
||||
SpriteRenderer bg_photo;
|
||||
Transform fishIconRT;
|
||||
RawImage rawImage;
|
||||
RenderTexture rt;
|
||||
GameObject fishGo;
|
||||
Camera rtCamera;
|
||||
Transform avatarCapture;
|
||||
Transform avatarEscape;
|
||||
int fieldOfView = 60;
|
||||
//鱼距离相机的位置
|
||||
int fishPosZ = 20;
|
||||
|
||||
SmallGameData smallGameData;
|
||||
string playFabId;
|
||||
OpponentItemData opponentItemData;
|
||||
bool isClick = false;
|
||||
AquariumShooterFishManager AM;
|
||||
int multiple;
|
||||
[HideInInspector]
|
||||
public ShooterFishAct shooterFishAct;
|
||||
EventFishHuntingAim eventFishHuntingAim;
|
||||
|
||||
FishMovement fishMovement;
|
||||
|
||||
FishMovement curTarget;
|
||||
int changeTargetCount = 0;
|
||||
UIDownUp uIDownUp;
|
||||
protected CompositeDisposable disposables = new CompositeDisposable();
|
||||
private void Awake()
|
||||
{
|
||||
multiple = GContext.container.Resolve<PlayerData>().GetMagnification();
|
||||
AM = GContext.container.Resolve<AquariumShooterFishManager>();
|
||||
|
||||
smallGameData = GContext.container.Resolve<SmallGameData>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
text_name = transform.Find("root/title/bg/text_name").GetComponent<TMP_Text>();
|
||||
head = transform.Find("root/title/btn_head").GetComponent<Head>();
|
||||
switchbtn = transform.Find("root/switch/btn_switch/btn_green").GetComponent<Button>();
|
||||
exchange = transform.Find("root/switch").gameObject;
|
||||
title = transform.Find("root/title").gameObject;
|
||||
btn_aim = transform.Find("root/btn_hunt").GetComponent<Button>();
|
||||
kill = transform.Find("root/root_settlement/kill").gameObject;
|
||||
hurt = transform.Find("root/root_settlement/hurt").gameObject;
|
||||
root_settlement = transform.Find("root/root_settlement").gameObject;
|
||||
btn_close = transform.Find("root/root_settlement/btn_play/btn_green").GetComponent<Button>();
|
||||
|
||||
fish_info = transform.Find("root/fish_info").gameObject;
|
||||
tag_fish = fish_info.transform.Find("text_name/tag_fish").GetComponent<Image>();
|
||||
text_fish_name = fish_info.transform.Find("text_name").GetComponent<TMP_Text>();
|
||||
mutated = fish_info.transform.Find("mutated").gameObject;
|
||||
mutated_settlement = transform.Find("root/root_settlement/photo/mutated").gameObject;
|
||||
photo = transform.Find("root/root_settlement/photo");
|
||||
bg_photo = photo.Find("mask_bg2/icon_fish/Camera/bg_photo").GetComponent<SpriteRenderer>();
|
||||
fishIconRT = transform.Find("root/root_settlement/photo/mask_bg2/icon_fish");
|
||||
avatarCapture = fishIconRT.Find("avatarCapture");
|
||||
avatarEscape = fishIconRT.Find("avatarEscape");
|
||||
rtCamera = fishIconRT.Find("Camera").GetComponent<Camera>();
|
||||
rawImage = transform.Find("root/root_settlement/photo/mask_bg2/RawImage").GetComponent<RawImage>();
|
||||
|
||||
text_num = transform.Find("root/root_settlement/photo/reward/text_num").GetComponent<TMP_Text>();
|
||||
text_num_buff = transform.Find("root/root_settlement/photo/reward/text_num/text_num_buff").GetComponent<TMP_Text>();
|
||||
fx_ui_eventbankheistreward_money_01 = transform.Find("root/root_settlement/particle/fx_ui_eventbankheistreward_money_01").gameObject;
|
||||
btn_close = transform.Find("root/root_settlement/btn_play/btn_green").GetComponent<Button>();
|
||||
bg_extra = transform.Find("root/root_settlement/photo/bonus").gameObject;
|
||||
reward_extra = transform.Find("root/root_settlement/photo/bonus/reward").GetComponent<RewardItemNew>();
|
||||
tag_fish_settlement = transform.Find("root/root_settlement/photo/icon_rate").GetComponent<Image>();
|
||||
text_fish_name_settlement = transform.Find("root/root_settlement/photo/text_name").GetComponent<TMP_Text>();
|
||||
uIDownUp = transform.Find("root/OpenHuntingAim").GetComponent<UIDownUp>();
|
||||
eventFishHuntingAim = transform.Find("root/EventFishHuntingAim").GetComponent<EventFishHuntingAim>();
|
||||
eventFishHuntingAim.eventFishHuntingPanel = this;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
GContext.OnEvent<ChangeSmallGameTargetEvent>().Subscribe(ChangeSmallGameTarget).AddTo(disposables);
|
||||
opponentItemData = smallGameData.opponentData;
|
||||
|
||||
playFabId = smallGameData.opponentData.playFabID;
|
||||
GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar).AddTo(disposables);
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
|
||||
SetAvatar(clubPlayInfo);
|
||||
if (GContext.container.Resolve<LeadboardData>().IsOpenleaderboard)
|
||||
{
|
||||
switchbtn.onClick.AddListener(OnClickHead);
|
||||
}
|
||||
else
|
||||
{
|
||||
exchange.SetActive(false);
|
||||
switchbtn.enabled = false;
|
||||
//exchange.SetActive(false);
|
||||
}
|
||||
btn_aim.onClick.AddListener(OnClickAni);
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
uIDownUp.onDown.AddListener(OnDownAim);
|
||||
Debug.Log($"target_source Start isRobot: {opponentItemData.isRobot} target_group: {opponentItemData.target_group} target_source {opponentItemData.target_source}");
|
||||
}
|
||||
|
||||
void OnClickClose()
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
}
|
||||
bool opening = false;
|
||||
IEnumerator aniCameraMoveCoroutine;
|
||||
void OnDownAim()
|
||||
{
|
||||
opening = true;
|
||||
aniCameraMoveCoroutine = shooterFishAct.AniCameraMove();
|
||||
StartCoroutine(FishHuntingAim());
|
||||
//计时UP
|
||||
uIDownUp.onUp.AddListener(OnUpAim);
|
||||
}
|
||||
|
||||
IEnumerator FishHuntingAim()
|
||||
{
|
||||
yield return StartCoroutine(aniCameraMoveCoroutine);
|
||||
if (!opening)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
eventFishHuntingAim.gameObject.SetActive(true);
|
||||
float aimTime = eventFishHuntingAim.AimTime;
|
||||
yield return new WaitForSeconds(aimTime);
|
||||
ChangeTarget(null);
|
||||
OnUpAim();
|
||||
}
|
||||
|
||||
public async void OnUpAim()
|
||||
{
|
||||
if (!opening)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uIDownUp.onUp.RemoveAllListeners();
|
||||
OnClickAni();
|
||||
eventFishHuntingAim.isFinish = true;
|
||||
StopAllCoroutines();
|
||||
opening = false;
|
||||
uIDownUp.gameObject.SetActive(false);
|
||||
|
||||
eventFishHuntingAim.Trigger("Aim");
|
||||
if (fishMovement == null)
|
||||
{
|
||||
await StartCoroutine(shooterFishAct.OnBack());
|
||||
eventFishHuntingAim.isFinish = false;
|
||||
eventFishHuntingAim.gameObject.SetActive(false);
|
||||
await Awaiters.Seconds(shooterFishAct.AimBlockTime);
|
||||
uIDownUp.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Awaiters.Seconds(2);
|
||||
eventFishHuntingAim.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
async void OnClickAni()
|
||||
{
|
||||
isClick = true;
|
||||
fishMovement = shooterFishAct.Target();
|
||||
if (fishMovement != null)
|
||||
{
|
||||
eventFishHuntingAim.Trigger("Shoot");
|
||||
int getGlodCount = (int)AM.RobFishRequest(changeTargetCount, multiple, playFabId, fishMovement.index, fishMovement.groupId, opponentItemData, out bool isRob, out int addRankCount);
|
||||
await shooterFishAct.OnShoot(isRob);
|
||||
title.SetActive(false);
|
||||
exchange.SetActive(false);
|
||||
btn_aim.gameObject.SetActive(false);
|
||||
UIManager.Instance.DestroyUI(UITypes.EventBankHeistOpponentPopupPanel);
|
||||
ShowFish(isRob);
|
||||
|
||||
await Awaiters.Seconds(shooterFishAct.ShootTime);
|
||||
tag_fish_settlement.sprite = tag_fish.sprite;
|
||||
text_fish_name_settlement.text = text_fish_name.text;
|
||||
mutated_settlement.SetActive(fishMovement.index < fishMovement.slotData.mutants);
|
||||
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
|
||||
hurt.SetActive(!isRob);
|
||||
kill.SetActive(isRob);
|
||||
fx_ui_eventbankheistreward_money_01.SetActive(isRob);
|
||||
await shooterFishAct.OnShooted(isRob);
|
||||
SetData(getGlodCount, addRankCount);
|
||||
|
||||
var mapData = _tables.TbMapData.DataMap[AM.MapId];
|
||||
|
||||
string prefabName = mapData.AquariumPrefab;
|
||||
Transform bg = photo.Find($"bg_{prefabName}");
|
||||
if (bg != null)
|
||||
{
|
||||
bg_photo.sprite = bg.GetComponent<Image>().sprite;
|
||||
}
|
||||
|
||||
root_settlement.SetActive(true);
|
||||
fish_info.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
eventFishHuntingAim.Trigger("Back");
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_AquariumPanel_46"));
|
||||
}
|
||||
//exchange.SetActive(false);
|
||||
}
|
||||
|
||||
async void OnClickHead()
|
||||
{
|
||||
//选择对象
|
||||
await UIManager.Instance.ShowUI(UITypes.EventBankHeistOpponentPopupPanel);
|
||||
}
|
||||
|
||||
|
||||
public void ChangeTarget(FishMovement fish)
|
||||
{
|
||||
if (shooterFishAct == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
shooterFishAct.OnTargetChange(fish);
|
||||
if (fish != curTarget)
|
||||
{
|
||||
fish_info.SetActive(fish != null);
|
||||
curTarget = fish;
|
||||
if (curTarget != null)
|
||||
{
|
||||
var item = _tables.TbItem.GetOrDefault(curTarget.slotData.fishItemID);
|
||||
mutated.SetActive(curTarget.slotData.mutants > curTarget.index);
|
||||
text_fish_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(tag_fish, "icon_fish_rate_tag_" + item.Quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async void ChangeSmallGameTarget(ChangeSmallGameTargetEvent data)
|
||||
{
|
||||
//exchange.SetActive(false);
|
||||
switchbtn.enabled = false;
|
||||
if (await data.ts.Task)
|
||||
{
|
||||
changeTargetCount++;
|
||||
opponentItemData = data.opponentItemData;
|
||||
playFabId = data.opponentItemData.playFabID;
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
|
||||
SetAvatar(clubPlayInfo);
|
||||
fish_info.SetActive(false);
|
||||
}
|
||||
//exchange.SetActive(true);
|
||||
switchbtn.enabled = true;
|
||||
}
|
||||
|
||||
public void SetAvatar(PlayInfo clubPlayInfo)
|
||||
{
|
||||
if (clubPlayInfo != null)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_29", clubPlayInfo.name);
|
||||
head.SetData(clubPlayInfo.avatarUrl);
|
||||
}
|
||||
}
|
||||
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
|
||||
{
|
||||
if (getClubPlayInfoEvent.id == playFabId)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_29", getClubPlayInfoEvent.name);
|
||||
head.SetData(getClubPlayInfoEvent.avatarUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (rt != null)
|
||||
{
|
||||
rt.Release();
|
||||
Destroy(rt);
|
||||
rt = null;
|
||||
}
|
||||
if (fishGo != null)
|
||||
{
|
||||
Destroy(fishGo);
|
||||
}
|
||||
rtCamera.targetTexture = null;
|
||||
disposables?.Dispose();
|
||||
disposables = null;
|
||||
}
|
||||
|
||||
|
||||
GameObject fx_ui_eventbankheistreward_money_01;
|
||||
TMP_Text text_num;
|
||||
TMP_Text text_num_buff;
|
||||
RewardItemNew reward_extra;
|
||||
GameObject bg_extra;
|
||||
int add = 0;
|
||||
Image tag_fish_settlement;
|
||||
TMP_Text text_fish_name_settlement;
|
||||
void ShowFish(bool isRob)
|
||||
{
|
||||
if (fishMovement != null)
|
||||
{
|
||||
RectTransform raw = rawImage.GetComponent<RectTransform>();
|
||||
rt = new RenderTexture((int)raw.rect.width, (int)raw.rect.height, 24, RenderTextureFormat.ARGB32);
|
||||
|
||||
rtCamera.fieldOfView = fieldOfView;
|
||||
rtCamera.enabled = true;
|
||||
var TankPosition = fishMovement.fishData.TankPosition;
|
||||
Vector3 pos = new Vector3(TankPosition[0], TankPosition[1], TankPosition[2] + fishPosZ);
|
||||
Transform avatar = isRob ? avatarCapture : avatarEscape;
|
||||
//rawImage.color = isRob ? Color.white : Color.black;
|
||||
pos += avatar.localPosition;
|
||||
avatar.localPosition = pos;
|
||||
//fishMovement.RemoveEye();
|
||||
fishGo = Instantiate(fishMovement.fish.gameObject, avatar);
|
||||
Fish fish = fishGo.GetComponent<Fish>();
|
||||
fish.animator.transform.localPosition = Vector3.zero;
|
||||
var TankRotation = fishMovement.fishData.TankRotation;
|
||||
fish.transform.localRotation = Quaternion.Euler(TankRotation[0], TankRotation[1], TankRotation[2]);
|
||||
fish.transform.localScale = Vector3.one * fishMovement.fishData.TankScale * fishMovement.mutantScale;
|
||||
//fish.transform.localPosition = pos;
|
||||
rtCamera.targetTexture = rt;
|
||||
rawImage.texture = rt;
|
||||
rtCamera.Render();
|
||||
}
|
||||
//var mapData = _tables.TbMapData.DataMap[AM.MapId];
|
||||
//var AquariumBg = transform.Find($"root/root_settlement/photo/mask_bg2/{mapData.AquariumBg}");
|
||||
//if (AquariumBg != null)
|
||||
//{
|
||||
// AquariumBg.gameObject.SetActive(true);
|
||||
//}
|
||||
}
|
||||
|
||||
void SetData(int glod, int addRankCount)
|
||||
{
|
||||
//superCashBonus = 0.5f;
|
||||
FishingEventData _fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
bool isRankInit = _fishingEventData.rankInit != null;
|
||||
if (isRankInit && addRankCount > 0)
|
||||
{
|
||||
reward_extra.SetData(new ItemData() { id = _fishingEventData.rankInit.TokenID, count = addRankCount });
|
||||
//GContext.container.Resolve<SmallGameData>().image_extra_pos = bg_extra.transform.position;
|
||||
bg_extra.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
bg_extra.SetActive(false);
|
||||
}
|
||||
//this.multiple = multiple;
|
||||
add = glod;
|
||||
|
||||
GContext.Publish(new TargetAddData(1002, 0, add));
|
||||
StartCoroutine(ShowMoney());
|
||||
}
|
||||
|
||||
IEnumerator ShowMoney()
|
||||
{
|
||||
text_num.text = "";
|
||||
text_num_buff.text = "";
|
||||
SuperHunt superHunt = GContext.container.Resolve<BuffDataCenter>().GetWeelyBuffTimeData<SuperHunt>(true);
|
||||
float superCashBonus = 0;
|
||||
if (superHunt != null)
|
||||
{
|
||||
superCashBonus = superHunt.CashBonus;
|
||||
}
|
||||
if (superCashBonus > 0.001f)
|
||||
{
|
||||
text_num.color = Color.black;
|
||||
text_num_buff.color = Color.white;
|
||||
}
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
int gold = 0;
|
||||
DOTween.To(() => gold, x => gold = x, add, 1f).OnUpdate(() =>
|
||||
{
|
||||
text_num.text = ConvertTools.GetNumberString2(gold);
|
||||
text_num_buff.text = text_num.text;
|
||||
});
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/EventFishHuntingPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/EventFishHuntingPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8ae7d2c2e5d06847933f4f790fb60e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
119
Assets/Scripts/Aquarium/UI/FishSellingPopupPanel.cs
Normal file
119
Assets/Scripts/Aquarium/UI/FishSellingPopupPanel.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishSellingPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
Button btn_sure;
|
||||
|
||||
Transform content;
|
||||
GameObject Item;
|
||||
|
||||
AquariumManager AM;
|
||||
List<SellingPopupItem> items = new List<SellingPopupItem>();
|
||||
Action sellSure;
|
||||
List<AquariumSlotData> slotDataSureList;
|
||||
private void Awake()
|
||||
{
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_sure = transform.Find("root/btn_sure/btn_green").GetComponent<Button>();
|
||||
|
||||
content = transform.Find("root/panel_list/ScrollView/Viewport/Content");
|
||||
Item = content.Find("Item").gameObject;
|
||||
Item.SetActive(false);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_sure.onClick.AddListener(OnClickSure);
|
||||
ShowFish();
|
||||
}
|
||||
public void Init(Action sellSure)
|
||||
{
|
||||
this.sellSure = sellSure;
|
||||
}
|
||||
void ShowFish()
|
||||
{
|
||||
List<AquariumSlotData> slotDataList = AM.data.slotDatas;
|
||||
if (slotDataList == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<AquariumResultData> aquariumResultDatas = AM.data.aquariumResultDatas;
|
||||
|
||||
var time = ZZTimeHelper.UtcNow();
|
||||
for (int i = 0; i < AM.data.slot; i++)
|
||||
{
|
||||
AquariumSlotData slotData = slotDataList[i];
|
||||
if (slotData.FishHatchTime() < time && !slotData.IsResult())
|
||||
{
|
||||
GameObject go = Instantiate(Item, content);
|
||||
go.SetActive(true);
|
||||
SellingPopupItem item = go.GetComponent<SellingPopupItem>();
|
||||
item.SetData(slotData);
|
||||
items.Add(item);
|
||||
|
||||
if (item.bar.IsActive() && slotData.FishGrowthTime() < time)
|
||||
{
|
||||
item.checkmark.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.checkmark.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async void OnClickSure()
|
||||
{
|
||||
slotDataSureList = new List<AquariumSlotData>();
|
||||
bool isAllMax = true;
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
if (items[i].IsSell())
|
||||
{
|
||||
slotDataSureList.Add(items[i].slotData);
|
||||
if (!items[i].isMax)
|
||||
{
|
||||
isAllMax = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slotDataSureList.Count > 0)
|
||||
{
|
||||
if (isAllMax)
|
||||
{
|
||||
Sure();
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
|
||||
var noticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
|
||||
string title = LocalizationMgr.GetText("UI_AquariumPanel_11");
|
||||
string info = LocalizationMgr.GetText("UI_AquariumPanel_12");
|
||||
string right_text = LocalizationMgr.GetText("UI_AquariumPanel_13");
|
||||
string left_text = LocalizationMgr.GetText("UI_COMMON_cancel");
|
||||
noticeConfirmPopupPanel.Init(2,title, info, onClickRight: Sure, btn_left_text: left_text, btn_right_text: right_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sure()
|
||||
{
|
||||
AM.SellFish(slotDataSureList);
|
||||
sellSure?.Invoke();
|
||||
UIManager.Instance.DestroyUI(UITypes.FishSellingPopupPanel);
|
||||
}
|
||||
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.FishSellingPopupPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/FishSellingPopupPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/FishSellingPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38ae5debb86322c45b46a046382e28c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
Assets/Scripts/Aquarium/UI/FishcardBenefitPopupPanel.cs
Normal file
58
Assets/Scripts/Aquarium/UI/FishcardBenefitPopupPanel.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishcardBenefitPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
Button btn_mask;
|
||||
Button btn_go;
|
||||
TMP_Text text_map;
|
||||
TMP_Text text_level;
|
||||
AquariumCardWeight[] aquariumCardWeights;
|
||||
AquariumManager AM;
|
||||
private void Awake()
|
||||
{
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
text_map = transform.Find("root/bg/map/text_name").GetComponent<TMP_Text>();
|
||||
text_level = transform.Find("root/bg/level/text_num").GetComponent<TMP_Text>();
|
||||
aquariumCardWeights = transform.Find("root/bg/weight_bonus").GetComponentsInChildren<AquariumCardWeight>();
|
||||
btn_go = transform.Find("root/bg/btn_go/btn_green").GetComponent<Button>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
Tables _tables = GContext.container.Resolve<Tables>();
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_mask.onClick.AddListener(OnClickClose);
|
||||
var mapData = _tables.TbMapData.DataMap[AM.MapId];
|
||||
text_map.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
//string levelLV = LocalizationMgr.GetText("UI_FishingMapPanel_101006");
|
||||
int fishCardLevel = GContext.container.Resolve<PlayerFishData>().GetFishLevelByMap(AM.MapId);
|
||||
|
||||
List<float> weight = AM.GetWeightMag();
|
||||
|
||||
text_level.text = /*levelLV +*/ fishCardLevel.ToString();
|
||||
for (int i = 0; i < aquariumCardWeights.Length; i++)
|
||||
{
|
||||
aquariumCardWeights[i].text_level.text = weight[i].ToPercentageString();
|
||||
}
|
||||
btn_go.onClick.AddListener(GoTO);
|
||||
}
|
||||
|
||||
async void GoTO()
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingMapPanel);
|
||||
OnClickClose();
|
||||
}
|
||||
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.FishcardBenefitPopupPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/FishcardBenefitPopupPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/FishcardBenefitPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3fc2046c48471243ac9e024c5cb6c1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Scripts/Aquarium/UI/IAquariumTips.cs
Normal file
9
Assets/Scripts/Aquarium/UI/IAquariumTips.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
using System;
|
||||
|
||||
public interface IAquariumTips
|
||||
{
|
||||
void SetData(AquariumSlot aquariumSlot);
|
||||
bool UpdateBar(DateTime dateTime);
|
||||
void SetActive(bool value);
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/IAquariumTips.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/IAquariumTips.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb703d0fe4013b64da9c753955114e13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
198
Assets/Scripts/Aquarium/UI/SellingPopupItem.cs
Normal file
198
Assets/Scripts/Aquarium/UI/SellingPopupItem.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SellingPopupItem : MonoBehaviour
|
||||
{
|
||||
public Button btn_toggle;
|
||||
public GameObject checkmark;
|
||||
public GameObject icon_hurt;
|
||||
public GameObject icon_killed;
|
||||
public Image bar;
|
||||
public Image bar_hurt;
|
||||
public Image icon_fish;
|
||||
public GameObject done;
|
||||
public Image icon_rate;
|
||||
public TMP_Text text_time;
|
||||
public GameObject recoverting;
|
||||
public TMP_Text text_time2;
|
||||
public GameObject text_max;
|
||||
public TMP_Text text_cash;
|
||||
public GameObject killed;
|
||||
public TMP_Text text_killed;
|
||||
public AquariumSlotData slotData;
|
||||
AquariumFish aquariumFish;
|
||||
DateTime StartTime;
|
||||
float injuryH;
|
||||
float baseRewardCount;
|
||||
float allRewardCount;
|
||||
float WeightIncEvent;
|
||||
AquariumManager AM;
|
||||
AquariumResultData aquariumResultDatas;
|
||||
[HideInInspector]
|
||||
public bool isMax;
|
||||
private void Awake()
|
||||
{
|
||||
btn_toggle.onClick.AddListener(Click);
|
||||
}
|
||||
|
||||
void Click()
|
||||
{
|
||||
if (aquariumResultDatas != null && aquariumResultDatas.IsResult())
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_97"));
|
||||
return;
|
||||
}
|
||||
checkmark.SetActive(!checkmark.activeSelf);
|
||||
}
|
||||
public bool IsSell()
|
||||
{
|
||||
return aquariumResultDatas == null || checkmark.activeSelf && !aquariumResultDatas.IsResult();
|
||||
}
|
||||
public void SetData(AquariumSlotData slotData)
|
||||
{
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
aquariumResultDatas = AM.data.aquariumResultDatas[slotData.index];
|
||||
|
||||
this.slotData = slotData;
|
||||
aquariumFish = GContext.container.Resolve<Tables>().TbAquariumFish.GetOrDefault(slotData.aquariumFishID);
|
||||
StartTime = slotData.FishHatchTime();
|
||||
injuryH = slotData.injuryGrowthTime;
|
||||
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(slotData.fishItemID);
|
||||
PlayerFishData.SetFishIcon(icon_fish, item);//鱼头像
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rate, $"icon_fish_rate_tag_{item.Quality}");
|
||||
|
||||
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||||
var weight = GContext.container.Resolve<AquariumManager>().GetWeightMag();
|
||||
WeightIncEvent = (1 + weight[slotData.aquariumFishID - 1]) * (1 + playerData.benefitsCashMag) * (1 + playerData.benefitsAquariumCashMag);
|
||||
|
||||
//金币显示
|
||||
baseRewardCount = slotData.allCash;
|
||||
allRewardCount = 0;
|
||||
int fishQ = slotData.fishMQ;
|
||||
for (int i = 0; i < fishQ; i++)
|
||||
{
|
||||
if (slotData.mutants > i)
|
||||
{
|
||||
allRewardCount += baseRewardCount * WeightIncEvent * (1 + aquariumFish.MutantExtraSoldReward) * (1 + aquariumFish.MutantGrowthExtraSoldReward);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRewardCount += baseRewardCount * WeightIncEvent * (1 + aquariumFish.GrowthExtraSoldReward);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateBar(ZZTimeHelper.UtcNow());
|
||||
}
|
||||
public void UpdateBar(DateTime dateTime)
|
||||
{
|
||||
//正常的成长进度 自然时间+加速成长 - 全部恢复时间
|
||||
float normalH = (float)(dateTime - StartTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
||||
//受伤时的成长进度
|
||||
|
||||
//受伤时的成长进度大于正常的成长进度
|
||||
float timeProgress;
|
||||
float barProgress;
|
||||
bar_hurt.gameObject.SetActive(false);
|
||||
icon_hurt.gameObject.SetActive(false);
|
||||
text_time.gameObject.SetActive(true);
|
||||
text_max.gameObject.SetActive(false);
|
||||
text_time.gameObject.SetActive(true);
|
||||
recoverting.gameObject.SetActive(false);
|
||||
isMax = false;
|
||||
timeProgress = normalH / slotData.growthTime;
|
||||
bar.gameObject.SetActive(true);
|
||||
if (aquariumResultDatas.IsResult())
|
||||
{
|
||||
bar.gameObject.SetActive(false);
|
||||
done.SetActive(true);
|
||||
killed.SetActive(true);
|
||||
text_time.gameObject.SetActive(false);
|
||||
AquariumResultData aquariumResultDatas = AM.data.aquariumResultDatas[slotData.index];
|
||||
text_killed.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_42", aquariumResultDatas.displayName);
|
||||
}
|
||||
else
|
||||
{
|
||||
bar.fillAmount = 1;
|
||||
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
text_time.gameObject.SetActive(false);
|
||||
recoverting.gameObject.SetActive(true);
|
||||
bar.gameObject.SetActive(false);
|
||||
bar_hurt.gameObject.SetActive(true);
|
||||
icon_hurt.gameObject.SetActive(true);
|
||||
bar_hurt.fillAmount = (injuryH - normalH) / slotData.recoveryTime;
|
||||
barProgress = injuryH / slotData.growthTime;
|
||||
if (barProgress > 1)
|
||||
{
|
||||
timeProgress = 1 - ((injuryH - normalH) / slotData.growthTime);
|
||||
}
|
||||
|
||||
int timeRemaining = (int)((injuryH - normalH) * 3600);
|
||||
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
||||
text_time2.text = ConvertTools.ConvertTime2(timeSpan);
|
||||
|
||||
if (timeProgress < 0)
|
||||
{
|
||||
timeProgress = 0;
|
||||
}
|
||||
}
|
||||
else if (normalH >= slotData.growthTime)
|
||||
{
|
||||
text_time.gameObject.SetActive(false);
|
||||
text_max.gameObject.SetActive(true);
|
||||
timeProgress = 1;
|
||||
barProgress = 1;
|
||||
isMax = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
barProgress = normalH / slotData.growthTime;
|
||||
bar.fillAmount = barProgress;
|
||||
}
|
||||
|
||||
if (timeProgress < 1)
|
||||
{
|
||||
int timeRemaining = (int)(slotData.growthTime * (1 - timeProgress) * 3600);
|
||||
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
||||
text_time.text = ConvertTools.ConvertTime2(timeSpan);
|
||||
}
|
||||
}
|
||||
|
||||
float rewardProgress = timeProgress;// normalH / slotData.growthTime;
|
||||
if (rewardProgress > 1)
|
||||
{
|
||||
rewardProgress = 1;
|
||||
}
|
||||
//金币显示
|
||||
int fishQ = slotData.fishMQ;
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
fishQ -= GContext.container.Resolve<AquariumManager>().data.aquariumHurtDatas[slotData.index].fishLQ;
|
||||
if (fishQ <= 0)
|
||||
{
|
||||
fishQ = 1;
|
||||
}
|
||||
}
|
||||
float rewardCount = 0;
|
||||
for (int i = 0; i < fishQ; i++)
|
||||
{
|
||||
if (slotData.mutants > i)
|
||||
{
|
||||
rewardCount += baseRewardCount * (1 + aquariumFish.MutantExtraSoldReward) * (1 + aquariumFish.MutantGrowthExtraSoldReward * rewardProgress) * WeightIncEvent;
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardCount += baseRewardCount * (1 + aquariumFish.GrowthExtraSoldReward * rewardProgress) * WeightIncEvent;
|
||||
}
|
||||
}
|
||||
|
||||
text_cash.text = $"{ConvertTools.GetNumberString2((int)(rewardCount))}/{ConvertTools.GetNumberString2((int)allRewardCount)}";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/SellingPopupItem.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/SellingPopupItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27133304bb28eca44baf5072685850ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
146
Assets/Scripts/Aquarium/UI/SpeedupPopupPanel.cs
Normal file
146
Assets/Scripts/Aquarium/UI/SpeedupPopupPanel.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SpeedupPopupPanel : MonoBehaviour
|
||||
{
|
||||
AdvertButton advertButton;
|
||||
Button freeButton;
|
||||
Button btn_diamonds;
|
||||
Button btn_diamonds_gray;
|
||||
TMP_Text text_info;
|
||||
TMP_Text p_text_num;
|
||||
TMP_Text p_text_num_gray;
|
||||
|
||||
Button btn_close;
|
||||
Action OnSucceedCall;
|
||||
Action<bool> StartSeedUp;
|
||||
TMP_Text p_text;
|
||||
TMP_Text p_text1;
|
||||
TMP_Text text_time;
|
||||
GameObject speedupPopupPanel;
|
||||
GameObject aquariumSpeedupPanel;
|
||||
private void Awake()
|
||||
{
|
||||
speedupPopupPanel = transform.Find("SpeedupPopupPanel").gameObject;
|
||||
aquariumSpeedupPanel = transform.Find("AquariumSpeedupPanel").gameObject;
|
||||
btn_diamonds = transform.Find("SpeedupPopupPanel/root/btn_diamonds/btn_adv").GetComponent<Button>();
|
||||
btn_diamonds_gray = transform.Find("SpeedupPopupPanel/root/btn_diamonds_gray/btn_adv").GetComponent<Button>();
|
||||
advertButton = transform.Find("SpeedupPopupPanel/root/btn_advert").GetComponent<AdvertButton>();
|
||||
btn_close = transform.Find("SpeedupPopupPanel/btn_close").GetComponent<Button>();
|
||||
text_info = transform.Find("SpeedupPopupPanel/root/bg_time/text_time").GetComponent<TMP_Text>();
|
||||
p_text = transform.Find("SpeedupPopupPanel/root/btn_advert/btn_adv/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
p_text1 = transform.Find("SpeedupPopupPanel/root/btn_advert/btn_ticket/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
p_text_num = transform.Find("SpeedupPopupPanel/root/btn_diamonds/btn_adv/Ani_Container/content_cost/cost/p_text_num").GetComponent<TMP_Text>();
|
||||
p_text_num_gray = transform.Find("SpeedupPopupPanel/root/btn_diamonds_gray/btn_adv/Ani_Container/content_cost/cost/p_text_num").GetComponent<TMP_Text>();
|
||||
text_time = transform.Find("SpeedupPopupPanel/root/text_time").GetComponent<TMP_Text>();
|
||||
freeButton = transform.Find("SpeedupPopupPanel/root/btn_free").GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
bool isGuide = GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("SpeedupPopupPanel");
|
||||
p_text_num_gray.text = p_text_num.text = GContext.container.Resolve<Tables>().TbAquariumConfig.AdAccelerateDiamondCost.ToString();
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
Tables tables = GContext.container.Resolve<Tables>();
|
||||
string contnet = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_16", tables.TbAquariumConfig.AdAccelerate * 60);
|
||||
if (isGuide)
|
||||
{
|
||||
//advertButton.SetData(null, AdvertPopupType.Aquarium);
|
||||
//advertButton.advBtn.onClick.AddListener(GuideAdsSucceed);
|
||||
freeButton.onClick.AddListener(GuideAdsSucceed);
|
||||
//p_text1.text = p_text.text = LocalizationMgr.GetText("UI_BattlePassPanel_3");
|
||||
contnet = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_16", tables.TbAquariumConfig.AdAccelerateFirst * 60);
|
||||
}
|
||||
else
|
||||
{
|
||||
advertButton.SetData(OnAdsSucceed, AdvertPopupType.Aquarium);
|
||||
}
|
||||
advertButton.gameObject.SetActive(!isGuide);
|
||||
freeButton.gameObject.SetActive(isGuide);
|
||||
btn_diamonds.onClick.AddListener(OnClickDiamonds);
|
||||
advertButton.advBtnGray.onClick.AddListener(ShowToast);
|
||||
btn_diamonds_gray.onClick.AddListener(ShowToast);
|
||||
text_info.text = contnet;
|
||||
}
|
||||
public void SetData(Action onSucceed, Action<bool> startSeedUp, string adContent)
|
||||
{
|
||||
if (onSucceed == null)
|
||||
{
|
||||
advertButton.SetGray();
|
||||
}
|
||||
btn_diamonds.gameObject.SetActive(onSucceed != null);
|
||||
btn_diamonds_gray.gameObject.SetActive(onSucceed == null);
|
||||
OnSucceedCall = onSucceed;
|
||||
StartSeedUp = startSeedUp;
|
||||
text_time.text = adContent;
|
||||
}
|
||||
|
||||
void ShowToast()
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_60"));
|
||||
}
|
||||
|
||||
void OnClickDiamonds()
|
||||
{
|
||||
if (OnSucceedCall == null)
|
||||
{
|
||||
ShowToast();
|
||||
return;
|
||||
}
|
||||
var curDiamond = GContext.container.Resolve<PlayerData>().diamond;
|
||||
int diamondCost = GContext.container.Resolve<Tables>().TbAquariumConfig.AdAccelerateDiamondCost;
|
||||
if (curDiamond >= diamondCost)
|
||||
{
|
||||
GContext.container.Resolve<PlayerData>().AddDiamond(-diamondCost);
|
||||
OnSucceed(false);
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("aquarium_speedup"))
|
||||
{
|
||||
e.AddContent("speedup_type", 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
//_ = UIManager.Instance.ShowUI(UITypes.LackOfResourceConfirmPopupPanel);
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_59"));
|
||||
}
|
||||
}
|
||||
void GuideAdsSucceed()
|
||||
{
|
||||
OnSucceed(true);
|
||||
}
|
||||
void OnAdsSucceed()
|
||||
{
|
||||
OnSucceed(false);
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("aquarium_speedup"))
|
||||
{
|
||||
e.AddContent("speedup_type", 2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
async void OnSucceed(bool isGuide)
|
||||
{
|
||||
StartSeedUp?.Invoke(isGuide);
|
||||
speedupPopupPanel.SetActive(false);
|
||||
aquariumSpeedupPanel.SetActive(true);
|
||||
await Awaiters.Seconds(2f);
|
||||
OnSucceedCall?.Invoke();
|
||||
await Awaiters.Seconds(0.5f);
|
||||
UIManager.Instance.DestroyUI(UITypes.SpeedupPopupPanel);
|
||||
}
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.SpeedupPopupPanel);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("AquariumPanel");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/SpeedupPopupPanel.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/SpeedupPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a833388a2ab4d8a4391806da05324b4a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/Aquarium/UI/UIDownUp.cs
Normal file
29
Assets/Scripts/Aquarium/UI/UIDownUp.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using static UnityEngine.UI.Button;
|
||||
|
||||
public class UIDownUp : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
private ButtonClickedEvent m_OnDown = new ButtonClickedEvent();
|
||||
private ButtonClickedEvent m_OnUp = new ButtonClickedEvent();
|
||||
public ButtonClickedEvent onDown
|
||||
{
|
||||
get { return m_OnDown; }
|
||||
set { m_OnDown = value; }
|
||||
}
|
||||
|
||||
public ButtonClickedEvent onUp
|
||||
{
|
||||
get { return m_OnUp; }
|
||||
set { m_OnUp = value; }
|
||||
}
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
m_OnDown.Invoke();
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
m_OnUp.Invoke();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Aquarium/UI/UIDownUp.cs.meta
Normal file
11
Assets/Scripts/Aquarium/UI/UIDownUp.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88c8989011cd49b418bd3c2567ede5ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user