Пример #1
0
        private void Timer_Tick(object sender, ElapsedEventArgs e)
        {
            if (this.GameEnd)
            {
                this.Pause();
                this.GameChanged?.Invoke(this);
            }

            if (!this.Movement.Down())
            {
                // End reached
                // Move data to field
                this.Field.Brick2Field();

                if (this.Field.FullLines().Count() > 0)
                {
                    bool megaLine = false;

                    // Check if there are 4-Lines in common
                    if (this.Field.MegaLine())
                    {
                        megaLine = true;
                    }

                    this.Score += (this.Level + 1) * this.Field.Size.Width * (megaLine ? 4 * 10 : this.Field.FullLines().Count());

                    // Remove FullLines
                    this.Field.FullLines().ToList().ForEach(x => this.Field.Line.Remove(x));

                    // Update Score
                    this.ScoreChanged?.Invoke(megaLine);
                }

                // New Blocks
                this.Field.Current = this.Field.Next;
                this.Field.Next    = gameFactory.CreateFieldBrick(this.RandomColor());

                this.Changed?.Invoke(this);
                this.BrickChanged?.Invoke(this);
            }
        }