先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
1557 lines
55 KiB
C#
1557 lines
55 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
using asap.core;
|
||
using cfg;
|
||
using DG.Tweening;
|
||
using game;
|
||
using Game;
|
||
using GameCore;
|
||
using TMPro;
|
||
using UI.Home.Event;
|
||
using UniRx;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class HideHomePanelEvent
|
||
{
|
||
public bool IsHideMap = true;
|
||
}
|
||
public partial class HomePanel : BasePanel
|
||
{
|
||
//拖动选择角度
|
||
Tables _tables;
|
||
FishingEventData _fishingEventData;
|
||
[Header("HomePanel操作相机x=Mathf.Clamp(z,x) y=Mathf.Clamp(w,y)")]
|
||
public float duration = 0.65f;
|
||
|
||
//屏幕拖动比例
|
||
public float dragCameraScale = 0.005f;
|
||
|
||
//重力旋转操作角度限制
|
||
public Vector4 gravityAngleLimit = new Vector4(75, 15, 15, -45);
|
||
|
||
//重力旋转游戏角度限制
|
||
public Vector4 gravityGameAngleLimit = new Vector4(-2, 0.25f, 2, 2);
|
||
|
||
//拖动旋转角度限制
|
||
public Vector4 dragEulerAngleLimit = new Vector4(2, 2, -2, -2);
|
||
[Range(0, 1)] public float gravitySub = 0.2f;
|
||
private CanvasGroup canvasGroup;
|
||
GameObject mask;
|
||
Animator anim;
|
||
Vector3 _targetEuler;
|
||
Vector3 _offsetEuler;
|
||
|
||
Vector3 _curEuler = new Vector3(0, 0, 0);
|
||
|
||
//private Quaternion startQuaternion;
|
||
|
||
//private Quaternion originalQuaternion;
|
||
|
||
private bool _isMoveing = true;
|
||
bool isMouse = false;
|
||
private Vector3 _curMousePos;
|
||
Button btn_questionmark;
|
||
private UIButton btn_play;
|
||
Animator btn_play_anim;
|
||
GameObject effect_beilv_loop;
|
||
private Button btn_beilv;
|
||
Image btn_beilv_image;
|
||
Image buff_beilv_image;
|
||
GameObject btn_task_gray;
|
||
GameObject btn_friend_gray;
|
||
private TMP_Text text_beilv;
|
||
|
||
private CanvasGroup beilvpanel;
|
||
public Transform beilvpanel_max;
|
||
public Transform bg_beilvlpanel;
|
||
private TMP_Text text_beilvpanel_title;
|
||
private TMP_Text text_beilvpanel_content;
|
||
|
||
//体力进度条
|
||
private Image image_slider_energy;
|
||
|
||
//体力当前值/最大值
|
||
private TMP_Text text_energy_value;
|
||
|
||
Timer EnergyTimer;
|
||
public TMP_Text text_energy_time;
|
||
//目标奖励活动====
|
||
HomeBubbleTask homeBubbleTask;
|
||
|
||
//锁链礼包
|
||
private Button btn_chainschest; // 锁链礼包按钮
|
||
|
||
//=====目标奖励活动礼包
|
||
HomeGiftBtnPanel homeGift;
|
||
//=====目标奖励活动礼包
|
||
//目标奖励活动====
|
||
private RankTargets rankTarget;
|
||
public Queue<RewardItemNew> imageQueue = new Queue<RewardItemNew>();
|
||
public Transform rewardFlyPanel;
|
||
public RewardItemNew rewardItemPrefab;
|
||
public Button btn_rank;
|
||
public Button btn_turntable;
|
||
GameObject btn_fishbowl;
|
||
|
||
// private Button btn_chainschest; // 锁链礼包
|
||
public TMP_Text text_turntable_time;
|
||
public TMP_Text text_rank_time;
|
||
public TMP_Text text_rank;
|
||
public Image rankIcon;
|
||
Timer rank_timer;
|
||
Timer showdownTimer;
|
||
public Button btn_friend;
|
||
|
||
UITopArea top_area;
|
||
int addGlodCount = 0;
|
||
private WheelLevel wheelLevel;
|
||
FishingStage fishingStage;
|
||
int Energy;
|
||
HomeBtnRank homeBtnRank;
|
||
|
||
PlayerFishData _playerFishData;
|
||
HomeBuffPanel homeBuffPanel;
|
||
HomeLeftPanel homeLeftPanel;
|
||
HomeRightPanel homeRightPanel;
|
||
|
||
HomeSupplyDropPanel homeSupplyDropPanel;
|
||
bool isFishingPanel = false;
|
||
|
||
FishingData fishingData;
|
||
bool isSuperEnergy = false;
|
||
Canvas RewardFlyPanel;
|
||
UIDrag moveCameraPanel;
|
||
int barDataProgress = 0;
|
||
bool skipFaceAfterRewardPanelClose;
|
||
private void Awake()
|
||
{
|
||
fishingData = GContext.container.Resolve<FishingData>();
|
||
panelName = "HomePanel";
|
||
fishingStage = GContext.container.ResolveStage("FishingStage") as FishingStage;
|
||
_offsetEuler = Vector3.zero;
|
||
GContext.container.Resolve<PlayerShopData>().InitShopPackData();
|
||
moveCameraPanel = transform.Find("moveCameraPanel").GetComponent<UIDrag>();
|
||
mask = transform.Find("mask").gameObject;
|
||
mask.SetActive(false);
|
||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||
_playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||
top_area = transform.Find("top_area").GetComponent<UITopArea>();
|
||
beilvpanel_max = transform.Find("DownMiddlePanel/btn_play/beilvpanel/bg_beilv_max").GetComponent<Transform>();
|
||
bg_beilvlpanel = transform.Find("DownMiddlePanel/btn_play/beilvpanel/bg_beilv").GetComponent<Transform>();
|
||
|
||
text_energy_time = transform.Find("DownMiddlePanel/bg_info/text_info").GetComponent<TMP_Text>();
|
||
|
||
var supplyDropGO = transform.Find("DownMiddlePanel/SupplyDrop");
|
||
if (supplyDropGO != null) homeSupplyDropPanel = supplyDropGO.GetComponent<HomeSupplyDropPanel>();
|
||
|
||
var bubbleTaskGO = transform.Find("safearea/MiddlePanel/btn_bubble_task");
|
||
if (bubbleTaskGO != null) homeBubbleTask = bubbleTaskGO.GetComponent<HomeBubbleTask>();
|
||
|
||
var chainschestGO = transform.Find("safearea/LeftPanel/layout/btn_offerchainschest");
|
||
if (chainschestGO != null) btn_chainschest = chainschestGO.GetComponent<Button>();
|
||
|
||
rewardFlyPanel = transform.Find("RewardFlyPanel").GetComponent<Transform>();
|
||
rewardItemPrefab = transform.Find("RewardFlyPanel/reward").GetComponent<RewardItemNew>();
|
||
rewardItemPrefab.gameObject.SetActive(false);
|
||
btn_questionmark = transform.Find("DownMiddlePanel/bar/btn_questionmark").GetComponent<Button>();
|
||
btn_play = transform.Find("DownMiddlePanel/btn_play").GetComponent<UIButton>();
|
||
btn_play_anim = btn_play.GetComponent<Animator>();
|
||
effect_beilv_loop = transform.Find("DownMiddlePanel/btn_play/beilv/effect_beilv_loop").gameObject;
|
||
btn_beilv = transform.Find("DownMiddlePanel/btn_play/beilv").GetComponent<Button>();
|
||
btn_beilv_image = transform.Find("DownMiddlePanel/btn_play/beilv").GetComponent<Image>();
|
||
buff_beilv_image = transform.Find("DownMiddlePanel/btn_play/beilv/buff_beilv").GetComponent<Image>();
|
||
|
||
text_beilv = transform.Find("DownMiddlePanel/btn_play/beilv/text_beilv").GetComponent<TMP_Text>();
|
||
|
||
|
||
canvasGroup = GetComponent<CanvasGroup>();
|
||
anim = GetComponent<Animator>();
|
||
beilvpanel = transform.Find("DownMiddlePanel/btn_play/beilvpanel").GetComponent<CanvasGroup>();
|
||
text_beilvpanel_title =
|
||
transform.Find("DownMiddlePanel/btn_play/beilvpanel/text_title").GetComponent<TMP_Text>();
|
||
text_beilvpanel_content =
|
||
transform.Find("DownMiddlePanel/btn_play/beilvpanel/bg_beilv/text_beilv").GetComponent<TMP_Text>();
|
||
image_slider_energy = transform.Find("DownMiddlePanel/bar/Fill Area/Fill").GetComponent<Image>();
|
||
text_energy_value = transform.Find("DownMiddlePanel/bar/Fill Area/text_progress").GetComponent<TMP_Text>();
|
||
|
||
btn_rank = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_rank").GetComponent<Button>();
|
||
text_rank_time = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_rank/text_time").GetComponent<TMP_Text>();
|
||
text_rank = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_rank/text_rank").GetComponent<TMP_Text>();
|
||
rankIcon = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_rank/icon").GetComponent<Image>();
|
||
btn_friend = transform.Find("safearea/DownPanel/btn_friend").GetComponent<Button>();
|
||
|
||
btn_turntable = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_event").GetComponent<Button>();
|
||
|
||
var fishbowlGO = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_fishbowl");
|
||
if (fishbowlGO != null) btn_fishbowl = fishbowlGO.gameObject;
|
||
|
||
text_turntable_time = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_event/text_time").GetComponent<TMP_Text>();
|
||
_tables = GContext.container.Resolve<Tables>();
|
||
btn_task_gray = transform.Find("safearea/DownPanel/btn_task/icon_gray").gameObject;
|
||
btn_friend_gray = transform.Find("safearea/DownPanel/btn_friend/icon_gray").gameObject;
|
||
|
||
if (Energy == 0)
|
||
{
|
||
Energy = GContext.container.Resolve<PlayerData>().Energy;
|
||
}
|
||
|
||
homeBtnRank = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content/btn_rank").GetComponent<HomeBtnRank>();
|
||
homeBuffPanel = transform.Find("safearea/RightPanel/btn_buff").GetComponent<HomeBuffPanel>();
|
||
homeLeftPanel = transform.Find("safearea/LeftPanel/layout").GetComponent<HomeLeftPanel>();
|
||
homeLeftPanel.homePanel = this;
|
||
homeRightPanel = transform.Find("safearea/RightPanel/ScrollView/Viewport/Content").GetComponent<HomeRightPanel>();
|
||
homeGift = transform.Find("safearea/LeftPanel/layout").GetComponent<HomeGiftBtnPanel>();
|
||
|
||
dragEulerAngleLimit.y = ConvertTools.CalculateActualRotationAngle(dragEulerAngleLimit.y);
|
||
dragEulerAngleLimit.w = -ConvertTools.CalculateActualRotationAngle(-dragEulerAngleLimit.w);
|
||
CollectingTargetNext();
|
||
}
|
||
|
||
protected override void Start()
|
||
{
|
||
homeGift.Init();
|
||
Input.multiTouchEnabled = false;
|
||
base.Start();
|
||
if (homeSupplyDropPanel != null) homeSupplyDropPanel.Init();
|
||
|
||
btn_beilv.onClick.AddListener(OnclickMagnification);
|
||
btn_questionmark.onClick.AddListener(Questionmark);
|
||
btn_questionmark.gameObject.SetActive(GContext.container.Resolve<FishingEventData>().IsOpenDrop);
|
||
btn_play.onDown.AddListener(StartAutoTimer);
|
||
btn_play.onUp.AddListener(StopCoroutineTimer);
|
||
btn_play.onClick.AddListener(OnClickPlay);
|
||
|
||
btn_friend.onClick.AddListener(() =>
|
||
{
|
||
});
|
||
btn_rank.onClick.AddListener(OnClickRank);
|
||
// [REMOVED] Turntable deleted
|
||
btn_turntable.gameObject.SetActive(false);
|
||
btn_turntable.onClick.AddListener(() => { });
|
||
// btn_turntable.onClick.AddListener(() =>
|
||
// {
|
||
// btn_turntable.enabled = false;
|
||
// OnPushPanelOrScene(UITypes.FishingTurntablePanel);
|
||
// btn_turntable.enabled = true;
|
||
// });
|
||
|
||
dragCameraScale = (dragEulerAngleLimit.x - dragEulerAngleLimit.z) / Screen.width;
|
||
GContext.OnEvent<ResAddEvent>().Subscribe(ResAddEvent).AddTo(disposables);
|
||
GContext.OnEvent<TargetEvent>().Subscribe(FishingEvent).AddTo(disposables);
|
||
GContext.OnEvent<HideHomePanelEvent>().Subscribe(OnHideHomePanelEvent).AddTo(disposables);
|
||
GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose).AddTo(disposables);
|
||
GContext.OnEvent<RewardPanelCloseSkipFace>().Subscribe(_ => skipFaceAfterRewardPanelClose = true).AddTo(disposables);
|
||
GContext.OnEvent<GetUIAsyncEvent>().Subscribe(OnGetUIAsyncEvent).AddTo(disposables);
|
||
GContext.OnEvent<FaceUICloseEvent>().Subscribe(FaceUIEventClose).AddTo(disposables);
|
||
GContext.OnEvent<EventRankData>().Subscribe(SetRankRank).AddTo(disposables);
|
||
GContext.OnEvent<TriggerPackEvent>().Subscribe(TriggerPackEvent).AddTo(disposables);
|
||
GContext.OnEvent<BuffChangeEvent>().Subscribe(BufChangeEvent).AddTo(disposables);
|
||
//GContext.OnEvent<LackOfResourceCloseEvent>().Subscribe(x =>
|
||
//{
|
||
// if (!x.resultToShop)
|
||
// {
|
||
// ResourceCloseEvent();
|
||
// }
|
||
//}).AddTo(disposables);
|
||
|
||
GContext.OnEvent<ShowRewardPopupTop>().Subscribe(x =>
|
||
{
|
||
x.isHide = true;
|
||
}).AddTo(disposables);
|
||
|
||
transform.SetAsFirstSibling();
|
||
|
||
SetMoveCameraPanel();
|
||
|
||
GContext.Publish(new HomeStartEvent());
|
||
}
|
||
void SetMoveCameraPanel()
|
||
{
|
||
moveCameraPanel.OnPointerDownCall = () =>
|
||
{
|
||
fishingData.mainCamera.DOKill(false);
|
||
_curMousePos = Input.mousePosition;
|
||
_offsetEuler = Vector3.zero;
|
||
_isMoveing = false;
|
||
isMouse = true;
|
||
};
|
||
moveCameraPanel.OnPointerUpCall = () =>
|
||
{
|
||
if (isMouse)
|
||
{
|
||
_isMoveing = true;
|
||
isMouse = false;
|
||
_offsetEuler = Vector3.zero;
|
||
_targetEuler = fishingData.startEuler.eulerAngles + _curEuler;
|
||
Move();
|
||
}
|
||
};
|
||
moveCameraPanel.OnDragCall = (eventData) =>
|
||
{
|
||
if (isMouse)
|
||
{
|
||
Vector3 ver = Input.mousePosition - _curMousePos;
|
||
_offsetEuler.x = CheckAngle(_offsetEuler.x);
|
||
_offsetEuler.y = CheckAngle(_offsetEuler.y);
|
||
_offsetEuler += new Vector3(-ver.y, ver.x, 0) * dragCameraScale;
|
||
//目标旋转角度
|
||
_offsetEuler.x = Mathf.Clamp(_offsetEuler.x, dragEulerAngleLimit.z, dragEulerAngleLimit.x);
|
||
_offsetEuler.y = Mathf.Clamp(_offsetEuler.y, dragEulerAngleLimit.w, dragEulerAngleLimit.y);
|
||
_curMousePos = Input.mousePosition;
|
||
}
|
||
};
|
||
}
|
||
void BufChangeEvent(BuffChangeEvent bufChangeEvent)
|
||
{
|
||
CheckSuperEnergyBuff();
|
||
SetShowMagnification();
|
||
}
|
||
|
||
//开始下一次钓鱼长按
|
||
void StartAutoTimer()
|
||
{
|
||
btn_play_anim.Play("Pressed", -1, 0);
|
||
}
|
||
void StopCoroutineTimer()
|
||
{
|
||
btn_play_anim.Play("Normal", -1, 0);
|
||
}
|
||
|
||
|
||
void ResAddEvent(ResAddEvent resAddEvent)
|
||
{
|
||
if (resAddEvent.id == 1001)
|
||
{
|
||
EnergyChangeAnim(resAddEvent.addCount);
|
||
}
|
||
else if (resAddEvent.id == 1002)
|
||
{
|
||
GoldChange();
|
||
}
|
||
}
|
||
void GoldChange()
|
||
{
|
||
GContext.container.Resolve<CampDataMM>().SetRedPoint();
|
||
}
|
||
|
||
void SetRank()
|
||
{
|
||
rankTarget = _fishingEventData.rankTarget;
|
||
if (rankTarget != null)
|
||
{
|
||
if (rank_timer == null || rank_timer.isDone)
|
||
{
|
||
btn_rank.gameObject.SetActive(true);
|
||
btn_rank.enabled = true;
|
||
btn_rank.transform.Find("lock").gameObject.SetActive(false);
|
||
|
||
DateTime endTime = _fishingEventData.GetRankEndTime();
|
||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||
double seconds = now.TotalSeconds;
|
||
rank_timer = this.AttachTimer((float)seconds, RefreshRank,
|
||
(elapsed) =>
|
||
{
|
||
now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||
text_rank_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||
}, useRealTime: true);
|
||
|
||
GContext.container.Resolve<IUIService>().SetImageSprite(rankIcon, _fishingEventData.rankInit.Icon, "HomePanel");
|
||
SetRankRank();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (GContext.container.Resolve<PlayerData>().lv >= GContext.container.Resolve<Tables>().TbGlobalConfig.PreviewUnlockLevel)
|
||
{
|
||
btn_rank.gameObject.SetActive(true);
|
||
rank_timer?.Cancel();
|
||
rank_timer = null;
|
||
// btn_rank.enabled = false;
|
||
var rankEvent = GContext.container.Resolve<FishingEventData>().GetEventeByTimType(3, 3);
|
||
if (rankEvent != null)
|
||
{
|
||
var rankInit = _tables.TbRankInit.GetOrDefault(rankEvent.RedirectID);
|
||
if (rankInit != null)
|
||
{
|
||
GContext.container.Resolve<IUIService>().SetImageSprite(rankIcon, rankInit.Icon, "HomePanel");
|
||
}
|
||
btn_rank.transform.Find("lock").gameObject.SetActive(true);
|
||
text_rank_time.gameObject.SetActive(false);
|
||
TMP_Text text_level = btn_rank.transform.Find("lock/text_level").GetComponent<TMP_Text>();
|
||
text_level.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", rankEvent.ConditionList[0].Param[0]);
|
||
text_rank.text = "";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
btn_rank.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
async void OnClickRank()
|
||
{
|
||
var rankInit = GContext.container.Resolve<FishingEventData>().rankInit;
|
||
if (rankInit == null)
|
||
{
|
||
GameObject panel = await UIManager.Instance.ShowUILoad(new UIType("FeatureUnlockPreviewPopupPanel"));
|
||
FeatureUnlockPreviewPopupPanel featureUnlockPreviewPopupPanel = panel.GetComponent<FeatureUnlockPreviewPopupPanel>();
|
||
featureUnlockPreviewPopupPanel.InitPanel(2);
|
||
return;
|
||
}
|
||
await UIManager.Instance.ShowUILoad(UITypes.EventRankPopupPanel);
|
||
}
|
||
void RefreshRank()
|
||
{
|
||
rank_timer?.Cancel();
|
||
rank_timer = null;
|
||
GContext.container.Resolve<FishingEventData>().GetEventAndInit(3, 3);
|
||
//await GContext.container.Resolve<LeadboardData>().GetRewards();
|
||
}
|
||
void SetRankRank(EventRankData data = null)
|
||
{
|
||
if (_fishingEventData.IsOpenRank() && GContext.container.Resolve<LeadboardData>().GetMeRank() > 0)
|
||
{
|
||
text_rank.text = LocalizationMgr.GetFormatTextValue("UI_EventChallengeCrocodilePanel_9",
|
||
GContext.container.Resolve<LeadboardData>().GetMeRank());
|
||
}
|
||
else
|
||
{
|
||
text_rank.text = "--";
|
||
}
|
||
}
|
||
void SetTurntable() { btn_turntable.gameObject.SetActive(false); }
|
||
void RefreshTurntable() { btn_turntable.gameObject.SetActive(false); }
|
||
|
||
void OnClickPlay()
|
||
{
|
||
if (GContext.container.Resolve<GuideDataCenter>().curDefine != null &&
|
||
GContext.container.Resolve<GuideDataCenter>().curDefine.fingerType != FingerType.None &&
|
||
GContext.container.Resolve<GuideDataCenter>().curDefine.panelName == "HomePanel")
|
||
{
|
||
return;
|
||
}
|
||
StartFishingPlay();
|
||
}
|
||
public async void PopupStore()
|
||
{
|
||
if (GContext.container.Resolve<PlayerData>().GetCanMagnification() == false)
|
||
{
|
||
await Awaiters.NextFrame;
|
||
if (GContext.container.Resolve<GuideDataCenter>().curDefine != null &&
|
||
GContext.container.Resolve<GuideDataCenter>().curDefine.panelName == "HomePanel")
|
||
{
|
||
return;
|
||
}
|
||
ShowOfferSweep();
|
||
}
|
||
}
|
||
async void ShowOfferSweep()
|
||
{
|
||
OnPlayFailed();
|
||
}
|
||
async void StartFishingPlay()
|
||
{
|
||
if (isFishingPanel)
|
||
{
|
||
return;
|
||
}
|
||
GContext.Publish(new EventFishingSound(SoundType.audio_ui_btn_cast));
|
||
GContext.Publish(new VibrationData(HapticTypes.Selection));
|
||
|
||
if (GContext.container.Resolve<PlayerData>().GetCanMagnification() == false)
|
||
{
|
||
GContext.Publish(new VibrationData(HapticTypes.Failure));
|
||
ShowOfferSweep();
|
||
#if AGG
|
||
using (var e = GEvent.GameEvent("lack_resources"))
|
||
{
|
||
e.AddContent("item_id", 1001)
|
||
.AddContent("lv", GContext.container.Resolve<PlayerData>().lv);
|
||
}
|
||
#endif
|
||
}
|
||
else
|
||
{
|
||
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
|
||
DisableBlocksRaycasts();
|
||
isFishingPanel = true;
|
||
await UIManager.Instance.ShowUI(UITypes.FishingPanel);
|
||
UIManager.Instance.DestroyUI(UITypes.HomePanel);
|
||
}
|
||
}
|
||
IDisposable disposable_6;
|
||
void OnPlayFailed()
|
||
{
|
||
Debug.Log("OnPlayFailed");
|
||
GContext.container.Resolve<TriggerPackData>().UpdateTriggerPackData(new ConditionTypeEvent(ConditionType.AccountLevelAfterNoEnergy, 1));
|
||
int curEnergy = GContext.container.Resolve<PlayerData>().Energy;
|
||
if (GContext.container.Resolve<PlayerShopData>().IsShopOpen)
|
||
{
|
||
GContext.container.Resolve<TriggerPackData>().AddTriggerPackData(4000001);
|
||
var triggerPackDic = GContext.container.Resolve<TriggerPackData>().GetTriggerPackList(1);
|
||
if (triggerPackDic.Count == 0)
|
||
{
|
||
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIForce(40000011, UITypes.GiftPopupPanel_8);
|
||
}
|
||
else
|
||
{
|
||
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIForce(triggerPackDic[0].ID, UITypes.GiftPopupPanel_6);
|
||
}
|
||
|
||
//拍脸
|
||
GContext.Publish(new TriggerPackEvent());
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
GContext.Publish(curRewardQCount);
|
||
if (curRewardQCount.count <= 0)
|
||
{
|
||
int faceCount = GContext.container.Resolve<IFaceUIService>().GetFaceUICount();
|
||
if (faceCount > 0)
|
||
{
|
||
disposable_6?.Dispose();
|
||
disposable_6 = null;
|
||
disposable_6 = GContext.OnEvent<GiftPopupPanelEnergyEvent>().Subscribe(x =>
|
||
{
|
||
disposable_6?.Dispose();
|
||
disposable_6 = null;
|
||
int newEnergy = GContext.container.Resolve<PlayerData>().Energy;
|
||
OnPhysicalBuyFailed(curEnergy == newEnergy);
|
||
});
|
||
return;
|
||
}
|
||
}
|
||
//OnPhysicalBuyFailed(true);
|
||
}
|
||
else
|
||
{
|
||
_ = UIManager.Instance.ShowUI(UITypes.LackOfLuresConfirmPopupPanel);
|
||
//GContext.container.Resolve<GuideDataCenter>().TriggerGuide(asap.core.GContext.container.Resolve<Tables>().TbGlobalConfig.FixedGuidance02, "HomePanel");
|
||
}
|
||
}
|
||
async void OnPhysicalBuyFailed(bool isToast)
|
||
{
|
||
if (isToast)
|
||
{
|
||
await UIManager.Instance.ShowUI(UITypes.LackOfResourcePopupPanel);
|
||
}
|
||
//else
|
||
//{
|
||
// OnPhysicalFailed();
|
||
//}
|
||
}
|
||
//void ResourceCloseEvent()
|
||
//{
|
||
// OnPhysicalFailed();
|
||
//}
|
||
|
||
void Questionmark()
|
||
{
|
||
if (GContext.container.Resolve<FishingEventData>().IsOpenDrop)
|
||
UIManager.Instance.ShowUI(UITypes.SupplyDropInfoPopupPanel);
|
||
}
|
||
|
||
void OnclickMagnification()
|
||
{
|
||
var playerData = GContext.container.Resolve<PlayerData>();
|
||
playerData.magnification += 1;
|
||
if (playerData.magnification >= playerData.MagnificationCount)
|
||
{
|
||
playerData.magnification = 0;
|
||
GContext.Publish(new VibrationData(HapticTypes.RigidImpact));
|
||
}
|
||
else
|
||
{
|
||
GContext.Publish(new VibrationData(HapticTypes.SoftImpact));
|
||
}
|
||
//空投倍率修改
|
||
bool isShow = homeSupplyDropPanel != null && homeSupplyDropPanel.Show();
|
||
playerData.SetMagnification();
|
||
text_beilv.text = $"x{playerData.GetMagnification()}";
|
||
SetShowMagnification();
|
||
if (!isShow)
|
||
{
|
||
GContext.Publish(new EventUISound("audio_ui_btn_beilv"));
|
||
beilvpanel.alpha = 1;
|
||
beilvpanel.DOKill();
|
||
beilvpanel.DOFade(0, 2f).SetDelay(1f);
|
||
}
|
||
else
|
||
{
|
||
beilvpanel.DOKill();
|
||
beilvpanel.alpha = 0;
|
||
}
|
||
}
|
||
|
||
void SetShowMagnification()
|
||
{
|
||
IUIService uIService = GContext.container.Resolve<IUIService>();
|
||
string beilvImage = GContext.container.Resolve<PlayerData>().GetMagnificationIcon();
|
||
bool IsMax = GContext.container.Resolve<PlayerData>().IsMaxMagnification();
|
||
if (!IsMax)
|
||
{
|
||
effect_beilv_loop.SetActive(GContext.container.Resolve<PlayerData>().IsShowEffectBeilvLoop());
|
||
}
|
||
else
|
||
{
|
||
effect_beilv_loop.SetActive(false);
|
||
}
|
||
uIService.SetImageSprite(btn_beilv_image, beilvImage, "HomePanel");
|
||
btn_beilv.gameObject.SetActive(GContext.container.Resolve<PlayerData>().IsOpenMagnification);
|
||
beilvpanel_max.gameObject.SetActive(IsMax);
|
||
bg_beilvlpanel.gameObject.SetActive(!IsMax);
|
||
text_beilvpanel_content.text = IsMax
|
||
? "MAX"
|
||
: $"x{GContext.container.Resolve<PlayerData>().GetMagnification()}";
|
||
}
|
||
|
||
//体力不足并且没有补充
|
||
//public void OnPhysicalFailed()
|
||
//{
|
||
// PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||
// int newMagnification = playerData.GetCurMaxMagnification();
|
||
// if (newMagnification < playerData.magnification)
|
||
// {
|
||
// playerData.magnification = newMagnification;
|
||
// //ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_5"));
|
||
// }
|
||
// if (playerData.Energy < playerData.GetMagnification())
|
||
// {
|
||
// playerData.magnification = playerData.SetLittleMagnification();
|
||
// }
|
||
// GContext.container.Resolve<PlayerData>().SetMagnification();
|
||
// text_beilv.text = $"x{GContext.container.Resolve<PlayerData>().GetMagnification()}";
|
||
// SetShowMagnification();
|
||
//}
|
||
|
||
private void InitPanel()
|
||
{
|
||
beilvpanel.alpha = 0;
|
||
CheckSuperEnergyBuff();
|
||
OnPhysicalChange();
|
||
}
|
||
|
||
void CheckSuperEnergyBuff()
|
||
{
|
||
var buffTimeData = GContext.container.Resolve<BuffDataCenter>().GetWeelyBuffTimeData<SuperEnergyMag>();
|
||
bool curSuperEnergy = buffTimeData != null;
|
||
if (!curSuperEnergy)
|
||
{
|
||
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||
playerData.CheckSuperEnergyBuff();
|
||
}
|
||
SetBeiLvImage(curSuperEnergy);
|
||
text_beilv.text = $"x{GContext.container.Resolve<PlayerData>().GetMagnification()}";
|
||
}
|
||
|
||
void SetBeiLvImage(bool curSuperEnergy)
|
||
{
|
||
if (isSuperEnergy != curSuperEnergy)
|
||
{
|
||
isSuperEnergy = curSuperEnergy;
|
||
buff_beilv_image.gameObject.SetActive(isSuperEnergy);
|
||
}
|
||
}
|
||
private void OnPhysicalChange()
|
||
{
|
||
SetShowMagnification();
|
||
SetEnergyTimer();
|
||
ShowEnergy();
|
||
}
|
||
|
||
void ShowEnergy()
|
||
{
|
||
text_energy_value.text = $"{Energy}/{GContext.container.Resolve<PlayerData>().MaxEnergy}";
|
||
image_slider_energy.fillAmount = Energy / (float)GContext.container.Resolve<PlayerData>().MaxEnergy;
|
||
}
|
||
|
||
void SetEnergyTimer()
|
||
{
|
||
EnergyTimer?.Cancel();
|
||
EnergyTimer = null;
|
||
text_energy_time.gameObject.SetActive(false);
|
||
if (EnergyTimer == null)
|
||
{
|
||
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||
if (playerData.Energy < playerData.MaxEnergy)
|
||
{
|
||
text_energy_time.gameObject.SetActive(true);
|
||
int EnergyRecover = playerData.EnergyRecover;
|
||
TimeSpan now = playerData.GetEnergyRecoveryTimeMAndS();
|
||
string Time2 = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||
text_energy_time.text = LocalizationMgr.GetFormatTextValue("UI_LackOfResourcePopupPanel_3", EnergyRecover, Time2);
|
||
EnergyTimer = this.AttachTimer((float)now.TotalSeconds, SetEnergyTimer,
|
||
(elapsed) =>
|
||
{
|
||
now = playerData.GetEnergyRecoveryTimeMAndS();
|
||
string Time2 = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||
text_energy_time.text = LocalizationMgr.GetFormatTextValue("UI_LackOfResourcePopupPanel_3", EnergyRecover, Time2);
|
||
if (playerData.Energy >= playerData.MaxEnergy)
|
||
{
|
||
EnergyTimer?.Cancel();
|
||
EnergyTimer = null;
|
||
text_energy_time.gameObject.SetActive(false);
|
||
}
|
||
}, useRealTime: true);
|
||
|
||
}
|
||
else
|
||
{
|
||
text_energy_time.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void EnergyChangeAnim(int addCount)
|
||
{
|
||
int endEnergy = GContext.container.Resolve<PlayerData>().Energy;
|
||
if (addCount > 0)
|
||
{
|
||
endEnergy = Energy + addCount;
|
||
}
|
||
if (Energy == endEnergy)
|
||
{
|
||
return;
|
||
}
|
||
int curEnergy = Energy;
|
||
Energy = endEnergy;
|
||
DOTween.Kill("home_text_energy");
|
||
OnPhysicalChange();
|
||
DOTween.To(() => curEnergy, x => curEnergy = x, endEnergy, 1f).OnUpdate(() =>
|
||
{
|
||
image_slider_energy.fillAmount = curEnergy / (float)GContext.container.Resolve<PlayerData>().MaxEnergy;
|
||
text_energy_value.text = $"{curEnergy}/{GContext.container.Resolve<PlayerData>().MaxEnergy}";
|
||
}).SetId("home_text_energy");
|
||
}
|
||
public async void OnPushPanelOrScene(UIType panelType) //UI的控件触发
|
||
{
|
||
GameObject go = await UIManager.Instance.ShowUILoad(panelType);
|
||
if (go != null)
|
||
{
|
||
OnHideHomePanelEvent(new HideHomePanelEvent());
|
||
}
|
||
}
|
||
void OnHideHomePanelEvent(HideHomePanelEvent e)
|
||
{
|
||
DisableBlocksRaycasts();
|
||
if (!e.IsHideMap)
|
||
{
|
||
isFishingPanel = true;
|
||
}
|
||
canvasGroup.alpha = 0;
|
||
canvasGroup.interactable = false;
|
||
Destroy(homeLeftPanel);
|
||
Destroy(homeBuffPanel);
|
||
Destroy(homeRightPanel);
|
||
Destroy(homeBtnRank);
|
||
Destroy(this);
|
||
|
||
}
|
||
void SetAlpha()
|
||
{
|
||
canvasGroup.alpha = DeBugPanel.isShow ? 1 : 0;
|
||
}
|
||
public async void OnStart()
|
||
{
|
||
anim.Play("HomePanel_show", -1, 0);
|
||
|
||
GContext.Publish(new MapShowEvent() { isShow = true });
|
||
SetAlpha();
|
||
//设置设备陀螺仪的开启/关闭状态,使用陀螺仪功能必须设置为 true
|
||
// Input.gyro.enabled = true;
|
||
// Input.gyro.updateInterval = 0.1f;
|
||
SetTurntable();
|
||
SystemSwitch();
|
||
TryRefreshClubOnHomeEnter();
|
||
InitPanel();
|
||
LeadboardData leadboardData = GContext.container.Resolve<LeadboardData>();
|
||
if (leadboardData.rankItemDatas != null)
|
||
{
|
||
ShowItemCount(leadboardData.rankItemDatas);
|
||
}
|
||
//else
|
||
//{
|
||
// _ = GContext.container.Resolve<LeadboardData>().GetRewards();
|
||
//}
|
||
if (_fishingEventData.targetItemDatas != null)
|
||
{
|
||
ShowItemCount(_fishingEventData.targetItemDatas);
|
||
}
|
||
if (_fishingEventData.rankItemDatas != null)
|
||
{
|
||
ShowItemCount(_fishingEventData.rankItemDatas);
|
||
}
|
||
//目标奖励活动和空投buff
|
||
// [REMOVED] SupplyDropCtrl type no longer exists, commented out the if-branch
|
||
// if (fishingData.supplyDropCtrl != null)
|
||
// {
|
||
// TargetAddData targetAddData = fishingData.supplyDropCtrl.targetAddData;
|
||
// if (targetAddData.id > 0)
|
||
// {
|
||
// if (fishingData.isAwaitTargetBuff)
|
||
// {
|
||
// ShowItemCount(targetAddData);
|
||
// EventTargetAdd(targetAddData.id, targetAddData.curCount, targetAddData.addCount, fishingData.supplyDropCtrl.targetPos);
|
||
// }
|
||
// else
|
||
// {
|
||
// fishingStage.q_TargetAddData.Add(targetAddData);
|
||
// }
|
||
// }
|
||
// if (fishingStage.q_TargetAddData != null)
|
||
// {
|
||
// ShowItemCount(fishingStage.q_TargetAddData);
|
||
// }
|
||
// ShowEnergy();
|
||
// fishingData.supplyDropCtrl = null;
|
||
// await homeBuffPanel.BuffShow();
|
||
// }
|
||
// else
|
||
{
|
||
if (fishingStage.q_TargetAddData != null)
|
||
{
|
||
ShowItemCount(fishingStage.q_TargetAddData);
|
||
}
|
||
ShowEnergy();
|
||
}
|
||
|
||
///中间插目标奖励活动Buff
|
||
if (fishingData.isAwaitTargetBuff)
|
||
{
|
||
await AddTargetBuff();
|
||
}
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
if (fishingStage.q_TargetAddData.Count > 0)
|
||
{
|
||
PlayTargetAdd();
|
||
}
|
||
else/*if (_fishingEventData.preCollectingTarget == null && _fishingEventData.preRankTarget == null)*/
|
||
{
|
||
//登陆的时候拿到补单数据,奖励显示在这里处理
|
||
GContext.container.Resolve<PlayerShopData>().ReleaseReplenishmentData();
|
||
//礼包拍脸在补单之后处理
|
||
GContext.container.Resolve<TriggerPackData>().SetInitFace();
|
||
GContext.Publish(new ShowData());
|
||
}
|
||
//先补单后各种拍脸
|
||
|
||
GContext.Publish(curRewardQCount);
|
||
if (curRewardQCount.count > 0)
|
||
{
|
||
AddBarProgress();
|
||
}
|
||
if (barDataProgress <= 0 && curRewardQCount.count <= 0)
|
||
{
|
||
OnNoReward();
|
||
}
|
||
StartCoroutine(MaskClose());
|
||
}
|
||
|
||
IEnumerator MaskClose()
|
||
{
|
||
yield return new WaitForSeconds(20);
|
||
if (mask != null)
|
||
mask.SetActive(false);
|
||
}
|
||
|
||
bool PlayTargetAdd()
|
||
{
|
||
var fishingStage = GContext.container.ResolveStage("FishingStage") as FishingStage;
|
||
int q_count = fishingStage.q_TargetAddData.Count;
|
||
if (q_count > 0)
|
||
{
|
||
//目标奖励活动获得的奖励
|
||
fishingStage.NextToQueue(FishingEventData.NextQueueKey);
|
||
}
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
GContext.Publish(curRewardQCount);
|
||
bool isShowReward = curRewardQCount.count > 0;
|
||
if (isShowReward)
|
||
{
|
||
mask.gameObject.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
mask.gameObject.SetActive(false);
|
||
}
|
||
|
||
if (q_count > 0)
|
||
{
|
||
int rootCount = fishingStage.q_TargetAddData.Count();
|
||
if (rootCount > 4)
|
||
{
|
||
rootCount = 4;
|
||
}
|
||
Transform flyPosRoot = transform.Find($"RewardFlyPanel/{rootCount}");
|
||
int index = 0;
|
||
for (int i = 0; i < q_count; i++)
|
||
{
|
||
TargetAddData targetAddData = fishingStage.q_TargetAddData[i];
|
||
Vector3 curPos = flyPosRoot.GetChild(index % rootCount).position;
|
||
index++;
|
||
EventTargetAdd(targetAddData.id, targetAddData.curCount, targetAddData.addCount, curPos);
|
||
}
|
||
fishingStage.ClearTargetAddData();
|
||
}
|
||
return isShowReward;
|
||
}
|
||
HashSet<string> GetUIAsyncEventCount = new HashSet<string>();
|
||
async void OnGetUIAsyncEvent(GetUIAsyncEvent data)
|
||
{
|
||
if (data.uIType == UITypes.HomePanel.Name)
|
||
{
|
||
return;
|
||
}
|
||
if (data.show)
|
||
{
|
||
GetUIAsyncEventCount.Add(data.uIType);
|
||
}
|
||
else
|
||
{
|
||
GetUIAsyncEventCount.Remove(data.uIType);
|
||
if (GetUIAsyncEventCount.Count == 0)
|
||
{
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
GContext.Publish(curRewardQCount);
|
||
int faceCount = GContext.container.Resolve<IFaceUIService>().GetFaceUICount();
|
||
if (faceCount == 0 && curRewardQCount.count == 0)
|
||
{
|
||
await homeBuffPanel.BuffShow();
|
||
LastShowPanel();
|
||
//钓鱼挑战赛 TODO:LF
|
||
// GContext.container.Resolve<FishingChallengeManager>().CheckAutoOpenPanel();
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
async void LastShowPanel()
|
||
{
|
||
try
|
||
{
|
||
var showFishBuffIds = GContext.container.Resolve<BuffDataCenter>().showFishBuffIds;
|
||
if (showFishBuffIds.Count == 0)
|
||
{
|
||
//Buff 之后的拍脸
|
||
await Awaiters.Seconds(0.5f);
|
||
GContext.container.Resolve<IFaceUIService>().ShowPostFaceUI();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Debug.LogError(ex);
|
||
}
|
||
}
|
||
void OnRewardPanelClose(RewardPanelClose rewardPanelClose)
|
||
{
|
||
bool skipFace = skipFaceAfterRewardPanelClose;
|
||
skipFaceAfterRewardPanelClose = false;
|
||
RmoveBarProgress(skipFace);
|
||
}
|
||
void FaceUIEventClose(FaceUICloseEvent faceUICloseEvent)
|
||
{
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
GContext.Publish(curRewardQCount);
|
||
if (curRewardQCount.count <= 0)
|
||
{
|
||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("HomePanel");
|
||
LastShowPanel();
|
||
}
|
||
else
|
||
{
|
||
GContext.Publish(new ShowData());
|
||
}
|
||
}
|
||
|
||
void OnNoReward()
|
||
{
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
GContext.Publish(curRewardQCount);
|
||
if (curRewardQCount.count > 0)
|
||
{
|
||
return;
|
||
}
|
||
_playerFishData.SetMapRed();
|
||
|
||
int faceCount = GContext.container.Resolve<IFaceUIService>().GetFaceUICount();
|
||
bool isGuide = GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("HomePanel");
|
||
if (!isGuide)
|
||
{
|
||
if (faceCount > 0)
|
||
{
|
||
GContext.container.Resolve<IFaceUIService>().ShowFaceUI();
|
||
}
|
||
else
|
||
{
|
||
//BuffShow();
|
||
//GContext.container.Resolve<FishingChallengeCenter>().IsAutoOpenPanel();
|
||
//钓鱼挑战赛
|
||
LastShowPanel();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (RewardFlyPanel == null)
|
||
{
|
||
RewardFlyPanel = transform.Find("RewardFlyPanel").gameObject.AddComponent<Canvas>();
|
||
RewardFlyPanel.overrideSorting = true;
|
||
RewardFlyPanel.sortingOrder = 10;
|
||
}
|
||
}
|
||
}
|
||
void TriggerPackEvent(TriggerPackEvent triggerPackEvent)
|
||
{
|
||
SystemSwitch();
|
||
}
|
||
void SystemSwitch()
|
||
{
|
||
SetRank();
|
||
if (btn_task_gray != null) btn_task_gray.SetActive(!_playerFishData.IsOpenMap);
|
||
GContext.container.Resolve<CampDataMM>().SetRedPoint();
|
||
btn_friend_gray.SetActive(true); // 隐藏好友按钮
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 仅在进入/重新显示首页时同步俱乐部(含聊天会话),避免随 TriggerPackEvent 频繁请求。
|
||
/// </summary>
|
||
void TryRefreshClubOnHomeEnter()
|
||
{
|
||
}
|
||
|
||
void DisableBlocksRaycasts()
|
||
{
|
||
anim.enabled = false;
|
||
canvasGroup.blocksRaycasts = false;
|
||
}
|
||
|
||
bool isEnterGamePlay = false;
|
||
async void EventPanelWrap(int code)
|
||
{
|
||
if (isEnterGamePlay)
|
||
{
|
||
return;
|
||
}
|
||
isEnterGamePlay = true;
|
||
var eventGamePlayPanel = await UIManager.Instance.GetUIAsync(UITypes.EventGamePlayPanel);
|
||
eventGamePlayPanel.GetComponent<EventGamePlayPanel>().StartGame(code);
|
||
}
|
||
|
||
public void Update()
|
||
{
|
||
if (fishingData == null || fishingData.mainCamera == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
#if UNITY_EDITOR
|
||
#region 快捷键
|
||
// Some event that you may want to open, or close, if all works are done.
|
||
if (Input.GetKeyDown(KeyCode.E))
|
||
{
|
||
}
|
||
//同时按下G键和数字键1,EventShowDownPanel
|
||
if (Input.GetKey(KeyCode.G))
|
||
{
|
||
if (Input.GetKeyDown(KeyCode.F1))
|
||
{
|
||
EventBankHeistPanel.selectionType = 1;
|
||
EventPanelWrap(11);
|
||
}
|
||
else if (Input.GetKeyDown(KeyCode.F2))
|
||
{
|
||
EventBankHeistPanel.selectionType = 2;
|
||
EventPanelWrap(11);
|
||
}
|
||
else if (Input.GetKeyDown(KeyCode.F3))
|
||
{
|
||
EventBankHeistPanel.selectionType = 3;
|
||
EventPanelWrap(11);
|
||
}
|
||
else
|
||
if (Input.GetKeyDown(KeyCode.Alpha2))
|
||
{
|
||
EventBankHeistPanel.selectionType = 0;
|
||
EventPanelWrap(11);
|
||
}
|
||
else
|
||
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||
{
|
||
EventPanelWrap(12);
|
||
}
|
||
}
|
||
else if (Input.GetKey(KeyCode.X) && Input.GetKeyDown(KeyCode.Alpha1))
|
||
{
|
||
DeBugPanel.isShow = !DeBugPanel.isShow;
|
||
SetAlpha();
|
||
}
|
||
else if (Input.GetKeyDown(KeyCode.D))
|
||
{
|
||
// var fcm = GContext.container.Resolve<FishingChallengeManager>();
|
||
// fcm.ClearFishingChallengeData();
|
||
// fcm.Init();
|
||
|
||
|
||
// var manager = GContext.container.Resolve<OfferChainsChestManager>();
|
||
// manager.ClearOfferChainsData();
|
||
// manager?.Init();
|
||
|
||
// var manager = GContext.container.Resolve<EventPartnerGatherManager>();
|
||
// manager?.ClearData();
|
||
// manager?.ReInit();
|
||
|
||
// var manager = GContext.container.Resolve<OfferDiscoPartyManager>();
|
||
// manager.ClearOfferDiscoPartyData();
|
||
// manager.Init();
|
||
|
||
|
||
}
|
||
else if (Input.GetKeyDown(KeyCode.F2))
|
||
{
|
||
PlayerPrefs.SetInt($"P_CleanFace", 1);
|
||
}
|
||
#endregion
|
||
#endif
|
||
|
||
|
||
if (isMouse && !_isMoveing)
|
||
{
|
||
if (fishingData.mainCamera != null)
|
||
{
|
||
Quaternion target = Quaternion.Euler(_offsetEuler + _targetEuler);
|
||
fishingData.mainCamera.localRotation = Quaternion.Angle(target, fishingData.mainCamera.localRotation) > 0.1f
|
||
? Quaternion.Lerp(Quaternion.Euler(fishingData.mainCamera.localEulerAngles), target, 0.2f)
|
||
: target;
|
||
}
|
||
}
|
||
}
|
||
|
||
public float CheckAngle(float value)
|
||
{
|
||
float angle = value - 180;
|
||
|
||
if (angle > 0)
|
||
return angle - 180;
|
||
|
||
return angle + 180;
|
||
}
|
||
|
||
void Move()
|
||
{
|
||
fishingData.mainCamera.DOLocalRotate(_targetEuler, duration)
|
||
.OnComplete(() => { _isMoveing = false; })
|
||
.SetEase(Ease.Linear);
|
||
}
|
||
/// <summary>
|
||
/// 所有Event配置控制的主界面按钮
|
||
/// 跨天 或者其他情况玩家在主界面的时候 Event开启或关闭
|
||
/// 一般只有开启需要处理 关闭活动本身相关脚本中就处理了
|
||
/// </summary>
|
||
/// <param name="data"> type == 0 触发礼包 type != 0 event.type</param>
|
||
void FishingEvent(TargetEvent data)
|
||
{
|
||
switch (data.type)
|
||
{
|
||
case 3:
|
||
switch (data.subType)
|
||
{
|
||
case 2:
|
||
CollectingTargetNext();
|
||
break;
|
||
case 3:
|
||
SetRank();
|
||
break;
|
||
case 4:
|
||
SetTurntable();
|
||
break;
|
||
case 10:
|
||
homeLeftPanel.SetChainGiftPackTimer();
|
||
break;
|
||
}
|
||
break;
|
||
case 4:
|
||
switch (data.subType)
|
||
{
|
||
case 3:
|
||
btn_fishbowl.SetActive(true);
|
||
break;
|
||
}
|
||
break;
|
||
case 9:
|
||
switch (data.subType)
|
||
{
|
||
case 4:
|
||
if (btn_chainschest != null) btn_chainschest.gameObject.SetActive(true);
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
void CollectingTargetNext()
|
||
{
|
||
var collectingTarget = _fishingEventData.collectingTarget;
|
||
if (collectingTarget != null)
|
||
{
|
||
homeBubbleTask.CheckResource();
|
||
}
|
||
else
|
||
{
|
||
homeBubbleTask.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
async void PlayGoldAddAnim(Vector3 startPos)
|
||
{
|
||
if (addGlodCount > 1)
|
||
{
|
||
int addGold = addGlodCount;
|
||
addGlodCount = 0;
|
||
|
||
top_area.text_gold.text = ConvertTools.GetNumberString2(top_area.curGold);
|
||
//飞上去
|
||
await GetRewardFly(1002, startPos, addGold);
|
||
}
|
||
}
|
||
void PlayEnergyAdd(int addCount, Vector3 startPos)
|
||
{
|
||
GetRewardFly(1001, startPos, addCount);
|
||
}
|
||
void EventTargetAdd(int id, int curCount, int addCount, Vector3 startPos)
|
||
{
|
||
if (id == 1002)
|
||
{
|
||
addGlodCount = addCount;
|
||
PlayGoldAddAnim(startPos);
|
||
}
|
||
else if (id == 1001)
|
||
{
|
||
PlayEnergyAdd(addCount, startPos);
|
||
}
|
||
else if (_fishingEventData.collectingTarget != null && id == _fishingEventData.collectingTargetInitTokenID)
|
||
{
|
||
PlayEventTargetAdd(id, curCount, addCount, startPos);
|
||
}
|
||
else if (_fishingEventData.rankInit != null && id == _fishingEventData.rankInit.TokenID)
|
||
{
|
||
PlayEventRankTargetAdd(id, curCount, addCount, startPos);
|
||
}
|
||
// [REMOVED] PiggyBankPackData deleted
|
||
// else if (id == GContext.container.Resolve<PiggyBankPackData>().EventItemId)
|
||
// {
|
||
// PiggyBankPackAdd(id, curCount, addCount, startPos);
|
||
// }
|
||
//砍一刀
|
||
else if (id == GContext.container.Resolve<BargainPackData>().EventItemId)
|
||
{
|
||
BargainPackPack(id, curCount, addCount, startPos);
|
||
}
|
||
else
|
||
{
|
||
_ = GetRewardFly(id, startPos, addCount);
|
||
}
|
||
}
|
||
|
||
void ShowItemCount(List<TargetAddData> itemDatas)
|
||
{
|
||
if (itemDatas != null)
|
||
{
|
||
for (int i = 0; i < itemDatas.Count; i++)
|
||
{
|
||
ShowItemCount(itemDatas[i]);
|
||
}
|
||
}
|
||
}
|
||
|
||
void ShowItemCount(TargetAddData itemDatas)
|
||
{
|
||
|
||
if (itemDatas.id == 1001)
|
||
{
|
||
Energy = Energy - (int)itemDatas.addCount;
|
||
if (Energy < 0)
|
||
{
|
||
Energy = 0;
|
||
}
|
||
}
|
||
else if (itemDatas.id == 1002)
|
||
{
|
||
ulong curGold = (ulong)itemDatas.addCount;
|
||
if (top_area.curGold > curGold)
|
||
{
|
||
top_area.curGold -= curGold;
|
||
top_area.text_gold.text = ConvertTools.GetNumberString2(top_area.curGold);
|
||
}
|
||
}
|
||
else if (_fishingEventData.collectingTarget != null && itemDatas.id == _fishingEventData.collectingTargetInitTokenID)
|
||
{
|
||
CollectingTargetReward collectingTarget = _fishingEventData.collectingTarget;
|
||
float curCount = itemDatas.curCount;
|
||
if (_fishingEventData.preCollectingTarget != null)
|
||
{
|
||
collectingTarget = _fishingEventData.preCollectingTarget.Peek();
|
||
List<ItemData> itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdLureInflation(_fishingEventData.CollectingTargetInflation, collectingTarget.DropID);
|
||
if (itemData is { Count: > 0 })
|
||
{
|
||
homeBubbleTask.SetCollectingTargetRewardIcon(itemData);
|
||
}
|
||
}
|
||
homeBubbleTask.bar.fillAmount = curCount / (float)collectingTarget.TokenRequiredB;
|
||
homeBubbleTask.text_progress.text = $"{curCount}/{collectingTarget.TokenRequiredB}";
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主界面的钱、体力等显示未添加之前的
|
||
/// </summary>
|
||
/// <param name="itemDatas"></param>
|
||
void ShowItemCount(List<ItemData> itemDatas)
|
||
{
|
||
if (itemDatas != null)
|
||
{
|
||
for (int i = 0; i < itemDatas.Count; i++)
|
||
{
|
||
if (itemDatas[i].id == 1001)
|
||
{
|
||
Energy = Energy - (int)itemDatas[i].count;
|
||
if (Energy < 0)
|
||
{
|
||
Energy = 0;
|
||
}
|
||
}
|
||
else if (itemDatas[i].id == 1002)
|
||
{
|
||
ulong curGold = (ulong)itemDatas[i].count;
|
||
if (top_area.curGold > curGold)
|
||
{
|
||
top_area.curGold -= curGold;
|
||
top_area.text_gold.text = ConvertTools.GetNumberString2(top_area.curGold);
|
||
}
|
||
}
|
||
itemDatas[i].curCount = (ulong)(GContext.container.Resolve<PlayerItemData>().GetItemCount(itemDatas[i].id) - itemDatas[i].count);
|
||
}
|
||
}
|
||
}
|
||
async void PlayEventTargetAdd(int id, int curCount, int addCount, Vector3 startPos)
|
||
{
|
||
//Vector3 startPos = fishingData.image_extra_pos;
|
||
_fishingEventData.targetItemDatas = null;
|
||
CollectingTargetReward collectingTarget = _fishingEventData.collectingTarget;
|
||
if (collectingTarget != null && _fishingEventData.collectingTargetInitTokenID == id)
|
||
{
|
||
int endCount = _fishingEventData.GetCurCollectingTarget();
|
||
if (endCount >= collectingTarget.TokenRequiredB && _fishingEventData.preCollectingTarget == null)
|
||
{
|
||
ShowItem();
|
||
return;
|
||
}
|
||
|
||
if (_fishingEventData.preCollectingTarget != null)
|
||
{
|
||
collectingTarget = _fishingEventData.preCollectingTarget.Peek();
|
||
List<ItemData> itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdLureInflation(_fishingEventData.CollectingTargetInflation, collectingTarget.DropID);
|
||
if (itemData is { Count: > 0 })
|
||
{
|
||
homeBubbleTask.SetCollectingTargetRewardIcon(itemData);
|
||
}
|
||
}
|
||
|
||
homeBubbleTask.bar.fillAmount = curCount / (float)collectingTarget.TokenRequiredB;
|
||
homeBubbleTask.text_progress.text = $"{curCount}/{collectingTarget.TokenRequiredB}";
|
||
//飞上去
|
||
await GetRewardFly(id, startPos, addCount);
|
||
if (_fishingEventData.preCollectingTarget != null)
|
||
{
|
||
collectingTarget = _fishingEventData.preCollectingTarget.Dequeue();
|
||
endCount = collectingTarget.TokenRequiredB;
|
||
}
|
||
else
|
||
{
|
||
ShowItem();
|
||
}
|
||
homeBubbleTask.PlayEventTargetAdd(collectingTarget, curCount, endCount);
|
||
}
|
||
else
|
||
{
|
||
ShowItem();
|
||
_fishingEventData.preCollectingTarget = null;
|
||
CollectingTargetNext();
|
||
}
|
||
}
|
||
async void PlayEventRankTargetAdd(int id, int curCount, int addCount, Vector3 startPos)
|
||
{
|
||
//Vector3 startPos = GContext.container.Resolve<SmallGameData>().image_extra_pos;
|
||
rankTarget = _fishingEventData.rankTarget;
|
||
bool isUp = _fishingEventData.preRankTarget != null;
|
||
_fishingEventData.rankItemDatas = null;
|
||
if (rankTarget != null && _fishingEventData.rankInit.TokenID == id)
|
||
{
|
||
//飞上去
|
||
await GetRewardFly(id, startPos, addCount);
|
||
if (homeBtnRank == null)
|
||
{
|
||
return;
|
||
}
|
||
homeBtnRank.Init(curCount);
|
||
if (!isUp)
|
||
{
|
||
ShowItem();
|
||
}
|
||
}
|
||
}
|
||
// [REMOVED] PiggyBankPackData deleted
|
||
async void PiggyBankPackAdd(int id, int curCount, int addCount, Vector3 startPos) { }
|
||
async void BargainPackPack(int id, int curCount, int addCount, Vector3 startPos)
|
||
{
|
||
BargainPackData bargainPackData = GContext.container.Resolve<BargainPackData>();
|
||
bool IsFull = bargainPackData.IsFull;
|
||
|
||
if (IsFull)
|
||
{
|
||
AddBarProgress();
|
||
}
|
||
BargainPackProgressEvent piggyBankProgressEvent = new BargainPackProgressEvent();
|
||
piggyBankProgressEvent.addProgress = addCount;
|
||
piggyBankProgressEvent.type = 0;
|
||
await Awaiters.NextFrame;
|
||
GContext.Publish(piggyBankProgressEvent);
|
||
//飞上去
|
||
await GetRewardFly(id, startPos, addCount);
|
||
piggyBankProgressEvent.type = 1;
|
||
GContext.Publish(piggyBankProgressEvent);
|
||
if (IsFull)
|
||
{
|
||
await Awaiters.Seconds(0.5f);
|
||
RmoveBarProgress();
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 需要播进度增加的时候调用此方法
|
||
/// </summary>
|
||
void AddBarProgress()
|
||
{
|
||
barDataProgress++;
|
||
if (mask != null)
|
||
mask.SetActive(true);
|
||
}
|
||
/// <summary>
|
||
/// 进度动画播完之后调用此方法,开始后续拍脸或跳转
|
||
/// </summary>
|
||
void RmoveBarProgress(bool skipFace = false)
|
||
{
|
||
barDataProgress--;
|
||
if (barDataProgress <= 0)
|
||
{
|
||
if (mask != null)
|
||
mask.SetActive(false);
|
||
if (!skipFace)
|
||
{
|
||
OnNoReward();
|
||
}
|
||
}
|
||
}
|
||
|
||
void ShowItem()
|
||
{
|
||
if (mask != null)
|
||
mask.SetActive(false);
|
||
GContext.Publish(new ShowData());
|
||
}
|
||
private async void FishingChallengeAdd(int id, int addCount, Vector3 startPos)
|
||
{
|
||
await GetRewardFly(id, startPos, addCount);
|
||
|
||
// [REMOVED] FishingChallengeManager deleted
|
||
// GContext.Publish(new FishingChallengeAddEvent());
|
||
}
|
||
|
||
//获得奖励UI向上飞的方法
|
||
public async System.Threading.Tasks.Task GetRewardFly(int id, Vector3 startPos, int addCount)
|
||
{
|
||
if (imageQueue.Count == 0)
|
||
{
|
||
AddRewardFlyItem();
|
||
}
|
||
RewardItemNew rewardNew = imageQueue.Dequeue();
|
||
rewardNew.transform.localScale = Vector3.one;
|
||
rewardNew.transform.position = startPos;
|
||
rewardNew.gameObject.SetActive(true);
|
||
rewardNew.SetRewardPopupData(new ItemData() { count = addCount, id = id }, false);
|
||
rewardNew.PlayOpen();
|
||
await Awaiters.Seconds(0.4f);
|
||
if (rewardNew == null)
|
||
{
|
||
return;
|
||
}
|
||
await rewardNew.PlayClose();
|
||
await rewardNew.ParticleAttractor();
|
||
if (rewardNew == null)
|
||
{
|
||
return;
|
||
}
|
||
rewardNew.gameObject.SetActive(false);
|
||
imageQueue.Enqueue(rewardNew);
|
||
}
|
||
|
||
public void AddRewardFlyItem()
|
||
{
|
||
for (int i = 0; i < 2; i++)
|
||
{
|
||
GameObject go = Instantiate(rewardItemPrefab.gameObject, rewardFlyPanel, true);
|
||
go.SetActive(false);
|
||
RewardItemNew reward = go.GetComponent<RewardItemNew>();
|
||
imageQueue.Enqueue(reward);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 没有Buff需要播放或播放完,并且没有体力不足等一系列弹窗,才自动跳转到挑战面板
|
||
/// </summary>
|
||
void IsAutoOpenChallangePanel()
|
||
{
|
||
//if (GContext.container.Resolve<PlayerData>().GetCanMagnification())
|
||
// GContext.container.Resolve<FishingChallengeCenter>().IsAutoOpenPanel();
|
||
}
|
||
//触发目标奖励活动Buff
|
||
async Task AddTargetBuff()
|
||
{
|
||
mask.SetActive(true);
|
||
|
||
fishingData.isAwaitTargetBuff = false;
|
||
await Awaiters.Seconds(3.5f);
|
||
mask.SetActive(false);
|
||
}
|
||
|
||
public void OnDisable()
|
||
{
|
||
if (RewardFlyPanel != null)
|
||
{
|
||
Destroy(RewardFlyPanel);
|
||
}
|
||
if (fishingData != null)
|
||
{
|
||
fishingData.isAddTargetBuff = false;
|
||
fishingData.isAddPiggyBank = false;
|
||
fishingData.isAddBarginPack = false;
|
||
fishingData.isShowTargetPanel = false;
|
||
fishingData.isAwaitTargetBuff = false;
|
||
}
|
||
if (fishingStage != null)
|
||
{
|
||
fishingStage.ClearTargetAddData();
|
||
}
|
||
_fishingEventData.preCollectingTarget = null;
|
||
if (!isFishingPanel)
|
||
{
|
||
GContext.Publish(new MapShowEvent() { isShow = false });
|
||
}
|
||
}
|
||
|
||
// [REMOVED] Turntable deleted
|
||
private void UpdateTurntableTimer(long _ = 0L) { }
|
||
private void HideTurntableEntranceBtn() { btn_turntable?.gameObject.SetActive(false); }
|
||
private void InitTurnTableTimer() { }
|
||
}
|