public override void HandelTileWithProperty(Vector2Int _tileIndex, Vector2 _tileTopCenterScenePos, float _tileWidthInUnit, float _tileHeightInUnit, ITU_TmxLayerMeta _layerMeta, ITU_TsxEachTileMeta _tileMeta) { if (_tileMeta.property.HasProperty("IsWalkable")) { var pos = new Vector3(_tileTopCenterScenePos.x, -0.2f, _tileTopCenterScenePos.y - _tileHeightInUnit / 2f); var navTile = ITU_MeshTileMaker.MakeTile(_tileWidthInUnit, _tileHeightInUnit, 0.2f, navTempBlockMat); navTile.name = "NavTempBlock"; navTile.isStatic = true; navTile.transform.parent = mNavTempRootGo.transform; navTile.transform.localPosition = pos; } }
public override void OnRenderTile(Vector2Int _tileIndex, Vector2 _tileTopCenterScenePos, float _tileWidthInUnit, float _tileHeightInUnit, ITU_TmxLayerMeta _layerMeta, ITU_TsxEachTileMeta _tileMeta) { var minX = _tileTopCenterScenePos.x - _tileWidthInUnit / 2f; var maxX = _tileTopCenterScenePos.x + _tileWidthInUnit / 2f; var maxY = _tileTopCenterScenePos.y; var minY = _tileTopCenterScenePos.y - _tileHeightInUnit; minPosX = Mathf.Min(minPosX, minX); minPosY = Mathf.Min(minPosY, minY); maxPosX = Mathf.Max(maxPosX, maxX); maxPosY = Mathf.Max(maxPosY, maxY); }
private void DoPushTile(int _posX, int _posY, ITU_TsxEachTileMeta _tileMeta) { var tileWidthInUnit = (float)mMapMeta.tileWidthInPixel / mRenderSetting.pixelsPreUnit; var tileHeighInUnit = (float)mMapMeta.tileHeightInPixel / mRenderSetting.pixelsPreUnit; var halfTileWidthInUnit = tileWidthInUnit / 2; var tilesetHeightInUnit = (float)_tileMeta.tileHeightInPixel / mRenderSetting.pixelsPreUnit; Vector2 topCenterPos; ITU_MathUtils.TileTopCorner2World(_posX, _posY, tileWidthInUnit, tileHeighInUnit, mMapMeta.orientation == ITU_TmxRootMeta.ORIENTAION_STAGGERED, out topCenterPos); var bottomCenterPos = new Vector2(topCenterPos.x, topCenterPos.y - tileHeighInUnit); var v2 = new Vector3(bottomCenterPos.x - halfTileWidthInUnit, bottomCenterPos.y, 0); var v1 = new Vector3(bottomCenterPos.x + halfTileWidthInUnit, bottomCenterPos.y + tilesetHeightInUnit, 0); var v0 = new Vector3(v2.x, v1.y, 0); var v3 = new Vector3(v1.x, v2.y, 0); mVertices.Add(v0); mUVList.Add(_tileMeta.uv_p0); var indexV0 = mVertices.Count - 1; mVertices.Add(v1); mUVList.Add(_tileMeta.uv_p1); var indexV1 = mVertices.Count - 1; mVertices.Add(v2); mUVList.Add(_tileMeta.uv_p2); var indexV2 = mVertices.Count - 1; mVertices.Add(v3); mUVList.Add(_tileMeta.uv_p3); var indexV3 = mVertices.Count - 1; mTriangles.Add(indexV0); mTriangles.Add(indexV1); mTriangles.Add(indexV2); mTriangles.Add(indexV2); mTriangles.Add(indexV1); mTriangles.Add(indexV3); var tileIndex = new Vector2Int(_posX, _posY); mAllExtensionList.ForEach(x => x.OnRenderTile(tileIndex, topCenterPos, tileWidthInUnit, tileHeighInUnit, mLayerMeta, _tileMeta)); }
public override void HandelTileWithProperty(Vector2Int _tileIndex, Vector2 _tileTopCenterScenePos, float _tileWidthInUnit, float _tileHeightInUnit, ITU_TmxLayerMeta _layerMeta, ITU_TsxEachTileMeta _tileMeta) { //Only replace tile in deco layer with prefab //the support deco is also used in Ground layer,and it will not replace. if (_layerMeta.layerName != "Deco") { return; } if (_tileMeta.property.HasProperty("IsDeco")) { var ID = _tileMeta.property.GetProperty("ID").value; var PrefabDeco = ID == "Box" ? PrefabBoxDeco : PrefabSupportDeco; var go = PrefabUtility.InstantiatePrefab(PrefabDeco) as GameObject; go.transform.parent = prefabDecoRoot.transform; go.transform.localEulerAngles = new Vector3(90, 0, 0); go.transform.position = new Vector3(_tileTopCenterScenePos.x, 1f, _tileTopCenterScenePos.y - +_tileHeightInUnit / 2f); } }
public virtual void HandelTileWithProperty(Vector2Int _tileIndex, Vector2 _tileTopCenterScenePos, float _tileWidthInUnit, float _tileHeightInUnit, ITU_TmxLayerMeta _layerMeta, ITU_TsxEachTileMeta _tileMeta) { }
/// <summary> /// 根据在当前地图中指定的Gid,返回其所对应的TileMeta /// </summary> public static void GetTileMetaByGid(ITU_TmxRootMeta _mapMeta, int _gid, out ITU_TsxRootMeta _tilesetMeta, out ITU_TsxEachTileMeta _eachTileMeta) { foreach (var tilesetMeta in _mapMeta.tilsetList) { foreach (var tileMeta in tilesetMeta.eachTileMetaList) { if (tileMeta.gid == _gid) { _tilesetMeta = tilesetMeta; _eachTileMeta = tileMeta; return; } } } throw new Exception(string.Format("Can't find tile meta with gid {0} in Txm file {1}", _gid, _mapMeta.fileName)); }