Exemple #1
0
 private void deleteObstacleWithMouse()
 {
     vecteurPosition = Input.mousePosition;
     if (Input.GetMouseButtonUp(0))
     {
         RaycastHit hit;
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hit))
         {
             Hex        g          = new Hex(hit.point.x, hit.point.z);
             List <Hex> atomicList = new List <Hex>();
             obstacles.Remove(g);
             atomicList.Add(g);
             Hex.purge(mapHexGameobject, atomicList);
         }
     }
 }
Exemple #2
0
    void Update()
    {
        // définit les étapes du jeu, NONE, SETUP, PLAYER1, PLAYER2
        {
            if (Input.GetKeyDown(KeyCode.S))
            {
                SETUP           = true;
                PLAYER1         = false;
                PLAYER2         = false;
                chapitre.text   = Messages.messageSETUP1;
                paragraphe.text = Messages.messageSETUP2;
            }
            if (Input.GetKeyDown(KeyCode.D))
            {
                SETUP           = false;
                PLAYER1         = true;
                PLAYER2         = false;
                currentPlayer   = friend;
                chapitre.text   = Messages.messagePLAYER1;
                paragraphe.text = "";
                friendPlayerController.AllowMove(true);
                enemyPlayerController.AllowMove(false);
            }

            if (Input.GetKeyDown(KeyCode.F))
            {
                SETUP           = false;
                PLAYER1         = false;
                PLAYER2         = true;
                currentPlayer   = enemy;
                chapitre.text   = Messages.messagePLAYER2;
                paragraphe.text = "";
                friendPlayerController.AllowMove(false);
                enemyPlayerController.AllowMove(true);
            }
        }

        // définit la valeur de ADDOBSTACLE si la touche "1" est pressée ou relevée
        if (Input.GetKeyDown(KeyCode.Keypad1))
        {
            ADDOBSTACLE = true;
        }
        if (Input.GetKeyUp(KeyCode.Keypad1))
        {
            ADDOBSTACLE = false;
        }

        // définit la valeur de ADDOBSTACLE si la touche "2" est pressée ou relevée
        if (Input.GetKeyDown(KeyCode.Keypad2))
        {
            DELETEOBSTACLE = true;
        }
        if (Input.GetKeyUp(KeyCode.Keypad2))
        {
            DELETEOBSTACLE = false;
        }

        // durant la phase de SETUP
        if (SETUP)
        {
            if (ADDOBSTACLE)
            {
                plotObstacleWithMouse();
            }
            if (DELETEOBSTACLE)
            {
                deleteObstacleWithMouse();
            }
        }

        // affiche l'aide en pressant la touche "espace"
        if (Input.GetKeyDown(KeyCode.Space))
        {
            help.text = Messages.messageHelp;
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            help.text = "";
        }

        // a tout instant, affiche puis efface le plus court chemin entre enemy et friend
        {
            if (Input.GetKeyDown("l"))
            {
                Hex enemyPosition  = new Hex(enemy.transform.position.x, enemy.transform.position.z);
                Hex friendPosition = new Hex(friend.transform.position.x, friend.transform.position.z);
                plusCourtChemin = Hex.shortestPath(friendPosition, enemyPosition, obstacles, portée_de_tir);
                Hex.display(plusCourtChemin, tile, mapHexGameobject);
            }
            if (Input.GetKeyUp("l"))
            {
                Hex.purge(mapHexGameobject, plusCourtChemin);
            }
        }
        // a tout instant, affiche puis efface les éléments visibles par currentPlayer
        {
            if (Input.GetKeyDown("o"))
            {
                Hex currentPlayerPosition = new Hex(currentPlayer.transform.position.x, currentPlayer.transform.position.z);
                Visibles = Hex.visibleHex(currentPlayerPosition, obstacles, portée_de_tir);
                Hex.display(Visibles, tile, mapHexGameobject);
            }

            if (Input.GetKeyUp("o"))
            {
                Hex.purge(mapHexGameobject, Visibles);
            }
        }
    }