980 lines
31 KiB
C#
980 lines
31 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using DG.Tweening;
|
|
using Game;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using TMPro;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.AddressableAssets;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
public class StopAutoEvent
|
|
{
|
|
public bool IsDrawing;
|
|
}
|
|
public class FishingPanel_Advanced : MonoBehaviour
|
|
{
|
|
public static FishingPanel_Advanced Instance { get; private set; }
|
|
GameObject MaxComboTip;
|
|
GameObject MaxComboFx;
|
|
GameObject btn_draw_combo_down;
|
|
GameObject btn_draw_combo_top;
|
|
GameObject btn_up;
|
|
private Animator _btnAnimator;
|
|
private Animator _sliderAnimator;
|
|
private Animator _sliderAnimator2;
|
|
private CanvasGroup _canvasGroup;
|
|
LongPressOrClickTrigger drawButton;
|
|
TMP_Text text_play;
|
|
GameObject FX_info_combo;
|
|
Dictionary<string, GameObject> FX_info_warning = new Dictionary<string, GameObject>();
|
|
Transform tips;
|
|
bool AutomaticFishing;
|
|
|
|
FishingFishInfo fishInfo;
|
|
FishingStart fishingStart;
|
|
FishingBlood fishBlood;
|
|
PiercingInfo piercingInfo;
|
|
float WarningLineLengthRatio = 0.8f;
|
|
List<GameObject> PiercingSuccessFx = new List<GameObject>();
|
|
List<GameObject> PiercingSuccess = new List<GameObject>();
|
|
List<GameObject> MaxComboFxs = new List<GameObject>();
|
|
GameObject FxChangeStartUI;
|
|
bool isOpenPiercing = false;
|
|
string curFishShakeIdle;
|
|
FishingData fishingData;
|
|
FishingUpdateSys fishingUpdateSys;
|
|
RodSkinData rodSkinData;
|
|
/// <summary>
|
|
/// 特殊技能相关
|
|
/// </summary>
|
|
Transform fx_target_bar_bg;
|
|
Image bar_target;
|
|
Transform fx_target_bar;
|
|
|
|
Transform highlight_target;
|
|
Image highlight;
|
|
Transform fx_target_bar_highlight;
|
|
|
|
/// <summary>
|
|
/// 本帧按下时触点是否在收线按钮子树内;按住过程中保持,避免子 Graphic 抢射线导致进度中断,也避免屏外按下再滑入误触发。
|
|
/// </summary>
|
|
bool _reelTouchStartedOnDrawButton;
|
|
|
|
Transform barFx;
|
|
Transform bloodBossFx;
|
|
Perk perk;
|
|
GameObject perk_go;
|
|
|
|
protected CompositeDisposable disposables = new CompositeDisposable();
|
|
public bool IsDown()
|
|
{
|
|
if (drawButton == null || EventSystem.current == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (!Input.GetMouseButton(0))
|
|
{
|
|
_reelTouchStartedOnDrawButton = false;
|
|
return false;
|
|
}
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
_reelTouchStartedOnDrawButton = IsPointerOverDrawButtonTree();
|
|
}
|
|
if (drawButton.IsPressing)
|
|
{
|
|
return true;
|
|
}
|
|
return _reelTouchStartedOnDrawButton;
|
|
}
|
|
|
|
bool IsPointerOverDrawButtonTree()
|
|
{
|
|
var pointerEventData = new PointerEventData(EventSystem.current)
|
|
{
|
|
position = Input.mousePosition
|
|
};
|
|
|
|
List<RaycastResult> results = new List<RaycastResult>();
|
|
EventSystem.current.RaycastAll(pointerEventData, results);
|
|
foreach (RaycastResult result in results)
|
|
{
|
|
if (result.gameObject == drawButton.gameObject)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
transform.SetAsFirstSibling();
|
|
fishingUpdateSys = gameObject.AddComponent<FishingUpdateSys>();
|
|
fishingData = GContext.container.Resolve<FishingData>();
|
|
if (fishingData.IsDuel)
|
|
{
|
|
// TODO: restore when FishingDuelManager is available
|
|
// var fishingDuelManager = GContext.container.Resolve<FishingDuelManager>();
|
|
// if (fishingDuelManager != null)
|
|
// {
|
|
// fishingDuelManager.OnFishingChangeStateEvent(FishingChangeState.Cast, fishingData.fishItem.ID);
|
|
// }
|
|
}
|
|
int skindID = GContext.container.Resolve<PlayerFishData>().GetRodSkin(fishingData.RodId);
|
|
rodSkinData = GContext.container.Resolve<Tables>().TbRodSkinData.GetOrDefault(skindID);
|
|
isOpenPiercing = GContext.container.Resolve<PlayerFishData>().IsOpenPiercing;
|
|
GContext.OnEvent<StopAutoEvent>().Subscribe(StopAuto).AddTo(disposables);
|
|
GContext.OnEvent<HideUI>().Subscribe(HideUI).AddTo(disposables);
|
|
|
|
_canvasGroup = GetComponent<CanvasGroup>();
|
|
//换按钮
|
|
btn_draw_combo_down = transform.Find("safearea/middlepanel/btn_draw/btn_draw_combo_down").gameObject;
|
|
btn_draw_combo_top = transform.Find("safearea/middlepanel/btn_draw/btn_draw_combo_top").gameObject;
|
|
text_play = transform.Find("safearea/middlepanel/btn_draw/text_play").GetComponent<TMP_Text>();
|
|
drawButton = transform.Find("safearea/middlepanel/btn_draw").GetComponent<LongPressOrClickTrigger>();
|
|
btn_up = transform.Find("safearea/middlepanel/btn_draw/up").gameObject;
|
|
//换按钮
|
|
drawButton.onLongPress.AddListener((() => { SetBtnAnimatorState(BtnAnimatorState.Pressed); }));
|
|
drawButton.onUp.AddListener(OnUpButton);
|
|
drawButton.onDown.AddListener(OnClickButton);
|
|
|
|
drawButton.gameObject.SetActive(false);
|
|
_btnAnimator = drawButton.GetComponent<Animator>();
|
|
_sliderAnimator = drawButton.transform.Find("slider").GetComponent<Animator>();
|
|
_sliderAnimator2 = transform.Find("fish_info/combo/barRoot/icon").GetComponent<Animator>();
|
|
tips = transform.Find("tips");
|
|
FX_info_combo = transform.Find("tips/FX_info_combo").gameObject;
|
|
|
|
fx_target_bar_bg = transform.Find("fish_info/combo/barRoot/fx_target_bar_bg").transform;
|
|
fx_target_bar = transform.Find("fish_info/combo/barRoot/bar_target/fx_target_bar").transform;
|
|
bar_target = transform.Find("fish_info/combo/barRoot/bar_target").GetComponent<Image>();
|
|
highlight_target = transform.Find("fish_info/combo/barRoot/highlight_target").transform;
|
|
highlight = transform.Find("fish_info/combo/barRoot/highlight_target/highlight").GetComponent<Image>();
|
|
fx_target_bar_highlight = transform.Find("fish_info/combo/barRoot/highlight_target/fx_target_bar_highlight").transform;
|
|
barFx = transform.Find("fish_info/combo/barRoot/fx_ui_lightning").transform;
|
|
bloodBossFx = transform.Find("fish_info/blood/icon_fish_boss/fx").transform;
|
|
fishInfo = transform.Find("fish_info").GetComponent<FishingFishInfo>();
|
|
fishInfo.InitPanel(fishingUpdateSys);
|
|
fishInfo.gameObject.SetActive(false);
|
|
fishingStart = fishInfo.transform.Find("start").GetComponent<FishingStart>();
|
|
fishBlood = fishInfo.transform.Find("blood").GetComponent<FishingBlood>();
|
|
fishBlood.Init();
|
|
piercingInfo = transform.Find("piercing_info").GetComponent<PiercingInfo>();
|
|
piercingInfo.gameObject.SetActive(false);
|
|
|
|
perk_go = transform.Find("perk_info/perk_info_1").gameObject;
|
|
perk_go.SetActive(false);
|
|
perk = perk_go.transform.Find("perk").GetComponent<Perk>();
|
|
GContext.OnEvent<RodPerkTriggerEvent>().Subscribe(OnRodPerkTriggerEvent).AddTo(disposables);
|
|
}
|
|
void OnRodPerkTriggerEvent(RodPerkTriggerEvent rodPerkTriggerEvent)
|
|
{
|
|
perk_go.SetActive(false);
|
|
perk_go.SetActive(true);
|
|
|
|
perk.SetData(rodPerkTriggerEvent.PerkID, rodPerkTriggerEvent.level, fishingData.fishRodData.Quality);
|
|
}
|
|
async void LoadFx()
|
|
{
|
|
int level = QualitySettings.GetQualityLevel();
|
|
Transform parent = Camera.main.transform;
|
|
if (level > 1)
|
|
{
|
|
var fxNames = rodSkinData.PiercingSuccessFx;
|
|
for (int i = 0; i < fxNames.Count; i++)
|
|
{
|
|
var go = await Addressables.LoadAssetAsync<GameObject>(fxNames[i]).Task;
|
|
if (go != null && Instance != null)
|
|
{
|
|
var fx = Instantiate(go, parent);
|
|
fx.SetActive(false);
|
|
PiercingSuccessFx.Add(fx);
|
|
PiercingSuccess.Add(go);
|
|
}
|
|
}
|
|
}
|
|
|
|
var MaxComboFxParent1 = await Addressables.LoadAssetAsync<GameObject>(rodSkinData.MaxComboFx).Task;
|
|
if (MaxComboFxParent1 != null)
|
|
MaxComboFxs.Add(MaxComboFxParent1);
|
|
var MaxComboParentTip1 = await Addressables.LoadAssetAsync<GameObject>(rodSkinData.MaxComboTip).Task;
|
|
if (MaxComboParentTip1 != null)
|
|
MaxComboFxs.Add(MaxComboParentTip1);
|
|
if (Instance != null)
|
|
{
|
|
if (MaxComboFxParent1 != null)
|
|
MaxComboFx = Instantiate(MaxComboFxParent1, parent);
|
|
if (MaxComboParentTip1 != null)
|
|
MaxComboTip = Instantiate(MaxComboParentTip1, parent);
|
|
MaxComboTip?.SetActive(false);
|
|
MaxComboFx?.SetActive(false);
|
|
}
|
|
}
|
|
void OnUpButton()
|
|
{
|
|
SetBtnAnimatorState(BtnAnimatorState.Normal);
|
|
}
|
|
|
|
|
|
void OnClickButton()
|
|
{
|
|
SetBtnAnimatorState(BtnAnimatorState.Clicked);
|
|
if (fishingData.IsDrawing)
|
|
{
|
|
OnClickSkill();
|
|
return;
|
|
}
|
|
if (isOpenPiercing)
|
|
{
|
|
if (fishingStart.curIndex != -1)
|
|
{
|
|
StopAllCoroutines();
|
|
fishingStart.StopMove();
|
|
PiercingInfo(fishingStart.GetCurPos());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GContext.Publish(new EventUISound("audio_fishing_piercing_noviceguide"));
|
|
fishingUpdateSys.PiercingFish(100);
|
|
}
|
|
}
|
|
public void SetFishIconDir(bool left)
|
|
{
|
|
fishBlood.SetFishIconDir(left);
|
|
}
|
|
void PiercingInfo(int index)
|
|
{
|
|
fishingUpdateSys.PiercingFish(index);
|
|
piercingInfo.gameObject.SetActive(true);
|
|
piercingInfo.Show(index);
|
|
int level = QualitySettings.GetQualityLevel();
|
|
if (level > 0 && index > 0 && index <= PiercingSuccessFx.Count)
|
|
{
|
|
PiercingSuccessFx[index - 1].SetActive(true);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新手引导专用
|
|
/// </summary>
|
|
/// <param name="hideUI"></param>
|
|
void HideUI(HideUI hideUI)
|
|
{
|
|
_canvasGroup.alpha = hideUI.hide ? 0 : 1;
|
|
_canvasGroup.blocksRaycasts = !hideUI.hide;
|
|
}
|
|
|
|
void StopAuto(StopAutoEvent IsDrawing)
|
|
{
|
|
AutomaticFishing = false;
|
|
if (IsDrawing.IsDrawing)
|
|
{
|
|
ShowTensionBar();
|
|
drawButton.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
//设置动画状态
|
|
public void SetBtnAnimatorState(BtnAnimatorState state)
|
|
{
|
|
string nameAni = "Normal1";
|
|
string nameAni2 = "Normal1";
|
|
_btnAnimator.SetBool("Normal1", false);
|
|
_btnAnimator.SetBool("Clicked1", false);
|
|
_btnAnimator.SetBool("Pressed1", false);
|
|
_sliderAnimator.SetBool("Normal1", false);
|
|
_sliderAnimator.SetBool("Pressed1", false);
|
|
_sliderAnimator2.SetBool("Normal1", false);
|
|
_sliderAnimator2.SetBool("Pressed1", false);
|
|
switch (state)
|
|
{
|
|
case BtnAnimatorState.Pressed:
|
|
nameAni = "Pressed1";
|
|
nameAni2 = "Pressed1";
|
|
break;
|
|
case BtnAnimatorState.Clicked:
|
|
nameAni = "Clicked1";
|
|
nameAni2 = "Pressed1";
|
|
break;
|
|
}
|
|
|
|
_btnAnimator.SetTrigger(nameAni);
|
|
_sliderAnimator.SetTrigger(nameAni2);
|
|
_sliderAnimator2.SetTrigger(nameAni2);
|
|
}
|
|
|
|
public void OnEnable()
|
|
{
|
|
DoEnable();
|
|
GContext.Publish(new OnSoundStateEvent(1));
|
|
text_play.text = LocalizationMgr.GetText("UI_FishingPanel_Advanced_101021");
|
|
WarningLineLengthRatio = GContext.container.Resolve<Tables>().TbGlobalConfig.WarningLineLengthRatio;
|
|
}
|
|
private void Start()
|
|
{
|
|
if (isOpenPiercing)
|
|
{
|
|
LoadFx();
|
|
}
|
|
}
|
|
private void DoEnable()
|
|
{
|
|
_canvasGroup.alpha = DeBugPanel.isShow ? 1 : 0;
|
|
}
|
|
void SetBoosFish()
|
|
{
|
|
fishBlood.FXInfoInit();
|
|
bool isBoos = fishBlood.ShowFishBossIcon(fishingData.curFishData.BattleAvatar);
|
|
if (!string.IsNullOrEmpty(curFishShakeIdle))
|
|
{
|
|
PlayBarAni(curFishShakeIdle, false);
|
|
}
|
|
curFishShakeIdle = fishingData.curFishData.ShakeIdle;
|
|
if (!string.IsNullOrEmpty(curFishShakeIdle))
|
|
{
|
|
PlayBarAni(curFishShakeIdle, true);
|
|
}
|
|
}
|
|
void ShowFishBlood()
|
|
{
|
|
SetBoosFish();
|
|
fishInfo.ShowState(1);
|
|
}
|
|
//UI吃鱼
|
|
public void UIEatFish()
|
|
{
|
|
//只显示鱼嘴和距离/播放mouse动画
|
|
fishBlood.SetFishHPScale(1);
|
|
}
|
|
public void UIEatFishEnd()
|
|
{
|
|
//换鱼显示节点
|
|
ShowFishBlood();
|
|
}
|
|
//完美刺鱼
|
|
public async void ExtraDrawingHP(float extraDrawingHP, int waitingZone, float fishHPScale, float damageProtectionTime)
|
|
{
|
|
text_play.text = LocalizationMgr.GetText("UI_FishingPanel_Advanced_101004");
|
|
fishInfo.ShowState(-1);
|
|
fishBlood.SetFishHPScale(fishHPScale);
|
|
piercingInfo.textBlood[waitingZone - 1].text = extraDrawingHP.ToString("-0");
|
|
|
|
await new WaitForSeconds(damageProtectionTime);
|
|
if (Instance != null)
|
|
{
|
|
ShowTensionBar();
|
|
fishBlood.WhiteDOFillAmount(fishHPScale);
|
|
fishingUpdateSys.UIEatCheck();
|
|
LoadFxChangeStartUI();
|
|
}
|
|
}
|
|
async void LoadFxChangeStartUI()
|
|
{
|
|
ETChangeMaterial eTDropAfterDrop = GContext.container.Resolve<CollectingData>().MaterialChange();
|
|
if (eTDropAfterDrop != null && eTDropAfterDrop.FxChangeStartUI != "None")
|
|
{
|
|
GContext.Publish(new EventUISound(eTDropAfterDrop.AudioChange));
|
|
FxChangeStartUI = await Addressables.InstantiateAsync(eTDropAfterDrop.FxChangeStartUI, fishBlood.transform).Task;
|
|
if (FxChangeStartUI != null)
|
|
{
|
|
FxChangeStartUI.transform.SetAsFirstSibling();
|
|
}
|
|
}
|
|
}
|
|
public async void StartDrawing(float damageProtectionTime)
|
|
{
|
|
text_play.text = LocalizationMgr.GetText("UI_FishingPanel_Advanced_101004");
|
|
fishInfo.ShowState(-1);
|
|
fishBlood.SetFishHPScale(1);
|
|
await new WaitForSeconds(damageProtectionTime);
|
|
if (Instance != null)
|
|
{
|
|
ShowTensionBar();
|
|
LoadFxChangeStartUI();
|
|
}
|
|
}
|
|
//动画吃鱼结束 重置UI
|
|
public void OnEatEnd()
|
|
{
|
|
SetBoosFish();
|
|
btn_up.SetActive(false);
|
|
fishInfo.fx_ui_barlianji_full.SetActive(false);
|
|
MaxComboTip?.SetActive(false);
|
|
ShowTensionBar();
|
|
drawButton.gameObject.SetActive(true);
|
|
fishInfo.gameObject.SetActive(true);
|
|
}
|
|
|
|
void ShowTensionBar()
|
|
{
|
|
if (PiercingSuccessFx != null && PiercingSuccessFx.Count > 0)
|
|
{
|
|
for (int i = 0; i < PiercingSuccessFx.Count; i++)
|
|
{
|
|
PiercingSuccessFx[i].SetActive(false);
|
|
}
|
|
}
|
|
fishInfo.ShowTensionBar();
|
|
fishInfo.SetTensionBarScale(fishingUpdateSys.ComboZone);
|
|
ShowFishBlood();
|
|
}
|
|
public void PlayBarAni(string aniName, bool isShake)
|
|
{
|
|
float barShakeAmp = fishingUpdateSys.GetBarShakeAmp();
|
|
fishInfo.PlayBarAni(aniName, isShake, barShakeAmp);
|
|
}
|
|
public void SetTensionBarScale(float ComboZone)
|
|
{
|
|
fishInfo.SetTensionBarScale(ComboZone);
|
|
}
|
|
public void UpdateTensionBar(int type, float power, float fishSwimAreaZFar, float fishSwimAreaZNear, float linelength)
|
|
{
|
|
fishInfo.OnDrawFishingLine(fishSwimAreaZFar, fishSwimAreaZNear, linelength, fishingData.MaxLinelength, WarningLineLengthRatio);
|
|
fishInfo.UpdateTensionBar(type, power);
|
|
}
|
|
|
|
|
|
public void UpdateComboMultiplayer(float _curComboMultiplayer, bool isMaxZone)
|
|
{
|
|
// 全力收线按钮
|
|
if (btn_up != null)
|
|
{
|
|
btn_up.SetActive(isMaxZone);
|
|
}
|
|
fishInfo.fx_ui_barlianji_full.SetActive(isMaxZone);
|
|
fishInfo.UpdateComboMultiplayer(_curComboMultiplayer);
|
|
}
|
|
public void ShowComboTips(bool isShow)
|
|
{
|
|
fishInfo.ShowComboTips(isShow);
|
|
}
|
|
Transform finger;
|
|
public void ShowFinger()
|
|
{
|
|
if (GuidancePanel.Instance)
|
|
{
|
|
var go = GuidancePanel.Instance.finger;
|
|
finger = Instantiate(go, drawButton.transform);
|
|
finger.localPosition = new Vector3(0, 0, 0);
|
|
finger.gameObject.SetActive(true);
|
|
finger.GetComponent<Animator>().Play("finger_loop2");
|
|
}
|
|
}
|
|
public void HideFinger()
|
|
{
|
|
if (finger)
|
|
{
|
|
Destroy(finger.gameObject);
|
|
finger = null;
|
|
}
|
|
}
|
|
public void ShowFishInfo(int text, float fishHPScale, bool isCombo, bool crit)
|
|
{
|
|
fishBlood.ShowFishInfo(text, fishHPScale, isCombo, crit);
|
|
}
|
|
|
|
public void ShowFishInfoPos(Vector3 bobber)
|
|
{
|
|
fishInfo.ShowFishInfoPos(bobber);
|
|
}
|
|
public void HideFishInfo()
|
|
{
|
|
fishInfo.gameObject.SetActive(false);
|
|
MaxComboTip?.SetActive(false);
|
|
MaxComboFx?.SetActive(false);
|
|
btn_draw_combo_down.SetActive(false);
|
|
btn_draw_combo_top.SetActive(false);
|
|
}
|
|
|
|
public void ShowDrawButton()
|
|
{
|
|
if (AutomaticFishing)
|
|
{
|
|
PiercingInfo(1);
|
|
}
|
|
else
|
|
{
|
|
drawButton.gameObject.SetActive(true);
|
|
}
|
|
fishInfo.gameObject.SetActive(true);
|
|
if (isOpenPiercing)
|
|
{
|
|
fishInfo.ShowState(0);
|
|
List<int> waitingSequence = fishingUpdateSys.WaitingSequence;
|
|
var waitingZone = GContext.container.Resolve<Tables>().TbRodWaitingZone.GetOrDefault(fishingUpdateSys.WaitingZone);
|
|
if (waitingZone == null)
|
|
{
|
|
waitingSequence = fishingData.fishRodData.WaitingSequence;
|
|
waitingZone = GContext.container.Resolve<Tables>().TbRodWaitingZone.GetOrDefault(fishingData.fishRodData.WaitingZone);
|
|
Debug.LogError("waitingZone==null" + fishingData.fishRodData.WaitingZone);
|
|
}
|
|
fishingStart.SetBar(waitingZone, fishingData.StrengthToScale);
|
|
fishingStart.StopMove();
|
|
fishingStart.StartMoveCo(waitingSequence, fishingData.FishVigilanceToTime, fishingData.RodVigilanceToTime);
|
|
}
|
|
else
|
|
{
|
|
fishInfo.ShowState(-1);
|
|
}
|
|
if (GContext.container.Resolve<PlayerFishData>().GetAnglingCount() != 5)
|
|
{
|
|
GContext.Publish(new OnEventTriggerGuide(GetType().Name));
|
|
}
|
|
}
|
|
|
|
public void HideDrawButton()
|
|
{
|
|
SetBtnAnimatorState(BtnAnimatorState.Normal);
|
|
drawButton.gameObject.SetActive(false);
|
|
}
|
|
public void ShowState(int state)
|
|
{
|
|
fishInfo.ShowState(state);
|
|
}
|
|
|
|
public enum BtnAnimatorState
|
|
{
|
|
None = 0,
|
|
Normal = 1,
|
|
Pressed = 2,
|
|
Clicked = 3
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
disposables.Dispose();
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
Destroy(MaxComboTip);
|
|
Destroy(MaxComboFx);
|
|
Instance = null;
|
|
SkillRelease();
|
|
SkillDirtyRelease();
|
|
if (PiercingSuccessFx != null)
|
|
{
|
|
for (int i = 0; i < PiercingSuccessFx.Count; i++)
|
|
{
|
|
Destroy(PiercingSuccessFx[i]);
|
|
}
|
|
PiercingSuccessFx.Clear();
|
|
}
|
|
if (PiercingSuccess != null)
|
|
{
|
|
for (int i = 0; i < PiercingSuccess.Count; i++)
|
|
{
|
|
Addressables.Release(PiercingSuccess[i]);
|
|
}
|
|
PiercingSuccess.Clear();
|
|
}
|
|
if (MaxComboFxs != null)
|
|
{
|
|
for (int i = 0; i < MaxComboFxs.Count; i++)
|
|
{
|
|
Addressables.Release(MaxComboFxs[i]);
|
|
}
|
|
MaxComboFxs.Clear();
|
|
}
|
|
|
|
if (FxChangeStartUI != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxChangeStartUI);
|
|
}
|
|
}
|
|
public void ShowFX_info_combo(bool isStart)
|
|
{
|
|
if (isStart)
|
|
{
|
|
CloseMaxComboTip();
|
|
ShowMaxComboFx();
|
|
}
|
|
else
|
|
{
|
|
CloseMaxComboFx();
|
|
}
|
|
btn_draw_combo_down.SetActive(isStart);
|
|
btn_draw_combo_top.SetActive(isStart);
|
|
FX_info_combo.SetActive(isStart);
|
|
btn_up.SetActive(false);
|
|
fishInfo.fx_ui_barlianji_full.SetActive(false);
|
|
fishInfo.EndFull(isStart, fishingData.fishRodData.ComboTime);
|
|
}
|
|
void ShowMaxComboFx()
|
|
{
|
|
if (MaxComboFx != null)
|
|
{
|
|
MaxComboFx.transform.DOKill();
|
|
MaxComboFx.transform.localScale = Vector3.one;
|
|
MaxComboFx.SetActive(true);
|
|
}
|
|
}
|
|
async void CloseMaxComboFx()
|
|
{
|
|
if (MaxComboFx != null)
|
|
{
|
|
MaxComboFx.transform.DOKill();
|
|
MaxComboFx.transform.DOScaleX(2f, 0.5f);
|
|
MaxComboFx.transform.DOScaleY(2f, 0.5f);
|
|
|
|
await Awaiters.Seconds(0.5f);
|
|
MaxComboFx?.SetActive(false);
|
|
}
|
|
}
|
|
public void ShowMaxComboTip()
|
|
{
|
|
MaxComboTip?.SetActive(true);
|
|
}
|
|
public void CloseMaxComboTip()
|
|
{
|
|
MaxComboTip?.SetActive(false);
|
|
}
|
|
public async Task ShowWarning(string warning)
|
|
{
|
|
if (string.IsNullOrEmpty(warning))
|
|
{
|
|
return;
|
|
}
|
|
foreach (var item in FX_info_warning)
|
|
{
|
|
item.Value.SetActive(false);
|
|
}
|
|
//警告
|
|
if (!FX_info_warning.ContainsKey(warning))
|
|
{
|
|
FX_info_warning[warning] = null;
|
|
FX_info_warning[warning] = await Addressables.InstantiateAsync(warning, tips).Task;
|
|
}
|
|
GameObject fx = FX_info_warning[warning];
|
|
if (fx != null)
|
|
{
|
|
fx.SetActive(true);
|
|
}
|
|
}
|
|
public void FXInfo(int index)
|
|
{
|
|
fishBlood.FXInfo(index);
|
|
}
|
|
|
|
public void PlayDistance()
|
|
{
|
|
fishInfo.distance_ani.Play();
|
|
}
|
|
public void StopDistance()
|
|
{
|
|
fishInfo.distance_ani.Stop();
|
|
}
|
|
#region 特殊技能相关
|
|
int FreezeSkill = 0;
|
|
public bool UISpSkill => FreezeSkill > 0;
|
|
GameObject FxScreenWarning;
|
|
GameObject FxScreen;
|
|
GameObject FxBtn;
|
|
GameObject FxClick;
|
|
GameObject FxBreak;
|
|
GameObject FxBar;
|
|
GameObject FxFishIcon;
|
|
|
|
GameObject FxTargetBarBg;
|
|
GameObject FxTargetBar;
|
|
GameObject FxTargetBarHighlight;
|
|
|
|
string AudioClick;
|
|
string AudioBreak;
|
|
public void SetImageSprite(BarTarget barTarget)
|
|
{
|
|
if (!string.IsNullOrEmpty(barTarget.bar_target))
|
|
{
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(bar_target, barTarget.bar_target);
|
|
}
|
|
if (!string.IsNullOrEmpty(barTarget.highlight))
|
|
{
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(highlight, barTarget.highlight);
|
|
}
|
|
}
|
|
public async void PlaySpKillFx(IFishSpSkillData fishSpSkillData)
|
|
{
|
|
BarTarget barTarget = fishSpSkillData.GetBarTarget();
|
|
if (barTarget != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(barTarget.fx_target_bar_bg) && FxTargetBarBg == null)
|
|
{
|
|
FxTargetBarBg = await Addressables.InstantiateAsync(barTarget.fx_target_bar_bg, fx_target_bar_bg).Task;
|
|
}
|
|
if (!string.IsNullOrEmpty(barTarget.fx_target_bar) && FxTargetBar == null)
|
|
{
|
|
FxTargetBar = await Addressables.InstantiateAsync(barTarget.fx_target_bar, fx_target_bar).Task;
|
|
}
|
|
if (!string.IsNullOrEmpty(barTarget.fx_target_bar_highlight) && FxTargetBarHighlight == null)
|
|
{
|
|
FxTargetBarHighlight = await Addressables.InstantiateAsync(barTarget.fx_target_bar_highlight, fx_target_bar_highlight).Task;
|
|
}
|
|
if (!string.IsNullOrEmpty(barTarget.fxScreenWarning))
|
|
{
|
|
FxScreenWarning = await Addressables.InstantiateAsync(barTarget.fxScreenWarning, transform).Task;
|
|
FxScreenWarning?.SetActive(false);
|
|
}
|
|
|
|
}
|
|
//界面特效
|
|
if (FxScreen == null && !string.IsNullOrEmpty(fishSpSkillData.FxScreen()))
|
|
{
|
|
FxScreen = await Addressables.InstantiateAsync(fishSpSkillData.FxScreen(), transform).Task;
|
|
}
|
|
if (FxBar == null && !string.IsNullOrEmpty(fishSpSkillData.FxBar()))
|
|
{
|
|
FxBar = await Addressables.InstantiateAsync(fishSpSkillData.FxBar(), barFx).Task;
|
|
}
|
|
if (FxFishIcon == null && !string.IsNullOrEmpty(fishSpSkillData.FxFishIcon()))
|
|
{
|
|
FxFishIcon = await Addressables.InstantiateAsync(fishSpSkillData.FxFishIcon(), bloodBossFx).Task;
|
|
}
|
|
if (Instance == null)
|
|
{
|
|
SkillRelease();
|
|
return;
|
|
}
|
|
FxScreen?.SetActive(true);
|
|
FxBar?.SetActive(true);
|
|
FxTargetBarBg?.SetActive(true);
|
|
FxTargetBar?.SetActive(true);
|
|
FxTargetBarHighlight?.SetActive(true);
|
|
}
|
|
|
|
public void ShowFxScreenWarning(bool isWarning)
|
|
{
|
|
FxScreen?.SetActive(!isWarning);
|
|
FxScreenWarning?.SetActive(isWarning);
|
|
}
|
|
|
|
public void UpdateTargetBar(float bar_target_p)
|
|
{
|
|
float bar_target_fill = (bar_target_p * 86 + 2f) / 90;
|
|
bar_target.fillAmount = bar_target_fill;
|
|
highlight_target.localEulerAngles = new Vector3(0, 0, (1 - bar_target_fill) * 90f);
|
|
bar_target.gameObject.SetActive(bar_target_p > 0.01f);
|
|
highlight_target.gameObject.SetActive(bar_target_p > 0.01f);
|
|
}
|
|
public void StopFxSpKill()
|
|
{
|
|
//界面特效
|
|
FxScreen?.SetActive(false);
|
|
FxScreenWarning?.SetActive(false);
|
|
FxBar?.SetActive(false);
|
|
FxTargetBarBg?.SetActive(false);
|
|
FxTargetBarHighlight?.SetActive(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示冰冻界面
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async void ShowFreezeSkill(Freeze freeze)
|
|
{
|
|
FreezeSkill = freeze.ClickCount;
|
|
AudioClick = freeze.AudioClick;
|
|
AudioBreak = freeze.AudioBreak;
|
|
//界面特效
|
|
if (FxScreen == null)
|
|
{
|
|
FxScreen = await Addressables.InstantiateAsync(freeze.FxScreen, transform).Task;
|
|
}
|
|
GContext.Publish(new EventUISound(freeze.AudioScreen));
|
|
//按钮特效
|
|
if (FxBtn == null)
|
|
{
|
|
FxBtn = await Addressables.InstantiateAsync(freeze.FxBtn, drawButton.transform).Task;
|
|
}
|
|
if (FxClick == null)
|
|
{
|
|
FxClick = await Addressables.InstantiateAsync(freeze.FxClick, drawButton.transform).Task;
|
|
}
|
|
if (FxBreak == null)
|
|
{
|
|
FxBreak = await Addressables.InstantiateAsync(freeze.FxBreak, transform).Task;
|
|
}
|
|
if (Instance == null)
|
|
{
|
|
SkillRelease();
|
|
return;
|
|
}
|
|
FxClick?.SetActive(false);
|
|
FxBreak?.SetActive(false);
|
|
FxScreen?.SetActive(true);
|
|
FxBtn?.SetActive(true);
|
|
}
|
|
GameObject FxScreenDirty;
|
|
GameObject FxClickDirty;
|
|
GameObject FxBarDirty;
|
|
/// <summary>
|
|
/// 显示污渍界面
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async void ShowDirtyStuckSkill(DirtyStuck dirtyStuck)
|
|
{
|
|
bool isGuide = GContext.container.Resolve<FishingEventData>().TargetGuidance(GContext.container.Resolve<Tables>().TbGlobalConfig.PollutionSkillGuidance);
|
|
|
|
FreezeSkill = dirtyStuck.ClickCount;
|
|
//界面特效
|
|
Transform parent = Camera.main.transform;
|
|
if (FxScreenDirty == null)
|
|
{
|
|
FxScreenDirty = await Addressables.InstantiateAsync(dirtyStuck.StuckFx, parent).Task;
|
|
}
|
|
|
|
if (FxClickDirty == null)
|
|
{
|
|
FxClickDirty = await Addressables.InstantiateAsync(dirtyStuck.StuckClickFx, parent).Task;
|
|
}
|
|
if (FxBarDirty == null)
|
|
{
|
|
FxBarDirty = await Addressables.InstantiateAsync(dirtyStuck.StuckBarFx, barFx).Task;
|
|
}
|
|
if (Instance == null)
|
|
{
|
|
SkillDirtyRelease();
|
|
return;
|
|
}
|
|
FxClickDirty?.SetActive(false);
|
|
FxScreenDirty?.SetActive(true);
|
|
}
|
|
|
|
void OnClickSkill()
|
|
{
|
|
if (FreezeSkill > 0)
|
|
{
|
|
FreezeSkill--;
|
|
|
|
if (FreezeSkill == 0)
|
|
{
|
|
//技能结束
|
|
FxBreak?.SetActive(true);
|
|
FxScreen?.SetActive(false);
|
|
FxBtn?.SetActive(false);
|
|
ClickSkillDirty();
|
|
if (!string.IsNullOrEmpty(AudioBreak))
|
|
GContext.Publish(new EventUISound(AudioBreak));
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(AudioClick))
|
|
GContext.Publish(new EventUISound(AudioClick));
|
|
}
|
|
if (FxClick != null)
|
|
{
|
|
FxClick.SetActive(false);
|
|
FxClick.SetActive(true);
|
|
}
|
|
if (FxClickDirty != null)
|
|
{
|
|
FxClickDirty.SetActive(false);
|
|
FxClickDirty.SetActive(true);
|
|
}
|
|
fishingUpdateSys.OnClickSkill(FreezeSkill);
|
|
}
|
|
}
|
|
async void ClickSkillDirty()
|
|
{
|
|
if (FxScreenDirty!=null)
|
|
{
|
|
Animation animation = FxScreenDirty.GetComponent<Animation>();
|
|
if (animation != null)
|
|
{
|
|
animation.Play();
|
|
await Awaiters.Seconds(animation.clip.length);
|
|
}
|
|
|
|
FxScreenDirty.SetActive(false);
|
|
}
|
|
|
|
if (FxBarDirty != null)
|
|
{
|
|
FxBarDirty.SetActive(false);
|
|
}
|
|
if (FxClickDirty != null)
|
|
{
|
|
FxClickDirty.SetActive(false);
|
|
}
|
|
}
|
|
void SkillDirtyRelease()
|
|
{
|
|
if (FxScreenDirty != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxScreenDirty);
|
|
FxScreenDirty = null;
|
|
}
|
|
|
|
if (FxBarDirty != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxBarDirty);
|
|
FxBarDirty = null;
|
|
}
|
|
if (FxClickDirty != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxClickDirty);
|
|
FxClickDirty = null;
|
|
}
|
|
}
|
|
|
|
public void SkillRelease()
|
|
{
|
|
if (FxScreen != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxScreen);
|
|
FxScreen = null;
|
|
}
|
|
if (FxScreenWarning != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxScreenWarning);
|
|
FxScreenWarning = null;
|
|
}
|
|
if (FxBtn != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxBtn);
|
|
FxBtn = null;
|
|
}
|
|
if (FxClick != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxClick);
|
|
FxClick = null;
|
|
}
|
|
if (FxBreak != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxBreak);
|
|
FxBreak = null;
|
|
}
|
|
if (FxBar != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxBar);
|
|
FxBar = null;
|
|
}
|
|
if (FxFishIcon != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxFishIcon);
|
|
FxFishIcon = null;
|
|
}
|
|
if (FxTargetBarBg != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxTargetBarBg);
|
|
FxTargetBarBg = null;
|
|
}
|
|
if (FxTargetBar != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxTargetBar);
|
|
FxTargetBar = null;
|
|
}
|
|
|
|
if (FxTargetBarHighlight != null)
|
|
{
|
|
Addressables.ReleaseInstance(FxTargetBarHighlight);
|
|
FxTargetBarHighlight = null;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|