Esempio n. 1
0
 private void SelectCell(Cell cell, Cell origin, bool mustBeEmpty, bool lineOfSight, bool addCellToAoe)
 {
     if (cell.IsWalkable == true)
     {
         if ((mustBeEmpty && cell.IsTaken != null) || Selection.Contains(MapInfos.ProjectionMap[cell.X, cell.Z]))
         {
             return;
         }
         if (lineOfSight)
         {
             RaycastHit hit;
             Vector3    startPos = origin.GetVector3PositionSimple() + new Vector3(0, 0.5f, 0);
             Vector3    endPos   = cell.GetVector3PositionSimple() + new Vector3(0, 0.5f, 0);
             float      dist     = Vector3.Distance(endPos, startPos);
             Physics.Raycast(startPos, endPos - startPos, out hit, dist);
             if (hit.collider != null)
             {
                 if (hit.collider.name != "Collider" || (hit.collider.name == "Collider" && hit.distance + 0.6f < dist))
                 {
                     NotInLOS.Add(MapInfos.ProjectionMap[cell.X, cell.Z]);
                     return;
                 }
             }
         }
         if (addCellToAoe)
         {
             AreaOfEffect.Add(cell);
         }
         Selection.Add(MapInfos.ProjectionMap[cell.X, cell.Z]);
     }
 }