备份CatanBuilding瘦身独立工程
This commit is contained in:
99
Assets/Scripts/Duel/UI/DuelUIView.cs
Normal file
99
Assets/Scripts/Duel/UI/DuelUIView.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
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;
|
||||
[HideInInspector]
|
||||
public ReactiveProperty<int> curPTS = new ReactiveProperty<int>();
|
||||
public List<DuelFishState> duelFishStates = new List<DuelFishState>();
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
duelFishStates[0].current.SetActive(true);
|
||||
}
|
||||
public void SetDuelFishingEvent(int roleID, int fishCount)
|
||||
{
|
||||
GContext.OnEvent<DuelFishingEvent>().Where(x => x.RoleID == roleID).Subscribe(e =>
|
||||
{
|
||||
if (e.ItemID > 0)
|
||||
{
|
||||
Fishing(e.ItemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
EndFishing(e.index, e.data, 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, 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, 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(int itemID)
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user