/// <summary> /// /// </summary> /// <param name="size">size指的是xyz方向的长度,所以到侧墙,x和z应该互换</param> /// <param name="setType"></param> /// <param name="data"></param> public void GetMinMaxPos(MapUtil.IVector3 size, MapUtil.SetType setType, ref FurnitureInitData data) { data.m_MinPos = m_StartPos + size.MulVal(GameApp.Inst.m_MapGridUnityLenHalf); data.m_MaxPos = m_StartPos + m_Size.MulVal(GameApp.Inst.m_MapGridUnityLen) - size.MulVal(GameApp.Inst.m_MapGridUnityLenHalf); if (setType == MapUtil.SetType.WallOnFloor) { data.m_MaxPos.y = data.m_MinPos.y; } else if (setType == MapUtil.SetType.Wall)//墙上的不能贴地 { data.m_MinPos.y += GameApp.Inst.m_MapGridUnityLen; } //墙面可以互跳 if (m_Type == Enum_Wall.Wall) { data.m_MinPos.x -= GameApp.Inst.m_MapGridUnityLen; data.m_MaxPos.x += GameApp.Inst.m_MapGridUnityLen; } else if (m_Type == Enum_Wall.Left || m_Type == Enum_Wall.Right) { data.m_MaxPos.z += GameApp.Inst.m_MapGridUnityLen; } data.m_MinPos = AdjustFurn2Wall(size, false, data.m_MinPos); data.m_MaxPos = AdjustFurn2Wall(size, false, data.m_MaxPos); //Debug.LogWarning("min=" + MapUtil.Vector3String(data.m_MinPos) + " max=" + MapUtil.Vector3String(data.m_MaxPos) + " size=" + size); }
/// <summary> /// 默认放一个位置 /// </summary> /// <returns></returns> public static RayClickPos GetFirstPos(MapUtil.SetType setType) { RayClickPos ret = new RayClickPos(); ret.pos = Vector3.zero; ret.wallType = Enum_Wall.Wall; Vector3 pos = new Vector3(Screen.width / 2, Screen.height / 2, 0f); if (setType == SetType.Floor) { pos.y = Screen.height / 4; } Ray ray = Camera.main.ScreenPointToRay(pos); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, 100, JerryUtil.MakeLayerMask(JerryUtil.MakeLayerMask(false), GetWallLayerNames(setType)))) { if (hitInfo.collider != null && hitInfo.collider.gameObject != null) { ret.pos = hitInfo.point; ret.wallType = WallLayer2WallEnum(hitInfo.collider.gameObject.layer); } } else { Debug.LogError("first error"); } return(ret); }
public void ShowGrid(MapUtil.SetType setType, int par = 6) { switch (setType) { case MapUtil.SetType.Floor: { m_Floor = true; } break; case MapUtil.SetType.WallOnFloor: { m_WallStart = 0; m_WallEnd = par; } break; case MapUtil.SetType.Wall: { m_WallStart = 1; m_WallEnd = 6; } break; } RefreshGrid(); }
public static FurnitureInitData InitFurn(IVector3 size, MapUtil.SetType setType, FurnitureInitData oldData, Enum_Wall wall) { if (oldData == null) { oldData = new FurnitureInitData(); } oldData.m_CurWall = wall; GetMap(oldData.m_CurWall).GetMinMaxPos(size, setType, ref oldData); oldData.m_AdjustPar = GetMap(oldData.m_CurWall).GetAdjustPar(size); return(oldData); }
public void ShowGrid(MapUtil.SetType setType, int par = 6) { DoClean(); switch (setType) { case MapUtil.SetType.Floor: { AddOneConfig(m_Floor); } break; case MapUtil.SetType.WallOnFloor: { m_Left.m_Size.y = par; m_Right.m_Size.y = par; m_Wall.m_Size.y = par; m_Left.m_StartPos.y = GameApp.Inst.GetHouseYOffset; m_Right.m_StartPos.y = GameApp.Inst.GetHouseYOffset; m_Wall.m_StartPos.y = GameApp.Inst.GetHouseYOffset; AddOneConfig(m_Left); AddOneConfig(m_Right); AddOneConfig(m_Wall); } break; case MapUtil.SetType.Wall: { m_Left.m_Size.y = 5; m_Right.m_Size.y = 5; m_Wall.m_Size.y = 5; m_Left.m_StartPos.y = GameApp.Inst.GetHouseYOffset + GameApp.Inst.m_MapGridUnityLen; m_Right.m_StartPos.y = GameApp.Inst.GetHouseYOffset + GameApp.Inst.m_MapGridUnityLen; m_Wall.m_StartPos.y = GameApp.Inst.GetHouseYOffset + GameApp.Inst.m_MapGridUnityLen; AddOneConfig(m_Left); AddOneConfig(m_Right); AddOneConfig(m_Wall); } break; } ApplyDraw(); }