using asap.core; using DG.Tweening; using System; using System.Collections.Generic; using TMPro; using UniRx; using UnityEngine; public class DuelUIView : DuelChatView, IDuelUIView { public TMP_Text text_point; public Animation anim; public Head icon_head; public TMP_Text text_name; public TMP_Text text_add; public DuelFishProgress fishProgress; [NonSerialized] public ReactiveProperty curPTS = new ReactiveProperty(); public List duelFishStates = new List(); protected override void Awake() { base.Awake(); duelFishStates[0].current.SetActive(true); } public void SetDuelFishingEvent(int roleID, int fishCount) { GContext.OnEvent().Where(x => x.RoleID == roleID).Subscribe(e => { if (e.fishing) { Fishing(); } else { EndFishing(e.index, e.data, e.ItemID, e.isEnd); } }).AddTo(this); for (int i = fishCount; i < duelFishStates.Count; i++) { duelFishStates[i].gameObject.SetActive(false); } SetDuelFishingEvent(roleID); } public void EndFishing(int index, FishInfoData data, int fishItemId, bool isEnd) { if (index > duelFishStates.Count) { return; } if (index > 0) { duelFishStates[index - 1].current.SetActive(false); if (data.point > 0) { PTSAdd(data.point); duelFishStates[index - 1].done.SetActive(true); duelFishStates[index - 1].failed.SetActive(false); fishProgress.ShowFishInfo(data, fishItemId, isEnd); } else { duelFishStates[index - 1].done.SetActive(false); duelFishStates[index - 1].failed.SetActive(true); fishProgress.Failed(); } if (index < duelFishStates.Count) { duelFishStates[index].current.SetActive(true); } } else { fishProgress.NoCatched(); } } public void Fishing() { fishProgress.Catching(); } async void PTSAdd(int add) { text_add.text = $"+{add}"; text_add.gameObject.SetActive(true); anim.Play(); await Awaiters.Seconds(1); //eventFishingDuelTopArea.text_add.gameObject.SetActive(false); int pts = curPTS.Value; curPTS.Value += add; int newPts = pts + add; DOTween.To(() => pts, x => pts = x, newPts, 1).OnUpdate(() => { text_point.text = ConvertTools.GetNumberString2(pts); }); } }