public Seed(int x, int y, ref TileSystem tileSystem) { this.TileSystem = tileSystem; X = x; Y = y; }
private void Start() { // Use large system be default _currentSystem = largeSystem; _usingLarge = true; _brush = largeBrush; // Ignore last painted state _lastPainted = new TileIndex(-1, -1); }
void Awake() { tileSystem = GameObject.Find(TILE_MAP).GetComponent<TileSystem>(); mapColumns = tileSystem.ColumnCount; mapRows = tileSystem.RowCount; PaintBaseTiles(); CarveRandomRooms(); }
void Awake() { map = GameObject.Find(TILE_MAP).GetComponent<TileSystem>(); mapColumns = map.ColumnCount; mapRows = map.RowCount; rooms = new List<ProcRoom>(); GenerateDungeon(); }
void Awake() { map = GameObject.Find(TILE_MAP).GetComponent<TileSystem>(); mapColumns = map.ColumnCount; mapRows = map.RowCount; rooms = new List<ProcRoom>(); halls = new List<ProcHall>(); crawlways = new List<ProcHall>(); GenerateRandomDungeons(); }
public static GameObject GetTileBelow(this Transform transform, TileSystem tileSystem, int direction) { int convertedX = (int) Math.Floor(transform.position.x); int convertedY = (int) Math.Floor(Math.Abs(transform.position.y)); TileData tile = tileSystem.GetTile(convertedY, convertedX + direction); if (tile != null) { return tile.gameObject; } return null; }
void Start() { tileSystem = GameObject.Find(TILE_MAP).GetComponent<TileSystem>(); Vector3 tileSystemSize = new Vector3( tileSystem.ColumnCount * tileSystem.CellSize.x, tileSystem.RowCount * tileSystem.CellSize.y, tileSystem.CellSize.z ); leftBound = 0f; rightBound = tileSystemSize.x; lowerBound = -(tileSystemSize.y); upperBound = 0f; }
void Start() { spriteWidth = GetComponent<Renderer>().bounds.size.x; spriteHeight = GetComponent<Renderer>().bounds.size.y; tileSystem = GameObject.Find(TILE_MAP).GetComponent<TileSystem>(); Vector3 tileSystemSize = new Vector3( tileSystem.ColumnCount * tileSystem.CellSize.x, tileSystem.RowCount * tileSystem.CellSize.y, tileSystem.CellSize.z ); leftBound = 0f; rightBound = tileSystemSize.x; lowerBound = -(tileSystemSize.y); upperBound = 0f; }
// transform extensions for checking nearby tile data public static GameObject GetTileInfo(this Transform transform, TileSystem tileSystem, int xDirection, int yDirection) { // grabs tile info at a given transform: // x = 0, y = 0 will get you the tile the transform occupies // plus or minus x or y will get you tiles backwards, forwards, up or down int convertedX = (int) Math.Floor(transform.position.x); int convertedY = (int) Math.Ceiling(Math.Abs(transform.position.y)); TileData tile = tileSystem.GetTile(convertedY + yDirection, convertedX + xDirection); if (tile != null) { return tile.gameObject; } return null; }
/// <inheritdoc/> public override void OnDrawGizmos(TileSystem system) { // We need to populate properties of `IBrushContext` for preview generation. var brush = (PreviousToolEvent != null && PreviousToolEvent.IsRightButtonPressed) ? ToolUtility.SelectedBrushSecondary : ToolUtility.SelectedBrush; if (!PlopUtility.CanPlopWithBrush(brush)) { return; } // Do not draw immediate preview when mouse is positioned over a plop // unless overpainting is permitted. if (!this.allowOverpaint && ToolUtility.ActivePlop != null) { return; } // Offset preview against mouse position. Vector3 placementPoint = PlopUtility.PositionFromPlopPoint(system, this.ApplySnapping(this.localMousePoint)); ImmediatePreviewUtility.Matrix = system.transform.localToWorldMatrix * MathUtility.TranslationMatrix(placementPoint); this._fakeContext.TileSystem = system; this._fakeContext.Brush = brush; // Pretend to paint tile so that we can see its data beforehand! var previewTile = ImmediatePreviewUtility.GetPreviewTileData(this._fakeContext, brush, ToolUtility.Rotation); // Plop tool does not support orientations. previewTile.orientationMask = 0; var args = GetPaintingArgs(brush); if (args.variation == Brush.RANDOM_VARIATION) { args.variation = this.PreRandomizeVariation(brush, 0); } previewTile.variationIndex = (byte)args.ResolveVariation(0); brush.OnDrawImmediatePreview(this._fakeContext, previewTile, ImmediatePreviewUtility.PreviewMaterial, brush); }
void Start() { tileSystem = GameObject.Find(TILE_MAP).GetComponent <TileSystem>(); Assert.IsNotNull(tileSystem); spriteWidth = renderer.bounds.size.x; spriteHeight = renderer.bounds.size.y; var tileSystemSize = new Vector3( tileSystem.ColumnCount * tileSystem.CellSize.x, tileSystem.RowCount * tileSystem.CellSize.y, tileSystem.CellSize.z ); leftBound = 0f; rightBound = tileSystemSize.x; lowerBound = -(tileSystemSize.y); upperBound = 0f; }
private void projectionWorkerDoWork(object sender, DoWorkEventArgs args) { var worker = sender as BackgroundWorker; for (int i = 21; i > 0; i--) { if (worker != null && worker.CancellationPending) { args.Cancel = true; break; } int pixelX; int pixelY; TileSystem.LatLongToPixelXY(Location.Latitude, Location.Longitude, i, out pixelX, out pixelY); ProjectedPoints.Add(i, new Point(pixelX, pixelY)); } Initalized = true; }
// Use this for initialization void Start() { GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; GetComponent<Renderer>().receiveShadows = true; player = GameObject.Find("SB_Player"); tileSystem = player.GetComponent<SB_PlayerController>().tileSystem; startPos = tileSystem.GetTile(startTile).gameObject.transform.position; startPos.y = .74f; transform.position = startPos; endPos = tileSystem.GetTile(endTile).gameObject.transform.position; endPos.y = .74f; gameCon = player.GetComponent<SB_GameController>(); seeker = GetComponent<Seeker>(); currentPos = 0; controller = GetComponent<CharacterController>(); //A* function that generates the closest path from startPos to endPos. seeker.StartPath(startPos, endPos, OnPathComplete); to = true; from = false; updatedPos = false; moved = true; isAlarmed = false; }
private static void DrawTileSystemHandle(TileSystem system) { // Apply rotation to gizmos. Matrix4x4 originalMatrix = Gizmos.matrix; Gizmos.matrix = system.transform.localToWorldMatrix; Vector3 tileSize = new Vector3(0.5f, 0.5f, 0.5f); Vector3 boundsSize = new Vector3(tileSize.x * 3, tileSize.y * 3, 0f); // Prepare cursor to draw rows. Vector3 cursor = Vector3.zero; Vector3 cursorEnd = Vector3.zero; Gizmos.color = new Color(0.35f, 0.35f, 0.35f, 0.3f); Gizmos.DrawCube(boundsSize / 2f + new Vector3(0f, 0f, 0.01f), boundsSize); Gizmos.color = new Color(0.35f, 0.35f, 0.35f, 0.5f); cursorEnd.x += 3 * tileSize.x; // Draw rows. for (int rowIndex = 0; rowIndex < 4; ++rowIndex) { Gizmos.DrawLine(cursor, cursorEnd); cursor.y += tileSize.y; cursorEnd.y += tileSize.y; } // Prepare cursor to draw columns. cursorEnd = cursor = Vector3.zero; cursorEnd.y += 3 * tileSize.y; // Draw columns. for (int columnIndex = 0; columnIndex < 4; ++columnIndex) { Gizmos.DrawLine(cursor, cursorEnd); cursor.x += tileSize.x; cursorEnd.x += tileSize.x; } // Restore original gizmos matrix. Gizmos.matrix = originalMatrix; }
public bool clear2Door() { try { floorGo[2].SetActive(true); TileSystem ts_object = floorGo[2].GetComponent <TileSystem>(); GameObject door = GameObject.Find("Floor2/chunk_0_0/door-01_3").gameObject; TileData tile = ts_object.GetTile(6, 1); GameObject.Destroy(door.gameObject); tile.Clear(); //_GDM.sceneData[2][6, 1] = 1; floorGo[2].SetActive(false); return(true); } catch { return(false); } }
/// <inheritdoc/> public override void OnDrawGizmos(TileSystem system) { var brush = (PreviousToolEvent != null && PreviousToolEvent.IsRightButtonPressed) ? ToolUtility.SelectedBrushSecondary : ToolUtility.SelectedBrush; if (brush == null) { return; } // Do not draw immediate preview when larger radius is selected. if (this.NozzleSize > 1) { return; } // Only draw immediate preview when not disabled on per-brush basis. if (!brush.disableImmediatePreview) { // Preview is forced when see-through material is used. bool force = ImmediatePreviewUtility.IsSeeThroughPreviewMaterial; // Only display immediate preview if it differs from actual tile. var existingTile = ToolUtility.ActiveTile; if (existingTile == null || existingTile.brush != brush || existingTile.PaintedRotation != ToolUtility.Rotation || force) { var context = Brush.GetSharedContext(brush, system, ToolUtility.ActiveTileIndex); var previewTile = ImmediatePreviewUtility.GetPreviewTileData(context, brush, ToolUtility.Rotation); var args = this.GetPaintingArgs(brush); if (args.variation == Brush.RANDOM_VARIATION) { args.variation = this.PreRandomizeVariation(brush, previewTile.orientationMask); } previewTile.variationIndex = (byte)args.ResolveVariation(previewTile.orientationMask); ImmediatePreviewUtility.Matrix = system.transform.localToWorldMatrix; brush.OnDrawImmediatePreview(context, previewTile, ImmediatePreviewUtility.PreviewMaterial, brush); } } }
private static void DrawTileSystemGizmosNotSelected(TileSystem system) { // Apply rotation to gizmos. Matrix4x4 originalMatrix = Gizmos.matrix; Gizmos.matrix = system.transform.localToWorldMatrix; Gizmos.color = new Color(0.35f, 0.35f, 0.35f, 0.5f); // Prepare cursor to draw rows. Vector3 cellSize = system.CellSize; Vector3 boundsSize = new Vector3(cellSize.x * system.ColumnCount, -cellSize.y * system.RowCount, 0f); // Prepare cursor to draw rows. Vector3 cursor = Vector3.zero; Vector3 cursorEnd = Vector3.zero; cursorEnd.x += 1 * boundsSize.x; // Draw rows. for (int rowIndex = 0; rowIndex < 2; ++rowIndex) { Gizmos.DrawLine(cursor, cursorEnd); cursor.y += boundsSize.y; cursorEnd.y += boundsSize.y; } // Prepare cursor to draw columns. cursorEnd = cursor = Vector3.zero; cursorEnd.y += 1 * boundsSize.y; // Draw columns. for (int columnIndex = 0; columnIndex < 2; ++columnIndex) { Gizmos.DrawLine(cursor, cursorEnd); cursor.x += boundsSize.x; cursorEnd.x += boundsSize.x; } // Restore original gizmos matrix. Gizmos.matrix = originalMatrix; }
private IEnumerator CheckTime() { while (bCheckingTime) { yield return(null); //일시정지 중, 또는 타일이 터지거나 스킬 사용 중에는 시간이 흐르지 않는다. // if (TileSystem.CanClickTile() && !bPause && freezingTime == 0f) { remainTime -= Time.deltaTime; if (remainTime <= 0f) { remainTime = 0f; bCheckingTime = false; GameManager.GameOver(true); } if (gameTimeUpdateCallback != null) { gameTimeUpdateCallback(remainTime); } } if (bCheckingTime) { if (remainTime <= Define.warningTime && !warningMode) { warningMode = true; scoreAssistance.SetWarningBonus(); SoundManager.GetInstance().FadeInAndPlayBGM(Define.SoundType.TickTock); SoundManager.GetInstance().FadeInAndPlayBGM(Define.SoundType.TickTockBack); SoundManager.GetInstance().FadeOutAndStopBGM(Define.SoundType.GameBGM); if (warningUICallback != null) { warningUICallback(warningMode); } } } } }
private bool BuildTileInfoLabel() { preprocessError = null; Point start = Util.LatLonToTileCoordinate((double)nudStartLat.Value, (double)nudStartLon.Value, (int)nudZoom.Value); Point end = Util.LatLonToTileCoordinate((double)nudEndLat.Value, (double)nudEndLon.Value, (int)nudZoom.Value); if (start.X > end.X || start.Y > end.Y) { lblTileInfo.Text = preprocessError = "Upper-Left coordinate must be above and to the left of Lower-Right coordinate."; return false; } StringBuilder sb = new StringBuilder(); sb.AppendLine("Upper-Left Tile:"); sb.AppendLine(" " + start.X + ", " + start.Y); sb.AppendLine(); sb.AppendLine("Lower-Right Tile:"); sb.AppendLine(" " + end.X + ", " + end.Y); sb.AppendLine(); long tilesWide = ((end.X - (long)start.X) + 1); long tilesTall = ((end.Y - (long)start.Y) + 1); long totalTiles = tilesWide * tilesTall; sb.AppendLine("Tiles: " + totalTiles + " (" + tilesWide + "x" + tilesTall + ")"); long maxMapTiles = 10922; if (totalTiles > 10922) { sb.AppendLine("TOO MANY MAP TILES!"); sb.AppendLine("Please choose " + maxMapTiles + " or fewer!"); preprocessError = "You have currently selected " + totalTiles + " map tiles, which is too large for this program to stitch because the uncompressed format would exceed the capacity of a byte array." + Environment.NewLine + Environment.NewLine + "Please reduce the selection size or zoom out until you have selected " + maxMapTiles + " or fewer tiles."; } sb.AppendLine(); sb.AppendLine("Megapixels: " + ((tilesWide * 256 * tilesTall * 256) / 1000000d).ToString("0") + " (" + (tilesWide * 256) + "x" + (tilesTall * 256) + ")"); sb.AppendLine(); double groundRes = TileSystem.GroundResolution((double)nudStartLat.Value, (int)nudZoom.Value); string sGroundRes; if (groundRes > 0 && groundRes < 1) sGroundRes = (1 / groundRes).ToString("0.##") + " pixels/m"; else sGroundRes = groundRes.ToString("0.##") + " m/pixel"; sb.Append("Ground Resolution: " + sGroundRes); lblTileInfo.Text = sb.ToString(); return true; }
/// <summary> /// Get minimum and maximum bounds from anchor and target tile indices clamped within /// bounds of tile system. /// </summary> /// <param name="system">Tile system.</param> /// <param name="anchor">Anchor index.</param> /// <param name="target">Target index.</param> /// <param name="min">Minimum tile index.</param> /// <param name="max">Maximum tile index.</param> /// <param name="uniform">Indicates whether bounds should be uniformly sized.</param> public static void GetRectangleBoundsClamp(TileSystem system, TileIndex anchor, TileIndex target, out TileIndex min, out TileIndex max, bool uniform) { GetRectangleBounds(anchor, target, out min, out max, uniform); if (min.row < 0) { min.row = 0; } if (min.column < 0) { min.column = 0; } if (max.row >= system.RowCount) { max.row = system.RowCount - 1; } if (max.column >= system.ColumnCount) { max.column = system.ColumnCount - 1; } }
private void OnDrag(Vector2 delta) { if (isMoving || !GameManager.IsPlaying() || !TileSystem.CanClickTile()) { if (clickedTile == null) { return; } else if (clickedTile != this) { return; } } if (clickedTile != this) { return; } mTrans.localPosition += new Vector3(delta.x * ScreenSizeGetter.invRate, delta.y * ScreenSizeGetter.invRate, 0f); }
public override Uri GetUri(int x, int y, int zoomLevel) { if (zoomLevel > 0) { //var Url = string.Format(UriFormat, Server, MapMode, zoomLevel, x, y); double lat; double lon; int xPix; int yPix; TileSystem.TileXYToPixelXY(x, y, out xPix, out yPix); xPix += 256 / 2; yPix += 256 / 2; TileSystem.PixelXYToLatLong(xPix, yPix, zoomLevel, out lat, out lon); var Url = string.Format(UriFormat, lat, lon, zoomLevel, MarkOnMap.Current.Latitude, MarkOnMap.Current.Longitude); return(new Uri(Url)); } return(null); }
public void UpdatePosition(Vector2 position) { float speed = _status.speed + GetCurrentTileCell().GetProperties(eTileLayer.GROUND).speed; Vector2 destination = (Vector2)(_transform.position) + (position.normalized * speed * Time.deltaTime); TileSystem tileSystem = TileSystem.Instance; TileCell curTileCell = GetCurrentTileCell(); eTileDirection boundaryDirection = curTileCell.CheckTileBoundary(destination); sTilePosition nextTilePos = new sTilePosition(_tileX, _tileY); TileHelper.GetNextTilePosByTileDirection(boundaryDirection, ref nextTilePos); if (tileSystem.CanMoveTileCell(nextTilePos.tileX, nextTilePos.tileY)) { //타일 오프셋에 따른 캐릭터 y값 보정(des = des + (next.offset - cur.offset)) if (eTileDirection.IN_TILE != boundaryDirection) { int layerOrder = tileSystem.GetTileCell(nextTilePos.tileX, nextTilePos.tileY).GetGroundLayerOrder(); var sprites = GetComponentsInChildren <SpriteRenderer>(true); foreach (var spriteRenderer in sprites) { spriteRenderer.sortingOrder = layerOrder; } float curOffset = curTileCell.GetOffset(); float nextOffset = tileSystem.GetTileCell(nextTilePos.tileX, nextTilePos.tileY).GetOffset(); destination.y = destination.y + (nextOffset - curOffset); var layer = GetCurrentLayer(); tileSystem.GetTileCell(_tileX, _tileY).RemoveObject(this, layer); tileSystem.GetTileCell(nextTilePos).AddObject(this, layer); } _tileX = nextTilePos.tileX; _tileY = nextTilePos.tileY; //z값 -1 : 동일한 레이어 + 동일한 order 에서 캐릭터들이 타일보다 뒤에 있으면 안됨 transform.position = new Vector3(destination.x, destination.y, -1.0f); } }
/// <summary> /// Display user interface to clear all plops associated with a tile system. /// </summary> /// <param name="system">Tile system.</param> /// <exception cref="System.ArgumentNullException"> /// If <paramref name="system"/> is <c>null</c>. /// </exception> internal static void Command_ClearPlops(TileSystem system) { if (system == null) { throw new ArgumentNullException("system"); } if (!EditorUtility.DisplayDialog( TileLang.ParticularText("Action", "Clear Plops"), string.Format( /* 0: name of tile system */ TileLang.Text("Do you want to clear all plops associated with '{0}'?"), system.name ), TileLang.ParticularText("Action", "Yes"), TileLang.ParticularText("Action", "No") )) { return; } // Clear all plops which are associated with tile system. foreach (var plop in UnityEngine.Resources.FindObjectsOfTypeAll <PlopInstance>()) { if (plop.Owner == system) { Undo.DestroyObjectImmediate(plop.gameObject); } } // Clear plop groups from tile system. foreach (var plopGroup in system.GetComponentsInChildren <PlopGroup>()) { var plopGroupTransform = plopGroup.transform; if (plopGroupTransform.childCount == 0 && plopGroupTransform.GetComponents <Component>().Length == 2) { Undo.DestroyObjectImmediate(plopGroup.gameObject); } } }
/// <summary> /// Paint line of tiles using tool configuration. /// </summary> /// <param name="system">Tile system.</param> /// <param name="from">Index of tile at start of line.</param> /// <param name="to">Index of tile at end of line.</param> /// <param name="brush">Brush to paint with or specify <c>null</c> to erase existing tiles.</param> protected void PaintLine(TileSystem system, TileIndex from, TileIndex to, Brush brush) { var args = this.GetPaintingArgs(brush); if (args.variation == Brush.RANDOM_VARIATION) { // Use pre-randomized variation when painting individual tiles? if (brush != null && from == to && this.NozzleSize == 1) { int orientationMask = OrientationUtility.DetermineTileOrientation(system, from, brush, args.rotation); args.variation = this.PreRandomizeVariation(brush, orientationMask); this.RandomizeVariationShift(); } } switch (ToolUtility.BrushNozzle) { default: case BrushNozzle.Round: PaintingUtility.StrokeLineWithCircle( system: system, from: from, to: to, radius: this.NozzleRadius, args: args ); break; case BrushNozzle.Square: PaintingUtility.StrokeLineWithSquare( system: system, from: from, to: to, size: this.NozzleSize, args: args ); break; } }
private static void OnDrawGizmosSelected(TileSystem system, GizmoType gizmoType) { DrawTileSystemGizmosSelected(system, 2.0f); // Do not display gizmos when tile system is locked, this would be confusing! if (system.Locked) { return; } if (!RtsPreferences.ToolImmediatePreviews) { return; } ToolBase currentTool = ToolManager.Instance.CurrentTool; if (currentTool != null && ToolBase.IsEditorNearestControl) { ImmediatePreviewUtility.PreviewMaterial.color = RtsPreferences.ToolImmediatePreviewsTintColor; currentTool.OnDrawGizmos(system); } }
public void InitMapFromLatLongBox(LegLatLngBox latLngBox, int lod) { mapcoord = new LegMapCoordblock(this); var llbl = latLngBox.GetBottomLeft(); var llul = latLngBox.GetUpperLeft(); var llbr = latLngBox.GetBottomRight(); var llur = latLngBox.GetUpperRight(); var llmp = latLngBox.GetMidPoint(); var pixToMeters = TileSystem.GroundResolution(llmp.lat, lod); var orgpix = llbl.GetPixelCoords(lod); var orgmeters = new Vector2d(orgpix.x * pixToMeters, orgpix.y * pixToMeters); mapcoord.AddRowLngLat(llbl, lod, pixToMeters, orgmeters); mapcoord.AddRowLngLat(llul, lod, pixToMeters, orgmeters); mapcoord.AddRowLngLat(llbr, lod, pixToMeters, orgmeters); mapcoord.AddRowLngLat(llur, lod, pixToMeters, orgmeters); mapcoord.AddRowLngLat(llmp, lod, pixToMeters, orgmeters); glbllm = this; maps.latmap = mapcoord.DoRegression("lat = x + z"); maps.lngmap = mapcoord.DoRegression("lng = x + z"); maps.xmap = mapcoord.DoRegression("x = lng + lat"); maps.zmap = mapcoord.DoRegression("z = lng + lat"); }
private static TileSystem GetTempSystem(TileSystem activeSystem) { // Get or create a temporary 1x1 tile system. if (s_TempSystem == null) { var go = GameObject.Find("{{Plop Tool}} Temp System"); if (go == null) { go = EditorUtility.CreateGameObjectWithHideFlags("{{Plop Tool}} Temp System", HideFlags.HideAndDontSave); s_TempSystem = go.AddComponent <TileSystem>(); s_TempSystem.CreateSystem(1, 1, 1, 1, 1, 1, 1); } else { s_TempSystem = go.GetComponent <TileSystem>(); } } // Mimic tile size and facing as active tile system. s_TempSystem.CellSize = activeSystem.CellSize; s_TempSystem.TilesFacing = activeSystem.TilesFacing; return(s_TempSystem); }
public static PlopInstance CyclePlop(TileSystem system, PlopInstance plop, Brush brush, int nextRotation, int nextVariation) { Undo.RecordObject(plop, TileLang.ParticularText("Action", "Cycle Plop")); var parentTransform = plop.transform.parent; var tileData = plop.ToTileData(); nextVariation = Brush.WrapVariationIndexForCycle(Brush.GetSharedContext(brush, GetTempSystem(system), TileIndex.zero), tileData, nextVariation); var newPlop = PaintPlop(system, plop.PlopPoint, brush, nextRotation, nextVariation); ErasePlop(plop); // New plop should have same parent as original plop. var newPlopTransform = newPlop.transform; if (newPlopTransform.parent != parentTransform) { newPlopTransform.SetParent(parentTransform); } return(newPlop); }
public int CountTasks(TileSystem system) { int count = 0; // Optimize tile colliders? if (system.ReduceColliders.Active) { ++count; } // Prepare Map. count += system.RowCount; // Snap and smooth. count += system.RowCount; // Merge meshes into chunks. this.PrepareChunkData(system); count += this.combineChunkRows * this.combineChunkColumns; // Stripping. ++count; return(count); }
/// <summary> /// Strip unwanted aspects of tile system with specified stripping options. /// </summary> /// <remarks> /// <para>Chunks cannot be stripped from tile system when combine method is set /// to <see cref="BuildCombineMethod.ByChunk"/>.</para> /// </remarks> /// <param name="tileSystem">Tile system.</param> public static void ApplyStripping(TileSystem tileSystem) { // Strip chunks from tile system? if (tileSystem.StripChunks && tileSystem.combineMethod != BuildCombineMethod.ByChunk) { StripChunks(tileSystem); } if (tileSystem.StripPlopComponents) { StripPlopComponents(tileSystem); } else if (tileSystem.StripBrushReferences) { StripBrushReferencesFromPlopComponents(tileSystem); } // Strip empty objects? if (tileSystem.StripEmptyObjects) { var children = tileSystem.transform.OfType <Transform>().ToArray(); foreach (var child in children) { StripEmptyGameObjectsRecursive(child); } } // Strip empty chunks? if (tileSystem.StripEmptyChunks) { StripEmptyChunks(tileSystem); } // Finally, apply runtime stripping. ApplyRuntimeStripping(tileSystem); }
public bool RangedAttack(Vector3 attackDirection, Projectile projectile) { Vector3 actorPos = actorPosition.position; actorPos.y -= 0.5f; Vector3Int gridDirection = grid.WorldToCell(attackDirection); Vector3Int actorTile = grid.WorldToCell(actorPosition.position); actorTile.y -= 1; gridDirection.z = actorTile.z; Vector3 spawnPoint = TileSystem.AdjacentTile(gridDirection, actorTile, actorPosition.position); spawnPoint.y -= 0.5f; Vector3 rotatedVectorToTarget = Quaternion.Euler(0, 0, -45) * (spawnPoint - actorPos); Quaternion targetRotation = Quaternion.LookRotation(forward: Vector3.forward, upwards: rotatedVectorToTarget); Projectile p = GameObject.Instantiate(projectile, spawnPoint, targetRotation); EventManager.RaiseCombatSpawn(p); return(true); }
private bool CanConstructAllBuildings() { TileSystem tileSystem = TileSystem.Instance; foreach (var cBuilding in _previewBuildings) { Vector3 buildingPosition = cBuilding.Building.transform.position; // if the tile is the same type of 'EntityID' if (tileSystem.GetTile(buildingPosition) != null && tileSystem.DoTileContainsEntityOfID(buildingPosition, EntityID)) { continue; } if (tileSystem.DoTilesFillConditions(buildingPosition, EntityData.TileSize, TileFlag.All)) { continue; } return(false); } return(true); }
private void ConstructBuilding(PreviewBuilding cBuilding) { GameObject building = cBuilding.Building; Vector3 buildingPosition = building.transform.position; TileSystem tileSystem = TileSystem.Instance; // don't make construction unsuccessful because building on the same entiy if (tileSystem.GetTile(buildingPosition) != null && tileSystem.DoTileContainsEntityOfID(buildingPosition, EntityID)) { // destroy, but don't interupt construction cBuilding.Destroy(); return; } const TileFlag condition = TileFlag.Free | TileFlag.Visible; bool tileSetSuccessfully = tileSystem.TrySetTile(building, EntityData.TileSize, condition, EntityID); if (tileSetSuccessfully) { cBuilding.SetConstructionAsFinish(Team.Player); _constructionAchievedBuilding.Add(cBuilding); } }
/// <summary> /// This will list all the affected assets affected by lightning strikes. /// </summary> /// <returns>A collection of Asset objects.</returns> public List <Asset> ListAffectedAssets() { // This will get the data of lightning strikes. var strikes = _dataContext.Strikes .Where(x => x.FlashType == FlashType.CloudToGround); // This will initialize the quad key collection. var quadKeys = new List <string>(); // This will iterate through the collection of lightning strikes. foreach (var item in strikes) { // This will initialize the required values int pixelX, pixelY, tileX, tileY; // This will convert the inital longitude and latitude value to pixel x and y values. TileSystem.LatLongToPixelXY(item.Latitude, item.Longitude, 12, out pixelX, out pixelY); // This will convert the pixel x and y values to tile x and y values. TileSystem.PixelXYToTileXY(pixelX, pixelY, out tileX, out tileY); // This will convert the tile x and y values to a usable quad key. var quadKey = TileSystem.TileXYToQuadKey(tileX, tileY, 12); // This will determine if the resulting quad key already exists in the collection. if (!quadKeys.Contains(quadKey)) { // This will add the quad key to the quad key collection. quadKeys.Add(quadKey); } } // This will extract the affected assets by their quad key. var affectedAssets = _dataContext.Assets.Where(x => quadKeys.Contains(x.QuadKey)); return(affectedAssets.ToList()); }
/// <summary> /// Finds nearest tile system in parent hierarchy of specified object. Does not /// attempt to find tile system component from prefabs. /// </summary> /// <remarks> /// <para>Always returns a value of <c>null</c> for tile system components which /// reside within prefabs.</para> /// </remarks> /// <param name="transform">Transform component of input object.</param> /// <returns> /// The nearest <see cref="TileSystem"/> component; otherwise a value of <c>null</c>. /// </returns> public static TileSystem FindParentTileSystem(Transform transform) { // Does not find parent component of tile systems which are stored inside prefabs. if (transform == null || EditorUtility.IsPersistent(transform)) { return(null); } TileSystem system = null; while (transform != null) { system = transform.GetComponent <TileSystem>(); if (system != null) { return(system); } transform = transform.parent; } // Being extra careful since Unity overloads equality operators. return(system != null ? system : null); }
/// <summary> /// Erase all out-of-bound tiles. /// </summary> /// <param name="system">Tile system.</param> /// <param name="newRows">New number of rows.</param> /// <param name="newColumns">New number of columns.</param> /// <param name="rowOffset">Number of rows of tiles to offset by.</param> /// <param name="columnOffset">Number of columns of tiles to offset by.</param> private void EraseOutOfBoundTiles(TileSystem system, int newRows, int newColumns, int rowOffset, int columnOffset) { if (system.Chunks == null) { return; } rowOffset = -rowOffset; columnOffset = -columnOffset; int offsetEndRow = rowOffset + newRows; int offsetEndColumn = columnOffset + newColumns; system.BeginBulkEdit(); for (int row = 0; row < system.RowCount; ++row) { for (int column = 0; column < system.ColumnCount; ++column) { var tile = system.GetTile(row, column); if (tile == null) { continue; } // Is tile out-of-bounds? if (row < rowOffset || row >= offsetEndRow || column < columnOffset || column >= offsetEndColumn) { system.EraseTile(row, column); system.RefreshSurroundingTiles(row, column); } } } system.EndBulkEdit(); }
public SmallTree(int x, int y, ref TileSystem tileSystem) : base(x, y, ref tileSystem) { }
public void FillTileMapWithStone(TileSystem mapGo) { SetTileMapSpecs(mapGo); PaintBaseTiles(stoneBrush); }
void OnTileSystemAnnounced(TileSystem incomingTileSystem) { map = incomingTileSystem; Continue(); }
public BigTree(int x, int y, ref TileSystem tileSystem) : base(x, y, ref tileSystem) { }
void SetTileMapSpecs(TileSystem mapGo) { map = mapGo; mapColumns = mapGo.ColumnCount; mapRows = mapGo.RowCount; }
void PCMove(out Vector2 newPosition, out Vector2Int lookDirection) { TileSystem tileSystem = TileSystem.Instance; //Vector2Int lookDirection = new Vector2Int(); //Vector2 newPosition = Vector2.zero lookDirection = Vector2Int.zero; newPosition = Vector2.zero; if (Input.GetKey(KeyCode.UpArrow)) { if (Input.GetKey(KeyCode.RightArrow)) { newPosition += new Vector2(1.0f, tileSystem.GetSlope()); lookDirection += new Vector2Int(1, 1); } else if (Input.GetKey(KeyCode.LeftArrow)) { newPosition += new Vector2(-1.0f, tileSystem.GetSlope()); lookDirection += new Vector2Int(-1, 1); } //else //{ // newPosition += new Vector2(0.0f, 1.0f); // lookDirection += new Vector2Int(0, 1); //} } if (Input.GetKey(KeyCode.DownArrow)) { if (Input.GetKey(KeyCode.RightArrow)) { newPosition += new Vector2(1.0f, -tileSystem.GetSlope()); lookDirection += new Vector2Int(1, -1); } else if (Input.GetKey(KeyCode.LeftArrow)) { newPosition += new Vector2(-1.0f, -tileSystem.GetSlope()); lookDirection += new Vector2Int(-1, -1); } //else //{ // newPosition += new Vector2(0.0f, -1.0f); // lookDirection += new Vector2Int(0, -1); //} } //if (Input.GetKey(KeyCode.LeftArrow)) //{ // if (!Input.GetKey(KeyCode.UpArrow) && !Input.GetKey(KeyCode.DownArrow)) // { // newPosition += new Vector2(-1.0f, 0.0f); // lookDirection += new Vector2Int(-1, 0); // } //} //else if (Input.GetKey(KeyCode.RightArrow)) //{ // if (!Input.GetKey(KeyCode.UpArrow) && !Input.GetKey(KeyCode.DownArrow)) // { // newPosition += new Vector2(1.0f, 0.0f); // lookDirection += new Vector2Int(1, 0); // } //} }
public static TileData PaintTile(this Brush brush, TileSystem map, int x, int y) { return brush.Paint(map, y, x); }
public Tile(TileSystem parent, TerrainType type, int x, int y, int id) { mType = type; mX = x; mY = y; mPlaceables = new ArrayList(); mParentNavGrid = parent; mSpecialCaseID = id; switch (mType) { case TerrainType.kPass: mTileBaseObject = parent.PassableTile; mDisplayOffsets.z -= 0.07f; break; case TerrainType.kWall: mPlayerPassable = false; mBlockPassable = false; mTileBaseObject = parent.WallTile; mDisplayOffsets.z -= 0.15f; break; case TerrainType.kExit: mTileBaseObject = parent.DoorTile; mDisplayOffsets.z += -0.08f; mBlockPassable = false; break; case TerrainType.kHumanExit: mTileBaseObject = parent.HumanDoorTile; mDisplayOffsets.z += -0.08f; mBlockPassable = false; break; case TerrainType.kBlockHole: mTileBaseObject = parent.EmptyTile; mPlayerPassable = false; break; case TerrainType.kBlockOnly: mTileBaseObject = parent.BlockOnlyTile; mDisplayOffsets.z -= 0.15f; mPlayerPassable = false; break; case TerrainType.kPushUp: mTileBaseObject = parent.PushUpTile; mDisplayOffsets.z -= 0.1f; mPushDirY = 1; break; case TerrainType.kPushRight: mTileBaseObject = parent.PushRightTile; mDisplayOffsets.z -= 0.1f; mPushDirX = 1; break; case TerrainType.kPushDown: mTileBaseObject = parent.PushDownTile; mDisplayOffsets.z -= 0.1f; mPushDirY = -1; break; case TerrainType.kPushLeft: mTileBaseObject = parent.PushLeftTile; mDisplayOffsets.z -= 0.1f; mPushDirX = -1; break; case TerrainType.kPressure: mTileBaseObject = parent.PressureTile; mDisplayOffsets.z -= 0.2f; break; case TerrainType.kPressureDoor: mTileBaseObject = parent.OmenDoor; mDisplayOffsets.z -= 0.15f; mIsDoor = true; mPlayerPassable = false; mBlockPassable = false; DelegateHost.GetInstance().OnPressureChange += HandleOnPressureChange; break; default: break; } }