コード例 #1
0
        public override void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            DamageTimer.Update(gameTime);
            CheckLavaTimer.Update(gameTime);
            SoundTimer.Update(gameTime);
            if (CheckLavaTimer.HasTriggered)
            {
                CheckForLavaAndWater(gameTime, chunks);
            }
            Heat *= 0.999f;

            if (Heat > Flashpoint)
            {
                if (DamageTimer.HasTriggered)
                {
                    Health.Damage(Damage, Health.DamageType.Fire);
                }

                if (SoundTimer.HasTriggered)
                {
                    SoundManager.PlaySound(ContentPaths.Audio.fire, LocParent.Position, true, 0.5f);
                }
                double totalSize = (LocParent.BoundingBox.Max - LocParent.BoundingBox.Min).Length();
                int    numFlames = (int)(totalSize / 4.0f) + 1;

                for (int i = 0; i < numFlames; i++)
                {
                    Vector3 extents     = (LocParent.BoundingBox.Max - LocParent.BoundingBox.Min);
                    Vector3 randomPoint = LocParent.BoundingBox.Min + new Vector3(extents.X * MathFunctions.Rand(), extents.Y * MathFunctions.Rand(), extents.Z * MathFunctions.Rand());
                    PlayState.ParticleManager.Trigger("flame", randomPoint, Color.White, GetNumTrigger());
                }
            }

            base.Update(gameTime, chunks, camera);
        }
コード例 #2
0
ファイル: Flammable.cs プロジェクト: polytronicgr/dwarfcorp
        override public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            if (!Active)
            {
                return;
            }

            var body = Parent as Body;

            System.Diagnostics.Debug.Assert(body != null);

            DamageTimer.Update(gameTime);
            CheckLavaTimer.Update(gameTime);
            SoundTimer.Update(gameTime);
            if (CheckLavaTimer.HasTriggered)
            {
                CheckForLavaAndWater(body, gameTime, chunks);
            }
            Heat *= 0.999f;

            if (Heat > Flashpoint)
            {
                UpdateRate = 1;
                if (DamageTimer.HasTriggered)
                {
                    Health.Damage(Damage, Health.DamageType.Fire);
                }

                if (SoundTimer.HasTriggered)
                {
                    SoundManager.PlaySound(ContentPaths.Audio.fire, body.Position, true, 1.0f);
                }
                double totalSize = (body.BoundingBox.Max - body.BoundingBox.Min).Length();
                int    numFlames = (int)(totalSize / 4.0f) + 1;

                for (int i = 0; i < numFlames; i++)
                {
                    Vector3 extents     = (body.BoundingBox.Max - body.BoundingBox.Min);
                    Vector3 randomPoint = body.BoundingBox.Min + new Vector3(extents.X * MathFunctions.Rand(), extents.Y * MathFunctions.Rand(), extents.Z * MathFunctions.Rand());
                    Manager.World.ParticleManager.Trigger("flame", randomPoint, Color.White, GetNumTrigger(body));
                }
            }
        }
コード例 #3
0
ファイル: Flammable.cs プロジェクト: hhy5277/dwarfcorp
        override public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            if (!Active)
            {
                return;
            }
            base.Update(gameTime, chunks, camera);
            var body = Parent as GameComponent;

            global::System.Diagnostics.Debug.Assert(body != null);

            DamageTimer.Update(gameTime);
            CheckLavaTimer.Update(gameTime);
            SoundTimer.Update(gameTime);
            if (CheckLavaTimer.HasTriggered)
            {
                CheckSurroundings(body, gameTime, chunks);
            }
            Heat *= 0.999f;

            if (Heat > Flashpoint)
            {
                if (DamageTimer.HasTriggered)
                {
                    Health.Damage(Damage, Health.DamageType.Fire);
                }

                if (SoundTimer.HasTriggered)
                {
                    SoundManager.PlaySound(ContentPaths.Audio.fire, body.Position, true, 1.0f);
                }
                double totalSize = (body.BoundingBox.Max - body.BoundingBox.Min).Length();
                int    numFlames = (int)(totalSize / 4.0f) + 1;
                for (int i = FlameSprites.Count; i < numFlames; i++)
                {
                    CreateFlameSprite(MathFunctions.RandVector3Box(body.BoundingBox));
                }

                if (MathFunctions.RandEvent(0.06f))
                {
                    foreach (var sprite in FlameSprites)
                    {
                        Manager.World.ParticleManager.Trigger("smoke", sprite.Position + Vector3.Up * 0.5f, Color.Black, 1);
                        Manager.World.ParticleManager.Trigger("flame", sprite.Position + Vector3.Up * 0.5f, Color.Black, 1);
                    }
                }

                if (MathFunctions.RandEvent(0.01f))
                {
                    foreach (var sprite in FlameSprites)
                    {
                        sprite.Die();
                    }
                    FlameSprites.Clear();
                }
                var mesh = Parent.GetComponent <InstanceMesh>();

                if (mesh != null)
                {
                    mesh.VertexColorTint = Color.DarkGray;
                }
            }
            else
            {
                foreach (var sprite in FlameSprites)
                {
                    sprite.Die();
                }
                FlameSprites.Clear();
            }
        }