2024-12-10 06:57:53 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2024-12-19 11:48:31 +08:00
|
|
|
|
using DG.Tweening;
|
2024-12-10 06:57:53 +08:00
|
|
|
|
|
|
|
|
|
public class CharacterClick : MonoBehaviour
|
|
|
|
|
{
|
2024-12-10 07:32:01 +08:00
|
|
|
|
public Role role;
|
2024-12-13 08:48:10 +08:00
|
|
|
|
public Character MyCharacter=null;
|
2024-12-10 07:32:01 +08:00
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>")] public GameObject panelPrefab;
|
2024-12-19 11:48:31 +08:00
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵĹ<D6B5><C4B9><EFBFBD><EFBFBD><EFBFBD>Χ")] public GameObject attackRange;
|
2024-12-19 19:02:10 +08:00
|
|
|
|
[Header("<22>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>")] public bool isShowPanel = false;
|
|
|
|
|
[Header("<22><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>")] public GameObject instantiatedPanel;
|
2024-12-19 11:48:31 +08:00
|
|
|
|
private Vector3 OrigScale;
|
|
|
|
|
private bool isShowAttackRange=true;
|
2024-12-13 22:29:17 +08:00
|
|
|
|
public WaveData MyWaveData=null;
|
2024-12-13 08:48:10 +08:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
2024-12-20 17:40:13 +08:00
|
|
|
|
if (attackRange!=null)
|
|
|
|
|
{
|
|
|
|
|
OrigScale = attackRange.transform.localScale;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-20 16:29:02 +08:00
|
|
|
|
if (transform.GetComponent<enemy>()!=null)
|
|
|
|
|
{
|
|
|
|
|
IdForInfo(transform.GetComponent<enemy>().enemyId);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 11:48:31 +08:00
|
|
|
|
|
2024-12-13 08:48:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-10 06:57:53 +08:00
|
|
|
|
private void OnMouseDown()
|
|
|
|
|
{
|
2024-12-10 09:14:54 +08:00
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD> Trigger <20><><EFBFBD><EFBFBD>
|
|
|
|
|
Collider2D parentCollider = GetComponent<Collider2D>();
|
|
|
|
|
if (parentCollider != null && parentCollider.isTrigger)
|
|
|
|
|
{
|
2024-12-12 17:05:28 +08:00
|
|
|
|
// parentCollider.enabled = true;
|
2024-12-10 09:14:54 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
|
|
|
|
|
Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
|
|
|
RaycastHit2D hit = Physics2D.Raycast(mousePosition, Vector2.zero);
|
|
|
|
|
|
|
|
|
|
if (hit.collider != null && hit.collider.gameObject == gameObject)
|
|
|
|
|
{
|
2024-12-19 19:02:10 +08:00
|
|
|
|
//ShowAttackRange();
|
2024-12-10 09:14:54 +08:00
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8>ڵ<EFBFBD>");
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ﴦ<EFBFBD><EFB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
2024-12-19 19:02:10 +08:00
|
|
|
|
|
|
|
|
|
ShowInfoPanel();
|
2024-12-13 22:29:17 +08:00
|
|
|
|
|
|
|
|
|
|
2024-12-13 08:48:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-19 19:02:10 +08:00
|
|
|
|
public void ShowInfoPanel()
|
|
|
|
|
{
|
|
|
|
|
if (instantiatedPanel == null)
|
|
|
|
|
{
|
2024-12-20 10:42:20 +08:00
|
|
|
|
|
|
|
|
|
if (UIContorl.instance.NowShowInfo!=null)
|
|
|
|
|
{
|
|
|
|
|
Destroy(UIContorl.instance.NowShowInfo._closePanel);
|
|
|
|
|
HideAttackRange(UIContorl.instance.NowAttackRange);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 19:02:10 +08:00
|
|
|
|
instantiatedPanel = GameObject.Instantiate(panelPrefab, GameObject.Find("Canvas").transform);
|
2024-12-20 10:42:20 +08:00
|
|
|
|
UIContorl.instance.NowShowInfo = instantiatedPanel.GetComponent<charainfoPanel>();
|
|
|
|
|
UIContorl.instance.NowAttackRange = attackRange;
|
|
|
|
|
ShowAttackRange(UIContorl.instance.NowAttackRange);
|
|
|
|
|
instantiatedPanel.GetComponent<charainfoPanel>().closeBtn.onClick.AddListener(() => {
|
|
|
|
|
|
|
|
|
|
Destroy(instantiatedPanel.GetComponent<charainfoPanel>()._closePanel);
|
|
|
|
|
HideAttackRange(UIContorl.instance.NowAttackRange);
|
|
|
|
|
});
|
2024-12-19 19:02:10 +08:00
|
|
|
|
RectTransform panelRect = instantiatedPanel.GetComponent<RectTransform>();
|
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD>岻<EFBFBD>ᵲס<E1B5B2><D7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
panelRect.SetAsLastSibling(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD> Canvas <20>㼶<EFBFBD><E3BCB6><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD>
|
|
|
|
|
if (role.camp == Camp.Enemy)
|
|
|
|
|
{
|
|
|
|
|
//string eveText,string name,string def,string speed,string shanghai,string info,int hp,int maxHp
|
|
|
|
|
panelRect.GetComponent<charainfoPanel>().UpDateShow("1", "Enemy_002", "0", "3", "1", "<22><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>һ", role.hp, 100f);
|
2024-12-13 08:48:10 +08:00
|
|
|
|
|
2024-12-19 19:02:10 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
panelRect.GetComponent<charainfoPanel>().UpDateShow("1", MyCharacter.Name, MyCharacter.Info, MyCharacter.MaxAttack + "~" + MyCharacter.MinAttack, MyCharacter.AttackRange, MyCharacter.AttackCD);
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-20 10:42:20 +08:00
|
|
|
|
|
2024-12-19 19:02:10 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-12-20 10:42:20 +08:00
|
|
|
|
//HideAttackRange();
|
2024-12-19 19:02:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-20 10:42:20 +08:00
|
|
|
|
public void ShowAttackRange(GameObject attackRange)
|
2024-12-19 11:48:31 +08:00
|
|
|
|
{
|
2024-12-19 19:02:10 +08:00
|
|
|
|
if (attackRange!=null)
|
2024-12-19 11:48:31 +08:00
|
|
|
|
{
|
|
|
|
|
attackRange.transform.DOScale(OrigScale, 0.3f).SetEase(Ease.InOutBack);
|
2024-12-19 19:02:10 +08:00
|
|
|
|
|
2024-12-19 11:48:31 +08:00
|
|
|
|
}
|
2024-12-19 19:02:10 +08:00
|
|
|
|
|
2024-12-19 11:48:31 +08:00
|
|
|
|
|
|
|
|
|
}
|
2024-12-19 19:02:10 +08:00
|
|
|
|
|
|
|
|
|
|
2024-12-20 10:42:20 +08:00
|
|
|
|
public void HideAttackRange(GameObject attackRange)
|
2024-12-19 11:48:31 +08:00
|
|
|
|
{
|
|
|
|
|
if (attackRange != null )
|
|
|
|
|
{
|
|
|
|
|
attackRange.transform.DOScale(Vector3.zero, 0.3f).SetEase(Ease.InOutBack);
|
2024-12-19 19:02:10 +08:00
|
|
|
|
|
2024-12-19 11:48:31 +08:00
|
|
|
|
}
|
2024-12-13 08:48:10 +08:00
|
|
|
|
|
2024-12-19 11:48:31 +08:00
|
|
|
|
}
|
2024-12-13 08:48:10 +08:00
|
|
|
|
void IdForInfo(string id)
|
|
|
|
|
{
|
|
|
|
|
List<Character> mY = MengyaoInfo.Instance.m_Mengyao;
|
|
|
|
|
foreach (Character temp in mY)
|
|
|
|
|
{
|
|
|
|
|
if (temp.Id==id)
|
|
|
|
|
{
|
|
|
|
|
MyCharacter=temp;
|
|
|
|
|
break;
|
2024-12-10 09:14:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-10 06:57:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|