예제 #1
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
    }