Esempio n. 1
0
    public PlayerController SpawnPlayer(RavenNest.Models.Player playerDef)
    {
        if (!chunkManager)
        {
            Debug.LogError("No chunk manager available!");
            return(null);
        }

        var starter = chunkManager.GetStarterChunk();

        if (starter == null)
        {
            Debug.LogError("No starter chunk available!");
            return(null);
        }

        var spawnPoint = starter.GetPlayerSpawnPoint();
        var vector3    = Random.insideUnitSphere * 1f;
        var player     = playerManager.Spawn(spawnPoint + vector3, playerDef);

        if (!player)
        {
            Debug.LogError("Can't spawn player, player is already playing.");
        }

        this.playerList.AddPlayer(player);

        return(player);
    }
Esempio n. 2
0
    public PlayerController Spawn(
        Vector3 position,
        RavenNest.Models.Player playerDefinition,
        Player streamUser,
        StreamRaidInfo raidInfo)
    {
        lock (mutex)
        {
            if (activePlayers.Any(x => x.PlayerName == playerDefinition.Name))
            {
                return(null); // player is already in game
            }

            var player = Instantiate(playerControllerPrefab);
            if (!player)
            {
                Debug.LogError("Player Prefab not found!!!");
                return(null);
            }

            player.transform.position = position;

            return(Add(player.GetComponent <PlayerController>(), playerDefinition, streamUser, raidInfo));
        }
    }
Esempio n. 3
0
 private PlayerController Add(
     PlayerController player,
     RavenNest.Models.Player def,
     Player streamUser,
     StreamRaidInfo raidInfo)
 {
     player.SetPlayer(def, streamUser, raidInfo);
     activePlayers.Add(player);
     return(player);
 }
Esempio n. 4
0
    public PlayerController SpawnPlayer(
        RavenNest.Models.Player playerDefinition,
        Player streamUser       = null,
        StreamRaidInfo raidInfo = null)
    {
        if (!chunkManager)
        {
            Debug.LogError("No chunk manager available!");
            return(null);
        }

        var starter = chunkManager.GetStarterChunk();

        if (starter == null)
        {
            Debug.LogError("No starter chunk available!");
            return(null);
        }

        var spawnPoint = starter.GetPlayerSpawnPoint();
        //var startIsland = playerDefinition?.State?.Island;
        //var island = Islands.Find(startIsland);
        //if (island != null)
        //{
        //    spawnPoint = island.SpawnPosition;
        //}

        var vector3 = Random.insideUnitSphere * 1f;
        var player  = playerManager.Spawn(spawnPoint + vector3, playerDefinition, streamUser, raidInfo);

        if (!player)
        {
            Debug.LogError("Can't spawn player, player is already playing.");
            return(null);
        }

        playerList.AddPlayer(player);
        PlayerJoined(player);

        if (player && gameCamera && gameCamera.AllowJoinObserve)
        {
            gameCamera.ObservePlayer(player);
        }

        if (dropEventManager.IsActive)
        {
            player.BeginItemDropEvent();
        }

        return(player);
    }
Esempio n. 5
0
 private PlayerController Add(
     PlayerController player,
     RavenNest.Models.Player def,
     Player streamUser,
     StreamRaidInfo raidInfo)
 {
     player.SetPlayer(def, streamUser, raidInfo);
     lock (mutex)
     {
         activePlayers.Add(player);
         gameManager.Village.TownHouses.InvalidateOwnershipOfHouses();
         return(player);
     }
 }
Esempio n. 6
0
    public void SetPlayer(RavenNest.Models.Player player)
    {
        gameObject.name = player.Name;

        if (!gameManager)
        {
            gameManager = FindObjectOfType <GameManager>();
        }
        if (!playerAppearance)
        {
            playerAppearance = GetComponent <PlayerAppearance>();
        }
        if (playerAppearance)
        {
            playerAppearance.SetAppearance(player.Appearance);
        }

        UserId      = player.UserId;
        PlayerName  = player.Name;
        Stats       = new Skills(player.Skills);
        Resources   = player.Resources;
        Statistics  = player.Statistics;
        ExpOverTime = 1m; // P...

        Inventory.Create(player.InventoryItems, gameManager.Items.GetItems());

        lastSavedExperienceTotal = Stats.TotalExperience;

        // remove after all players have been fixed ;o or make a repository fixer or whatever.

        if (!nameTagManager)
        {
            nameTagManager = GameObject.Find("NameTags").GetComponent <NameTagManager>();
        }

        if (nameTagManager)
        {
            nameTagManager.Add(this);
        }

        Stats.Health.Reset();

        Inventory.EquipBestItems();
        Equipment.HideEquipments(); // don't show sword on join
    }
Esempio n. 7
0
    public PlayerController SpawnPlayer(
        RavenNest.Models.Player playerDef,
        Player streamUser       = null,
        StreamRaidInfo raidInfo = null)
    {
        if (!chunkManager)
        {
            Debug.LogError("No chunk manager available!");
            return(null);
        }

        var starter = chunkManager.GetStarterChunk();

        if (starter == null)
        {
            Debug.LogError("No starter chunk available!");
            return(null);
        }

        var spawnPoint = starter.GetPlayerSpawnPoint();
        var vector3    = Random.insideUnitSphere * 1f;
        var player     = playerManager.Spawn(spawnPoint + vector3, playerDef, streamUser, raidInfo);

        if (!player)
        {
            Debug.LogError("Can't spawn player, player is already playing.");
        }

        playerList.AddPlayer(player);

        PlayerJoined(player);

        if (player && gameCamera && gameCamera.AllowJoinObserve)
        {
            gameCamera.ObservePlayer(player);
        }

        return(player);
    }
Esempio n. 8
0
 private PlayerController Add(PlayerController player, RavenNest.Models.Player def)
 {
     player.SetPlayer(def);
     this.activePlayers.Add(player);
     return(player);
 }