// Update is called once per frame
    void Update()
    {
        ClearAllLights();
        LightDirection();

        bool isPlayerTurn = scrGM.GetIsPlayerTurn();

        if (isPlayerTurn == false)
        {
            float step = moveSpeed * Time.deltaTime;

            gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, goalPos, step);

            if (moveCurrent == 0 && gameObject.transform.position == goalPos)
            {
                scrGM.SetIsPlayerTurn(true);
                moveCurrent = moveMax;
            }

            if (gameObject.transform.position == goalPos && isGoing == true && pathNumber < path.Length - 1)
            {
                pathNumber++;
                goalPos = path[pathNumber];
                moveCurrent--;

                if (pathNumber == path.Length - 1)
                {
                    isGoing = false;
                }
            }
            else if (gameObject.transform.position == goalPos && isGoing == false && pathNumber > 0)
            {
                pathNumber--;
                goalPos = path[pathNumber];
                moveCurrent--;

                if (pathNumber == 0)
                {
                    isGoing = true;
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        scrGM = GameObject.Find("GameManager").GetComponent <ScrGameManager>();

        // Player
        startPosPlayer = new Vector3(-8, -4, 0);

        instancePlayer = Instantiate(player);
        instancePlayer.transform.position = startPosPlayer;

        // Ennemy
        startPosEnnemy1 = new Vector3(6, 2, 0);

        instanceEnnemy1 = Instantiate(ennemy1);
        instanceEnnemy1.transform.position = startPosEnnemy1;

        // Ennemy Path
        pathEnnemy1 = new Vector3[]
        {
            startPosEnnemy1,
            new Vector3(6, 1, 0),
            new Vector3(5, 1, 0),
            new Vector3(4, 1, 0),
            new Vector3(4, 0, 0),
            new Vector3(3, 0, 0),
            new Vector3(2, 0, 0),
            new Vector3(1, 0, 0),
            new Vector3(0, 0, 0),
            new Vector3(-1, 0, 0),
            new Vector3(-2, 0, 0),
            new Vector3(-3, 0, 0),
            new Vector3(-4, 0, 0),
            new Vector3(-5, 0, 0),
        };

        instanceEnnemy1.GetComponent <ScrEnnemyMoves>().SetPath(pathEnnemy1);

        scrGM.SetIsPlayerTurn(true);
    }
    // Update is called once per frame
    void Update()
    {
        bool isPlayerTurn = scrGM.GetIsPlayerTurn();

        if (isPlayerTurn == true)
        {
            float step = moveSpeed * Time.deltaTime;

            gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, goalPos, step);

            if (moveCurrent > 0)
            {
                if (canPressButton == true)
                {
                    if (isItFirstAppearance == true)
                    {
                        CheckMoveDirectionAllowed();
                        isItFirstAppearance = false;
                    }

                    if (Input.GetKeyDown("up") && isMoveUpAllowed == true)
                    {
                        goalPos        = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + 1, gameObject.transform.position.z);
                        canPressButton = false;
                        moveCurrent--;
                        ClearArrows();
                    }
                    else if (Input.GetKeyDown("down") && isMoveDownAllowed == true)
                    {
                        goalPos        = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y - 1, gameObject.transform.position.z);
                        canPressButton = false;
                        moveCurrent--;
                        ClearArrows();
                    }
                    else if (Input.GetKeyDown("left") && isMoveLeftAllowed == true)
                    {
                        goalPos        = new Vector3(gameObject.transform.position.x - 1, gameObject.transform.position.y, gameObject.transform.position.z);
                        canPressButton = false;
                        moveCurrent--;
                        ClearArrows();
                    }
                    else if (Input.GetKeyDown("right") && isMoveRightAllowed == true)
                    {
                        goalPos        = new Vector3(gameObject.transform.position.x + 1, gameObject.transform.position.y, gameObject.transform.position.z);
                        canPressButton = false;
                        moveCurrent--;
                        ClearArrows();
                    }
                }

                if (gameObject.transform.position == goalPos)
                {
                    CheckMoveDirectionAllowed();
                    canPressButton = true;
                }
            }
            else if (moveCurrent == 0 && gameObject.transform.position == goalPos)
            {
                scrGM.SetIsPlayerTurn(false);
                moveCurrent = moveMax;
            }
        }
    }