Exemplo n.º 1
0
        // Convert XXX Pollen (should be Nectar, but unimplemented) to YYY Honey
        // and WWW Water + ZZZ Pollen to RoyalJelly
        private ResourceSet refineResources(Cell.RefinedResource what)
        {
            var res = new ResourceSet();

            // Ensure the player has all the due resources.

            bool refiningRJ = (what & Cell.RefinedResource.RoyalJelly) != 0,
             refiningHoney = (what & Cell.RefinedResource.Honey) != 0;

            int pollen = rm.GetResource(ResourceType.Pollen),
            water = rm.GetResource(ResourceType.Water);

            if (refiningHoney && pollen >= PollenForHoney && water >= WaterForHoney) {
            rm.RemoveResource(ResourceType.Pollen, PollenForHoney);
            rm.RemoveResource(ResourceType.Water, WaterForHoney);
            res += new ResourceSet().With(ResourceType.Honey, RefinedHoneyYield);
            }

            if (refiningRJ && pollen >= PollenForRoyalJelly && water >= WaterForRoyalJelly) {
            rm.RemoveResource(ResourceType.Pollen, PollenForRoyalJelly);
            rm.RemoveResource(ResourceType.Water, WaterForRoyalJelly);
            res += new ResourceSet().With(ResourceType.RoyalJelly, RefinedRoyalJellyYield);
            }

            return res;
        }
Exemplo n.º 2
0
        public override Status Process()
        {
            ActivateIfInactive();
            timeFromLastTheft += Time.deltaTime;

            if (warehouse.IsEmpty)
            {
                status = Status.Completed;
            }
            else if (timeFromLastTheft >= stats.LoadTime)
            {
                ResourceSet toSteal = new ResourceSet()
                    .With(ResourceType.Beeswax, 10)
                    .With(ResourceType.Honey, 5)
                    .With(ResourceType.Nectar, 10)
                    .With(ResourceType.Pollen, 10)
                    .With(ResourceType.RoyalJelly, 2)
                    .With(ResourceType.Water, 10);
                warehouse.RemoveResources(toSteal);
                if (!warningGiven) {
                    TextController.Instance.Add("Your resources are being stolen!");
                    SoundEffects.Instance.Play(SoundEffects.Sound.Attacked);
                    warningGiven = true;
                }
                timeFromLastTheft = 0.0f;
            }

            return status;
        }
Exemplo n.º 3
0
 public static ResourceSet operator -(ResourceSet rs1, ResourceSet rs2)
 {
     ResourceSet result = new ResourceSet();
     foreach (ResourceType type in Enum.GetValues(typeof(ResourceType))) {
     result[type] = Mathf.Max(0, rs1[type] - rs2[type]);
     }
     return result;
 }
Exemplo n.º 4
0
 public static ResourceSet operator *(ResourceSet rs1, float mult)
 {
     ResourceSet result = new ResourceSet();
     foreach (ResourceType type in Enum.GetValues(typeof(ResourceType))) {
     result[type] = (int)(rs1[type] * mult);
     }
     return result;
 }
Exemplo n.º 5
0
        public override Status Process()
        {
            ActivateIfInactive();

            timeFromLastExtraction += Time.deltaTime;

            if (load.IsFull)
            {
                status = Status.Completed;
            }
            else if (yielder.IsDepleted)
            {
                status = Status.Failed;
            }
            else if (timeFromLastExtraction > stats.LoadTime)
            {
                ResourceSet requestAmount = new ResourceSet()
                    .With(ResourceType.Nectar, yielder.defaultNectarYield)
                    .With(ResourceType.Pollen, yielder.defaultPollenYield)
                    .With(ResourceType.Water, yielder.defaultWaterYield)
                    .With(ResourceType.Beeswax, yielder.defaultBeeswaxYield)
                    .With(ResourceType.Honey, yielder.defaultHoneyYield)
                    .With(ResourceType.RoyalJelly, yielder.defaultRoyalJellyYield);

                ResourceSet result = yielder.Yield(requestAmount);

                if (result.IsEmpty())
                {
                    return Status.Failed;
                }

                load.AddResources(result);
                if (agent.GetComponent<Selectable>().IsSelected)
                    UIController.Instance.SetBeeLoadText(agent);
                timeFromLastExtraction = 0.0f;

                if (ResourceExtracted != null)
                {
                    ResourceExtracted(agent, yielder.gameObject);
                }
            }

            return status;
        }
Exemplo n.º 6
0
 void Start()
 {
     Load = new ResourceSet();
     stats = gameObject.GetComponent<Stats>();
 }
Exemplo n.º 7
0
 public void AddResources(ResourceSet amount)
 {
     Load += amount;
 }
Exemplo n.º 8
0
 public void AddResources(ResourceSet amount)
 {
     Load += amount;
 }
Exemplo n.º 9
0
 void Start()
 {
     Load  = new ResourceSet();
     stats = gameObject.GetComponent <Stats>();
 }
Exemplo n.º 10
0
 public void RemoveResources(ResourceSet resources)
 {
     rm.RemoveResources(resources);
 }
Exemplo n.º 11
0
 public void AddResources(ResourceSet resources)
 {
     rm.AddResources(resources);
 }
Exemplo n.º 12
0
 public void RemoveResources(ResourceSet resources)
 {
     rm.RemoveResources(resources);
 }
Exemplo n.º 13
0
 public void AddResources(ResourceSet resources)
 {
     rm.AddResources(resources);
 }