12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
- using UnityEngine;
- public class InGameCharacterMgr : MonoBehaviour
- {
- // [SerializeField] private GameObject SwordBtn;
- // [SerializeField] private GameObject MageBtn;
- // [SerializeField] private GameObject BawBtn;
- public GameObject[] attackBtns;
- public string selectedCharacter;
- public List<CharacterDataSO> characterDataScriptable ;
- public Character4D character4D;
- float timer= 10;
- void Update()
- {
- if(timer < 5){timer+=Time.deltaTime; return;}
- timer=0;
- SetAttackBtn();
- }
- void Start()
- {
- // SetAttackBtn();
- }
- public string currentJson;
- void SetAttackBtn(){
- currentJson = character4D.ToJson();
- selectedCharacter = "attack";
- foreach(CharacterDataSO character in characterDataScriptable){
- if(character.jsonCharData == currentJson){
- selectedCharacter = character.charName;
- break;
- }
- }
- //
- foreach(GameObject button in attackBtns){
- button.SetActive(false);
- }
- //
- switch (selectedCharacter){
- case "attack":
- attackBtns[0].SetActive(true);
- break;
- case "mage":
- attackBtns[1].SetActive(true);
- break;
- case "range":
- attackBtns[2].SetActive(true);
- break;
- default:
- //set sword btn
- attackBtns[0].SetActive(true) ;
- break;
- }
- }
- }
|