Beispiel #1
0
 protected virtual void OnShapeChanged(ShapeEventArgs e)
 {
     //EventHandler<ShapeEventArgs> handler = ShapeChanged;
     //if (handler != null)
     //{
     //    handler(this, e);
     //}
     ShapeChanged?.Invoke(this, e);
 }
    public void UpdateShape()
    {
        shape = null;

        if (ShapeChanged != null)
        {
            ShapeChanged.Invoke();
        }
    }
Beispiel #3
0
 // Responds to UP arrow button key down
 public void RotateShape()
 {
     if (currentShape == null)
     {
         return;
     }
     gameGrid = currentShape.RotateShape(gameGrid);
     HasChanged(gameGrid, false, -1);
     ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor); // ShapeChanged != null
 }
Beispiel #4
0
 // On tick, all shapes move down one row
 private void TmrTick(object sender, EventArgs e)
 {
     if (missATick)
     {
         return;
     }
     if (moveCounter >= 27)
     {
         moveCounter = 0;
         NewShape();
         if (listShapes.Count == 1)
         {
             currentShape = listShapes[0];
             ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor);
         }
     }
     MoveDown();
 }
Beispiel #5
0
        // Clears the game board and score and initiates a new game
        public void NewGame()
        {
            tmr.Stop();
            tmr.Interval = 500;
            listShapes.Clear();
            moveCounter = 0;

            gameGrid = new string[30][];
            for (int x = 1; x <= 30; x++)
            {
                string[] row = new string[20];
                gameGrid[x - 1] = (string[])row.Clone();
            }
            NewShape();
            currentShape = listShapes[0];
            ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor); // ShapeChanged != NULL
            rowCounter = 0;
            tmr.Start();
            flashtmr.Start();
        }
Beispiel #6
0
        // Responds to shape touchdown
        private void CurrentShapeTouchDown(Shape sender)
        {
            if (sender.CurrentPoints.Any(p => p.Y < 0))
            {
                tmr.Stop();
            }

            currentShape.TouchDown -= CurrentShapeTouchDown;
            listShapes.Remove(sender);

            if (listShapes.Count < 1)
            {
                currentShape = null;
                moveCounter  = 27;
            }
            else
            {
                currentShape = listShapes[0];
                ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor); // ShapeChanged != NULL
            }
        }
Beispiel #7
0
 protected virtual void OnShapeChanged(MyEventArgs e)
 {
     ShapeChanged?.Invoke(this, e);
 }
Beispiel #8
0
 protected virtual void OnShapeChanged(ShapeEventArgs e)
 {
     ShapeChanged?.Invoke(this, e);  // 当shape改变的时候 , 就调用事件 , 通知别人.
 }
Beispiel #9
0
 private void EhShapeChanged(object sender, SelectionChangedEventArgs e)
 {
     GuiHelper.SynchronizeSelectionFromGui(_guiShape);
     ShapeChanged?.Invoke(((SelectableListNode)_guiShape.SelectedValue).Tag as Type);
 }
 public void RemovePositions(int index, int count)
 {
     positions.RemoveRange(index, count);
     changes |= ShapeChanged.LengthChanged;
 }
 public void RemovePosition(int index)
 {
     positions.RemoveAt(index);
     changes |= ShapeChanged.LengthChanged;
 }
 public void InsertPosition(int index, Vector2 value)
 {
     positions.Insert(index, value);
     changes |= ShapeChanged.LengthChanged;
 }
 public void AddPosition(Vector2 value)
 {
     positions.Add(value);
     changes |= ShapeChanged.LengthChanged;
 }
 public void SetPosition(int index, Vector2 value)
 {
     positions[index] = value;
     changes         |= ShapeChanged.PositionMoved;
 }