Пример #1
0
        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");
            }
        }
Пример #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (statesMine == MineStates.Reposo)
     {
         if (other.gameObject.tag == "Player")
         {
             gameController.DetectedMine();
             statesMine            = MineStates.Contando;
             sphereCollider.radius = 5f;
         }
     }
 }
Пример #3
0
    void Update()
    {
        if (statesMine == MineStates.Contando)
        {
            if (timeToExploit <= 0)
            {
                statesMine = MineStates.Detonacion;
            }
        }

        DoActionState();
    }
Пример #4
0
    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;
        }
    }
Пример #5
0
 public void RestartMine(float pMineExploitTime)
 {
     statesMine    = MineStates.Reposo;
     timeToExploit = pMineExploitTime;
 }
Пример #6
0
 void Start()
 {
     statesMine = MineStates.Reposo;
 }