Esempio n. 1
0
 void Update()
 {
     GameObject[] obstacles = GameObject.FindGameObjectsWithTag("Obstacle"); //procura os obstaculos na tela
     if (obstacles.Length > 0)
     {
         distance   = new float[obstacles.Length];
         height     = new float[obstacles.Length];
         speed      = new float[obstacles.Length];
         width      = new float[obstacles.Length];
         heightJump = new float[obstacles.Length];
         int   ind           = 0;
         float minorDistance = 1000f;
         for (int i = 0; i < obstacles.Length; i++)
         {
             obstacleController = obstacles[i].GetComponent <ObstacleController>();
             height[i]          = obstacles[i].transform.position.y; //+ obstacleController.GetHeight()
             speed[i]           = obstacleController.GetSpeed();
             width[i]           = obstacleController.GetWidth();
             distance[i]        = obstacles[i].transform.position.x - gameObject.transform.position.x;
             heightJump[i]      = gameObject.transform.position.y;
         }
         for (int j = 0; j < obstacles.Length; j++)
         {
             if (distance[j] > 0)
             {
                 if (distance[j] < minorDistance)
                 {
                     minorDistance = distance[j];
                     ind           = j;
                 }
             }
         }
         NeuralNetwork(distance[ind], height[ind], speed[ind], width[ind], heightJump[ind]);
     }
 }