public void SetPlayer(Transform value) { player = value.GetComponent <Character>(); playerStart = FindObjectOfType <PlayerStartPosition>(); enemySpawnGraceCoroutine = BeginEnemySpawning(); StartCoroutine(enemySpawnGraceCoroutine); BeginArtifactSpawning(); }
public static Block GenerateRandomBlock(PlayerStartPosition player) { string[] randomColor = { "Gray", "Blue", "Green", "Cyan", "Red", "Magenta", "Yellow", "DarkBlue", "DarkGreen", "DarkMagenta", "DarkCyan", "DarkRed", "DarkYellow" }; // Colors allowed to be used Random randomGen = new Random(); // new random instance int pos = (int)player; int color = (int)Enum.Parse(typeof(ConsoleColor), randomColor[randomGen.Next(0, 12)]); // pick random color from the array int pieceType = randomGen.Next(0, 6); // generate random piece // Theese are the official Tetris block types switch (pieceType) { case 0: return(new Block(pos, 0, new int[, ] { { color, color }, { color, color } })); // The O-Tetrimino case 1: return(new Block(pos, 0, new int[, ] { { color, 0, 0 }, { color, color, color } })); // The J-Tetrimino case 2: return(new Block(pos, 0, new int[, ] { { 0, 0, color }, { color, color, color } })); // The L-Tetrimino case 3: return(new Block(pos, 0, new int[, ] { { 0, color, color }, { color, color, 0 } })); // The S-Tetrimino case 4: return(new Block(pos, 0, new int[, ] { { color, color, 0 }, { 0, color, color } })); // The Z-Tetrimino case 5: return(new Block(pos, 0, new int[, ] { { color, color, color, color } })); // The I-Tetrimino case 6: return(new Block(pos, 0, new int[, ] { { 0, color, 0 }, { color, color, color } })); // The T-Tetrimino default: return(new Block(pos, 0, new int[, ] { { 0, color, 0 }, { color, color, color } })); // The T-Tetrimino is default } }
void Start() { playerStart = FindObjectOfType <PlayerStartPosition>(); player = FindObjectOfType <Character>(); spawnedObjects = new List <Transform>(); }