예제 #1
0
 private void ConnectTilesAndAddToResult(GameObject tile1, GameObject tile2, List <GameObject> result, TileScript2D.TileType type)
 {
     RaycastHit[] tilesHits = RayCastUtils.RaycastTo(tile1.transform, tile2.transform, onlyTilesLayerMask);
     foreach (RaycastHit hit in tilesHits)
     {
         GameObject tile = hit.collider.gameObject;
         if (tile != tile1 && tile != tile2)
         {
             result.Add(tile);
             hit.collider.GetComponent <TileScript2D>().SetTileType(type);
         }
     }
 }
예제 #2
0
 public void CheckFog()
 {
     if (!suspended)
     {
         List <RaycastHit> actualHits = new List <RaycastHit>();
         rayCastTarget.position = this.transform.position + new Vector3(0.1f, 0, 0);
         for (int i = 0; i < 360; i += 1)
         {
             rayCastTarget.RotateAround(this.transform.position, new Vector3(0, 1, 0), ((float)i));
             actualHits.AddRange(RayCastUtils.RaycastTo(this.transform.position, rayCastTarget.position, fogAndWalls, lineOfSightObstructing, float.PositiveInfinity));
             //Debug.Log("rotated to "+rayCastTarget.position);
         }
         //casto un raggio anche verso il giocatore, per eliminare la nebbia su di lui
         rayCastTarget.position = this.transform.position + new Vector3(0, 2, 0);
         actualHits.AddRange(RayCastUtils.RaycastTo(rayCastTarget.position, this.transform.position, fogAndWalls, lineOfSightObstructing, 1));
         //Debug.Log("CheckFog hit " + actualHits.Count + " items");
         foreach (RaycastHit hit in actualHits)
         {
             Destroy(hit.collider.gameObject);
         }
         Suspend();
     }
 }