Beispiel #1
0
        public void DehydrateCharacter()
        {
            if (ClockFactory.IsTimerFinished(timer) && isDehydrationEnabled)
            {
                if (!StateManager.IsImmuneToDehydration)
                {
                    SoundFactory.PlayCharacterHurtSound();

                    HealthLevel -= dehydrationDamage;

                    if (HealthLevel <= 0)
                    {
                        StateManager.IsDead = true;
                        StateManager.HandleDeath();
                    }
                    else
                    {
                        characterDrawingManager.SetCharacterBlinking(true);
                    }
                }

                ClockFactory.ResetTimer(timer);
                ClockFactory.StartTimer(timer);
            }
        }
        public override void Draw(SpriteBatch spriteBatch, Camera camera)
        {
            base.Draw(spriteBatch, camera);

            if (ClockFactory.IsTimerFinished(timeIds[0]))
            {
                spriteBatch.Begin();
                spriteBatch.DrawString(completeFont.SpriteFont, completeMessage, completeMessagePosition + new Vector2(0, -1), Color.Black);
                spriteBatch.DrawString(completeFont.SpriteFont, completeMessage, completeMessagePosition + new Vector2(-1, 0), Color.Black);
                spriteBatch.DrawString(completeFont.SpriteFont, completeMessage, completeMessagePosition + new Vector2(0, 1), Color.Black);
                spriteBatch.DrawString(completeFont.SpriteFont, completeMessage, completeMessagePosition + new Vector2(1, 0), Color.Black);
                spriteBatch.DrawString(completeFont.SpriteFont, completeMessage, completeMessagePosition, completeFont.Color);
                spriteBatch.End();
            }

            if (ClockFactory.IsTimerFinished(timeIds[1]))
            {
                spriteBatch.Begin();
                spriteBatch.DrawString(scoreFont.SpriteFont, scoreMessage, scoreMessagePosition + new Vector2(0, -1), Color.Black);
                spriteBatch.DrawString(scoreFont.SpriteFont, scoreMessage, scoreMessagePosition + new Vector2(-1, 0), Color.Black);
                spriteBatch.DrawString(scoreFont.SpriteFont, scoreMessage, scoreMessagePosition + new Vector2(0, 1), Color.Black);
                spriteBatch.DrawString(scoreFont.SpriteFont, scoreMessage, scoreMessagePosition + new Vector2(1, 0), Color.Black);
                spriteBatch.DrawString(scoreFont.SpriteFont, scoreMessage, scoreMessagePosition, scoreFont.Color);
                spriteBatch.End();
            }
        }
 public void Update()
 {
     if (!EffectHasFinished && ClockFactory.IsTimerFinished(timer))
     {
         Destroy();
     }
 }
        public override void Update()
        {
            if (ClockFactory.IsTimerFinished(timeIds[2]))
            {
                this.level.IsCompleted = true;
                this.IsFinished        = true;
            }

            else if (ClockFactory.IsTimerFinished(timeIds[1]))
            {
                float x = camera.Transform.M11 + camera.View.Width / 2f - scoreFont.SpriteFont.MeasureString(scoreMessage).X / 2f;
                float y = (camera.Transform.M22 + camera.View.Height) * 2f / 3f;
                this.scoreMessagePosition = new Vector2(x, y);
                ClockFactory.StartTimer(timeIds[2]);
            }

            else if (ClockFactory.IsTimerFinished(timeIds[0]))
            {
                float x = camera.Transform.M11 + camera.View.Width / 2f - completeFont.SpriteFont.MeasureString(completeMessage).X / 2f;
                float y = camera.Transform.M22 + camera.View.Height / 3f;
                this.completeMessagePosition = new Vector2(x, y);
                ClockFactory.StartTimer(timeIds[1]);
            }


            foreach (AbstractTerrain terrain in terrainList)
            {
                terrain.Update();
            }
        }
        public override void Update()
        {
            if (ClockFactory.IsTimerFinished(timeIds[1]))
            {
                this.level.IsFailed = true;
                this.IsFinished     = true;
            }

            else if (ClockFactory.IsTimerFinished(timeIds[0]))
            {
                float x = camera.Transform.M11 + camera.View.Width / 2f - deathFont.SpriteFont.MeasureString(deathMessage).X / 2f;
                float y = camera.Transform.M22 + camera.View.Height / 2f;
                this.deathMessagePosition = new Vector2(x, y);
                ClockFactory.StartTimer(timeIds[1]);
            }

            foreach (AbstractCharacter character in characterList)
            {
                character.Update();
            }

            foreach (IEnemy enemy in enemyList)
            {
                enemy.Update();
            }

            foreach (AbstractTerrain terrain in terrainList)
            {
                terrain.Update();
            }

            foreach (ItemSet itemSet in itemSetList)
            {
                itemSet.Update();
            }

            foreach (ICollectable collectable in collectableList)
            {
                collectable.Update();
            }

            foreach (IItem item in itemList)
            {
                item.Update();
            }

            camera.Update();
        }