コード例 #1
0
        public override void OnEveryTick()
        {
            lock (Health)
            {
                Health.DisplayedString = "Health: " + GameContext.Health;
            }

            if (GameContext.Health <= 0)
            {
                Turrets.ForEach(x => x.HealthPoints = -1);
                GameContext.GameOver          = true;
                GameOverText.DisplayedString += GameContext.Score.ToString();
                GameContext.ZombieSpawner.Timer.Stop();
                GameLogicTimer.Stop();
            }
        }
コード例 #2
0
ファイル: Bullet.cs プロジェクト: JoonasKajava/Base-Defence
        public override void OnEveryTick()
        {
            var Zombie = GameContext.DrawQueue?.ToList()?.OfType <Zombie>()?.ToList()?.Find(x => x.Shape.GetGlobalBounds().Intersects(Shape.GetGlobalBounds()) && x.Alive);

            if (Zombie != null)
            {
                Zombie.HealthPoints -= 50;
                GameContext.Score   += 10;
                if (GameContext.ZombieSpawner.Timer.Interval > 10)
                {
                    GameContext.ZombieSpawner.Timer.Interval -= 10 / Environment.Turrets.Count;
                }
                GameContext.DrawQueue.RemoveAll(x => x == this);
                GameLogicTimer.Stop();
                Environment.OnScoreChange();
            }


            if ((Shape.Position.X > GameContext.Window.Size.X || Shape.Position.Y > GameContext.Window.Size.Y) || (Shape.Position.X < 0 || Shape.Position.Y < 0))
            {
                GameContext.DrawQueue.RemoveAll(x => x == this);
                GameLogicTimer.Stop();
            }
        }