コード例 #1
0
        /// <summary>
        /// Sets the quantity and type of animals in the housing and returns
        /// the new object.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public AnimalHousing SetAnimals(AnimalResource type, int count)
        {
            if (count > Capacity)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            return(new AnimalHousing(Id, Capacity, type, count));
        }
コード例 #2
0
ファイル: AnimalManager.cs プロジェクト: zerowhale/monkey
        public AnimalManager RemoveAnimals(AnimalResource type, int count)
        {
            ImmutableDictionary <string, AnimalHousing> newHousings = null;
            var matches = housings.Values.Where(x => x.AnimalType == type).OrderBy(x => x.AnimalCount);

            foreach (var m in matches)
            {
                var toRemove = m.AnimalCount < count ? m.AnimalCount : count;
                newHousings = housings.SetItem(m.Id, m.SetAnimals(type, m.AnimalCount - toRemove));
                count      -= toRemove;

                if (count == 0)
                {
                    break;
                }
            }
            return(newHousings == null ? this : new AnimalManager(newHousings));
        }
コード例 #3
0
 public void DistributeDelayedResources(List <GameActionNotice> resultingNotices)
 {
     foreach (var kvp in delayedResources)
     {
         var player = kvp.Key;
         foreach (var cache in kvp.Value.Values)
         {
             if (!(Enum.IsDefined(typeof(AnimalResource), cache.Type.ToString())))
             {
                 player.AddResource(cache);
             }
             else
             {
                 AnimalResource animalType = (AnimalResource)cache.Type;// (AnimalResource)Enum.Parse(typeof(AnimalResource), cache.Type.ToString());
                 ((AgricolaGame)player.Game).AddInterrupt(new AssignAnimalsAction(player, animalType, cache.Count, resultingNotices));
             }
         }
     }
     delayedResources.Clear();
 }
コード例 #4
0
 public Farmyard RemoveAnimals(AnimalResource type, int count)
 {
     return(Farmyard = Farmyard.RemoveAnimals(type, count));
 }
コード例 #5
0
ファイル: Farmyard.cs プロジェクト: zerowhale/monkey
 public Farmyard RemoveAnimals(AnimalResource type, int count)
 {
     return(new Farmyard(Grid, Pastures, Fences, AnimalManager.RemoveAnimals(type, count), HouseType));
 }
コード例 #6
0
ファイル: Farmyard.cs プロジェクト: zerowhale/monkey
 public int AnimalCount(AnimalResource Type)
 {
     return(AnimalManager.GetAnimalCount(Type));
 }
コード例 #7
0
ファイル: AnimalManager.cs プロジェクト: zerowhale/monkey
 public int GetAnimalCount(AnimalResource type)
 {
     return(housings.Values.Where(x => x.AnimalType == type).Sum(y => y.AnimalCount));
 }
コード例 #8
0
 public TakeAnimalActionTrigger(AnimalResource animalType = AnimalResource.Sheep)
     : base()
 {
     this.AnimalType = animalType;
 }
コード例 #9
0
 public AssignAnimalsAction(AgricolaPlayer player, AnimalResource animalType, int animalCount, List <GameActionNotice> resultingNotices)
     : this(player, new ResourceCache[] { new ResourceCache((Resource)animalType, animalCount) }, resultingNotices)
 {
 }