예제 #1
0
        /// <summary> Updates the creature </summary>
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            if (FirstUpdate)
            {
                FirstUpdate = false;
                Faction.Minions.Add(AI);
                Physics.AllowPhysicsSleep = false;
            }

            if (!Active)
            {
                return;
            }
            DrawLifeTimer.Update(gameTime);

            if (!DrawLifeTimer.HasTriggered)
            {
                float val   = Hp / MaxHealth;
                Color color = val < 0.75f ? (val < 0.5f ? Color.Red : Color.Orange) : Color.LightGreen;
                Drawer2D.DrawLoadBar(Manager.World.Camera, AI.Position - Vector3.Up * 0.5f, color, Color.Black, 32, 2, Hp / MaxHealth);
            }

            CheckNeighborhood(chunks, (float)gameTime.ElapsedGameTime.TotalSeconds);
            UpdateAnimation(gameTime, chunks, camera);
            Status.Update(this, gameTime, chunks, camera);
            JumpTimer.Update(gameTime);
            HandleBuffs(gameTime);

            if (Stats.LaysEggs)
            {
                if (EggTimer == null)
                {
                    EggTimer = new Timer(1200f + MathFunctions.Rand(-30, 30), false);
                }
                EggTimer.Update(gameTime);

                if (EggTimer.HasTriggered)
                {
                    LayEgg();
                    EggTimer = new Timer(1200f + MathFunctions.Rand(-30, 30), false);
                }
            }

            if (IsPregnant && World.Time.CurrentDate > CurrentPregnancy.EndDate)
            {
                var baby = EntityFactory.CreateEntity <GameComponent>(BabyType, Physics.Position);
                baby.GetRoot().GetComponent <CreatureAI>().PositionConstraint = AI.PositionConstraint;
                CurrentPregnancy = null;
            }

            if (MathFunctions.RandEvent(0.0001f))
            {
                NoiseMaker.MakeNoise("Chirp", AI.Position, true, 0.25f);
            }
        }
예제 #2
0
 private void UpdatePregnancy()
 {
     if (IsPregnant && World.Time.CurrentDate > CurrentPregnancy.EndDate)
     {
         if (!_speciesCounts.ContainsKey(Species) || _speciesCounts[Species] < _maxPerSpecies)
         {
             if (EntityFactory.HasEntity(BabyType))
             {
                 var baby = EntityFactory.CreateEntity <GameComponent>(BabyType, Physics.Position);
                 baby.GetRoot().GetComponent <CreatureAI>().PositionConstraint = AI.PositionConstraint;
             }
         }
         CurrentPregnancy = null;
     }
 }
예제 #3
0
 private void UpdatePregnancy()
 {
     if (IsPregnant && World.Time.CurrentDate > CurrentPregnancy.EndDate)
     {
         // Todo: This check really belongs before the creature becomes pregnant.
         if (World.GetSpeciesPopulation(Stats.CurrentClass) < Stats.Species.SpeciesLimit)
         {
             if (EntityFactory.HasEntity(Stats.Species.BabyType))
             {
                 var baby = EntityFactory.CreateEntity <GameComponent>(Stats.Species.BabyType, Physics.Position);
                 baby.GetRoot().GetComponent <CreatureAI>().PositionConstraint = AI.PositionConstraint;
             }
         }
         CurrentPregnancy = null;
     }
 }
예제 #4
0
        private void UpdatePregnancy()
        {
            if (IsPregnant && World.Time.CurrentDate > CurrentPregnancy.EndDate)
            {
                // Todo: This check really belongs before the creature becomes pregnant.
                if (World.CanSpawnWithoutExceedingSpeciesLimit(Stats.Species))
                {
                    if (EntityFactory.HasEntity(Stats.Species.BabyType))
                    {
                        var baby = EntityFactory.CreateEntity <GameComponent>(Stats.Species.BabyType, Physics.Position);

                        if (baby.GetRoot().GetComponent <CreatureAI>().HasValue(out var ai)) // Set position constraint so baby stays inside pen.
                        {
                            ai.PositionConstraint = AI.PositionConstraint;
                        }
                    }
                }
                CurrentPregnancy = null;
            }
        }