Exemple #1
0
 public Bee(BeeType beetype, int lifespan, int id)
 {
     beeType  = beetype;
     lifeSpan = lifespan;
     status   = BeeStatus.Alive;
     beeId    = id;
 }
Exemple #2
0
 public Bee(int ID, Point startingPlace, World world, Hive hive)
 {
     this.ID         = ID;
     Age             = 0;
     place           = startingPlace;
     InHive          = true;
     CurrentStatus   = BeeStatus.Useless;
     targetFlower    = null;
     CollectedNectar = 0;
     this.world      = world;
     this.hive       = hive;
 }
Exemple #3
0
        public void Progress(Random random)
        {
            Age++;
            BeeStatus ageStatus = CurrentStatus;

            switch (CurrentStatus)
            {
            case BeeStatus.Useless:
                if (Age > WorkingAge)
                {
                    CurrentStatus = BeeStatus.InRetirement;
                }
                else if (world.Flowers.Count > 0 && hive.ConsumeHoney(HoneyConsumption))
                {
                    Flower flower = world.Flowers[random.Next(world.Flowers.Count)];

                    if (flower.Nectar >= MinNectarInFlower && flower.Alive)
                    {
                        targetFlower  = flower;
                        CurrentStatus = BeeStatus.FlyingToFlower;
                    }
                }
                break;

            case BeeStatus.FlyingToFlower:
                if (!world.Flowers.Contains(targetFlower))
                {
                    CurrentStatus = BeeStatus.FlyingToHive;
                }
                else if (InHive)
                {
                    if (MoveToLocation(hive.LookupPlace("Exit")))
                    {
                        InHive = false;
                        place  = hive.LookupPlace("Entrance");
                    }
                }
                else
                {
                    if (MoveToLocation(targetFlower.Place))
                    {
                        CurrentStatus = BeeStatus.CollectingNectar;
                    }
                }
                break;

            case BeeStatus.CollectingNectar:
                double nectar = targetFlower.CollectNectar();
                if (nectar > 0)
                {
                    CollectedNectar += nectar;
                }
                else
                {
                    CurrentStatus = BeeStatus.FlyingToHive;
                }
                break;

            case BeeStatus.FlyingToHive:
                if (!InHive)
                {
                    if (MoveToLocation(hive.LookupPlace("Entrance")))
                    {
                        InHive = true;
                        place  = hive.LookupPlace("Exit");
                    }
                }
                else
                {
                    if (MoveToLocation(hive.LookupPlace("HoneyFactory")))
                    {
                        CurrentStatus = BeeStatus.ProducingHoney;
                    }
                }
                break;

            case BeeStatus.ProducingHoney:
                if (CollectedNectar < 0.5)
                {
                    CollectedNectar = 0;
                    CurrentStatus   = BeeStatus.Useless;
                }
                else
                {
                    if (hive.AddHoney(0.5))
                    {
                        CollectedNectar -= 0.5;
                    }
                    else
                    {
                        CollectedNectar = 0;
                    }
                }
                break;

            case BeeStatus.InRetirement:
                // Do nothing
                break;
            }

            if (ageStatus != CurrentStatus && Alerter != null)
            {
                Alerter(ID, CurrentStatus.ToString());
            }
        }
Exemple #4
0
        public void Walk(Random r)
        {
            Age++;
            switch (State)
            {
            case BeeStatus.Useless:
                if (Age > WorkAge)
                {
                    State = BeeStatus.InRetirement;
                }
                else if (World.Flowers.Count > 0 && Nest.UseHoney(HoneyConsumption))
                {
                    Flower flower = World.Flowers[r.Next(World.Flowers.Count)];
                    if (flower.Nectar <= MinNectarInFlower && flower.Alive)
                    {
                        TargetFlower = flower;
                        State        = BeeStatus.FlyingToFlower;
                    }
                }

                break;

            case BeeStatus.FlyingToFlower:
                if (!World.Flowers.Contains(TargetFlower))
                {
                    State = BeeStatus.FlyingToNest;
                }
                else if (InNest)
                {
                    if (MoveToLocation(Nest.LookupPlace("Exit")))
                    {
                        InNest = false;
                        place  = Nest.LookupPlace("Entrance");
                    }
                }
                else
                {
                    if (MoveToLocation(TargetFlower.Location))
                    {
                        State = BeeStatus.CollectingNectar;
                    }
                }

                break;

            case BeeStatus.CollectingNectar:
                double nectar = TargetFlower.CollectNectar();
                if (nectar > 0)
                {
                    CollectedNectar += nectar;
                }
                else
                {
                    State = BeeStatus.FlyingToNest;
                }

                break;

            case BeeStatus.FlyingToNest:
                if (!InNest)
                {
                    if (MoveToLocation(Nest.LookupPlace("HoneyFactory")))
                    {
                        InNest = true;
                        place  = Nest.LookupPlace("Exit");
                    }
                }
                else
                {
                    if (MoveToLocation(Nest.LookupPlace("HoneyFactory")))
                    {
                        State = BeeStatus.ProducingHoney;
                    }
                }

                break;

            case BeeStatus.ProducingHoney:
                if (CollectedNectar < 0.5)
                {
                    CollectedNectar = 0;
                    State           = BeeStatus.Useless;
                }
                else
                {
                    if (Nest.AddHoney(0.5))
                    {
                        CollectedNectar -= 0.5;
                    }
                    else
                    {
                        CollectedNectar = 0;
                    }
                }

                break;

            case BeeStatus.InRetirement:
                //Dont fecking Move
                break;
            }
        }
Exemple #5
0
 public Bee(BeeType type)
 {
     CurrentBee       = type;
     CurrentBeeStatus = BeeStatus.Alive;
     Health           = 100.00F;
 }