示例#1
0
        /// <summary> Updates the creature </summary>
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            if (!IsActive)
            {
                return;
            }

            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(1200.0f, false);
                }
                EggTimer.Update(gameTime);

                if (EggTimer.HasTriggered)
                {
                    LayEgg();
                    EggTimer = new Timer(1200.0f + MathFunctions.Rand(-30.0f, 30.0f), false);
                }
            }
        }
示例#2
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);
            }
        }
示例#3
0
        private void UpdateEggs(DwarfTime gameTime)
        {
            if (Stats.LaysEggs)
            {
                if (EggTimer == null)
                {
                    EggTimer = new Timer(3600f + MathFunctions.Rand(-120, 120), false);
                }
                EggTimer.Update(gameTime);

                if (EggTimer.HasTriggered)
                {
                    if (!_speciesCounts.ContainsKey(Species) || _speciesCounts[Species] < _maxPerSpecies)
                    {
                        LayEgg();
                        EggTimer = new Timer(3600f + MathFunctions.Rand(-120, 120), false);
                    }
                }
            }
        }