2024-12-14 23:20:55 +08:00
|
|
|
|
using DG.Tweening;
|
2024-12-09 23:24:46 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2024-12-24 12:02:32 +08:00
|
|
|
|
using Unity.VisualScripting;
|
2024-12-09 23:24:46 +08:00
|
|
|
|
using UnityEngine;
|
2024-12-10 06:57:53 +08:00
|
|
|
|
using UnityEngine.UI;
|
2024-12-09 23:24:46 +08:00
|
|
|
|
|
2024-12-10 06:57:53 +08:00
|
|
|
|
public class SkillBox : Base
|
2024-12-09 23:24:46 +08:00
|
|
|
|
{
|
2024-12-10 06:57:53 +08:00
|
|
|
|
|
|
|
|
|
public static SkillBox instance;
|
|
|
|
|
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)")] public int expNumber;
|
|
|
|
|
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)")] public Text expNumberText;
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD>ս<EFBFBD><D5BD>(<28><><EFBFBD><EFBFBD>)")] public int maxExpNumber;
|
2024-12-14 23:20:55 +08:00
|
|
|
|
[Header("<22><><EFBFBD>ɵ<EFBFBD>ս<EFBFBD><D5BD>")] public GameObject zhanhunPrefab;
|
|
|
|
|
public Camera MainCamera;
|
|
|
|
|
public RectTransform zhanhunicon;
|
|
|
|
|
|
|
|
|
|
public float shakeDuration = 0.5f; // <20>ڶ<EFBFBD><DAB6><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
public float shakeStrength = 0.1f; // <20>ڶ<EFBFBD><DAB6>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
public float finalMoveDuration = 1f; // Ʈ<><C6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
|
|
|
|
public GameObject infobox_skill;
|
|
|
|
|
|
|
|
|
|
public GameObject Skill;
|
|
|
|
|
|
|
|
|
|
public Transform SkillParent;
|
2024-12-14 23:20:55 +08:00
|
|
|
|
|
|
|
|
|
public Image ExpFill;
|
2024-12-24 12:02:32 +08:00
|
|
|
|
|
|
|
|
|
public Dictionary<string,Role> mengyaoRole=new Dictionary<string,Role>();
|
|
|
|
|
|
2024-12-10 06:57:53 +08:00
|
|
|
|
public int ExpNumber
|
|
|
|
|
{
|
|
|
|
|
get => expNumber;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
expNumber = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD>")] public GameObject ExpFileObj;
|
|
|
|
|
private int ExpFileObjNumber=0;
|
|
|
|
|
[Header("ս<><D5BD>(<28><><EFBFBD><EFBFBD>)<29><><EFBFBD>丸<EFBFBD>ڵ<EFBFBD>")] public GameObject ExpFilePrante;
|
|
|
|
|
|
|
|
|
|
public List<GameObject> expList = new List<GameObject>();
|
|
|
|
|
private void Start()
|
2024-12-09 23:24:46 +08:00
|
|
|
|
{
|
2024-12-14 23:20:55 +08:00
|
|
|
|
ExpFill.fillAmount = 0;
|
|
|
|
|
|
2024-12-10 06:57:53 +08:00
|
|
|
|
if (instance != null) return;
|
|
|
|
|
instance = this;
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
|
|
|
|
InitSkil();
|
|
|
|
|
|
2024-12-09 23:24:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-10 06:57:53 +08:00
|
|
|
|
public void UpdataExp(int number)
|
2024-12-09 23:24:46 +08:00
|
|
|
|
{
|
2024-12-14 23:20:55 +08:00
|
|
|
|
if (number==0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-12-10 06:57:53 +08:00
|
|
|
|
|
|
|
|
|
if (number > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < number; i++)
|
|
|
|
|
{
|
|
|
|
|
if (expList.Count < maxExpNumber)
|
|
|
|
|
{
|
|
|
|
|
GameObject obj = Instantiate(ExpFileObj, ExpFilePrante.transform);
|
|
|
|
|
expList.Add(obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(number < 0)
|
|
|
|
|
{
|
|
|
|
|
number *= -1;
|
|
|
|
|
for (int i = 0; i < number; i++)
|
|
|
|
|
{
|
|
|
|
|
GameObject obj = expList[expList.Count - 1];
|
|
|
|
|
expList.RemoveAt(expList.Count - 1);
|
|
|
|
|
Destroy(obj.gameObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expNumberText.text = expList.Count+"/"+maxExpNumber;
|
2024-12-09 23:24:46 +08:00
|
|
|
|
}
|
2024-12-10 06:57:53 +08:00
|
|
|
|
|
2024-12-13 05:40:51 +08:00
|
|
|
|
void InitSkil()
|
|
|
|
|
{
|
2024-12-24 14:35:02 +08:00
|
|
|
|
foreach (string _mengyaoRoleId in mengyaoRole.Keys)
|
2024-12-13 05:40:51 +08:00
|
|
|
|
{
|
2024-12-24 14:35:02 +08:00
|
|
|
|
foreach (Monster m in MengyaoInfo.Instance.m_SkillData)
|
|
|
|
|
{
|
|
|
|
|
if (m.temp_id == _mengyaoRoleId)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < 2; j++)
|
|
|
|
|
{
|
|
|
|
|
GameObject obj = Instantiate(Skill, SkillParent);
|
|
|
|
|
obj.GetComponent<Skill_Spend>().infobox_skill_up = infobox_skill;
|
|
|
|
|
//obj.GetComponent<Skill_Spend>().infobox_skill_up = infobox_skill;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
2024-12-13 07:16:44 +08:00
|
|
|
|
}
|
2024-12-24 14:35:02 +08:00
|
|
|
|
}
|
2024-12-13 05:40:51 +08:00
|
|
|
|
}
|
2024-12-14 23:20:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void GetZhanhun(int number)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
minZhanHun(number);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void minZhanHun(int number)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣩
|
|
|
|
|
int currentExp = (int)(ExpFill.fillAmount * 10);
|
|
|
|
|
|
|
|
|
|
// <20>ۼӾ<DBBC><D3BE><EFBFBD>
|
|
|
|
|
currentExp += number;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><C2BE><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
while (currentExp >= 10)
|
|
|
|
|
{
|
|
|
|
|
currentExp -= 10;
|
|
|
|
|
UpdataExp(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>¾<EFBFBD><C2BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
float expFillAmount = (float)currentExp / 10;
|
|
|
|
|
ExpFill.fillAmount = expFillAmount; // <20><><EFBFBD>¾<EFBFBD><C2BE><EFBFBD><EFBFBD><EFBFBD>UI<55><49>ʾ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void AddExperience(int amount,Transform pos)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD>岢<EFBFBD><E5B2A2><EFBFBD>ó<EFBFBD>ʼλ<CABC><CEBB>
|
|
|
|
|
GameObject expObj = Instantiate(zhanhunPrefab,pos.position, Quaternion.identity);
|
2024-12-16 17:46:38 +08:00
|
|
|
|
//expObj.transform.localScale = Vector3.zero;
|
|
|
|
|
//CreateAni(expObj);
|
2024-12-14 23:20:55 +08:00
|
|
|
|
ShakeAndMoveToExpSlot(expObj, pos.position, amount);
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-16 17:46:38 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>
|
|
|
|
|
private void CreateAni(GameObject expObj)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
expObj.transform.DOScale(new Vector3(1, 1, 1), 0.5f).SetEase(Ease.InBack);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-14 23:20:55 +08:00
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private void ShakeAndMoveToExpSlot(GameObject expObj, Vector3 spawnPosition, int amount)
|
|
|
|
|
{
|
|
|
|
|
// ԭ<>ذڶ<D8B0>
|
|
|
|
|
expObj.transform.DOShakePosition(shakeDuration, shakeStrength, 10, 90, false, true).OnComplete(() =>
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȡUIĿ<49><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ռ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
Vector3 targetScreenPosition = ExpFill.transform.position;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>Ļ<EFBFBD>ռ<EFBFBD>λ<EFBFBD><CEBB>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
Vector3 targetWorldPosition = MainCamera.ScreenToWorldPoint(targetScreenPosition);
|
|
|
|
|
|
|
|
|
|
// <20><>z<EFBFBD><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ʺϳ<CABA><CFB3><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
targetWorldPosition.z = expObj.transform.position.z;
|
|
|
|
|
|
|
|
|
|
// ʹ<><CAB9>DOTweenʹ<6E><CAB9>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|
|
|
|
expObj.transform.DOMove(targetWorldPosition, 1f).SetEase(Ease.InOutQuad).OnComplete(() =>
|
|
|
|
|
{
|
|
|
|
|
// Ʈ<><C6AE><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD>¾<EFBFBD><C2BE><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GetZhanhun(amount);
|
|
|
|
|
AnimateExpSlotIcon();
|
|
|
|
|
Destroy(expObj); // <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
private void AnimateExpSlotIcon()
|
|
|
|
|
{
|
|
|
|
|
// ͼ<><CDBC><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>1.2<EFBFBD><EFBFBD>
|
|
|
|
|
zhanhunicon.DOScale(1.2f, 0.1f).SetEase(Ease.OutBack).OnComplete(() =>
|
|
|
|
|
{
|
|
|
|
|
// <20>ص<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>С
|
|
|
|
|
zhanhunicon.DOScale(1f, 0.1f).SetEase(Ease.InBack);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-24 12:02:32 +08:00
|
|
|
|
void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
mengyaoRole = null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-09 23:24:46 +08:00
|
|
|
|
}
|