コード例 #1
0
        //Create a Bee
        //paint Bee
        //update lifecycle Bee
        //remove Bee
        public void CreateBee()
        {
            IBee       bee          = (IBee)_lifeFactory.CreateLivingBeing(LivingEntityEnum.Bee);
            List <int> availableIds = bees.Select(a => a.BeeId).ToList();

            bee.BeeId = _utilitiesResolver.GetMinimumNumberFromASequenceOfNumbers(availableIds);
            bee.BeeLifeCycleTotalCount = rand.Next(_minBeeLifeCycle, _maxBeeLifeCycle);

            int selectedIndex = GetRandomWingIndex(BeeEnvironmentEnum.Indoors);
            BeeWingMovementCycle beeWingAnimationInfo = _beeWingsMovementInvoker.GetBeeSelectedWingAnimation(selectedIndex, BeeEnvironmentEnum.Indoors);

            bee.BeeIndexWingAnimation = beeWingAnimationInfo.BeeWingMovementIndex;

            bee.BeeIsOnDisplayIndoors        = true;
            bee.BeeIndoorsWingAnimationImage = beeWingAnimationInfo.BeeWingMovementImage;
            var beeRandomLocationPoint = GetIndoorsRandomLocationPoint();
            var beeIndoorSize          = new Size(_widthBeeIndoors, _heightBeeIndoors);

            bee.BeeIndoorsSize = new Rectangle(beeRandomLocationPoint, beeIndoorSize);

            bee.BeeEnvironmentBehavior = _movementBehaviorCommandInvoker.SelectBehaviorRandomly(BeeEnvironmentEnum.Indoors);
            Point exitDoorLocationPoint = new Point(_beehiveExitDoorDimmensions.X, _beehiveExitDoorDimmensions.Y);

            bee.BeeIndoorsMovementDirection = _beeCommon.GetSelectedMovement(bee.BeeEnvironmentBehavior, beeRandomLocationPoint, exitDoorLocationPoint);

            bee.BeeIsOnDisplayOuterWorld = false;
            BeeWingMovementCycle BeeWingsInOuterWorld = _beeWingsMovementInvoker.GetBeeSelectedWingAnimation(selectedIndex, BeeEnvironmentEnum.OuterWorld);

            bee.BeeOuterWorldWingAnimationImage = BeeWingsInOuterWorld.BeeWingMovementImage;
            var beehiveWorldEntranceLocationPoint = new Point(_hiveInWorldEntranceDoorLocationX, _hiveInWorldEntranceDoorLocationY);
            var beeWorldSize = new Size(_widthBeeWorld, _heightBeeWorld);

            bee.BeeInOuterWorldSize            = new Rectangle(beehiveWorldEntranceLocationPoint, beeWorldSize);
            bee.BeeOuterWorldMovementDirection = MovementDirectionEnum.Static;

            bee.NextBeeMovementCycle             = rand.Next(_minNextMovementIteration, _maxNextMovementIteration);
            bee.BeeIterationMovementCycleCounter = 0;
            bee.NextBeeBehaviorType             = rand.Next(_minNextBehaviorIteration, _maxNextBehaviorIteration);
            bee.BeeIterationBehaviorTypeCounter = 0;

            bee.BeeTargetFlowerID         = -1;
            bee.BeePollenCarryingCapacity = rand.Next(_beeMinimumPollenCarryingCapacity, _beeMaximumPollenCarryingCapacity);
            bee.BeePollenCollected        = 0;
            bees.Add(bee);
        }
コード例 #2
0
        //Create Flower
        //paint flower
        //update lifecycle Flower
        //remove flower
        public void CreateFlower()
        {
            _landscapeDimmensions = _landscape.GetLandscapeDimmensions();
            Point randomFlowerLocationPoint = GetRandomLocation(_landscapeDimmensions.Height, _landscapeDimmensions.Width);
            Size  flowerSize = new Size(_defaultFlowerWidth, _defaultFlowerHeight);

            IFlower    flower       = (IFlower)_lifeFactory.CreateLivingBeing(Enums.LivingEntityEnum.Flower);
            List <int> availableIds = GetAllFlowers().Select(a => a.FlowerID).ToList();

            flower.FlowerID                     = _utilitiesResolver.GetMinimumNumberFromASequenceOfNumbers(availableIds);
            flower.FlowerLocation               = new Rectangle(randomFlowerLocationPoint, flowerSize);
            flower.FlowerImageStage             = Properties.Resource.plant01;
            flower.FlowerStage                  = FlowerLifeCycleEnum.Birth1;
            flower.FlowerPollenContainer        = rand.Next(_minPollenCount, _maxPollenCount);
            flower.MinimumCountsToDisplayFlower = SetMinimumCounterToDisplayFlower();
            flower.CountsToDisplayFlower        = 0;
            flower.FlowerIsOnDisplay            = false;
            flower.FlowerPollenArea             = new Rectangle(0, 0, 0, 0);
            flowers.Add(flower);
        }