71 lines
1.7 KiB
C#
71 lines
1.7 KiB
C#
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;
|
|
|
|
}
|
|
}
|
|
|
|
}
|