using System; using System.Collections; using System.Collections.Generic; using DarkTonic.MasterAudio; using DG.Tweening; using TMPro; using UnityEngine; using UnityEngine.UIElements; using Valheim; public class StartCard : MonoBehaviour { public int cardId; public GameObject outLight; public GameObject descUI; public TMP_Text nameTxt,attributeTxt,habitTxt; public GameObject[] stars; private bool _isRotate; public SpriteRenderer handSprite; [SoundGroup] public string selectedSound; public void Init() { outLight.SetActive(false); descUI.SetActive(false); _isRotate = true; SetData(); } public void SetData() { var data=GameManager.Ins.EnemyDataList[cardId]; string skillStr = ""; foreach (var skillId in data.SkillIds) { skillStr += GameManager.Ins.SkillDataList[skillId].SkillName + " "; } nameTxt.text = data.Name; //attributeTxt.text = data.Attribute; habitTxt.text = skillStr; for (int i = 0; i < stars.Length; i++) { stars[i].SetActive(i<=data.EnemyType); } handSprite.sprite = Resources.Load("Texture/PetIcon/" + cardId); } private void Update() { if (_isRotate) { transform.Rotate(0, 50 * Time.deltaTime, 0); } } public void Up() { if(cardId== GameManager.Ins.selectCardId) return; MasterAudio.PlaySound3DFollowTransform(selectedSound, transform); _isRotate = false; transform.localScale*=1.2f; outLight.SetActive(true); descUI.SetActive(true); GameManager.Ins.selectCardId = cardId; } public void Down() { _isRotate = true; outLight.SetActive(false); transform.localScale=new Vector3(10f,10f,1f); descUI.SetActive(false); GameManager.Ins.selectCardId = -1; } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Weapon")) { //Up(); GetCard(); } } public void GetCard() { GameManager.Ins.selectCardId = cardId; GameManager.Ins.SelectCard(); } private void OnTriggerExit(Collider other) { if (other.CompareTag("Weapon")) { //Down(); } } public void Show() { gameObject.SetActive(true); Up(); } }