Esempio n. 1
0
    public void Load_ClientInfo()
    {
        //client = Camera.main.GetComponent<GameManager>().currentClient;
        spriteClient = Camera.main.GetComponent <ClientCard>().clientSpriteCanvas;

        stateEmotion = (client.BaseLevelAngryness + client.BaseLevelHappyness) / 2;

        tempCube = controller.currentCube.GetComponent <InspectElement>(); //-> ?
        client.TemplateLoad();
    }
 public void StoreTest()
 {
     IInspecting inspecting             = new InspectElement();
     AutomationElementCollection window = inspecting.Inspect(@"..\..\..\Solution Utilities\Notepad Demo\bin\Debug\WPFNotepad.exe");
     //AutomationElementCollection window = inspecting.Inspect(@"..\..\..\Solution Utilities\SampleInput\bin\Debug\SampleInput.exe");
     IElementsAnalyzer elementsAnalyzer = new ElementsAnalyzer();
     //List<IElement> listRootElement = elementsAnalyzer.Analyzing(window);
     //ElementXmlGeneration elementXmlGeneration = new ElementXmlGeneration();
     //elementXmlGeneration.Store(listRootElement);
 }
Esempio n. 3
0
    public void  ChangeColorOnVisited()
    {
        InspectElement _element = currentCube.gameObject.GetComponent <InspectElement>();

        if (_element != null)
        {
            if (_element.visited)
            {
                Debug.Log("Already Visited !!");
                car.gameObject.GetComponent <MeshRenderer>().materials[0].SetColor("_BaseColor", Color.HSVToRGB(32, 68, 97));
            }
            else
            {
                car.gameObject.GetComponent <MeshRenderer>().materials[0].SetColor("_BaseColor", Color.white);
            }
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        if (stateEmotion > 60)
        {
            percentageState.color = Color.green;
        }
        else if (stateEmotion > 31 && stateEmotion < 60)
        {
            percentageState.color = Color.yellow;
        }
        else
        {
            percentageState.color = Color.red;
        }
        percentageState.text = Mathf.Round(stateEmotion) + "%";
        sliderValue.value    = stateEmotion;
        if (tempCube != null && tempCube.name != controller.currentCube.name)
        {
            tempCube = controller.currentCube.GetComponent <InspectElement>();
            if (tempCube.Event != InspectElement.Tyle_Evenement.Empty)
            {
                if (tempCube.Event == InspectElement.Tyle_Evenement.Chantier)
                {
                    //CheckCondition_Hated("ChantierT (TasteCustomer)");
                    //Animation car accident
                    controller.speed = controller.speedInChantier;
                }
                else
                {
                    controller.speed = controller.optimalSpeed;
                    if (tempCube.Event == InspectElement.Tyle_Evenement.Monument)
                    {
                        CheckCondition_Hated("MonumentT (TasteCustomer)");
                    }
                    else if (tempCube.Event == InspectElement.Tyle_Evenement.Restaurant)
                    {
                        //CheckCondition_Hated("RestaurantT (TasteCustomer)");
                        //pay

                        /*if ((ScoreManager.score - controller.manager.priceRestaurant) <= 0)
                         *  ScoreManager.score = 0;
                         * else
                         *  ScoreManager.score -= controller.manager.priceRestaurant;*/
                    }
                }
            }
            else
            {
                controller.speed = controller.optimalSpeed;
            }

            if (tempCube.visited)
            {
                //Debug.Log("already been here");
                feedBackEmotion.sprite = WonderingFace;
                currentDecrease        = decreaseFactor_Impact;
                ShowFloatingText(false);
            }
            else
            {
                currentDecrease = decreaseFactor;
                ShowFloatingText(true);
            }
        }

        //TODO : Optional
        if (Time.timeScale == 1)
        {
            stateEmotion *= currentDecrease;
        }

        if (stateEmotion > client.BaseLevelAngryness)
        {
            //Happy
            spriteClient.sprite = client.HappyFace;
        }
        else if (stateEmotion < client.BaseLevelHappyness)
        {
            //Angry
            spriteClient.sprite = client.AngryFace;
        }
        else
        {
            //Neutral
            spriteClient.sprite = client.NeutralFace;
        }
    }
Esempio n. 5
0
    public override void OnInspectorGUI()
    {
        //When you click on a tile, she's had to a list. If you choose to add a type, the type will be add to all tiles in this list
        InspectElement map = (InspectElement)target;

        if (!map.elementTest.test.Contains(map))
        {
            map.elementTest.test.Add(map);
        }

        if (DrawDefaultInspector()) //-> if something have changed
        {
        }

        EditorGUILayout.Space();
        if (GUILayout.Button("City")) //-> so if we decide the tile is a City block, we change the material and his property
        {
            foreach (InspectElement element in map.elementTest.test)
            {
                element.GetComponent <MeshRenderer>().material = map.elementTest.city;
                element.type = InspectElement.Tyle_Type.City;
            }
            map.elementTest.test.Clear(); //important to clear the list, unless you will change over and over tiles selected before
        }

        if (GUILayout.Button("Grass")) // -> same for grass block
        {
            foreach (InspectElement element in map.elementTest.test)
            {
                element.GetComponent <MeshRenderer>().material = map.elementTest.grass;
                element.type = InspectElement.Tyle_Type.Grass;
            }
            map.elementTest.test.Clear();
        }

        if (GUILayout.Button("ActualizeBoxCollider"))
        {
            foreach (Transform element in map.elementTest.Roads_Position)
            {
                var go = new GameObject();
                go.name = "DetectionCollision_Swipe";
                BoxCollider bxCollider = go.AddComponent <BoxCollider>();
                bxCollider.center           = element.transform.position;
                bxCollider.gameObject.layer = 9; //-> 9 is layerMask value for road
                bxCollider.size             = new Vector3(map.elementTest.scaleX, 1, map.elementTest.scaleZ);
                go.transform.SetParent(element);
            }
        }

        if (GUILayout.Button("EMERGENCY"))
        {
            map.elementTest.Roads_Position.Clear();
            map.elementTest.test.Clear();
            map.elementTest.Monuments_Position.Clear();
        }

        //Monument and Road Block are specific case -> like they are event for the player, we need to keep track of them
        if (GUILayout.Button("Monument"))
        {
            //Check for neighbour in Genereate method
            foreach (InspectElement element in map.elementTest.test)
            {
                element.GetComponent <MeshRenderer>().material = map.elementTest.monument_Mat;
                element.type = InspectElement.Tyle_Type.Monument_Source;
                if (!map.elementTest.Monuments_Position.Contains(element.transform))
                {
                    map.elementTest.Monuments_Position.Add(element.transform);
                }
            }
            map.elementTest.test.Clear();
        }

        if (GUILayout.Button("Malus"))
        {
            //Check for neighbour in Genereate method
            foreach (InspectElement element in map.elementTest.test)
            {
                element.GetComponent <MeshRenderer>().material = map.elementTest.Malus_Mat;
                element.type = InspectElement.Tyle_Type.Malus_Source;
                if (!map.elementTest.Malus_Position.Contains(element.transform))
                {
                    map.elementTest.Malus_Position.Add(element.transform);
                }
            }
            map.elementTest.test.Clear();
        }

        if (GUILayout.Button("Road"))
        {
            foreach (InspectElement element in map.elementTest.test)
            {
                element.GetComponent <MeshRenderer>().material = map.elementTest.road;
                element.type = InspectElement.Tyle_Type.Road;
                if (!map.elementTest.Roads_Position.Contains(element.transform))
                {
                    map.elementTest.Roads_Position.Add(element.transform);
                }
            }
            map.elementTest.test.Clear();
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (GUILayout.Button("Clear Selection"))
        {
            map.elementTest.test.Clear();
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (GUILayout.Button("Clear")) //-> this button clear all materials, prefabs, and event into the map
        {
            //Clear all tiles
            foreach (Transform temp in map.elementTest.isoSphere.transform)
            {
                temp.GetComponent <MeshRenderer>().material = map.elementTest.default_Mat;
                var tmp = temp.GetComponent <InspectElement>();
                tmp.type  = InspectElement.Tyle_Type.Empty;
                tmp.Event = InspectElement.Tyle_Evenement.Empty;
                tmp.neighborHex.Clear();

                if (temp.GetComponent <Walkable>() != null)
                {
                    DestroyImmediate(temp.GetComponent <Walkable>());
                }

                if (temp.transform.childCount > 0)
                {
                    foreach (Transform child in temp.transform)
                    {
                        DestroyImmediate(child.gameObject);
                    }
                }
            }
            for (int i = 0; i < map.elementTest.Roads_Position.Count; i++)
            {
                map.elementTest.Roads_Position[i].GetComponent <InspectElement>().neighborHex.Clear();
                map.elementTest.Roads_Position[i].GetComponent <BoxCollider>().size = new Vector3(1, 1, 1);
            }
            for (int i = 0; i < map.elementTest.Monuments_Position.Count; i++)
            {
                map.elementTest.Monuments_Position[i].GetComponent <InspectElement>().neighborHex.Clear();
            }

            for (int i = 0; i < map.elementTest.Malus_Position.Count; i++)
            {
                map.elementTest.Malus_Position[i].GetComponent <InspectElement>().neighborHex.Clear();
            }
            map.elementTest.Roads_Position.Clear();
            map.elementTest.Monuments_Position.Clear();
            map.elementTest.Malus_Position.Clear();
            map.elementTest.test.Clear();
        }


        //GENERATION

        if (GUILayout.Button("Generate"))
        {
            if (EditorUtility.DisplayDialog("Confirm Generation ? ", " Make sure every road are interconnected\n\n And that you have place everything where you really want", "Place", "Do not Generate"))
            {
                //So we iterate over the list of the road position, if a walkable script is not found, we had it and we connect it with all of his neighbor
                for (int i = 0; i < map.elementTest.Roads_Position.Count; i++)
                {
                    for (int j = 0; j < map.elementTest.Roads_Position.Count; j++)
                    {
                        if (map.elementTest.Roads_Position[i] != map.elementTest.Roads_Position[j])
                        {
                            if (Vector3.Distance(map.elementTest.Roads_Position[i].transform.position, map.elementTest.Roads_Position[j].transform.position) < map.distance_Check)
                            {
                                map.elementTest.Roads_Position[i].GetComponent <InspectElement>().neighborHex.Add(map.elementTest.Roads_Position[j]);
                            }
                        }
                    }
                    if (map.elementTest.Roads_Position[i].GetComponent <InspectElement>().Event == InspectElement.Tyle_Evenement.Restaurant)
                    {
                        map.elementTest.Roads_Position[i].GetComponent <MeshRenderer>().sharedMaterial = map.elementTest.restaurant_Mat;
                    }

                    if (map.elementTest.Roads_Position[i].GetComponent <InspectElement>().Event == InspectElement.Tyle_Evenement.Chantier)
                    {
                        map.elementTest.Roads_Position[i].GetComponent <MeshRenderer>().sharedMaterial = map.elementTest.chantier_Mat;
                    }
                }
            }

            foreach (Transform temp in map.elementTest.Roads_Position)
            {
                //Crossroads
                if (temp.GetComponent <InspectElement>().type == InspectElement.Tyle_Type.Road || temp.GetComponent <InspectElement>().type == InspectElement.Tyle_Type.CrossRoads)
                {
                    if (temp.GetComponent <Walkable>() == null)
                    {
                        var walk_Script = temp.gameObject.AddComponent <Walkable>();
                        foreach (Transform element in temp.gameObject.GetComponent <InspectElement>().neighborHex)
                        {
                            WalkPath walk = new WalkPath();
                            walk.target = element;
                            walk.active = true;
                            walk_Script.possiblePaths.Add(walk);
                        }
                    }
                }
            }

            //Monument

            /*if (map.elementTest.Monuments_Position.Count != 0){
             *  for (int j = 0; j < map.elementTest.isoSphere.childCount; j++){
             *      for (int i = 0; i < map.elementTest.Monuments_Position.Count; i++){
             *          if (Vector3.Distance(map.elementTest.isoSphere.GetChild(j).position, map.elementTest.Monuments_Position[i].position) < map.distance_Check && map.elementTest.isoSphere.GetChild(j) != map.elementTest.Monuments_Position[i]){
             *              if(map.elementTest.isoSphere.GetChild(j).GetComponent<InspectElement>().Event == InspectElement.Tyle_Evenement.Empty)
             *                  map.elementTest.isoSphere.GetChild(j).GetComponent<InspectElement>().Event = InspectElement.Tyle_Evenement.Monument;
             *          }
             *      }
             *  }
             * }*/

            /*if (map.elementTest.Malus_Position.Count != 0)
             * {
             *  for (int j = 0; j < map.elementTest.isoSphere.childCount; j++)
             *  {
             *      for (int i = 0; i < map.elementTest.Malus_Position.Count; i++)
             *      {
             *          if (Vector3.Distance(map.elementTest.isoSphere.GetChild(j).position, map.elementTest.Malus_Position[i].position) < map.distance_Check && map.elementTest.isoSphere.GetChild(j) != map.elementTest.Malus_Position[i])
             *          {
             *              if (map.elementTest.isoSphere.GetChild(j).GetComponent<InspectElement>().Event == InspectElement.Tyle_Evenement.Empty)
             *                  map.elementTest.isoSphere.GetChild(j).GetComponent<InspectElement>().Event = InspectElement.Tyle_Evenement.Monument;
             *          }
             *      }
             *  }
             * }*/

            //Prefabs instantiation

            /*for (int i = 0; i < map.elementTest.isoSphere.transform.childCount; i++){
             *  //We spawn prefabs depending of the type of the event we found on the planet
             *  //We calculate the normal to spawn the object on the ground of the tile
             *  if (map.elementTest.isoSphere.transform.GetChild(i).GetComponent<InspectElement>().type == InspectElement.Tyle_Type.Monument_Source){
             *      Vector3 normal = map.elementTest.isoSphere.transform.position - map.elementTest.isoSphere.transform.GetChild(i).transform.position; //Normal calculation of the actual tile
             *
             *      GameObject gameObject_ = Instantiate(map.elementTest.monumentPrefab[Random.Range(0, map.elementTest.monumentPrefab.Length)], map.elementTest.isoSphere.transform.GetChild(i));
             *      gameObject_.transform.localScale = new Vector3(0.0006f, 0.0006f, 0.0006f);
             *      gameObject_.transform.localPosition = new Vector3(0, 0, 0);
             *      gameObject_.transform.up = -normal;
             *  }
             *  else if (map.elementTest.isoSphere.transform.GetChild(i).GetComponent<InspectElement>().type == InspectElement.Tyle_Type.City){
             *      Vector3 normal = map.elementTest.isoSphere.transform.position - map.elementTest.isoSphere.transform.GetChild(i).transform.position;
             *
             *      GameObject gameObject_ = Instantiate(map.elementTest.cityPrefab[Random.Range(0, map.elementTest.cityPrefab.Length)], map.elementTest.isoSphere.transform.GetChild(i));
             *      gameObject_.transform.localScale = new Vector3(0.0006f, 0.0006f, 0.0006f);
             *      gameObject_.transform.localPosition = new Vector3(0, 0, 0);
             *      gameObject_.transform.up = -normal;
             *  }
             *  else if (map.elementTest.isoSphere.transform.GetChild(i).GetComponent<InspectElement>().type == InspectElement.Tyle_Type.Grass){
             *      Vector3 normal = map.elementTest.isoSphere.transform.position - map.elementTest.isoSphere.transform.GetChild(i).transform.position;
             *
             *      GameObject gameObject_ = Instantiate(map.elementTest.grassPrefab[Random.Range(0, map.elementTest.grassPrefab.Length)], map.elementTest.isoSphere.transform.GetChild(i));
             *      gameObject_.transform.localScale = new Vector3(0.0006f, 0.0006f, 0.0006f);
             *      gameObject_.transform.localPosition = new Vector3(0, 0, 0);
             *      gameObject_.transform.up = -normal;
             *  }
             *
             * }*/
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        //Rare utilisation Button -> if we import a map previously contruct, she will not have all of her events, we can use the Update button to replace everything
        //
        //Issue where encounters with materials -> use of the shared material, instead it create instance of material and it can break the game later on
        //
        if (GUILayout.Button("Update"))
        {
            if (EditorUtility.DisplayDialog("Confirm Update ? ", "You want to use update button only in the case where you have imported a new planet", "Update", "Do not Update"))
            {
                for (int i = 0; i < map.elementTest.isoSphere.transform.childCount; i++)
                {
                    if (map.elementTest.isoSphere.transform.GetChild(i).GetComponent <MeshRenderer>().sharedMaterial == map.elementTest.road || map.elementTest.isoSphere.transform.GetChild(i).GetComponent <MeshRenderer>().sharedMaterial == map.elementTest.crossroadsMat)
                    {
                        InspectElement tile = map.elementTest.isoSphere.transform.GetChild(i).GetComponent <InspectElement>();
                        tile.type = InspectElement.Tyle_Type.Road;
                        if (!map.elementTest.Roads_Position.Contains(tile.transform))
                        {
                            map.elementTest.Roads_Position.Add(tile.transform);
                        }
                    }
                    else if (map.elementTest.isoSphere.transform.GetChild(i).GetComponent <MeshRenderer>().sharedMaterial == map.elementTest.grass)
                    {
                        InspectElement tile = map.elementTest.isoSphere.transform.GetChild(i).GetComponent <InspectElement>();
                        tile.type = InspectElement.Tyle_Type.Grass;
                    }
                    else if (map.elementTest.isoSphere.transform.GetChild(i).GetComponent <MeshRenderer>().sharedMaterial == map.elementTest.monument_Mat)
                    {
                        InspectElement tile = map.elementTest.isoSphere.transform.GetChild(i).GetComponent <InspectElement>();
                        tile.type = InspectElement.Tyle_Type.Monument_Source;
                        if (!map.elementTest.Monuments_Position.Contains(tile.transform))
                        {
                            map.elementTest.Monuments_Position.Add(tile.transform);
                        }
                    }
                    else if (map.elementTest.isoSphere.transform.GetChild(i).GetComponent <MeshRenderer>().sharedMaterial == map.elementTest.city)
                    {
                        InspectElement tile = map.elementTest.isoSphere.transform.GetChild(i).GetComponent <InspectElement>();
                        tile.type = InspectElement.Tyle_Type.City;
                    }
                }

                //Monument
                if (map.elementTest.Monuments_Position.Count != 0)
                {
                    for (int j = 0; j < map.elementTest.isoSphere.childCount; j++)
                    {
                        for (int i = 0; i < map.elementTest.Monuments_Position.Count; i++)
                        {
                            if (Vector3.Distance(map.elementTest.isoSphere.GetChild(j).position, map.elementTest.Monuments_Position[i].position) < map.distance_Check && map.elementTest.isoSphere.GetChild(j) != map.elementTest.Monuments_Position[i])
                            {
                                map.elementTest.isoSphere.GetChild(j).GetComponent <InspectElement>().Event = InspectElement.Tyle_Evenement.Monument;
                            }
                        }
                    }
                }

                for (int i = 0; i < map.elementTest.Roads_Position.Count; i++)
                {
                    for (int j = 0; j < map.elementTest.Roads_Position.Count; j++)
                    {
                        //TODO : Check if needed in Upgrade Case

                        /*if (map.elementTest.Roads_Position[i] != map.elementTest.Roads_Position[j]){
                         *  /*if (Vector3.Distance(map.elementTest.Roads_Position[i].transform.position, map.elementTest.Roads_Position[j].transform.position) < map.distance_Check)
                         *      map.elementTest.Roads_Position[i].GetComponent<InspectElement>().neighborHex.Add(map.elementTest.Roads_Position[j]);
                         * }*/
                    }

                    /*if (map.elementTest.Roads_Position[i].GetComponent<InspectElement>().Event == InspectElement.Tyle_Evenement.Trafic_Jam)
                     *  map.elementTest.Roads_Position[i].GetComponent<MeshRenderer>().material = map.elementTest.traficJam_Mat;*/
                    if (map.elementTest.Roads_Position[i].GetComponent <InspectElement>().Event == InspectElement.Tyle_Evenement.Restaurant)
                    {
                        map.elementTest.Roads_Position[i].GetComponent <MeshRenderer>().material = map.elementTest.restaurant_Mat;
                    }
                    else if (map.elementTest.Roads_Position[i].GetComponent <InspectElement>().Event == InspectElement.Tyle_Evenement.Chantier)
                    {
                        map.elementTest.Roads_Position[i].GetComponent <MeshRenderer>().material = map.elementTest.chantier_Mat;
                    }
                    else if (map.elementTest.Roads_Position[i].GetComponent <InspectElement>().Event == InspectElement.Tyle_Evenement.Monument)
                    {
                        map.elementTest.Roads_Position[i].GetComponent <MeshRenderer>().material = map.elementTest.monument_Mat;
                    }
                    else if (map.elementTest.Roads_Position[i].GetComponent <InspectElement>().Event == InspectElement.Tyle_Evenement.Feux_Rouge)
                    {
                        map.elementTest.Roads_Position[i].GetComponent <MeshRenderer>().material = map.elementTest.feux_Rouge_Mat;
                    }
                }
            }
        }

        //Not used anymore

        /*if (GUILayout.Button("Clear unnecessary color")){
         *  if (EditorUtility.DisplayDialog("Confirm Update ? ", "This will clear all unnecessary color in the map", "Update", "Do not Update")){
         *      foreach (Transform element in map.elementTest.isoSphere.transform){
         *          if (element.GetComponent<InspectElement>().type != InspectElement.Tyle_Type.CrossRoads && element.GetComponent<InspectElement>().type != InspectElement.Tyle_Type.Road)
         *              element.GetComponent<MeshRenderer>().material = map.elementTest.default_Mat;
         *      }
         *  }
         * }*/
    }
    void Update()
    {
        swipedRight = false;
        swipedLeft  = false;
        swipedUp    = false;
        swipedDown  = false;

        if (Input.touches.Length > 0)
        {
            Touch t = Input.GetTouch(0);
            if (t.phase == TouchPhase.Began)
            {
                startPos  = new Vector2(t.position.x / (float)Screen.width, t.position.y / (float)Screen.width);
                startTime = Time.time;
            }
            if (t.phase == TouchPhase.Ended)
            {
                if (Time.time - startTime > MAX_SWIPE_TIME) // press too long
                {
                    return;
                }

                Vector2 endPos = new Vector2(t.position.x / (float)Screen.width, t.position.y / (float)Screen.width);
                Vector2 swipe  = new Vector2(endPos.x - startPos.x, endPos.y - startPos.y);

                if (swipe.magnitude < MIN_SWIPE_DISTANCE) // Too short swipe
                {
                    return;
                }

                if (Mathf.Abs(swipe.x) > Mathf.Abs(swipe.y))
                {     // Horizontal swipe
                    if (swipe.x > 0)
                    { //Right
                        directionIntX     = 0;
                        directionIntZ     = 1;
                        directionSupposed = "right";
                    }
                    else
                    {//Left
                        directionIntX     = 0;
                        directionIntZ     = -1;
                        directionSupposed = "left";
                    }
                }
                else
                {     // Vertical swipe
                    if (swipe.y > 0)
                    { //Top
                        directionIntX     = -1;
                        directionIntZ     = 0;
                        directionSupposed = "Up";
                    }
                    else
                    {//Bot
                        directionIntX     = 1;
                        directionIntZ     = 0;
                        directionSupposed = "Down";
                    }
                }
            }
        }

        if (debugWithArrowKeys)
        {
            swipedDown  = swipedDown || Input.GetKeyDown(KeyCode.DownArrow);
            swipedUp    = swipedUp || Input.GetKeyDown(KeyCode.UpArrow);
            swipedRight = swipedRight || Input.GetKeyDown(KeyCode.RightArrow);
            swipedLeft  = swipedLeft || Input.GetKeyDown(KeyCode.LeftArrow);
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        if (swipedLeft)
        {
            directionIntZ     = (int)Math.Round(Input.GetAxisRaw("Horizontal"));
            directionSupposed = "left";
        }
        else if (swipedRight)
        {
            directionIntZ     = (int)Math.Round(Input.GetAxisRaw("Horizontal"));
            directionSupposed = "right";
        }
        if (swipedDown)
        {
            directionIntX     = -(int)Math.Round(Input.GetAxisRaw("Vertical"));
            directionSupposed = "Down";
        }
        else if (swipedUp)
        {
            directionIntX     = -(int)Math.Round(Input.GetAxisRaw("Vertical"));
            directionSupposed = "Up";
        }

        if (directionSupposed != "")
        {
            int dist_min = int.MaxValue;
            for (int i = 0; i < list_TurnablePosition.Count; ++i)
            {
                int tmp_dist = 0;
                for (int j = 0; j < finalPath.Count; ++j)
                {
                    if (list_TurnablePosition[i].gameObject == finalPath[j].gameObject)
                    {
                        if (tmp_dist < dist_min)
                        {
                            dist_min    = tmp_dist;
                            pointToTurn = list_TurnablePosition[i];
                            break;
                        }
                    }
                    else
                    {
                        ++tmp_dist;
                    }
                }
            }
            if (pointToTurn != null && !derived)
            {
                foreach (Transform element in pointToTurn.neighborHex)
                {
                    direction = pointToTurn.transform.position - element.position;
                    if (direction.z == directionIntZ && direction.x == directionIntX)
                    {
                        target = element;
                        for (int j = 0; j < finalPath.Count; ++j)
                        {
                            if (finalPath[j].gameObject == pointToTurn.gameObject && j > 0)
                            {
                                privateCube = finalPath[j - 1];
                            }
                        }
                    }
                }
                var tmp = pointToTurn.GetComponent <Walkable>();

                if (target != null)
                {
                    //Block the road for the pathfindings
                    foreach (WalkPath Roads in tmp.possiblePaths)
                    {
                        if (Roads.target.gameObject != target.gameObject && Roads.target.gameObject != privateCube.gameObject)
                        {
                            Roads.active = false;
                        }
                    }

                    //Change material to road if the cube has not been visited
                    for (int i = finalPath.Count - 1; i >= 0; --i)
                    {
                        if (!finalPath[i].GetComponent <InspectElement>().visited)
                        {
                            finalPath[i].GetComponent <MeshRenderer>().material = controllerMat.road;
                            finalPath.RemoveAt(i);
                        }
                    }
                    SetMovement(false);
                    finalPath.Clear();
                    if (!derived && manager.Gettmp_target() != null)
                    {
                        manager.Settmp_target(null);
                    }
                    Clicked_NewFindPath(currentCube);
                    SetMovement(true);

                    directionSupposed = "";
                    swipedRight       = false;
                    swipedLeft        = false;
                    swipedUp          = false;
                    swipedDown        = false;

                    //Open back the path
                    foreach (WalkPath element in tmp.possiblePaths)
                    {
                        if (!element.active)
                        {
                            element.active = true;
                        }
                    }
                    index = 1;
                    //Visual indication to know where the point to turn is
                    //pointToTurn.GetComponent<MeshRenderer>().material = controllerMat.restaurant_Mat;
                }
                else
                {
                    //Corriger cette erreur -> si aucune target n'est trouvée, on nettoie le path et il ne se passe rien d'autre
                    derived = true;
                    for (int i = finalPath.Count - 1; i >= 0; --i)
                    {
                        if (!finalPath[i].GetComponent <InspectElement>().visited)
                        {
                            finalPath[i].GetComponent <MeshRenderer>().material = controllerMat.road;
                            finalPath.RemoveAt(i);
                        }
                    }
                    Clicked_NewFindPath(currentCube);
                }
                pointToTurn.GetComponent <MeshRenderer>().material = controllerMat.restaurant_Mat;
            }
        }
        else
        {
            directionIntX = 0;
            directionIntZ = 0;
        }

        if (move)
        {
            manager.timeTot += Time.deltaTime;
            RayCastDown();
            if (speed != 0)
            {
                if (finalPath.Count != 0)
                {
                    FollowPath();
                }
                if (currentCube != manager.GetmainTarget() && CheckTrafic())
                {
                    var truck = finalPath[index].GetComponent <InspectElement>().carInTheTile;
                    if (truck.transform.forward.x != 1 || truck.transform.forward.x != -1 &&
                        truck.transform.forward.z != 1 || truck.transform.forward.z != -1)
                    {
                        //Truck is turning
                        var   heading = car.transform.position - truck.transform.position;
                        float dot     = Vector3.Dot(heading, truck.transform.forward);
                        if (dot < 0)
                        {
                            if (truck.speed != 0)
                            {
                                speed = truck.speed - 0.1f;
                            }
                            else
                            {
                                speed = truck.speed;
                            }
                        }
                        else if (dot > 0)
                        {
                            //Frontal Collision
                            move           = false;
                            Time.timeScale = 0;
                            manager.truckCollision.SetActive(true);
                        }
                    }
                    else if (truck.transform.rotation.eulerAngles.y >= car.transform.rotation.eulerAngles.y + threesholdRotation_Traffic &&
                             truck.transform.rotation.eulerAngles.y >= car.transform.rotation.eulerAngles.y + threesholdRotation_Traffic)
                    {
                        //Frontal Collision
                        move           = false;
                        Time.timeScale = 0;
                        manager.truckCollision.SetActive(true);
                    }
                }
                else
                {
                    speed = optimalSpeed;
                }
            }
            else
            {
                if (currentCube != manager.GetmainTarget() && !CheckTrafic())
                {
                    speed = optimalSpeed;
                }
            }
        }

        if (manager.Gettmp_target() != null && currentCube == manager.Gettmp_target())
        {
            manager.Settmp_target(null);
            for (int i = finalPath.Count - 1; i >= 0; --i)
            {
                if (!finalPath[i].GetComponent <InspectElement>().visited)
                {
                    finalPath[i].GetComponent <MeshRenderer>().material = controllerMat.road;
                    finalPath.RemoveAt(i);
                }
            }

            SetMovement(false);
            finalPath.Clear();
            Clicked_NewFindPath(currentCube);
            SetMovement(true);
            index = 1;
        }
        else
        {
            if (manager.GetmainTarget() == currentCube && !manager.GetEvaluation())
            {
                //Level is Over
                move = false;
                manager.canvasGG.SetActive(true);
                manager.levelEnded = true;
                manager.EvaluateLevel();
            }
        }
    }