static void displayBoard() //This will display the board,and will also change the colour of the board being displayed. { { Console.Clear(); Console.WriteLine("MG's Minefield"); Console.Write("Current Position: {0}{1} ", (char)(currentPlayerYPosition + 65), currentPlayerXPosition); // Show as C3, B2 etc Console.Write("Moves taken: {0} ", numberOfMoves); Console.WriteLine("Lives remaining: {0}", livesRemaining); for (int xPos = 0; xPos < boardWidth; xPos = xPos + 1) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("{0,2}", xPos); Console.ForegroundColor = ConsoleColor.White; } } Console.WriteLine("\n"); for (int yPos = 1; yPos < boardHeight; yPos = yPos + 1) { for (int xPos = 0; xPos < boardWidth; xPos = xPos + 1) { if (xPos == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("{0,2}", (char)(yPos + 64)); // Convert column down to A, B, C etc Console.ForegroundColor = ConsoleColor.White; } else { // Print grid layout. Place a different character and colour depending on whether a mine found or not MineStates mineState = minefield[yPos, xPos]; switch (mineState) { case MineStates.Mined: drawOnGrid("-", false); break; case MineStates.Hidden: drawOnGrid("-", false); break; case MineStates.Visible: drawOnGrid(numberOfMinesAroundPos(yPos, xPos).ToString(), false); break; case MineStates.Defused: drawOnGrid("*", true); break; default: break; } } } Console.WriteLine("\n"); } }
private void OnTriggerEnter(Collider other) { if (statesMine == MineStates.Reposo) { if (other.gameObject.tag == "Player") { gameController.DetectedMine(); statesMine = MineStates.Contando; sphereCollider.radius = 5f; } } }
void Update() { if (statesMine == MineStates.Contando) { if (timeToExploit <= 0) { statesMine = MineStates.Detonacion; } } DoActionState(); }
private void DoActionState() { switch (statesMine) { case MineStates.Contando: { timeToExploit -= Time.deltaTime; } break; case MineStates.Detonacion: { // lanzar particulas // sonido explocion mineExplotion.Play(); gameController.MineExploision(this.gameObject, mineExplotion.main.duration); statesMine = MineStates.Detonada; //Destroy(gameObject); } break; } }
public void RestartMine(float pMineExploitTime) { statesMine = MineStates.Reposo; timeToExploit = pMineExploitTime; }
void Start() { statesMine = MineStates.Reposo; }