예제 #1
0
파일: Queen.cs 프로젝트: corefan/yad2
        public override bool Maintain(ISimulationWorld isw)
        {
            if (!IsAlive())
            {
                return(false);
            }

            if (Randomizer.NextDouble() < AntHillConfig.queenLayEggProbability)
            {
                isw.CreateEgg(this.Position);
            }

            if (this.TurnsToBecomeHungry <= 0)
            {
                if (foodQuantity > 0)
                {
                    this.Eat();
                    foodQuantity--;
                    this.TurnsToBecomeHungry = AntHillConfig.antTurnNumberToBecomeHungry;
                }
                else
                {
                    isw.CreateMessage(this.Position, MessageType.QueenIsHungry, this.Position);
                }
            }
            if (isw.GetVisibleSpiders(this).Count != 0)
            {
                isw.CreateMessage(this.Position, MessageType.QueenInDanger, this.Position);
            }
            return(true);
        }