备份CatanBuilding瘦身独立工程
This commit is contained in:
416
Assets/Scripts/Duel/FishingDuelRewardPanel.cs
Normal file
416
Assets/Scripts/Duel/FishingDuelRewardPanel.cs
Normal file
@@ -0,0 +1,416 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingDuelRewardPanel : BasePanel
|
||||
{
|
||||
Tables _tables;
|
||||
private CanvasGroup canvasGroup;
|
||||
private CanvasGroup root_success;
|
||||
private GameObject root_fail;
|
||||
private Button playButton;
|
||||
private TMP_Text text_title;
|
||||
private TMP_Text text_weight_num;
|
||||
|
||||
private Image img_fishTag;
|
||||
|
||||
private GameObject station_powerful;
|
||||
private GameObject station_weekly;
|
||||
private GameObject station_nopush;
|
||||
public TMP_Text text_info;
|
||||
private Button btn_green;
|
||||
TMP_Text text_tryagain_num;
|
||||
|
||||
int curRateIndex;
|
||||
public UIDrag dragImage;
|
||||
Animator anim_panel;
|
||||
public float fishRotateSpeed = 8f; //鱼旋转速度
|
||||
|
||||
TMP_Text text_num_fishcard;
|
||||
TMP_Text text_num_rod;
|
||||
|
||||
int fishID;
|
||||
FishingData fishingData;
|
||||
//AddCash等待时间
|
||||
public float waitTime1 = 0.2f;
|
||||
//AddCash持续时间
|
||||
public float duration1 = 1f;
|
||||
public float waitTime2 = 0.2f;
|
||||
public float duration2 = 1f;
|
||||
IUIService uiService;
|
||||
PlayerFishData playerFishData;
|
||||
PlayerData playerData;
|
||||
FishingDuelManager fishingDuelManager;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
fishingDuelManager = GContext.container.Resolve<FishingDuelManager>();
|
||||
uiService = GContext.container.Resolve<IUIService>();
|
||||
dragImage = transform.Find("root_success/UIDrag").GetComponent<UIDrag>();
|
||||
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
text_num_fishcard = transform.Find("root_success/info/fishcard/text_num").GetComponent<TMP_Text>();
|
||||
text_num_rod = transform.Find("root_success/info/rod/text_num").GetComponent<TMP_Text>();
|
||||
root_success = transform.Find("root_success").GetComponent<CanvasGroup>();
|
||||
|
||||
img_fishTag = transform.Find("root_success/info/name/icon_tag").GetComponent<Image>();
|
||||
anim_panel = GetComponent<Animator>();
|
||||
|
||||
text_title = transform.Find("root_success/info/name/text_name").GetComponent<TMP_Text>();
|
||||
|
||||
text_weight_num = transform.Find("root_success/info/score/text_point").GetComponent<TMP_Text>();
|
||||
|
||||
playButton = transform.Find("root_success/info/btn_play/btn_green").GetComponent<Button>();
|
||||
|
||||
root_fail = transform.Find("root_fail").gameObject;
|
||||
|
||||
text_info = transform.Find("root_fail/bg_info/text_info").GetComponent<TMP_Text>();
|
||||
station_powerful = transform.Find("root_fail/station_powerful").gameObject;
|
||||
station_weekly = transform.Find("root_fail/station_weekly").gameObject;
|
||||
station_nopush = transform.Find("root_fail/station_nopush").gameObject;
|
||||
|
||||
btn_green = transform.Find("root_fail/btn_tryagain/btn_green").GetComponent<Button>();
|
||||
text_tryagain_num = transform.Find("root_fail/btn_tryagain/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
playerData = GContext.container.Resolve<PlayerData>();
|
||||
fishingData = GContext.container.Resolve<FishingData>();
|
||||
if (fishingData.fishingResult == FishingResult.Success)
|
||||
{
|
||||
anim_panel.Play("info_show_1");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
SetFishingFocalVolume(50);
|
||||
|
||||
|
||||
playButton.onClick.AddListener(OnClickInHome);
|
||||
btn_green.onClick.AddListener(OnSucceed);
|
||||
|
||||
dragImage.OnPointerDownCall += () =>
|
||||
{
|
||||
GameEventMgr.Instance.Raise(GameEvents.EventFishingPlay);
|
||||
};
|
||||
StartDoRotate();
|
||||
dragImage.OnBeginDragCall += OnBeginDragCall;
|
||||
dragImage.OnDragCall += OnDragFish;
|
||||
dragImage.OnEndDragCall += StartDoRotate;
|
||||
|
||||
OnShow();
|
||||
}
|
||||
void StartDoRotate()
|
||||
{
|
||||
GContext.Publish(new FishRotateEvent(0, 1, fishingData.rodType));
|
||||
}
|
||||
void OnDragFish(PointerEventData eventData)
|
||||
{
|
||||
float x = Input.GetAxis("Mouse X") * fishRotateSpeed;
|
||||
GContext.Publish(new FishRotateEvent(x, 2, fishingData.rodType));
|
||||
|
||||
}
|
||||
void OnBeginDragCall()
|
||||
{
|
||||
GContext.Publish(new FishRotateEvent(0, 0, fishingData.rodType));
|
||||
}
|
||||
|
||||
void OnShow()
|
||||
{
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
fishingData.IsFree = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(fishingData.curFishData.AudioDuelRewardPanel))
|
||||
{
|
||||
GContext.Publish(new EventFishingSound(fishingData.curFishData.AudioDuelRewardPanel));
|
||||
}
|
||||
fishID = fishingData.curFishData.ID;
|
||||
if (fishingData.fixedFishList != null)
|
||||
{
|
||||
fishID = fishingData.fixedFishList.RealFishID;
|
||||
}
|
||||
|
||||
if (fishingData.fishingResult == FishingResult.Success)
|
||||
{
|
||||
root_fail.SetActive(false);
|
||||
root_success.gameObject.SetActive(fishingData.IsGeneralFish());
|
||||
Success();
|
||||
StartCoroutine(Blur());
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("pvp_fishing"))
|
||||
{
|
||||
int currentRodLevel = playerFishData.GetRodLevel(playerData.equipRodID);
|
||||
int currentRodStar = playerFishData.GetRodPiece(playerData.equipRodID);
|
||||
e.AddContent("map_id", fishingData.MapId)
|
||||
.AddContent("fishing_state", 1)
|
||||
.AddContent("fish_id", fishID)
|
||||
.AddContent("fish_time", fishingData.GetFishingTimer())
|
||||
.AddContent("charge_count", GContext.container.Resolve<PlayerShopData>().GetBuyPaymentAmount())
|
||||
.AddContent("hook_count", playerData.GetEnergyRM())
|
||||
.AddContent("available_hook_num", playerData.Energy)
|
||||
.AddContent("available_cash_num", playerData.gold)
|
||||
.AddContent("jerking_count", fishingData.jerking_count)
|
||||
.AddContent("stickle_state", fishingData.stickle_state)
|
||||
.AddContent("current_rod", playerData.equipRodID)
|
||||
.AddContent("current_rod_level", currentRodLevel)
|
||||
.AddContent("current_rod_star", currentRodStar)
|
||||
.AddContent("fish_card_lv", fishingData.CardLevel)
|
||||
.AddContent("reward_cash", 0)
|
||||
.AddContent("retry_ways", fishingData.retry_ways)
|
||||
.AddContent("retry", fishingData.IsRetry);
|
||||
|
||||
var _socialData = GContext.container.Resolve<ClubService>();
|
||||
if (_socialData.myClubInfo != null)
|
||||
{
|
||||
e.AddContent("guild_id", _socialData.myClubInfo.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.AddContent("guild_id", 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
root_success.gameObject.SetActive(false);
|
||||
root_fail.SetActive(true);
|
||||
|
||||
//#if AGG
|
||||
using (var e = GEvent.GameEvent("pvp_fishing"))
|
||||
{
|
||||
int currentRodLevel = playerFishData.GetRodLevel(playerData.equipRodID);
|
||||
int currentRodStar = playerFishData.GetRodPiece(playerData.equipRodID);
|
||||
e.AddContent("map_id", fishingData.MapId)
|
||||
.AddContent("fishing_state", 2)
|
||||
.AddContent("fishing_failed_reason", (int)fishingData.fishingResult)
|
||||
.AddContent("fish_id", fishID)
|
||||
.AddContent("fish_time", fishingData.GetFishingTimer())
|
||||
.AddContent("charge_count", GContext.container.Resolve<PlayerShopData>().GetBuyPaymentAmount())
|
||||
.AddContent("hook_count", playerData.GetEnergyRM())
|
||||
.AddContent("available_hook_num", playerData.Energy)
|
||||
.AddContent("available_cash_num", playerData.gold)
|
||||
.AddContent("jerking_count", fishingData.jerking_count)
|
||||
.AddContent("stickle_state", fishingData.stickle_state)
|
||||
.AddContent("current_rod", playerData.equipRodID)
|
||||
.AddContent("current_rod_level", currentRodLevel)
|
||||
.AddContent("current_rod_star", currentRodStar)
|
||||
.AddContent("fish_card_lv", fishingData.CardLevel)
|
||||
.AddContent("retry_ways", fishingData.retry_ways)
|
||||
.AddContent("retry", fishingData.IsRetry);
|
||||
|
||||
var _socialData = GContext.container.Resolve<ClubService>();
|
||||
if (_socialData.myClubInfo != null)
|
||||
{
|
||||
e.AddContent("guild_id", _socialData.myClubInfo.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.AddContent("guild_id", 0);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
OnFail();
|
||||
}
|
||||
fishingData.IsRetry = false;
|
||||
}
|
||||
|
||||
IEnumerator Blur()
|
||||
{
|
||||
//Pulling 结束后
|
||||
float time = fishingData.fishingBehaviorConf.blurDelay;
|
||||
yield return new WaitForSeconds(time);
|
||||
//ConvertTools.SetFSBlur(true, fishingData.fishingBehaviorConf.blurDistanceZ);
|
||||
EnableFishingBlur(true);
|
||||
}
|
||||
|
||||
//钓鱼成功
|
||||
void Success()
|
||||
{
|
||||
//GContext.container.Resolve<GuideDataCenter>().AddIndex(true);
|
||||
var PointBonus = playerFishData.GetRodAscendStats();
|
||||
DropPackageList dropPackageList = _tables.TbDrop[fishingData.curFishData.DropID].DropList;
|
||||
float proficiency = dropPackageList.DropCountList[0] * fishingData.random;
|
||||
SetProficiency(proficiency, PointBonus);
|
||||
|
||||
text_title.text = LocalizationMgr.GetText(fishingData.curFishData.Name_l10n_key);
|
||||
curRateIndex = 0;
|
||||
uiService.SetImageSprite(img_fishTag, "icon_fish_rate_tag_" + fishingData.curFishData.Quality);
|
||||
|
||||
_ = StartCoroutine(AddCash());
|
||||
//Show Fish Info UI
|
||||
|
||||
VibrationData();
|
||||
}
|
||||
|
||||
async void VibrationData()
|
||||
{
|
||||
await Awaiters.Seconds(2.5f);
|
||||
if (curRateIndex >= _tables.TbGlobalConfig.RankVibration.Count)
|
||||
curRateIndex = _tables.TbGlobalConfig.RankVibration.Count - 1;
|
||||
int hapticType = _tables.TbGlobalConfig.RankVibration[curRateIndex];
|
||||
if (hapticType == 1)
|
||||
{
|
||||
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
|
||||
|
||||
}
|
||||
else if (hapticType == 2)
|
||||
{
|
||||
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
|
||||
}
|
||||
else if (hapticType == 3)
|
||||
{
|
||||
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
|
||||
}
|
||||
}
|
||||
private float _fishScore;
|
||||
|
||||
void SetFishingFocalVolume(float value)
|
||||
{
|
||||
var stage = RootCtx.container.Resolve<IStageService>()?.GetStage("FishingStage");
|
||||
if (stage != null && stage.Id == "FishingStage")
|
||||
{
|
||||
var act = stage.CurrentAct as FishingAct;
|
||||
if (act != null)
|
||||
act.SetFishingFocalVolume(value);
|
||||
}
|
||||
}
|
||||
private void EnableFishingBlur(bool enable)
|
||||
{
|
||||
var stage = RootCtx.container.Resolve<IStageService>()?.GetStage("FishingStage");
|
||||
if (stage != null && stage.Id == "FishingStage")
|
||||
{
|
||||
var act = stage.CurrentAct as FishingAct;
|
||||
if (act != null)
|
||||
act.EnableFishingVolume(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator AddCash()
|
||||
{
|
||||
text_weight_num.text = "";
|
||||
var progress = 0f;
|
||||
yield return Awaiters.Seconds(waitTime1);
|
||||
DOTween.To(() => progress, x => progress = x, 1, duration1).OnUpdate(() =>
|
||||
{
|
||||
text_weight_num.text = ConvertTools.GetNumberString2((int)(_fishScore * progress));
|
||||
|
||||
}).SetId("AddCash");
|
||||
}
|
||||
|
||||
//设置熟练度
|
||||
void SetProficiency(float proficiency, float proficiencyExtra)
|
||||
{
|
||||
float extra1 = fishingData.WeightIncEvent;
|
||||
float extra2 = 0;
|
||||
if (!fishingData.IsNewItemFish())
|
||||
{
|
||||
proficiencyExtra = (1 + fishingData.WeightIncEvent) * (1 + proficiencyExtra);
|
||||
}
|
||||
else
|
||||
{
|
||||
proficiencyExtra = (1 + proficiencyExtra) * (1 + playerData.benefitsEventFishCashMag);
|
||||
}
|
||||
|
||||
if (fishingDuelManager != null)
|
||||
{
|
||||
int star = playerFishData.GetRodPiece(fishingData.fishRodData.ID);
|
||||
Dictionary<RodPerkType, string> RodPerkDic = playerFishData.GetRodPerk(fishingData.fishRodData.ID, star);
|
||||
extra2 = fishingDuelManager.GetCurRodBuff(RodPerkDic, fishingData.curFishData.Quality);
|
||||
proficiencyExtra *= (1 + extra2);
|
||||
}
|
||||
proficiency *= proficiencyExtra;
|
||||
proficiency = Mathf.RoundToInt(proficiency);
|
||||
if (fishingDuelManager != null)
|
||||
{
|
||||
fishingDuelManager.StopFishing(fishingData.fishItem.ID, (int)proficiency, extra1, extra2);
|
||||
}
|
||||
text_num_fishcard.text = extra1.ToString("P0");
|
||||
text_num_rod.text = extra2.ToString("P0");
|
||||
_fishScore = proficiency;
|
||||
}
|
||||
|
||||
void OnFail()
|
||||
{
|
||||
text_tryagain_num.text = LocalizationMgr.GetText("UI_FishingRewardPanel_101022");
|
||||
|
||||
|
||||
if (fishingDuelManager != null)
|
||||
{
|
||||
int RetryNum = fishingDuelManager.CurrentRetryNum;
|
||||
if (RetryNum > 1)
|
||||
{
|
||||
text_tryagain_num.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_50", RetryNum - 1);
|
||||
}
|
||||
fishingDuelManager.OnFishingChangeStateEvent(FishingChangeState.FishingFail, fishingData.fishItem.ID);
|
||||
}
|
||||
text_info.text = LocalizationMgr.GetFormatTextValue("UI_FishingRewardPanel_101008", fishingData.curFishData.Quality);
|
||||
station_powerful.SetActive(false);
|
||||
station_weekly.SetActive(false);
|
||||
station_nopush.SetActive(false);
|
||||
OnClickAdvertClose();
|
||||
}
|
||||
|
||||
|
||||
//第一次失败返回
|
||||
void OnClickAdvertClose()
|
||||
{
|
||||
switch (fishingData.fishingResult)
|
||||
{
|
||||
case FishingResult.Success:
|
||||
break;
|
||||
case FishingResult.Fail1:
|
||||
station_powerful.SetActive(true);
|
||||
break;
|
||||
case FishingResult.Fail2:
|
||||
station_weekly.SetActive(true);
|
||||
break;
|
||||
default:
|
||||
station_nopush.SetActive(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickInHome()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
GContext.Publish(new ResetFishingStatusEvent());
|
||||
GContext.Publish(new IsRecastEvent());
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingDuelRewardPanel);
|
||||
|
||||
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
||||
GContext.Publish(restartShowHomeUIEvent);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
//ConvertTools.SetFSBlur(false);
|
||||
EnableFishingBlur(false);
|
||||
DOTween.Kill("AddCash");
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
async void OnSucceed()
|
||||
{
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
GContext.Publish(new ResetFishingStatusEvent() { restart = true });
|
||||
GContext.Publish(new IsRecastEvent() { isRecast = true });
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingPanel);
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingDuelRewardPanel);
|
||||
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
||||
restartShowHomeUIEvent.isPopupStore = true;
|
||||
GContext.Publish(restartShowHomeUIEvent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user