备份CatanBuilding瘦身独立工程

This commit is contained in:
JSD\13999
2026-05-26 16:15:54 +08:00
commit 2d0e6a61b7
12001 changed files with 2431925 additions and 0 deletions

View File

@@ -0,0 +1,278 @@
using asap.core;
using Game;
using GameCore;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
using DG.Tweening;
using System.Collections;
using cfg;
public class EventFishingDuelArea : MonoBehaviour
{
private UIButton btn_play;
Button btn_yugan;
public Animation ani;
event_fishingduel_rod_change rodPanel;
Animator btn_play_anim;
[HideInInspector]
public GameObject DownPanel;
Animation text_time_ani;
TMP_Text text_time;
TMP_Text text_time_red;
public TMP_Text text_countdown;
GameObject TopArea;
Image bar;
string doTweenKey = "EventFishingDuelArea";
DuelUIView selfView;
DuelUIView enemyView;
FishingDuelManager FDM;
Button btn_chat;
GameObject chat;
GameObject redpoint;
Animator toast_start;
TMP_Text text_title;
public Animation toast_others;
public TMP_Text[] toasts;
protected CompositeDisposable disposables = new CompositeDisposable();
private void Awake()
{
FDM = GContext.container.Resolve<FishingDuelManager>();
TopArea = transform.Find("root/TopArea").gameObject;
bar = transform.Find("root/TopArea/bg_bar/bar_myself").GetComponent<Image>();
selfView = transform.Find("root/TopArea/SelfView").GetComponent<DuelUIView>();
enemyView = transform.Find("root/TopArea/EnemyView").GetComponent<DuelUIView>();
btn_play = transform.Find("root/DownPanel/btn_play").GetComponent<UIButton>();
btn_play_anim = btn_play.GetComponent<Animator>();
text_time_ani = transform.Find("root/TopArea/bg_bar/text_time").GetComponent<Animation>();
text_time = transform.Find("root/TopArea/bg_bar/text_time/text_time").GetComponent<TMP_Text>();
text_time_red = transform.Find("root/TopArea/bg_bar/text_time/text_time_red").GetComponent<TMP_Text>();
DownPanel = transform.Find("root/DownPanel").gameObject;
btn_chat = transform.Find("root/DownPanel/btn_layout/btn_chat").GetComponent<Button>();
chat = transform.Find("root/event_fishingduel_chat").gameObject;
rodPanel = transform.Find("root/event_fishingduel_rod_change").GetComponent<event_fishingduel_rod_change>();
redpoint = transform.Find("root/DownPanel/btn_yugan/redpoint").gameObject;
btn_yugan = transform.Find("root/DownPanel/btn_yugan").GetComponent<Button>();
toast_start = transform.Find("root/toast_start").GetComponent<Animator>();
text_title = transform.Find("root/toast_start/text/text_waiting").GetComponent<TMP_Text>();
GContext.OnEvent<RequestSvrTimeEvent>().Subscribe(RequestSvrTimeEvent).AddTo(disposables);
redpoint.SetActive(false);
rodPanel.gameObject.SetActive(true);
SetTopArea(false);
}
protected void Start()
{
btn_play.onDown.AddListener(StartAutoTimer);
btn_play.onUp.AddListener(StopCoroutineTimer);
btn_play.onClick.AddListener(OnClickPlay);
//btn_yugan.onClick.AddListener(OnClickRod);
btn_chat.onClick.AddListener(() =>
{
chat.SetActive(!chat.activeSelf);
});
InitView();
SetTopArea(false);
//redpoint.SetActive(FDM.InitRodRed());
//OnClickRod();
MapData mapData = GContext.container.Resolve<Tables>().TbMapData.DataMap[FDM.MapId];
rodPanel.text_title.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
rodPanel.allTime = FDM.eventSoloConfig.ChooseRodTime;
rodPanel.SetTimer();
}
void InitView()
{
selfView.icon_head.SetData(FDM.SelfModel.PlayerAvatar);
selfView.text_name.text = FDM.SelfModel.PlayerName;
selfView.text_point.text = "0";
selfView.text_add.gameObject.SetActive(false);
selfView.curPTS.Subscribe(curPTS =>
{
SetBar();
}).AddTo(disposables);
selfView.SetDuelFishingEvent(0, FDM.FishItemIDs.Count);
bar.fillAmount = 0.5f;
enemyView.icon_head.SetData(FDM.EnemyModel.PlayerAvatar);
enemyView.text_name.text = FDM.EnemyModel.PlayerName;
enemyView.text_point.text = "0";
enemyView.text_add.gameObject.SetActive(false);
enemyView.curPTS.Subscribe(curPTS =>
{
SetBar();
}).AddTo(disposables);
enemyView.SetDuelFishingEvent(1, FDM.FishItemIDs.Count);
FDM.SelfModel.RoleID = 0;
FDM.EnemyModel.RoleID = 1;
FDM.SelfChatModel.RoleID = 0;
FDM.EnemyChatModel.RoleID = 1;
}
public void SetBar()
{
float fillAmount = FDM.FillAmount;
if (fillAmount > 0)
{
DOTween.Kill(doTweenKey);
fillAmount = 0.05f + fillAmount * 0.9f;
bar.DOFillAmount(fillAmount, 1).SetId(doTweenKey);
}
}
bool Status = true;
void RequestSvrTimeEvent(RequestSvrTimeEvent requestSvrTimeEvent)
{
Status = requestSvrTimeEvent.Status;
TopArea.SetActive(Status);
}
/// <summary>
/// 显示Toast
/// </summary>
/// <param name="index">0== 对手先进 最后一轮, 1==对手完成2==我完成</param>
/// <param name="value"></param>
public void ShowToastOthers(int index, string value)
{
Debug.Log($"ShowToastOthers {index} {value}");
if (index < 0 || index >= toasts.Length) return;
var toast = toasts[index];
toast_others.gameObject.SetActive(true);
toast_others.Play($"toast_others_show_{index + 1}");
toast.text = value;
if (index == 1)
{
text_time_ani.Play("text_time_top_disappear_lose");
StartCoroutine(PlayAppear());
}
else if (index == 2)
{
text_time_ani.Play("text_time_top_disappear_win");
}
}
public async void ShowToastOthers(string value)
{
var toast = toasts[1];
toast_others.gameObject.SetActive(true);
toast_others.Play("toast_others_close");
await Awaiters.Seconds(0.5f);
toast_others.Play("toast_others_show_2");
toast.text = value;
}
public void PlayLoop()
{
text_time_ani.Play("text_time_red_loop");
}
IEnumerator PlayAppear()
{
yield return new WaitForSeconds(3f);
text_time_ani.Play("text_time_toast_appear");
yield return new WaitForSeconds(1f);
PlayLoop();
}
//void OnClickRod()
//{
// redpoint.SetActive(false);
// rodPanel.gameObject.SetActive(true);
// SetTopArea(false);
//}
void StartAutoTimer()
{
btn_play_anim.Play("Pressed", -1, 0);
}
void StopCoroutineTimer()
{
btn_play_anim.Play("Normal", -1, 0);
}
async void OnClickPlay()
{
GContext.Publish(new EventFishingSound(SoundType.audio_ui_btn_cast));
GContext.Publish(new VibrationData(HapticTypes.Selection));
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
var go = await UIManager.Instance.ShowUI(UITypes.FishingPanel);
if (go != null)
{
transform.SetAsLastSibling();
DownPanel.SetActive(false);
}
}
public void SetTopArea(bool value)
{
DownPanel.SetActive(value);
TopArea.SetActive(value && Status);
}
public void SetHideBtnPlay()
{
btn_play.gameObject.SetActive(false);
}
public void SetTime(TimeSpan timeSpan, bool selfIsLastFish)
{
if (/*selfIsLastFish || */timeSpan.TotalSeconds > FDM.eventSoloConfig.EndTime)
{
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_second", timeSpan.TotalSeconds.ToString("F0"));
text_time_red.text = "";
}
else
{
text_countdown.text = text_time_red.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_second", timeSpan.TotalSeconds.ToString("F0"));
text_time.text = "";
}
//UI_COMMON_second
}
public void SetState(int value, int role)
{
toast_start.gameObject.SetActive(true);
if (value == 1)
{
SetTimer();
}
else if (value == 2)
{
if (role == 1)
{
toast_start.SetBool("end", true);
}
else
{
toast_start.Play("duel_toast_late", -1, 0);
}
}
}
void SetTimer()
{
StartCoroutine(WaitTime());
}
IEnumerator WaitTime()
{
int allTime = rodPanel.allTime;
while (allTime > 0)
{
text_title.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_62", allTime);
yield return new WaitForSeconds(1);
if (FDM.RodState >= 2)
{
yield break;
}
allTime--;
}
text_title.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_62", 0);
if (FDM.RodState < 2)
{
//理论上这个时候双方都选好,防止意外强制开始
FDM.RodState++;
GContext.Publish(new RodStateEvent() { RoleID = 1 });
}
}
private void OnDestroy()
{
disposables?.Dispose();
disposables = null;
}
}