public static GameObject Load(BinaryReader reader, Transform parent) { int num = reader.ReadInt32(); string prefabPath = reader.ReadString(); GameObject gameObject = null; if (num >= 0) { gameObject = PlayersManager.FindMainChar(num, true); } if (gameObject == null) { Debug.LogError("PlayersManager.FindMainChar not found, tempID = " + num); } SavePrefabTarget savePrefabTarget = gameObject.GetComponent <SavePrefabTarget>(); if (savePrefabTarget == null) { savePrefabTarget = gameObject.AddComponent <SavePrefabTarget>(); } savePrefabTarget.PrefabPath = prefabPath; gameObject.transform.parent = parent; savePrefabTarget.Load(reader); return(gameObject); }
public static GameObject AddPlayer(int ID, bool bSetLevel = true) { GameObject player = PlayersManager.GetPlayer(ID); if (player != null) { Debug.Log("PlayersManager.AddPlayer 已经存在" + ID.ToString()); return(player); } GameObject gameObject = PlayersManager.FindMainChar(ID, true); if (gameObject != null && gameObject.GetComponent <PalNPC>() != null) { PlayersManager.AddPlayer(gameObject, bSetLevel); if (PlayersManager.ActivePlayers.Count == 1) { PlayersManager.SetPlayer(ID, false); } if (ID != 6 && PlayersManager.OnAddPlayer != null) { PlayersManager.OnAddPlayer(ID); } return(gameObject); } GameObject gameObject2 = PlayersManager.LoadPlayer(ID); if (gameObject2 != null) { if (PlayersManager.AllPlayers.Count > ID + 1 && PlayersManager.AllPlayers[ID] == null) { PlayersManager.AllPlayers[ID] = gameObject2; } PlayersManager.AddPlayer(gameObject2, bSetLevel); if (ID == 4) { PlayersManager.AddPlayer(6, true); } } if (ID != 6 && PlayersManager.OnAddPlayer != null) { PlayersManager.OnAddPlayer(ID); } return(gameObject2); }
public static void Initialize() { PlayersManager.AllPlayers.Clear(); PlayersManager.AllPlayersPerceptionRange.Clear(); GameObject gameObject2 = PlayersManager.FindMainChar(0, true); if (gameObject2 != null) { PalNPC component2 = gameObject2.GetComponent <PalNPC>(); if (component2 == null) { Debug.Log("PlayersManager.Initialize: NPC 0 is null"); } else { PalNPC expr_BF = component2; expr_BF.OnLoadModelEnd = (PalNPC.void_fun_TF)Delegate.Combine(expr_BF.OnLoadModelEnd, new PalNPC.void_fun_TF(PlayersManager.OnLoadModelEnd)); } } GameObject gameObject3 = PlayersManager.FindMainChar(5, true); if (gameObject3 != null) { PalNPC component3 = gameObject3.GetComponent <PalNPC>(); if (component3 == null) { Debug.Log("PlayersManager.Initialize: NPC 5 is null"); } else { PalNPC expr_11D = component3; expr_11D.OnLoadModelEnd = (PalNPC.void_fun_TF)Delegate.Combine(expr_11D.OnLoadModelEnd, new PalNPC.void_fun_TF(PlayersManager.OnLoadModelEnd)); } } GameObject gameObject4 = PlayersManager.FindMainChar(3, true); if (gameObject4 != null) { //ModelChangeScript component4 = gameObject4.GetComponent<ModelChangeScript>(); //if (component4 != null) //{ // ModelChangeScript expr_16C = component4; // expr_16C.OnSetModeEnd = (Action<PalNPC>)Delegate.Combine(expr_16C.OnSetModeEnd, new Action<PalNPC>(PlayersManager.OnSetModeEnd)); //} } GameObject gameObject5 = PlayersManager.FindMainChar(4, true); if (gameObject5 != null) { PalNPC component5 = gameObject5.GetComponent <PalNPC>(); if (component5 == null) { Debug.Log("PlayersManager.Initialize: NPC 4 is null"); } else if (component5.model != null) { // Agent component6 = component5.model.GetComponent<Agent>(); // component6.CrossZhuoDiTime = 0.12f; } else { PalNPC expr_1FB = component5; // expr_1FB.OnLoadModelEnd = (PalNPC.void_fun_TF)Delegate.Combine(expr_1FB.OnLoadModelEnd, new PalNPC.void_fun_TF(PlayersManager.OnLoadModelEnd)); } } //ScenesManager.Instance.OnChangeMap -= new Action<int>(PlayersManager.OnChangeMap); //ScenesManager.Instance.OnChangeMap += new Action<int>(PlayersManager.OnChangeMap); // FlagManager.OnSetFlag = (Action<int, int>)Delegate.Remove(FlagManager.OnSetFlag, new Action<int, int>(PlayersManager.OnSetFlag)); // FlagManager.OnSetFlag = (Action<int, int>)Delegate.Combine(FlagManager.OnSetFlag, new Action<int, int>(PlayersManager.OnSetFlag)); }