void Start() { // Keep track of the User Name input CurrentInput = transform.Find("InputField").GetComponent <InputField>(); // Set the UI with the current settings CurrentInput.text = PlayFabManager.UserDisplayName; var style = PlayFabManager.GetUserDataValue("ShipStyle"); var color = PlayFabManager.GetUserDataValue("ShipColor"); if (string.IsNullOrEmpty(style)) { style = Random.Range(0, 4).ToString(); } if (string.IsNullOrEmpty(color)) { color = Random.Range(0, 4).ToString(); } CurrentStyle = int.Parse(style); CurrentColor = int.Parse(color); SelectShip(CurrentStyle); SelectColor(CurrentColor); PreviousColor = CurrentColor; PreviousStyle = CurrentStyle; PreviousName = CurrentInput.text; }
public void GoToGamePlay() { PlayFabManager.UpdateStatistic("games_played", 1); if (PlayerShip == null) { var style = PlayFabManager.GetUserDataValue("ShipStyle"); var color = PlayFabManager.GetUserDataValue("ShipColor"); if (string.IsNullOrEmpty(style)) { style = Random.Range(0, 4).ToString(); } if (string.IsNullOrEmpty(color)) { color = Random.Range(0, 4).ToString(); } PlayerShip = Instantiate(ShipPrefabs[int.Parse(style)], new Vector3(0, 0, 1f), Quaternion.identity); PlayerShip.GetComponent <ShipBehavior>().ShipColor = ShipColors[int.Parse(color)]; PlayerShip.GetComponent <FireJoystickBehavior>().Joystick = FireStick; PlayerShip.GetComponent <MovementJoystickBehavior>().Joystick = ThrustStick; } // Reset positions to the origin Camera.main.transform.position = new Vector3(0, 0, Camera.main.transform.position.z); PlayerShip.transform.position = new Vector3(0, 0, 1f); // Stop scrolling the starfield FixedScroll.SetActive(false); // Turn on world map, asteroids and satellites WorldMap.SetActive(true); AsteroidField.SetActive(true); // Show the player PlayerShip.SetActive(true); // Start the game StartGame(); }