80 lines
2.1 KiB
C#
80 lines
2.1 KiB
C#
using CSNetwork.GPDataType;
|
|
using CSNetwork.Protocols.RPCData;
|
|
using System.Data;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
namespace PerfectWorld.Scripts.Managers
|
|
{
|
|
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 = FindAnyObjectByType<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 GameObject InitCharacter(cmd_self_info_1 info)
|
|
{
|
|
if(characterPrefab == null)
|
|
{
|
|
Debug.LogError("null prefab");
|
|
return null;
|
|
}
|
|
CharacterCtrl character = Instantiate(characterPrefab, transform);
|
|
character.InitCharacter(info);
|
|
//Vector3 pos = new Vector3(info.pos.x, info.pos.y, info.pos.z);
|
|
//Vector3 posCam = pos;
|
|
//posCam.z -= 10f;
|
|
//camera.transform.position = posCam;
|
|
//Vector3 posGround = pos;
|
|
//posGround.y -= 2f;
|
|
//ground.transform.position = posGround;
|
|
return character.gameObject;
|
|
}
|
|
|
|
public GameObject InitCharacter(info_player_1 info)
|
|
{
|
|
if (characterPrefab == null)
|
|
{
|
|
Debug.LogError("null prefab");
|
|
return null;
|
|
}
|
|
CharacterCtrl character = Instantiate(characterPrefab, transform);
|
|
character.InitCharacter(info);
|
|
return character.gameObject;
|
|
}
|
|
}
|
|
}
|