示例#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);
            }
        }
示例#2
0
        protected override void Update(GameTime gameTime)
        {
            ClockFactory.Update(gameTime);

            foreach (IController c in controllers)
            {
                if (c.IsActionActive(Actions.Quit))
                {
                    this.Exit();
                }
                else if (c.IsActionActive(Actions.Reset))
                {
                    LevelManager.ResetLevel();
                }

                c.Update();

                if (LevelManager.Finished == true)
                {
                    GameFinished();
                }
                else
                {
                    startMenu.Update();
                    LevelManager.Update();
                }

                base.Update(gameTime);
            }
        }
 public void Update()
 {
     if (!EffectHasFinished && ClockFactory.IsTimerFinished(timer))
     {
         Destroy();
     }
 }
示例#4
0
        protected override void Initialize()
        {
            SpriteFactory.SetContentManager(Content);
            SoundFactory.SetContentManager(Content);
            LevelFactory.Setup();
            ClockFactory.Setup();
            EventFactory.Setup();
            ScoreManager.Setup();
            keyboard          = new KeyboardController();
            gamepadcontroller = new GamePadController();
            controllers       = new List <IController>();

            if (gamepadcontroller.IsConnected())
            {
                controllers = new List <IController>()
                {
                    gamepadcontroller
                };
            }
            else
            {
                controllers = new List <IController>()
                {
                    keyboard
                };
            }


            IsMouseVisible = true;
            base.Initialize();
        }
 public void Consume()
 {
     ClockFactory.StartTimer(timer);
     //character.StateManager.IsInvincible = true;
     //character.StateManager.IsImmuneToDehydration = true;
     HasBeenConsumed = true;
 }
        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 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();
            }
        }
示例#8
0
        public DefaultSubLevelTransitionEvent(TimeSpan timeToTextOverlay, TimeSpan timeToLevelChange, String transitionMessage, SpriteFontContainer transitionFont)
        {
            this.timeIds                   = new int[2];
            this.timeIds[0]                = ClockFactory.RegisterTimer(timeToTextOverlay);
            this.timeIds[1]                = ClockFactory.RegisterTimer(timeToLevelChange);
            this.transitionMessage         = transitionMessage;
            this.transitionFont            = transitionFont;
            this.transitionMessagePosition = new Vector2();

            ClockFactory.StartTimer(timeIds[0]);
        }
        public DefaultDeathEvent(TimeSpan timeToTextOverlay, TimeSpan timeToLevelReset,
                                 String deathMessage, SpriteFontContainer deathFont)
        {
            this.timeIds              = new int[2];
            this.timeIds[0]           = ClockFactory.RegisterTimer(timeToTextOverlay);
            this.timeIds[1]           = ClockFactory.RegisterTimer(timeToLevelReset);
            this.deathMessage         = deathMessage;
            this.deathFont            = deathFont;
            this.deathMessagePosition = new Vector2();

            ClockFactory.StartTimer(timeIds[0]);
        }
 public InvincibilityStar(AbstractAnimatedSprite sprite, int duration, Rectangle position, CollisionType collisionType, string message)
 {
     this.timer                 = ClockFactory.RegisterTimer(new TimeSpan(0, 0, duration));
     this.EffectHasFinished     = false;
     this.HasBeenConsumed       = false;
     this.ShouldNotifyReceivers = false;
     this.CollisionType         = collisionType;
     this.sprite                = sprite;
     this.duration              = duration;
     this.Position              = new Vector2(position.X, position.Y);
     this.Size = new Vector2(position.Width, position.Height);
     this.MessageToReceivers = message;
 }
        public DefaultLevelCompleteEvent(TimeSpan timeToTextOverlay, TimeSpan timeToScoreOverlay,
                                         TimeSpan timeToLevelChange, String completeMessage, String scoreMessage, SpriteFontContainer completeFont, SpriteFontContainer scoreFont)
        {
            this.timeIds                 = new int[3];
            this.timeIds[0]              = ClockFactory.RegisterTimer(timeToTextOverlay);
            this.timeIds[1]              = ClockFactory.RegisterTimer(timeToScoreOverlay);
            this.timeIds[2]              = ClockFactory.RegisterTimer(timeToLevelChange);
            this.completeMessage         = completeMessage;
            this.scoreMessage            = scoreMessage;
            this.completeFont            = completeFont;
            this.scoreFont               = scoreFont;
            this.completeMessagePosition = new Vector2();

            ClockFactory.StartTimer(timeIds[0]);
        }
        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();
        }
示例#13
0
        public CharacterImpl(int health, int fishbowlWaterLevel, Rectangle position, List <IController> controllersList, bool isDehydrationEnabled, int dehydrationDamage, int dehydrationTime, CollisionType collisionType, string message)
        {
            this.Position              = new Vector2(position.X, position.Y);
            this.Size                  = new Vector2(position.Width, position.Height);
            this.Velocity              = new Vector2();
            this.originalHitbox        = position;
            this.HealthLevel           = health;
            this.maxHealthLevel        = health;
            this.MeterLevel            = fishbowlWaterLevel;
            this.controllers           = controllersList == null ? new List <IController>() : controllersList;
            this.StateManager          = new CharacterStateManagerImpl(this);
            this.CurrentItem           = null;
            this.ShouldNotifyReceivers = false;
            this.CollisionType         = collisionType;
            this.isDehydrationEnabled  = isDehydrationEnabled;
            this.keyPickupHeld         = false;
            this.dehydrationDamage     = dehydrationDamage;
            this.CurrentPowerup        = null;
            this.timer                 = ClockFactory.RegisterTimer(new TimeSpan(0, 0, dehydrationTime));
            this.MessageToReceivers    = message;

            ClockFactory.StartTimer(timer);
        }