Exemplo n.º 1
0
 private static WallOrientations GetWallOrientation(Transform wall)
 {
     if (wall.CompareTag(TagDefnitions.Wall))
     {
         return(PositionUtility.IsAngleNear(wall.eulerAngles.y, 0f)
             ? WallOrientations.Right
             : WallOrientations.Up);
     }
     else if (wall.CompareTag(TagDefnitions.CornerWall))
     {
         var angle = wall.eulerAngles.y;
         if (PositionUtility.IsAngleNear(angle, 0f))
         {
             return(WallOrientations.UpRight);
         }
         if (PositionUtility.IsAngleNear(angle, -90f))
         {
             return(WallOrientations.UpLeft);
         }
         if (PositionUtility.IsAngleNear(angle, 90f))
         {
             return(WallOrientations.DownRight);
         }
         return(WallOrientations.DownLeft);
     }
     Debug.LogError(wall.name + " is an untagged wall. Unable to determine type.");
     return(WallOrientations.Right);
 }
Exemplo n.º 2
0
        private void CheckOverlappingWalls(CursorUtility.Result result)
        {
            var checkOffset = (result.Direction == Directions.Horizontal ? Vector3.right : Vector3.forward) * 0.5f;
            var checkPos    = result.GridEdgePosition + checkOffset;

            var overlappingWall = GetOverlappingWall(checkPos);

            if (overlappingWall == null)
            {
                if (replacedWall != null)
                {
                    bool isSamePosition  = Vector3.Distance(result.GridEdgePosition, replacedWall.transform.position) < 0.1f;
                    bool isSameDirection = PositionUtility.GetWallDirection(replacedWall.transform) == result.Direction;
                    if (isSameDirection && isSamePosition)
                    {
                        return;
                    }
                    replacedWall.SetActive(true);
                    replacedWall = null;
                }
                return;
            }

            if (replacedWall != null && overlappingWall != replacedWall)
            {
                replacedWall.SetActive(true);
            }
            replacedWall = overlappingWall;
            replacedWall.SetActive(false);
        }