/// <summary> /// The method responsible for generating a new figure (used by the engine of the game) /// </summary> /// <param name="position">The position on which to be put the new generated figure</param> /// <returns>The generated figure</returns> public Figure GenerateFigure(Position position) { switch (this.randomGenerator.Next(1, 9)) { case 1: return new LeftG(position); case 2: return new LeftS(position); case 3: return new Line(position); case 4: return new RightS(position); case 5: return new Square(position); case 6: return new TFigure(position); case 7: return new UFigure(position); case 8: return new XFigure(position); default: return new Line(position); } }
/// <summary> /// The default constructor for the figure initialization /// </summary> /// <param name="position">The position of the figure on the game field</param> public UFigure(Position position) : base(position, new char[,] { { '#', ' ', '#' }, { '#', '#', '#' } }) { }
/// <summary> /// The main constructor of a game objects. /// </summary> /// <param name="position">The position of the game object on the field</param> /// <param name="image">The visible part of the object, in the form of a char matrix </param> public GameObject(Position position, char[,] image) { this.image = (char[,])image.Clone(); this.position = position; }
/// <summary> /// The default constructor for the figure initialization /// </summary> /// <param name="position">The position of the figure on the game field</param> public RightS(Position position) : base(position, new char[,] { { ' ', '#', '#' }, { '#', '#', ' ' } }) { }
/// <summary> /// The default constructor for the figure initialization /// </summary> /// <param name="position">The position of the figure on the game field</param> public Square(Position position) : base(position, new char[,] { { '#', '#' }, { '#', '#' } }) { }
/// <summary> /// The default constructor for the figure initialization /// </summary> /// <param name="position">The position of the figure on the game field</param> public LeftG(Position position) : base(position, new char[,] { { '#', '#' }, { ' ', '#' }, { ' ', '#' } }) { }
/// <summary> /// The default constructor for the figure initialization /// </summary> /// <param name="position">The position of the figure on the game field</param> public Line(Position position) : base(position, new char[,] { { '#' }, { '#' }, { '#' }, { '#' } }) { }
/// <summary> /// The constructor which initializes the figures properties /// </summary> /// <param name="position">The position of the figure in the game</param> /// <param name="image">The visual part(the image) if the figure, represented by char matrix</param> public Figure(Position position, char[,] image) : base(position, image) { }
protected Timer timer2; //快速下落后销毁方块 #endregion Fields #region Constructors public Box(GameFrame gf) { this.gFrame = gf; isActive = false; center = new Position(2, gFrame.Column / 2); }
public Square(string p) { string[] s = p.Split('.'); pos = new Position(System.Int32.Parse(s[0]), System.Int32.Parse(s[1])); value = (BoxShape)(System.Int32.Parse(s[2])); }
public BoxShape value; //种类 #endregion Fields #region Constructors public Square(Position p, BoxShape v) { this.pos = p; this.value = v; }