Files
MinFt/Client/Assets/Scripts/Aquarium/UI/EventFishHuntingPanel.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

341 lines
12 KiB
C#

using asap.core;
using cfg;
using DG.Tweening;
using game;
using GameCore;
using System;
using System.Collections;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class EventFishHuntingPanel : MonoBehaviour
{
Tables _tables;
Head head;
Button switchbtn;
GameObject exchange;
GameObject title;
Button btn_aim;
TMP_Text text_name;
GameObject fish_info;
Image tag_fish;
TMP_Text text_fish_name;
TMP_Text text_fish_num;
TMP_Text text_level_num;
GameObject mutated;
// GameObject mutated_settlement;
GameObject root_settlement;
GameObject kill;
GameObject hurt;
Button btn_close;
Transform photo;
EventFishHuntingPhoto eventFishHuntingPhoto;
SmallGameData smallGameData;
string playFabId;
OpponentItemData opponentItemData;
bool isClick = false;
AquariumShooterFishManager AM;
int multiple;
[NonSerialized]
public ShooterFishAct shooterFishAct;
EventFishHuntingAim eventFishHuntingAim;
FishMovement fishMovement;
FishMovement curTarget;
int changeTargetCount = 0;
UIDownUp uIDownUp;
protected CompositeDisposable disposables = new CompositeDisposable();
private void Awake()
{
multiple = GContext.container.Resolve<PlayerData>().GetMagnification();
AM = GContext.container.Resolve<AquariumShooterFishManager>();
smallGameData = GContext.container.Resolve<SmallGameData>();
_tables = GContext.container.Resolve<Tables>();
text_name = transform.Find("root/title/bg/text_name").GetComponent<TMP_Text>();
head = transform.Find("root/title/btn_head").GetComponent<Head>();
switchbtn = transform.Find("root/switch/btn_switch/btn_green").GetComponent<Button>();
exchange = transform.Find("root/switch").gameObject;
title = transform.Find("root/title").gameObject;
btn_aim = transform.Find("root/btn_hunt").GetComponent<Button>();
kill = transform.Find("root/root_settlement/kill").gameObject;
hurt = transform.Find("root/root_settlement/hurt").gameObject;
root_settlement = transform.Find("root/root_settlement").gameObject;
btn_close = transform.Find("root/root_settlement/btn_play/btn_green").GetComponent<Button>();
fish_info = transform.Find("root/fish_info").gameObject;
tag_fish = fish_info.transform.Find("text_name/tag_fish").GetComponent<Image>();
text_fish_name = fish_info.transform.Find("text_name").GetComponent<TMP_Text>();
text_fish_num = fish_info.transform.Find("text_num").GetComponent<TMP_Text>();
text_level_num = fish_info.transform.Find("text_level_num").GetComponent<TMP_Text>();
mutated = fish_info.transform.Find("mutated").gameObject;
photo = transform.Find("root/root_settlement/photo");
eventFishHuntingPhoto = photo.gameObject.GetOrAddComponent<EventFishHuntingPhoto>();
eventFishHuntingPhoto.Init();
text_num = transform.Find("root/root_settlement/photo/reward/text_num").GetComponent<TMP_Text>();
text_num_buff = transform.Find("root/root_settlement/photo/reward/text_num/text_num_buff").GetComponent<TMP_Text>();
bonusReward = transform.Find("root/root_settlement/photo/bonus").GetComponent<BonusReward>();
fx_ui_fishingsettlement_hunt_cash_1 = transform.Find("root/root_settlement/particle/fx_ui_fishingsettlement_hunt_cash_1").gameObject;
fx_ui_fishingsettlement_hunt_cash_2 = transform.Find("root/root_settlement/particle/fx_ui_fishingsettlement_hunt_cash_2").gameObject;
uIDownUp = transform.Find("root/OpenHuntingAim").GetComponent<UIDownUp>();
eventFishHuntingAim = transform.Find("root/EventFishHuntingAim").GetComponent<EventFishHuntingAim>();
eventFishHuntingAim.eventFishHuntingPanel = this;
}
private void Start()
{
GContext.OnEvent<ChangeSmallGameTargetEvent>().Subscribe(ChangeSmallGameTarget).AddTo(disposables);
opponentItemData = smallGameData.opponentData;
playFabId = smallGameData.opponentData.playFabID;
GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar).AddTo(disposables);
IUserService userService = GContext.container.Resolve<IUserService>();
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
SetAvatar(clubPlayInfo);
if (GContext.container.Resolve<LeadboardData>().IsOpenleaderboard)
{
switchbtn.onClick.AddListener(OnClickHead);
}
else
{
exchange.SetActive(false);
switchbtn.enabled = false;
//exchange.SetActive(false);
}
btn_aim.onClick.AddListener(OnClickAni);
btn_close.onClick.AddListener(OnClickClose);
uIDownUp.onDown.AddListener(OnDownAim);
}
void OnClickClose()
{
GContext.Publish(new UnloadActToNextAct());
}
bool opening = false;
IEnumerator aniCameraMoveCoroutine;
void OnDownAim()
{
opening = true;
aniCameraMoveCoroutine = shooterFishAct.AniCameraMove();
StartCoroutine(FishHuntingAim());
//计时UP
uIDownUp.onUp.AddListener(OnUpAim);
}
IEnumerator FishHuntingAim()
{
yield return StartCoroutine(aniCameraMoveCoroutine);
if (!opening)
{
yield break;
}
title.SetActive(false);
exchange.SetActive(false);
eventFishHuntingAim.gameObject.SetActive(true);
float aimTime = eventFishHuntingAim.AimTime;
yield return new WaitForSeconds(aimTime);
ChangeTarget(null);
OnUpAim();
}
public async void OnUpAim()
{
if (!opening)
{
return;
}
uIDownUp.onUp.RemoveAllListeners();
OnClickAni();
eventFishHuntingAim.isFinish = true;
StopAllCoroutines();
opening = false;
uIDownUp.gameObject.SetActive(false);
eventFishHuntingAim.Trigger("Aim");
if (fishMovement == null)
{
await StartCoroutine(shooterFishAct.OnBack());
eventFishHuntingAim.isFinish = false;
eventFishHuntingAim.gameObject.SetActive(false);
title.SetActive(true);
exchange.SetActive(true);
await Awaiters.Seconds(shooterFishAct.AimBlockTime);
uIDownUp.gameObject.SetActive(true);
}
else
{
await Awaiters.Seconds(2);
eventFishHuntingAim.gameObject.SetActive(false);
}
}
async void OnClickAni()
{
isClick = true;
fishMovement = shooterFishAct.Target();
if (fishMovement != null)
{
fish_info.SetActive(false);
eventFishHuntingAim.Trigger("Shoot");
GContext.Publish(new ConditionTypeEvent(ConditionType.MaxCashFromRaid, fishMovement.itemCount));
int getGlodCount = fishMovement.itemCount * multiple;
bool isRob = fishMovement.isRob;
int addRankCount = AM.RobFishRequest(changeTargetCount, multiple, playFabId, fishMovement.groupId, fishMovement.index, getGlodCount, isRob, opponentItemData);
await shooterFishAct.OnShoot(isRob);
title.SetActive(false);
exchange.SetActive(false);
btn_aim.gameObject.SetActive(false);
UIManager.Instance.DestroyUI(UITypes.EventBankHeistOpponentPopupPanel);
eventFishHuntingPhoto.ShowFish(fishMovement, isRob);
await Awaiters.Seconds(shooterFishAct.ShootTime);
eventFishHuntingPhoto.ShowSettlement(fishMovement, tag_fish.sprite, text_fish_name.text, isRob);
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
hurt.SetActive(!isRob);
kill.SetActive(isRob);
if (isRob)
{
var fishItem = _tables.TbItem.GetOrDefault(fishMovement.slotData.fishItemID);
bool isMutated = fishMovement.index < fishMovement.slotData.mutants;
if (isMutated)
{
fx_ui_fishingsettlement_hunt_cash_2.SetActive(true);
}
else if (fishItem.Quality >= 4)
{
fx_ui_fishingsettlement_hunt_cash_1.SetActive(true);
}
}
await shooterFishAct.OnShooted(isRob);
SetData(getGlodCount);
eventFishHuntingPhoto.SetBackground(AM.MapId);
root_settlement.SetActive(true);
}
else
{
eventFishHuntingAim.Trigger("Back");
ToastPanel.Show(LocalizationMgr.GetText("UI_AquariumPanel_46"));
}
//exchange.SetActive(false);
}
async void OnClickHead()
{
//选择对象
await UIManager.Instance.ShowUI(UITypes.EventBankHeistOpponentPopupPanel);
}
public void ChangeTarget(FishMovement fish)
{
if (shooterFishAct == null)
{
return;
}
shooterFishAct.OnTargetChange(fish);
if (fish != curTarget)
{
fish_info.SetActive(fish != null);
curTarget = fish;
if (curTarget != null)
{
var item = _tables.TbItem.GetOrDefault(curTarget.slotData.fishItemID);
text_fish_num.text = ConvertTools.GetNumberString2(curTarget.itemCount * multiple);
text_level_num.text = curTarget.cardLv;
mutated.SetActive(curTarget.slotData.mutants > curTarget.index);
text_fish_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
GContext.container.Resolve<IUIService>().SetImageSprite(tag_fish, "icon_fish_rate_tag_" + item.Quality);
}
}
}
async void ChangeSmallGameTarget(ChangeSmallGameTargetEvent data)
{
//exchange.SetActive(false);
switchbtn.enabled = false;
if (await data.ts.Task)
{
changeTargetCount++;
opponentItemData = data.opponentItemData;
playFabId = data.opponentItemData.playFabID;
IUserService userService = GContext.container.Resolve<IUserService>();
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
SetAvatar(clubPlayInfo);
fish_info.SetActive(false);
}
//exchange.SetActive(true);
switchbtn.enabled = true;
}
public void SetAvatar(PlayInfo clubPlayInfo)
{
if (clubPlayInfo != null)
{
text_name.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_29", clubPlayInfo.name);
head.SetData(clubPlayInfo.avatarUrl);
}
}
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
{
if (getClubPlayInfoEvent.id == playFabId)
{
text_name.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_29", getClubPlayInfoEvent.name);
head.SetData(getClubPlayInfoEvent.avatarUrl);
}
}
private void OnDisable()
{
eventFishHuntingPhoto.Cleanup();
disposables?.Dispose();
disposables = null;
}
GameObject fx_ui_fishingsettlement_hunt_cash_1;
GameObject fx_ui_fishingsettlement_hunt_cash_2;
TMP_Text text_num;
TMP_Text text_num_buff;
BonusReward bonusReward;
int add = 0;
void SetData(int glod)
{
add = glod;
bonusReward.Show();
GContext.Publish(new TargetAddData(1002, 0, add));
StartCoroutine(ShowMoney());
}
IEnumerator ShowMoney()
{
text_num.text = "";
text_num_buff.text = "";
SuperHunt superHunt = GContext.container.Resolve<BuffDataCenter>().GetWeelyBuffTimeData<SuperHunt>(true);
float superCashBonus = 0;
if (superHunt != null)
{
superCashBonus = superHunt.CashBonus;
}
if (superCashBonus > 0.001f)
{
text_num.color = Color.black;
text_num_buff.color = Color.white;
}
yield return new WaitForSeconds(1.2f);
int gold = 0;
DOTween.To(() => gold, x => gold = x, add, 1f).OnUpdate(() =>
{
text_num.text = ConvertTools.GetNumberString2(gold);
text_num_buff.text = text_num.text;
});
}
}