2024-12-13 05:40:51 +08:00
|
|
|
|
using DG.Tweening;
|
2024-12-09 18:01:59 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
2024-12-13 05:40:51 +08:00
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class MengyaoCardData
|
|
|
|
|
{
|
|
|
|
|
[Tooltip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID")]
|
|
|
|
|
public string cardID;
|
|
|
|
|
|
|
|
|
|
[Tooltip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>")]
|
|
|
|
|
public GameObject cardPrefab;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-09 18:01:59 +08:00
|
|
|
|
public class cardBox : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static cardBox instance;
|
2024-12-13 05:40:51 +08:00
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public int mengyaoNumber = 0;
|
|
|
|
|
[HideInInspector] public int inPlaceNumber = 0;
|
2024-12-09 18:01:59 +08:00
|
|
|
|
[Header("<22><>ʼ<EFBFBD><CABC>ťobj")] public GameObject btnObj;
|
2024-12-11 21:34:19 +08:00
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ<EFBFBD><CABE>ťobj")] public GameObject IconTipObj;
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>")] public List<MengyaoCardData> mengyaoCardDataList = new List<MengyaoCardData>();
|
|
|
|
|
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɸ<EFBFBD><C9B8>ڵ<EFBFBD>")] public Transform parentPos;
|
|
|
|
|
|
|
|
|
|
public float scaleUpDuration = 0.5f; // <20><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
public float fadeInDuration = 0.5f; // <20><><EFBFBD>붯<EFBFBD><EBB6AF>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
|
|
|
|
// ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD>ֵ<EFBFBD>
|
|
|
|
|
private Dictionary<string, GameObject> IDTomangyaoPrefab = new Dictionary<string, GameObject>();
|
|
|
|
|
|
2024-12-24 15:38:28 +08:00
|
|
|
|
|
|
|
|
|
//public Dictionary<string,>
|
|
|
|
|
|
|
|
|
|
|
2024-12-13 22:29:17 +08:00
|
|
|
|
[HideInInspector] public List<GameObject> card = new List<GameObject>();
|
2024-12-09 18:01:59 +08:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
instance = this;
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
if (btnObj == null)
|
2024-12-09 18:01:59 +08:00
|
|
|
|
{
|
|
|
|
|
Debug.LogError("btnObj==null");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
2024-12-09 18:01:59 +08:00
|
|
|
|
btnObj.SetActive(false);
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
|
|
|
|
InitializeDictionary();
|
|
|
|
|
Init();
|
2024-12-09 18:01:59 +08:00
|
|
|
|
}
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
|
|
|
|
public void ChangeInPlaceNumber(int number)
|
2024-12-09 18:01:59 +08:00
|
|
|
|
{
|
|
|
|
|
inPlaceNumber += number;
|
2024-12-13 05:40:51 +08:00
|
|
|
|
if (inPlaceNumber == mengyaoNumber)
|
2024-12-09 18:01:59 +08:00
|
|
|
|
{
|
|
|
|
|
gameGlobal.GameStart();
|
2024-12-12 23:04:13 +08:00
|
|
|
|
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
2024-12-09 18:01:59 +08:00
|
|
|
|
btnObj.SetActive(true);
|
2024-12-13 05:40:51 +08:00
|
|
|
|
btnObj.GetComponent<Button>().onClick.AddListener(() =>
|
|
|
|
|
{
|
2024-12-11 21:34:19 +08:00
|
|
|
|
IconTipObj.gameObject.SetActive(true);
|
2024-12-09 23:24:46 +08:00
|
|
|
|
btnObj.SetActive(false);
|
|
|
|
|
|
2024-12-09 18:01:59 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-13 05:40:51 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ʼ<EFBFBD><CABC>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD>ֵ<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
void InitializeDictionary()
|
|
|
|
|
{
|
|
|
|
|
foreach (var cardData in mengyaoCardDataList)
|
|
|
|
|
{
|
|
|
|
|
string id = cardData.cardID;
|
|
|
|
|
GameObject prefab = cardData.cardPrefab;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ID<49><44>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>
|
|
|
|
|
if (string.IsNullOrEmpty(id))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IDΪ<44>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prefab == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID '{id}' <20><>Ӧ<EFBFBD><D3A6>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ID<49>Ƿ<EFBFBD><C7B7>ظ<EFBFBD>
|
|
|
|
|
if (IDTomangyaoPrefab.ContainsKey(id))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID '{id}' <20><><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ڣ<EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD>彫<EFBFBD><E5BDAB><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ӵ<EFBFBD><D3B5>ֵ<EFBFBD>
|
|
|
|
|
IDTomangyaoPrefab.Add(id, prefab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
foreach (var kvp in IDTomangyaoPrefab)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log($"<22><>ʼ<EFBFBD><CABC><EFBFBD>ֵ<EFBFBD> - ID: {kvp.Key}, Prefab: {kvp.Value.name}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>CarryCardId<49>б<EFBFBD><D0B1><EFBFBD><EFBFBD>ɶ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
void Init()
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȡ CarryCardId <20>б<EFBFBD>
|
|
|
|
|
List<string> carryCardIdList = Base.GlobalObj.GetComponent<gameGlobal>().CarryCardId;
|
2024-12-14 00:14:40 +08:00
|
|
|
|
|
2024-12-13 05:40:51 +08:00
|
|
|
|
foreach (string id in carryCardIdList)
|
|
|
|
|
{
|
|
|
|
|
if (IDTomangyaoPrefab.TryGetValue(id, out GameObject prefab))
|
|
|
|
|
{
|
|
|
|
|
// ʵ<><CAB5><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD>壬<EFBFBD><E5A3AC><EFBFBD>ø<EFBFBD><C3B8>ڵ<EFBFBD>Ϊ parentPos
|
|
|
|
|
GameObject card = Instantiate(prefab, parentPos);
|
2024-12-13 22:29:17 +08:00
|
|
|
|
//card.GetComponent<enemy>().enemyId = id;
|
|
|
|
|
//this.card.Add(card);
|
2024-12-13 05:40:51 +08:00
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>зŴ<C5B4>
|
|
|
|
|
card.transform.localScale = Vector3.zero;
|
|
|
|
|
|
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>λ<EFBFBD><CEBB>Ϊ<EFBFBD><CEAA><EFBFBD>ڵ<EFBFBD><DAB5>ı<EFBFBD><C4B1><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
card.transform.localPosition = Vector3.zero;
|
|
|
|
|
// <20><><EFBFBD>ŷŴ<C5B4>
|
|
|
|
|
card.transform.DOScale(Vector3.one, scaleUpDuration).SetEase(Ease.OutBack);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"δ<>ҵ<EFBFBD>IDΪ '{id}' <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD>壡");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-09 18:01:59 +08:00
|
|
|
|
}
|