예제 #1
0
    void Start()
    {
        mapHexGameobject = new Dictionary <Hex, GameObject>();
        obstacles        = new List <Hex>();
        plusCourtChemin  = new List <Hex>();
        Visibles         = new List <Hex>();
        MapGenerator pg = new MapGenerator(Rayon, pourcentagedeRemplissage);

        obstacles = pg.listeObstacles;
        Hex.display(obstacles, obstacle, mapHexGameobject);
        Hex.setColor("Obstacle", Color.yellow);
        chapitre.text   = "";
        paragraphe.text = "";

        NONE           = true;
        SETUP          = false;
        PLAYER1        = false;
        PLAYER2        = false;
        ADDOBSTACLE    = false;
        DELETEOBSTACLE = false;
        PLAY           = false;
    }
예제 #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);
            }
        }
    }