예제 #1
0
 public virtual void BtnPause(MouseEventArgs args)
 {
     if (IsGameOver)
     {
         ThisDelay = InitialDelay;
         engine    = RunGame();
         UsedPoints.Clear();
         Pieces.Clear();
         IsGameOver = false;
         GameOver   = "";
         IsPaused   = false;
         BtnValue   = "Pause";
         return;
     }
     if (IsPaused == false)
     {
         IsPaused = true;
         BtnValue = "Resume";
     }
     else
     {
         IsPaused = false;
         BtnValue = "Pause";
     }
 }
예제 #2
0
        void UpdateMap(Piece piece)
        {
            var points = new List <Point>();

            if (!piece.Active)
            {
                UsedPoints.AddRange(piece.Tetris.Geos.Select(g => new Point(g.x + piece.Position.x, g.y + piece.Position.y, piece.Tetris.Colour)));
            }
            UsedPoints.OrderBy(p => p.y * 10 + p.x).ToList().ForEach(p => Console.WriteLine($"Map: {p.x},{p.y}"));
        }
예제 #3
0
        async Task ScorePoints()
        {
            //40 * (n + 1)	100 * (n + 1)	300 * (n + 1)	1200 * (n + 1)
            // n= Level
            int        lineCount = 0;
            List <int> lines     = new List <int>();

            //Go down the lines
            for (int i = 1; i < 21; i++)
            {
                int hitCount = UsedPoints.Where(x => x.y == i).Count();
                if (hitCount == 10)                 //Number of columns
                {
                    lines.Add(i);
                    UsedPoints.ForEach(p => { if (p.y == i)
                                              {
                                                  p.Class = "dying";
                                              }
                                       });
                }
            }
            StateHasChanged();
            await Task.Delay(450);

            UsedPoints.RemoveAll(p => p.Class == "dying");
            foreach (var item in lines)
            {
                UsedPoints.ForEach(p => { if (p.y < item)
                                          {
                                              p.y++;
                                          }
                                   });
            }
            lineCount = lines.Count;
            if (lineCount > 0)
            {
                Score += lineCount == 1 ? 40 : lineCount == 2 ? 100 : lineCount == 3 ? 300 : 1200;
            }
        }
예제 #4
0
        public void Update()
        {
            AlivePoints[NextFlip].Clear();

            AliveInit();

            foreach (Point p in AlivePoints[flip])
            {
                for (int i = p.X - 1; i <= p.X + 1; i++)
                {
                    for (int j = p.Y - 1; j <= p.Y + 1; j++)
                    {
                        // 未確定なら
                        if (alives[NextFlip][i, j] == null)
                        {
                            alives[NextFlip][i, j] = IsAliveNext(i, j);
                            UsedPoints.Add(new Point(i, j));
                        }
                    }
                }
            }

            flip = 1 - flip;
        }