Esempio n. 1
0
 public void EvaluateNeighbor()
 {
     if (thisNodeIsCurrentNode)
     {
         if (checkedn && checkede && checkeds && checkedw)
         {
             thisNodeIsCurrentNode = false;
             marker.SetActive(false);
             if (previousNode == null)
             {
                 MazeGenComplete.Raise();
             }
             else
             {
                 previousNode.GetComponent <MazeNode>().ActivateThisNode();
             }
         }
         else
         {
             Vector3    direction = GetUncheckedDirection();
             RaycastHit hit;
             LayerMask  lm = ~0;
             if (Physics.Raycast(transform.position + new Vector3(0, 2.75f, 0), direction, out hit, 6f, lm))
             {
                 if (hit.collider.gameObject.name == "UnVisited")
                 {
                     MazeNode mn = hit.collider.gameObject.GetComponentInParent <MazeNode>();
                     if (direction.x > 0)
                     {
                         Destroy(mn.negXWall);
                         Destroy(posXWall);
                     }
                     else if (direction.x < 0)
                     {
                         Destroy(mn.posXWall);
                         Destroy(negXWall);
                     }
                     else if (direction.z > 0)
                     {
                         Destroy(mn.negZWall);
                         Destroy(posZWall);
                     }
                     else if (direction.z < 0)
                     {
                         Destroy(mn.posZWall);
                         Destroy(negZWall);
                     }
                     thisNodeIsCurrentNode = false;
                     mn.previousNode       = gameObject;
                     mn.ActivateThisNode();
                 }
             }
             // else
             //     Debug.Log("Didnt Hit Anything");
             Invoke("EvaluateNeighbor", .05f / timeFactor.Value);
         }
     }
     else
     {
         marker.SetActive(false);
     }
 }