// Create a new tile for this row using common base public MetroTile AddTile(TileType type, TileWidth width, TileHeight height, string bgColor, string title, string onClick = "", string navUrl = "") { // Get the last tile added to this row MetroTile lastTileAdded = this.Tiles.LastOrDefault(); int nextLeftMargin = 0; // If this is the first tile in the row, margin is column margin if (lastTileAdded == null) { nextLeftMargin = this.Column.LeftMargin; } else { // Calculate left margin based on the previous tile in the row nextLeftMargin = lastTileAdded.LeftMargin + lastTileAdded.Width + Column.SpacingBetweenTiles; } // Now create the actual tile based on our calculations MetroTile newTile = new MetroTile(this.Column.Position, type, TopMargin, nextLeftMargin, width, height, bgColor, title, onClick, navUrl); // Add the new tile to the list of tiles for this row this.Tiles.Add(newTile); // Recalculate the width and height of this row this.Width = this.Width == 0 ? newTile.Width : this.Width + Column.SpacingBetweenTiles + newTile.Width; this.Height = this.Height < newTile.Height ? newTile.Height : this.Height; // Return the new tile so it can be further worked with return(newTile); }
/// <summary> /// Ermittelt, ob die Zelle eine plane Fläche ist. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="direction"></param> /// <param name="height"></param> /// <param name="message"></param> /// <returns></returns> private bool IsFlat(int x, int y, Compass direction, TileHeight height, out string message) { Index2 index = GetCellIndex(x, y, direction); // Auf definition prüfen if (IsNothing(index.X, index.Y)) { message = GetCellName(direction) + " is not defined"; return(false); } // Shape prüfen if (Tiles[index.X, index.Y].Shape != TileShape.Flat) { message = GetCellName(direction) + " is not plain"; return(false); } // Höhe prüfen if (Tiles[index.X, index.Y].Height != height) { message = GetCellName(direction) + " has the wrong height"; return(false); } message = string.Empty; return(true); }
// Create a new tile for this row using common base public MetroTile AddTile(TileType type, TileWidth width, TileHeight height, string bgColor, string title, string onClick = "", string navUrl = "") { // Get the last tile added to this row MetroTile lastTileAdded = this.Tiles.LastOrDefault(); int nextLeftMargin = 0; // If this is the first tile in the row, margin is column margin if (lastTileAdded == null) { nextLeftMargin = this.Column.LeftMargin; } else { // Calculate left margin based on the previous tile in the row nextLeftMargin = lastTileAdded.LeftMargin + lastTileAdded.Width + Column.SpacingBetweenTiles; } // Now create the actual tile based on our calculations MetroTile newTile = new MetroTile(this.Column.Position, type, TopMargin, nextLeftMargin, width, height, bgColor, title, onClick, navUrl); // Add the new tile to the list of tiles for this row this.Tiles.Add(newTile); // Recalculate the width and height of this row this.Width = this.Width == 0 ? newTile.Width : this.Width + Column.SpacingBetweenTiles + newTile.Width; this.Height = this.Height < newTile.Height ? newTile.Height : this.Height; // Return the new tile so it can be further worked with return newTile; }
/// <summary> /// Add or remove ellement of array /// </summary> /// <param name="i">New size</param> public void NewRowArray(int i) { int maxIndex = HeightGroundData.Length; TileHeight[] newAray = new TileHeight[i]; for (int x = 0; x < i; x++) { newAray[x].Row = new float[i]; } for (int y = 0; y < i; y++) { if (y >= maxIndex) { continue; } for (int x = 0; x < i; x++) { if (x >= maxIndex) { continue; } newAray[y].Row[x] = HeightGroundData[y].Row[x]; } } HeightGroundData = newAray; }
private void item_CellChanged(Item item, Index2 newValue) { // Environment Information aktualisieren VisibleEnvironment env = viewers[item.Id].Environment; // Element außerhalb des Spielfeldes Index2 limit = Engine.Map.GetCellCount(); if (newValue.X < 0 || newValue.X >= limit.X || newValue.Y < 0 || newValue.Y >= limit.Y) { env.Center = null; env.North = null; env.South = null; env.West = null; env.East = null; env.NorthWest = null; env.NorthEast = null; env.SouthWest = null; env.SouthEast = null; return; } // Umgebungszellen durchlaufen for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { var offset = new Index2(x, y); Index2 cell = newValue + offset; if (cell.X < 0 || cell.X >= limit.X || cell.Y < 0 || cell.Y >= limit.Y) { // Es existiert keine Zelle mehr env[offset] = null; } else { // Zelleninfos ermitteln float speed = Engine.Map.Tiles[cell.X, cell.Y].GetSpeedMultiplicator(); TileHeight height = Engine.Map.Tiles[cell.X, cell.Y].Height; env[offset] = new VisibleCell { Speed = speed, Height = height }; } } } // Inform user viewers[item.Id].RefreshEnvironment(); }
// private Sprite _sprite; public HexTile(HexPoint point, Vector3 position, Color color, TileHeight height) { _point = point; _position = position; _color = color; Height = height; _unit = null; _resource = null; // BoardManager.Instance.UpdateReachablePoints(this); }
// Initialize our tile, basic common settings // To make it more flexible, all other specialized properties are set on specific properties public MetroTile(int column, TileType tileType, int topMargin, int leftMargin, TileWidth width, TileHeight height, string bgColor, string title, string onClick = "", string navUrl = "") { this.LeftMargin = leftMargin; this.TopMargin = topMargin; this.Width = (int) width; this.Height = (int) height; this.BgColor = bgColor; this.OnClick = onClick; this.Column = column; this.TileType = tileType; this.Title = title; this.NavUrl = navUrl; this.id = (this.Column + "_" + this.TopMargin + "-" + this.LeftMargin).ToString(); }
// Initialize our tile, basic common settings // To make it more flexible, all other specialized properties are set on specific properties public MetroTile(int column, TileType tileType, int topMargin, int leftMargin, TileWidth width, TileHeight height, string bgColor, string title, string onClick = "", string navUrl = "") { this.LeftMargin = leftMargin; this.TopMargin = topMargin; this.Width = (int)width; this.Height = (int)height; this.BgColor = bgColor; this.OnClick = onClick; this.Column = column; this.TileType = tileType; this.Title = title; this.NavUrl = navUrl; this.id = (this.Column + "_" + this.TopMargin + "-" + this.LeftMargin).ToString(); }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } hash ^= tiles_.GetHashCode(); if (master_ != null) { hash ^= Master.GetHashCode(); } if (Random != false) { hash ^= Random.GetHashCode(); } if (TileWidth != 0) { hash ^= TileWidth.GetHashCode(); } if (TileHeight != 0) { hash ^= TileHeight.GetHashCode(); } if (ColourBlended != false) { hash ^= ColourBlended.GetHashCode(); } if (Enhanced != false) { hash ^= Enhanced.GetHashCode(); } if (EnhancedThreshold != 0) { hash ^= EnhancedThreshold.GetHashCode(); } if (EdgeDetection != false) { hash ^= EdgeDetection.GetHashCode(); } hash ^= edges_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static double GetTileHeightOpenGLUnits(TileHeight height) { switch (height) { case TileHeight.Ground: return -0.25; case TileHeight.BoxOne: return 0.5; case TileHeight.BoxTwo: return 1.2; case TileHeight.BoxThree: break; default: return 0.0; } return 0.0; }
public TileData Layer(TileHeight layer) { switch (layer) { case TileHeight.zero: return(_layer00); case TileHeight.one: return(_layer01); case TileHeight.two: return(_layer02); case TileHeight.three: return(_layer03); case TileHeight.four: return(_layer04); default: throw new System.Exception(); } }
public void SetTitleHeight(TileHeight height) { Floor[GameHandler.Position.Row, GameHandler.Position.Column].Height = height; }
private void parseTileLine(string[] tokens, out int tileRow, out int tileColumn, out TileType tileType, out TileHeight tileHeight) { try { tileRow = int.Parse(tokens[0], CultureInfo.InvariantCulture); tileColumn = int.Parse(tokens[1], CultureInfo.InvariantCulture); tileType = (TileType)int.Parse(tokens[2], CultureInfo.InvariantCulture); tileHeight = (TileHeight)int.Parse(tokens[3], CultureInfo.InvariantCulture); } catch (Exception) { throw new LevelFileException("Error while parsing tile settings"); } }
public void SetHeight(TileHeight height) { Height = height; }
public float GetHeight(TileHeight h) { switch (h) { case TileHeight.Deep: return -4f; case TileHeight.Shore: return -1f; case TileHeight.Coast: return -0.5f; case TileHeight.Zero: return 0.0f; case TileHeight.Hill: return 2f; case TileHeight.Peak: return 4; case TileHeight.None: return -1; } return -1; }
public float CalcHeight(TileHeight h1, TileHeight h2, TileHeight h3) { int num = 0; float sum = 0f; if (h1 == TileHeight.Coast || h2 == TileHeight.Coast || h3 == TileHeight.Coast) return GetHeight(TileHeight.Coast); if (h1 == h2 && h1 != TileHeight.None && h3 != TileHeight.None) return ( 3 * GetHeight(h1) + GetHeight(h3) ) / 4f; if (h2 == h3 && h2 != TileHeight.None && h1 != TileHeight.None) return (3 * GetHeight(h2) + GetHeight(h1)) / 4f; if (h1 == h3 && h1 != TileHeight.None && h2 != TileHeight.None) return (3 * GetHeight(h1) + GetHeight(h2)) / 4f; if (h1 != TileHeight.None) { sum += GetHeight(h1); num++; } if (h2 != TileHeight.None) { sum += GetHeight(h2); num++; } if (h3 != TileHeight.None) { sum += GetHeight(h3); num++; } if (num == 0) return 0f; return sum / num; }
protected void CheckTileFail(Tile tile) { if (!CheckTile(tile)) { throw new ArgumentException(String.Format("Tried to add tile with dimenions ({0}, {1}), layer expects tile dimensions ({2}, {3})", new string[] { tile.Width.ToString(), tile.Height.ToString(), TileWidth.ToString(), TileHeight.ToString() })); } }
public Map(int width, int height, bool blockBorder, TileSpeed initialSpeed = TileSpeed.Normal, TileHeight initialHeight = TileHeight.Medium) { // Check Parameter if (width < MIN_WIDTH) { throw new ArgumentOutOfRangeException(string.Format("Map must have at least {0} Columns", MIN_WIDTH)); } if (width > MAX_WIDTH) { throw new ArgumentOutOfRangeException(string.Format("Map must have a max of {0} Columns", MAX_WIDTH)); } if (height < MIN_HEIGHT) { throw new ArgumentOutOfRangeException(string.Format("Map must have at least {0} Rows", MIN_HEIGHT)); } if (height > MAX_HEIGHT) { throw new ArgumentOutOfRangeException(string.Format("Map must have a max of {0} Rows", MAX_HEIGHT)); } BlockBorder = blockBorder; // Create Tiles Tiles = new MapTile[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Tiles[x, y] = new MapTile { Height = initialHeight, Shape = TileShape.Flat, Speed = initialSpeed }; } } // Create Players int dx = width / 6; int dy = height / 6; StartPoints = new Index2[8]; StartPoints[0] = new Index2(dx, dy); StartPoints[1] = new Index2(5 * dx, 5 * dy); StartPoints[2] = new Index2(5 * dx, dy); StartPoints[3] = new Index2(dx, 5 * dy); StartPoints[4] = new Index2(3 * dx, dy); StartPoints[5] = new Index2(3 * dx, 5 * dy); StartPoints[6] = new Index2(dx, 3 * dy); StartPoints[7] = new Index2(5 * dx, 3 * dy); }