58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using CSNetwork.Protocols.RPCData;
|
|
using System.Data;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
public class GameController : MonoBehaviour
|
|
{
|
|
private static GameController instance;
|
|
|
|
[SerializeField] private CharacterCtrl characterPrefab;
|
|
[SerializeField] private Transform ground;
|
|
|
|
Camera camera;
|
|
|
|
public static GameController Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = new GameController();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if(instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
camera = Camera.main;
|
|
}
|
|
|
|
public void Log(string s)
|
|
{
|
|
Debug.LogError(s);
|
|
}
|
|
|
|
public void InitCharacter(RoleInfo roleInfo)
|
|
{
|
|
CharacterCtrl character = Instantiate(characterPrefab, transform);
|
|
character.InitCharacter(roleInfo);
|
|
Vector3 pos = new Vector3(roleInfo.posx, roleInfo.posy, roleInfo.posz);
|
|
Vector3 posCam = pos;
|
|
posCam.z -= 10f;
|
|
camera.transform.position = posCam;
|
|
Vector3 posGround = pos;
|
|
posGround.y -= 2f;
|
|
ground.transform.position = posGround;
|
|
}
|
|
}
|