public Mino(int _id) //构造指定ID的块 { id = IntToMinoID(_id); rotation = 0; position = new Vector2Int(4, 19); SetArray(id, 0); }
public Mino(int _id, int x, int y, int _rotation) //构造指定ID的块 { id = IntToMinoID(_id); rotation = _rotation; position = new Vector2Int(x, y); SetArray(id, rotation); }
public Mino(MinoID _id) //构造指定ID的块 { id = _id; rotation = 0; position = new Vector2Int(0, 0); SetArray(_id, 0); }
public Mino() //不带参数的构造函数,默认初始化一个S块 { id = MinoID.S; array = new int[, ] { { 0, 0, 0 }, { 1, 1, 0 }, { 0, 1, 1 } }; position = new Vector2Int(0, 0); }
public static int NameToId(string name) { int id = -1; switch (name) { case "S": id = 1; break; case "Z": id = 2; break; case "L": id = 3; break; case "J": id = 4; break; case "T": id = 5; break; case "O": id = 6; break; case "I": id = 7; break; } return(id); }
public void SetArray(MinoID id, int rotationID) //初始化ID对应的数组 { switch (id) { case MinoID.S: array = arrayS.Clone() as int[, ]; break; case MinoID.Z: array = arrayZ.Clone() as int[, ]; break; case MinoID.L: array = arrayL.Clone() as int[, ]; break; case MinoID.J: array = arrayJ.Clone() as int[, ]; break; case MinoID.T: array = arrayT.Clone() as int[, ]; break; case MinoID.O: array = arrayO.Clone() as int[, ]; break; case MinoID.I: array = arrayI.Clone() as int[, ]; break; } for (int i = 0; i < (4 - rotationID) % 4; i++) { array = Game.RotateMatrix(array, GetSize()); } }
public static int MinoIDToInt(MinoID i) { return((int)i + 1); }