public static int NewPlayer(ExampleSimplePlayer playerInterface) { PlayerInfo newPlayer = new PlayerInfo (); newPlayer.score = 0; newPlayer.gameObject = playerInterface.gameObject; //newPlayer.color = playerInterface.m_color; [!!!] playerInfos.Add (newPlayer); return playerInfos.Count - 1; }
void StartNewPlayer(object sender, PlayerConnectMessageArgs e) { ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings(); Vector3 position = new Vector3(m_rand.Next(settings.areaWidth), 0, m_rand.Next(settings.areaHeight)); // Spawn a new player then add a script to it. GameObject gameObject = (GameObject)Instantiate(prefabToSpawnForPlayer, position, Quaternion.identity); // Add the ExampleSimplePlayer script to this object. Note: We could possible add this to the prefab. // Not sure which is best. ExampleSimplePlayer player = gameObject.AddComponent <ExampleSimplePlayer>(); player.Init(e.netPlayer); }