コード例 #1
0
 /// <summary>
 /// returns the amount that the player has of a certain resource
 /// </summary>
 /// <param name="resource"></param>
 /// <returns></returns>
 public int GetInventoryAmount(Resource.Resources resource)
 {
     if (inventory.ContainsKey(resource))
     {
         return(inventory[resource]);
     }
     return(0);
 }
コード例 #2
0
 /// <summary>
 /// Add resources to the player inventory.
 /// </summary>
 /// <param name="pResource"></param>
 /// <param name="pAmount"></param>
 public void AddItem(Resource.Resources pResource, int pAmount)
 {
     if (inventory.ContainsKey(pResource))
     {
         inventory[pResource] += pAmount;
     }
     else
     {
         inventory.Add(pResource, pAmount);
     }
 }
コード例 #3
0
 /// <summary>
 /// Remove a given amount of a resource from the inventory.
 /// </summary>
 /// <param name="pResource"></param>
 /// <param name="pAmount"></param>
 public void RemoveItem(Resource.Resources pResource, int pAmount)
 {
     if (inventory.ContainsKey(pResource))
     {
         if (inventory[pResource] <= pAmount)
         {
             inventory.Remove(pResource);
         }
         else
         {
             inventory[pResource] -= pAmount;
         }
     }
 }
コード例 #4
0
ファイル: Tile.cs プロジェクト: Xivolos/IndieGame_Networking
        /// <summary>
        /// Returns a certain amount of loot found on this tile.
        /// </summary>
        /// <param name="loot"></param>
        /// <returns></returns>
        public bool Search(out Resource.Loot loot)
        {
            state = States.searched;
            loot  = new Resource.Loot(0, 0);
            int amount = random.Next(minValue, maxValue + 1);

            if (amount == 0)
            {
                return(false);
            }
            loot.Amount = amount;

            Array enumValues = Enum.GetValues(typeof(Resource.Resources));

            Resource.Resources resource = (Resource.Resources)enumValues.GetValue(random.Next(0, enumValues.Length * 10) / 10);
            loot.Resource = resource;
            return(true);
        }