备份CatanBuilding瘦身独立工程
This commit is contained in:
172
Assets/Scripts/UI/Fishing/FishingBlood.cs
Normal file
172
Assets/Scripts/UI/Fishing/FishingBlood.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingBlood : MonoBehaviour
|
||||
{
|
||||
public float barWhiteSpeed = 0.1f;
|
||||
public float barWhiteSpeedFast = 0.6f;
|
||||
public float barWhiteSpeedThreshhold = 0.125f;
|
||||
public Image barRed;
|
||||
public Image barWhite;
|
||||
private GameObject textFloatingnumber;
|
||||
Transform FloatingnumberRoot;
|
||||
List<GameObject> gameObjects = new List<GameObject>();
|
||||
List<float> DamageParam;
|
||||
List<float> ScaleList;
|
||||
Animation icon_fish_ani;
|
||||
FishingPanelIconFish icon_fish;
|
||||
FishingPanelIconFish icon_fish_boss;
|
||||
GameObject FX_info_1;
|
||||
GameObject FX_info_2;
|
||||
GameObject FX_info_3;
|
||||
GameObject FX_info_4;
|
||||
public void Init()
|
||||
{
|
||||
icon_fish_ani = transform.Find("icon_fish/icon").GetComponent<Animation>();
|
||||
icon_fish = transform.Find("icon_fish").GetComponent<FishingPanelIconFish>();
|
||||
icon_fish_boss = transform.Find("icon_fish_boss").GetComponent<FishingPanelIconFish>();
|
||||
DamageParam = GContext.container.Resolve<Tables>().TbGlobalConfig.BattleFloatingNumberDamageParam;
|
||||
ScaleList = GContext.container.Resolve<Tables>().TbGlobalConfig.BattleFloatingNumberScaleList;
|
||||
|
||||
barRed = transform.Find("bar_red").GetComponent<Image>();
|
||||
barWhite = transform.Find("bar_white").GetComponent<Image>();
|
||||
FloatingnumberRoot = transform.Find("floatingnumber");
|
||||
textFloatingnumber = transform.Find("floatingnumber/text_floatingnumber").gameObject;
|
||||
FX_info_1 = transform.Find("FX_info_1").gameObject;
|
||||
FX_info_2 = transform.Find("FX_info_2").gameObject;
|
||||
FX_info_3 = transform.Find("FX_info_3").gameObject;
|
||||
FX_info_4 = transform.Find("FX_info_4").gameObject;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
textFloatingnumber.SetActive(false);
|
||||
gameObjects.Add(textFloatingnumber);
|
||||
GameObject go;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
go = Instantiate(textFloatingnumber, FloatingnumberRoot);
|
||||
go.transform.localPosition = textFloatingnumber.transform.localPosition;
|
||||
gameObjects.Add(go);
|
||||
}
|
||||
//ShowFishBossIcon(false);
|
||||
}
|
||||
public void SetFishIconDir(bool isLeft)
|
||||
{
|
||||
icon_fish_ani.Play(isLeft ? "icon_fish_left" : "icon_fish_right");
|
||||
}
|
||||
IEnumerator ShowFloatingNumber(int value, bool isCombo, bool crit)
|
||||
{
|
||||
GameObject go = null;
|
||||
for (int i = 0; i < gameObjects.Count; i++)
|
||||
{
|
||||
if (!gameObjects[i].activeSelf)
|
||||
{
|
||||
go = gameObjects[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (go == null)
|
||||
{
|
||||
go = Instantiate(textFloatingnumber, FloatingnumberRoot);
|
||||
gameObjects.Add(go);
|
||||
}
|
||||
go.transform.localScale = Vector3.one;
|
||||
for (int i = 0; i < ScaleList.Count; i++)
|
||||
{
|
||||
if (value > DamageParam[i])
|
||||
{
|
||||
go.transform.localScale = new Vector3(ScaleList[i], ScaleList[i], 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (crit)
|
||||
{
|
||||
go.transform.localScale *= 1.2f;
|
||||
}
|
||||
go.transform.Find("text").GetComponent<TMP_Text>().text = value.ToString("-0");
|
||||
go.transform.Find("text2").GetComponent<TMP_Text>().text = value.ToString("-0");
|
||||
go.transform.Find("text3").GetComponent<TMP_Text>().text = value.ToString("-0");
|
||||
go.SetActive(true);
|
||||
if (crit)
|
||||
{
|
||||
go.GetComponent<Animator>().Play("BattleFloatingNumber3Appear", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
go.GetComponent<Animator>().Play(isCombo ? "BattleFloatingNumber2Appear" : "BattleFloatingNumberAppear", 0, 0);
|
||||
}
|
||||
yield return new WaitForSeconds(1f);
|
||||
go.SetActive(false);
|
||||
}
|
||||
public void ShowFishInfo(int text, float fishHPScale, bool isCombo, bool crit)
|
||||
{
|
||||
if (gameObject.activeInHierarchy)
|
||||
{
|
||||
StartCoroutine(ShowFloatingNumber(text, isCombo, crit));
|
||||
barRed.fillAmount = fishHPScale;
|
||||
WhiteDOFillAmount(fishHPScale);
|
||||
}
|
||||
}
|
||||
public void WhiteDOFillAmount(float fishHPScale)
|
||||
{
|
||||
if (gameObject.activeInHierarchy)
|
||||
{
|
||||
barWhite.DOKill();
|
||||
float offset = barWhite.fillAmount - fishHPScale;
|
||||
float fillSpeed = barWhiteSpeed;
|
||||
if (offset > barWhiteSpeedThreshhold)
|
||||
{
|
||||
fillSpeed = 1 / (barWhiteSpeedThreshhold / barWhiteSpeed + (offset - barWhiteSpeedThreshhold) / barWhiteSpeedFast);
|
||||
}
|
||||
barWhite.DOFillAmount(fishHPScale, fillSpeed).SetSpeedBased();
|
||||
}
|
||||
}
|
||||
public void SetFishHPScale(float fishHPScale)
|
||||
{
|
||||
barWhite.DOKill();
|
||||
barRed.fillAmount = fishHPScale;
|
||||
barWhite.fillAmount = 1;
|
||||
}
|
||||
|
||||
public bool ShowFishBossIcon(string showName)
|
||||
{
|
||||
bool isBoss = icon_fish_boss.name == showName;
|
||||
icon_fish_boss.gameObject.SetActive(isBoss);
|
||||
icon_fish.gameObject.SetActive(!isBoss);
|
||||
return isBoss;
|
||||
}
|
||||
public void FXInfoInit()
|
||||
{
|
||||
FX_info_1.gameObject.SetActive(false);
|
||||
FX_info_2.gameObject.SetActive(false);
|
||||
FX_info_3.gameObject.SetActive(false);
|
||||
FX_info_4.gameObject.SetActive(false);
|
||||
}
|
||||
public void FXInfo(int index)
|
||||
{
|
||||
FXInfoInit();
|
||||
switch (index)
|
||||
{
|
||||
case 1:
|
||||
FX_info_1.SetActive(true);
|
||||
break;
|
||||
case 2:
|
||||
FX_info_2.SetActive(true);
|
||||
break;
|
||||
case 3:
|
||||
FX_info_3.SetActive(true);
|
||||
break;
|
||||
case 4:
|
||||
FX_info_4.SetActive(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user