public void ShowTempObject(UIManager.UIObjectType objectTypeToDisplay, Vector3 position) { //If no hologram, grab one if (m_objectHologram == null) { m_objectHologram = CacheManager.Singleton.RequestInteriorDoor(); m_objectHologram.gameObject.SetActive(true); m_objectHologram.transform.parent = null; m_objectHologram.SetMaterial(PrefabAssets.Singleton.doorHologramMat); switch (objectTypeToDisplay) { case UIManager.UIObjectType.Door: m_objectHologram.tileType = GroundManager.GroundTileType.Door; break; } } m_hologramObjectLocationValid = false; Vec2Int tilePos = GroundManager.Singleton.ConvertWorldPositionToTile(position); m_objectHologram.transform.position = new Vector3(tilePos.x + m_objectHologram.defaultOffset.x, 0, tilePos.y + m_objectHologram.defaultOffset.z); Color holoColor = PrefabAssets.Singleton.hologramColor; GroundManager.GroundTileType curTile = m_associatedGroundData.GetTileType(tilePos); if (m_objectHologram.tileType == GroundManager.GroundTileType.Door) { if (curTile == GroundManager.GroundTileType.Wall) { int index = m_associatedGroundData.ConvertVec2IntToInt(tilePos); BaseGroundObject baseObj = m_groundTilesGOs[index]; if (baseObj is WallObject) { GroundManager.WallType wallType = (baseObj as WallObject).WallType; //Doors can only go on straight walls if (wallType == GroundManager.WallType.Straight) { m_objectHologram.transform.rotation = baseObj.transform.rotation; m_hologramObjectLocationValid = true; } else { holoColor = PrefabAssets.Singleton.hologramColorError; } } } else { holoColor = PrefabAssets.Singleton.hologramColorError; } } m_objectHologram.SetMaterialColor(holoColor); }
public void SetWallType(GroundManager.WallType wallType) { m_wallType = wallType; }
/// <summary> /// Useful for wall tiles /// </summary> /// <param name="tileIndex"></param> /// <param name="xz"></param> /// <param name="neighborIndex"></param> /// <param name="wallType"></param> public void UpdateGraphicalTile(int tileIndex, Vec2Int xz, int neighborIndex, GroundManager.WallType wallType) { WallObject wallPiece = null; //m_tilePos float rot = 0f; if (m_groundTilesGOs[tileIndex] == null) { if (wallType == GroundManager.WallType.Corner) { wallPiece = CacheManager.Singleton.RequestWallCorner();//(WallObject)GameObject.Instantiate(PrefabAssets.Singleton.prefabWallCorner); //Rotation if (neighborIndex == 6) { //wallPiece.transform.rotation = Quaternion.Euler(0, 90f + wallPiece.defaultOrientation, 0f); rot = 90f + wallPiece.defaultOrientation; } else if (neighborIndex == 1 || neighborIndex == 3 || neighborIndex == 2) { //wallPiece.transform.rotation = Quaternion.Euler(0, 180f + wallPiece.defaultOrientation, 0f); rot = 180f + wallPiece.defaultOrientation; } else if (neighborIndex == 9) { //wallPiece.transform.rotation = Quaternion.Euler(0, 270f + wallPiece.defaultOrientation, 0f); rot = 270f + wallPiece.defaultOrientation; } } else if (wallType == GroundManager.WallType.Cross) { wallPiece = CacheManager.Singleton.RequestWallCross();//(WallObject)GameObject.Instantiate(PrefabAssets.Singleton.prefabWallCross); } else if (wallType == GroundManager.WallType.ThreeWay) { wallPiece = CacheManager.Singleton.RequestWallT(); if (neighborIndex == 13 || neighborIndex == 77 || neighborIndex == 205) { rot = wallPiece.defaultOrientation + 270f; } else if (neighborIndex == 135 || neighborIndex == 7) { rot = wallPiece.defaultOrientation + 90f; } else if (neighborIndex == 11 || neighborIndex == 151 || neighborIndex == 75 || neighborIndex == 139) { rot = wallPiece.defaultOrientation + 180f; } } else //if (wallType == WallType.Straight) { wallPiece = CacheManager.Singleton.RequestWallStraight();//(WallObject)GameObject.Instantiate(PrefabAssets.Singleton.prefabWallStraight); //Horizontal if (neighborIndex == 37 || neighborIndex == 149 || neighborIndex == 133 || neighborIndex == 21 || neighborIndex == 69 || neighborIndex == 5 || neighborIndex == 101 || neighborIndex == 229 || neighborIndex == 213 || neighborIndex == 117 || neighborIndex == 181 || neighborIndex == 197 || neighborIndex == 53) { //wallPiece.transform.rotation = Quaternion.Euler(0, wallPiece.defaultOrientation + 90f, 0f); rot = wallPiece.defaultOrientation; } } wallPiece.AssignToPosition(xz, rot, true); wallPiece.SetWallType(wallType); } else { wallPiece = (m_groundTilesGOs[tileIndex] as WallObject); //If the exist type doesn't match the desired type, return it, and then get a new one if (wallPiece.WallType != wallType) { switch (wallPiece.WallType) { case GroundManager.WallType.Corner: CacheManager.Singleton.ReturnWallCorner(wallPiece); break; case GroundManager.WallType.Cross: CacheManager.Singleton.ReturnWallCross(wallPiece); break; case GroundManager.WallType.Straight: CacheManager.Singleton.ReturnWallStraight(wallPiece); break; case GroundManager.WallType.ThreeWay: CacheManager.Singleton.ReturnWallT(wallPiece); break; } SetTileGO(tileIndex, null); wallPiece = null; UpdateGraphicalTile(tileIndex, xz, neighborIndex, wallType); return; } } SetTileGO(tileIndex, wallPiece); }