void CreateChracter(int job, int userNumber, Packet msg) { for (int i = 0; i < userNumber; i++) { int user_position = msg.PopInt32(); string msgUserLoginID = msg.PopString(); GameObject objSpawner = GameObject.Find("Player_Spawn"); Player_Spawn componentSpawner = objSpawner.GetComponent <Player_Spawn>(); //캐릭터 생성 GameObject myPlayer = componentSpawner.CreateMyPlayer(job, user_position); //myPlayer.GetComponent<Player5>().headCamera.SetActive(false); //디폴트를 비활성화 시킴 NetworkObj objNetInfo = myPlayer.GetComponent <NetworkObj>(); objNetInfo.remoteId = msgUserLoginID; lock (csNetworkObj) { networkObj.Add(objNetInfo.remoteId, myPlayer); print("추가됨"); } if (userID == objNetInfo.remoteId) { myPlayer.GetComponent <Player5>().isPlayer = true; myPlayer.GetComponent <Player5>().main_camera.gameObject.SetActive(true); GameObject winlose = GameObject.Find("WinLose"); winlose winlose_component = winlose.GetComponent <winlose>(); winlose_component.user_job = myPlayer.GetComponent <Player5>().player_job; myPlayer.GetComponent <Player5>().user_name.text = userID; if (job == 1) { myPlayer.GetComponent <Player5>().user_job.text = "경찰"; } else if (job == 2) { myPlayer.GetComponent <Player5>().user_job.text = "도둑"; } } } }
// client void OnConnectedToServer() { Debug.Log("Connected to server"); obj = gameObject.AddComponent("NetworkObj") as NetworkObj; }
public override void InitObject(NetworkObj obj, Offsets offsets) { }
void OnServerInitialized() { Debug.Log("Server initialized and ready"); obj = gameObject.AddComponent("NetworkObj") as NetworkObj; }