public static void AddTank(GameObject tank, int playerNum, Color c, string name) { TankManager tmp = new TankManager { m_Instance = tank, m_PlayerNumber = playerNum, m_PlayerColor = c, m_PlayerName = name }; tmp.Setup(); m_Tanks.Add(tmp); }
/// <summary> /// 创建Tank /// </summary> /// <param name="tank"></param> /// <param name="playerNum"></param> /// <param name="color"></param> /// <param name="name"></param> /// <param name="localId"></param> public GameObject AddTank(int playerNum, Color color, string name, string localId, Vector3 position, Quaternion rotation) { TankManager tm = new TankManager { m_Instance = Instantiate(m_TankPrefab, position, rotation) as GameObject, m_PlayerNumber = playerNum, m_PlayerColor = color, m_playerName = name, m_LocalPlayerId = localId, isLocalPlayer = false }; tm.m_SpawnPoint = tm.m_Instance.transform; tm.Setup(); m_Tanks.Add(tm); SetCameraTargets(); return(tm.m_Instance); }
/// <summary> /// 创建Tank /// </summary> /// <param name="tank"></param> /// <param name="playerNum"></param> /// <param name="color"></param> /// <param name="name"></param> /// <param name="localId"></param> public GameObject AddTank(int playerNum, Color color, string name, string localId, bool isLocalPlayer) { System.Random r = new System.Random(); Transform t = spawnPoints[playerNum]; TankManager tm = new TankManager { m_Instance = Instantiate(m_TankPrefab, t.position, t.rotation) as GameObject, m_PlayerNumber = playerNum, m_PlayerColor = color, m_playerName = name, m_LocalPlayerId = localId, m_SpawnPoint = t, isLocalPlayer = isLocalPlayer }; tm.Setup(); m_Tanks.Add(tm); SetCameraTargets(); return(tm.m_Instance); }
private void SpawnAllTanks() { // 主客户端 if (g_MainPlayer != null) { g_MainPlayer.m_TankManager.m_Instance = Instantiate(m_TankPrefab, g_MainPlayer.position, Quaternion.Euler(g_MainPlayer.direction)) as GameObject; g_MainPlayer.m_TankManager.m_PlayerNumber = 1; g_MainPlayer.m_TankManager.Setup(); } // 其他客户端 foreach (var avatar in g_OtherPlayers.Values) { TankManager tank = new TankManager { m_Instance = Instantiate(m_TankPrefab, avatar.position, Quaternion.Euler(avatar.direction)) as GameObject, m_PlayerNumber = avatar.id }; tank.Setup(); avatar.m_TankManager = tank; } }