InGameCharacterMgr.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
  5. using UnityEngine;
  6. public class InGameCharacterMgr : MonoBehaviour
  7. {
  8. // [SerializeField] private GameObject SwordBtn;
  9. // [SerializeField] private GameObject MageBtn;
  10. // [SerializeField] private GameObject BawBtn;
  11. public GameObject[] attackBtns;
  12. public string selectedCharacter;
  13. public List<CharacterDataSO> characterDataScriptable ;
  14. public Character4D character4D;
  15. float timer= 10;
  16. void Update()
  17. {
  18. if(timer < 5){timer+=Time.deltaTime; return;}
  19. timer=0;
  20. SetAttackBtn();
  21. }
  22. void Start()
  23. {
  24. // SetAttackBtn();
  25. }
  26. public string currentJson;
  27. void SetAttackBtn(){
  28. currentJson = character4D.ToJson();
  29. selectedCharacter = "attack";
  30. foreach(CharacterDataSO character in characterDataScriptable){
  31. if(character.jsonCharData == currentJson){
  32. selectedCharacter = character.charName;
  33. break;
  34. }
  35. }
  36. //
  37. foreach(GameObject button in attackBtns){
  38. button.SetActive(false);
  39. }
  40. //
  41. switch (selectedCharacter){
  42. case "attack":
  43. attackBtns[0].SetActive(true);
  44. break;
  45. case "mage":
  46. attackBtns[1].SetActive(true);
  47. break;
  48. case "range":
  49. attackBtns[2].SetActive(true);
  50. break;
  51. default:
  52. //set sword btn
  53. attackBtns[0].SetActive(true) ;
  54. break;
  55. }
  56. }
  57. }