Exemplo n.º 1
0
    /// <summary>
    ///   Spawns the player if there isn't currently a player node existing
    /// </summary>
    public void SpawnPlayer()
    {
        if (Player != null)
        {
            return;
        }

        Player = MicrobeSpawner.Spawn(GameWorld.PlayerSpecies, new Vector3(0, 0, 0),
                                      rootOfDynamicallySpawned, MicrobeSpawner.LoadMicrobeScene(), false, Clouds,
                                      CurrentGame);
        Player.AddToGroup("player");

        Player.OnDeath = OnPlayerDied;

        Player.OnReproductionStatus = OnPlayerReproductionStatusChanged;

        Camera.ObjectToFollow = Player;

        if (spawnedPlayer)
        {
            // Random location on respawn
            var random = new Random();
            Player.Translation = new Vector3(
                random.Next(Constants.MIN_SPAWN_DISTANCE, Constants.MAX_SPAWN_DISTANCE), 0,
                random.Next(Constants.MIN_SPAWN_DISTANCE, Constants.MAX_SPAWN_DISTANCE));

            spawner.RespawningPlayer();
        }

        TutorialState.SendEvent(TutorialEventType.MicrobePlayerSpawned, new MicrobeEventArgs(Player), this);

        spawnedPlayer      = true;
        playerRespawnTimer = Constants.PLAYER_RESPAWN_TIME;
    }