Esempio n. 1
0
 public static bool SameAmount(this Resources res, Resources other)
 {
     if (other == null)
     {
         return(false);
     }
     return(res.Wood == other.Wood && res.Ore == other.Ore && res.Fish == other.Fish &&
            res.Magic == other.Magic && res.Wheat == other.Wheat && res.Arrows == other.Arrows &&
            res.Coins == other.Coins);
 }
Esempio n. 2
0
 public static decimal[] ToList(this Resources res)
 {
     return(new[]
     {
         res.Wood,
         res.Fish,
         res.Ore,
         res.Wheat,
         res.Coins,
         res.Magic,
         res.Arrows
     });
 }
Esempio n. 3
0
    public async Task SaveResourcesAsync()
    {
        var result = await gameManager.RavenNest.Players.UpdateResourcesAsync(UserId, Resources.GetResourceList());

        if (result)
        {
            Debug.Log("Resources for " + this.PlayerName + " saved.");
        }
        else
        {
            Debug.LogError("Resources for " + this.PlayerName + " failed to save!");
        }
        lastSavedResources = DataMapper.Map <Resources, Resources>(this.Resources);
    }
Esempio n. 4
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
    }