public static bool PlayerSpawned = false; //Player has spawned private void Start() { //If the player has been spawned if (PlayerSpawned) { Debug.Log("Setting up player in new scene"); //Call the event to set the character's position setPlayerPosEvent.Raise(transform); //Call the event to start up the player startPlayerEvent.Raise(); } else { if (SelectedCharacter == null) { //Set the default character to be the selected character SelectedCharacter = defaultCharacter; } //Spawn the player prefab GameObject playerObject = Instantiate(SelectedCharacter.characterObject, transform.position, transform.rotation); //Set the player object not to be destroyed on load DontDestroyOnLoad(playerObject); PlayerSpawned = true; } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.enabled = Application.isPlaying; TransformEvent e = target as TransformEvent; if (GUILayout.Button("Raise")) { e.Raise(value); } }
public void StartLevel() { //Set up the player UI setMaxHealthEvent.Raise((int)maxHealth.Value); setMaxManaEvent.Raise((int)maxMana.Value); setManaEvent.Raise(mana); setHealthEvent.Raise(health); setScoreEvent.Raise(score); //Link the player inventory to any relevant components inventoryEvent.Raise(inventory); //Set up the reference to the camera setCameraRefEvent.Raise(cameraTarget); }