public Tile(TerrainTypes terrainType, Sprite terrainSprite, bool isTraversable, float traversalDifficulty) { TerrainType = terrainType; this.terrainSprite = terrainSprite; IsTraversable = isTraversable; TraversalDifficulty = traversalDifficulty; }
public static int GetNumberOfTileSpriteRotationsNeeded(TerrainTypes type, Directions placementDirection) { switch (type) { case TerrainTypes.Floor: case TerrainTypes.Mashrooms: case TerrainTypes.Chasm: case TerrainTypes.Pillar: case TerrainTypes.River: case TerrainTypes.Lair: { return(GetRandomSpriteRotation()); } case TerrainTypes.VolcanicVent: case TerrainTypes.Bridge: case TerrainTypes.Crystal: case TerrainTypes.Throne: { return(GetNumberOfSpriteRotationsNeeded(placementDirection)); } case TerrainTypes.DwarfStatue: case TerrainTypes.Wall: case TerrainTypes.Campfire: case TerrainTypes.Exit: { return(0); } default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public Tile(TerrainTypes terrain, Biomes biome, Point coordinate, double elevation) { this.coordinate = coordinate; Terrain = terrain; Biome = biome; this.Elevation = elevation; }
private bool isPassable; // This will be used to determine whether you can occupy this tile //Class constructor public Tile(TerrainTypes myTerrain, float mySpeedModifer, int myHealthModifer, bool myIsPassable) { terrain = myTerrain; speedModifer = mySpeedModifer; healthModifer = myHealthModifer; isPassable = myIsPassable; }
/// <summary> /// Set the terrain at the given index to the type specified. /// </summary> /// <param name="type">The type of terrain to position.</param> /// <param name="x">The x index of the tile to position at.</param> /// <param name="y">The y index of the tile to position at.</param> public void SetTerrainAt(TerrainTypes terrainType, int x, int y) { if (!InBounds(x, y)) { return; // Out of bounds } var tile = this.tiles[x][y]; switch (terrainType) { case TerrainTypes.Grass: if (this.Terrains.Contains(tile.Terrain)) { this.Terrains.Remove(tile.Terrain); } break; case TerrainTypes.Mountain: case TerrainTypes.Water: if (!this.Terrains.Contains(tile.Terrain)) { this.Terrains.Add(tile.Terrain); } break; default: return; } tile.SetTerrain(terrainType); }
public StandNearSquareCondition(StandNearSquareConditionData data) { _relatedTileName = data.RelatedTileName; _type = data.Type; _distanse = data.Distanse; InitializeCoordinatesToCheck(); }
// Generate terrain values depending on the terrain type // Terrain values include : the maximal height of the terrain, and the smoothness of it public void GenerateTerrainValues(int tType) { if (tType == 0) { this.terrainType = TerrainTypes.PLAINS; this.maxHeight = 50; this.smooth = Random.Range(0.007f, 0.009f); } else if (tType == 1) { this.terrainType = TerrainTypes.HILLS; this.maxHeight = 100; this.smooth = Random.Range(0.009f, 0.011f); } else { this.terrainType = TerrainTypes.MOUNTAINS; this.maxHeight = 150; this.smooth = Random.Range(0.011f, 0.013f); } this.octaves = Random.Range(3, 5); this.persistence = 0.5f; }
public override void ChangeValues(string[] table) { id = int.Parse(table[0]); iconName = table[1]; iconPath = table[2]; terrainType = (TerrainTypes)int.Parse(table[3]); }
/// <summary> /// Configure the tile parameters using columna nd row data. /// </summary> /// <param name="q">The Column of the tile.</param> /// <param name="r">The Row of the tile.</param> public void ConfigureTile(int q, int r) { hexTransform = new HexTransform(q, r); SetTexture(TerrainTypes.Sea); TerrainType = TerrainTypes.Sea; ASI = new AStarInfo <HexTile>(this, 1); }
public override void SetInfo(BaseInfo baseInfo) { TerrainTextureInfo info = (TerrainTextureInfo)baseInfo; base.SetInfo(info); iconPath = info.iconPath; iconName = info.iconName; terrainType = info.terrainType; }
public TerrainTile(char c, libtcodWrapper.Color col, bool d, bool w, bool s, TerrainTypes t) { CharRepresentation = c; DrawColor = col; Destructible = d; Walkable = w; Seethrough = s; Type = t; HasBeenSeen = IsVisible = false; }
public void OnHexCreated(Point cubeCoord, HexCoord hexCoord, TerrainTypes hexType) { var hex = HexGenerator.MakeHex().transform; hex.GetComponent<Renderer>().material.mainTexture = TerrainTextures.GetTexture(hexType); HexGenerator.SetHexInfo(hexCoord, hex); hex.position = HexGenerator.CorrelateCoordWithMap(cubeCoord); hex.parent = HexMap.transform; }
public Tile SetTile(HexGrid grid, GameObject tileModel) { adjacencyList = new List <Tile>(); tileOwner = PlayerNumber.NONE; tileState = TileState.UNCLAIMED; terrainType = TerrainTypes.PLAINS; this.tileModel = tileModel; currentPoints = 0; this.grid = grid; return(this); }
public Sprite(string texString, int x, int y, int texWidth, int texHeight) { //_graphicsDevice = graphicsDevice; //_spriteBatch = spriteBatch; _textureString = texString; _position.X = x; _position.Y = y; _width = texWidth; _height = texHeight; _terrainType = Sprite.TerrainTypes.None; }
/// <summary> /// /// Obtain a particular terrain colour /// /// </summary> public Color GetTerrainColour(TerrainTypes neededTerrain) { var terrainColour = new Color(); terrainColour = terrainColours.FirstOrDefault(x => x.terrainType == neededTerrain).terrainColour; if (terrainColour == null) { terrainColour = new Color(); } return(terrainColour); }
private void AddSquare(TerrainTypes type) { if (string.IsNullOrEmpty(_layout)) { _layout += type; } else { _layout += $";{type}"; } }
public TerrainType(TerrainTypes terrainType, string name, bool canPass, bool isWater, bool canSwim, float moveRate) { m_name = name; m_isWater = isWater; m_canPass = canPass; m_canSwim = canSwim; m_moveRate = moveRate; m_terrainType = terrainType; }
protected int GetTerrainCost(TerrainTypes type) { switch (type) { case TerrainTypes.Exit: case TerrainTypes.Plain: return(1); case TerrainTypes.Swamp: return(5); default: return(int.MaxValue); } }
internal void setResource(Product inres) { resource = inres; if (resource == Product.Stone || resource == Product.Gold || resource == Product.MetalOre || resource == Product.Coal) { terrain = TerrainTypes.Mountains; } else { terrain = TerrainTypes.Plains; } }
public TerrainTypes GetTerrainAt(RoomPosition pos) { TerrainTypes result = TerrainTypes.Plain; var terrain = _terrain.FirstOrDefault(t => t.Pos.Equals(pos)); if (terrain != null) { result = terrain.Type; } return(result); }
public void ChooseTerrainType() { // No terrain generated if (generator.Next(2) == 0) { currentTerrain = TerrainTypes.DefaultRandom; } // Terrain generated. Randomly select a type. else { currentTerrain = (TerrainTypes)(generator.Next(1, 1)); } }
// Takes a height value (0f - 1f) and finds the TerrainType associated with it (regions set in inspector currently) private TerrainTypes heightToTerrain(float height) { TerrainTypes cur = regions[0]; foreach (TerrainTypes ter in regions) { if (height <= ter.height) { return(ter); } } return(regions[regions.Length - 1]); }
public bool IsNextSquarePassable(TerrainTypes passableTerrainTypes) { TerrainTypes terrainType = ((WorldTile)terrainMap.GetTile(nextCellCoords)).terrainType; Debug.Log("tile " + terrainMap.GetTile(nextCellCoords).name); Debug.Log(nextCellCoords); Debug.Log("terrain in next square " + terrainType); Debug.Log("passable terrain by this actor " + passableTerrainTypes); if ((passableTerrainTypes & terrainType) != 0) { return(true); } return(false); }
private Globals() { _random = new Random(); GameWorld = GameWorld.Create(); MovementTypes = MovementTypes.Create(new List <MovementType> { MovementType.Create(1, "Ground") }); TerrainTypes = TerrainTypes.Create(TerrainTypesLoader.GetTerrainTypes()); MineralTypes = MineralTypes.Create(MineralTypesLoader.GetMineralTypes()); UnitTypes = UnitTypes.Create(UnitTypesLoader.GetUnitTypes(MovementTypes)); RaceTypes = RaceTypes.Create(RaceTypesLoader.GetRaceTypes()); BuildingTypes = BuildingTypesLoader.GetBuildingTypes(); }
private static bool IsValidTerrainTypeForNewTilePlacement(TerrainTypes type) { switch (type) { case TerrainTypes.Floor: case TerrainTypes.Mashrooms: case TerrainTypes.Crystal: case TerrainTypes.Bridge: case TerrainTypes.Lair: return(true); default: return(false); } }
bool Surrounded(HexTile h, TerrainTypes x) { var l = h.GetHexRing(2); bool Surrounded = true; foreach (HexTile H1 in l) { if (H1.TerrainType != x) { Surrounded = false; } } return(Surrounded); }
public void Load(BinaryReader reader) { terrainType = (TerrainTypes)reader.ReadInt32(); elevation = reader.ReadInt32(); waterLevel = reader.ReadInt32(); hasIncomingRiver = reader.ReadBoolean(); incomingRiver = (HexDirection)reader.ReadInt32(); hasOutgoingRiver = reader.ReadBoolean(); outgoingRiver = (HexDirection)reader.ReadInt32(); RefreshPosition(); ResourceKind resourceKind = (ResourceKind)reader.ReadInt32(); SetResource(resourceKind); }
public static TerrainTile Create(TerrainTypes Type) { switch (Type) { case (TerrainTypes.IndestructibleWall): return(new TerrainTile('#', libtcodWrapper.ColorPresets.GhostWhite, false, false, false, Type)); break; case (TerrainTypes.DestructibleWall): return(new TerrainTile('=', libtcodWrapper.ColorPresets.GhostWhite, true, false, false, Type)); break; case (TerrainTypes.ExitPortal): return(new TerrainTile('>', libtcodWrapper.ColorPresets.GhostWhite, false, true, true, Type)); break; case (TerrainTypes.EmptyFloor): return(new TerrainTile('.', libtcodWrapper.ColorPresets.GhostWhite, false, true, true, Type)); break; case (TerrainTypes.Water): return(new TerrainTile('~', libtcodWrapper.ColorPresets.Blue, false, true, true, Type)); break; case (TerrainTypes.Lava): return(new TerrainTile('~', libtcodWrapper.ColorPresets.Red, false, true, true, Type)); break; case (TerrainTypes.Fog): return(new TerrainTile('\'', libtcodWrapper.ColorPresets.Gray, false, true, false, Type)); break; default: return(new TerrainTile('?', libtcodWrapper.ColorPresets.Pink, false, true, true, Type)); break; } }
public Sprite GetTerrainSprite(TerrainTypes type) { switch (type) { case TerrainTypes.Water: return(water[UnityEngine.Random.Range(0, water.Length)]); case TerrainTypes.Sand: return(sand[UnityEngine.Random.Range(0, sand.Length)]); case TerrainTypes.Plains: return(grass[UnityEngine.Random.Range(0, grass.Length)]); default: Debug.LogError("Unknown terrain type requested. Type " + type); return(null); } }
public void Load(BinaryReader reader) { elevation = reader.ReadByte(); waterLevel = reader.ReadByte(); if (!HexMetrics.instance.isEditorTexture) { color = new Color(reader.ReadByte() / 255.0f, reader.ReadByte() / 255.0f, reader.ReadByte() / 255.0f, reader.ReadByte() / 255.0f); } else { terrainTypeIndex = (TerrainTypes)reader.ReadByte(); } RefreshPosition(elevation); for (int i = 0; i < isStepDirection.Length; i++) { isStepDirection[i] = reader.ReadBoolean(); } }
public static bool CanMoveOnHere(this TerrainTypes type) { switch (type) { case TerrainTypes.Floor: case TerrainTypes.Mashrooms: case TerrainTypes.Crystal: case TerrainTypes.Bridge: case TerrainTypes.Lair: case TerrainTypes.Exit: { return(true); } default: { return(false); } } }
public TransitionTemplate(TerrainTypes[][] template) { m_template = template; }
public HexEventArgs(Point cubeCoord, HexCoord hexCoord, TerrainTypes hexType) : base(hexCoord, hexType) { CubeCoord = cubeCoord; }
TerrainTypes[,] GetRawTerrainMap(Size sizTile, TemplateDoc tmpd) { TerrainTypes[,] aterMap = new TerrainTypes[Bounds.Height, Bounds.Width]; foreach (IMapItem mi in m_alsmi) { if (mi is Tile) { Tile tile = mi as Tile; int x = (int)mi.tx * sizTile.Width; int y = (int)mi.ty * sizTile.Height; Rectangle rc = tile.GetBoundingRectAt(x, y, sizTile, m_tmpd); rc.Width /= sizTile.Width; rc.Height /= sizTile.Height; rc.X /= sizTile.Width; rc.Y /= sizTile.Height; rc.Intersect(Bounds); for (int ty = rc.Y - (int)tile.ty; ty < rc.Bottom - (int)tile.ty; ty++) { for (int tx = rc.X - (int)tile.tx; tx < rc.Right - (int)tile.tx; tx++) { if (tile.Visibility == null || tile.IsVisible(tx, ty)) { Template tmpl = tile.GetTemplate(m_tmpd); // Maybe this template doesn't exist in document's current tile collection if (tmpl == null) continue; // Make sure this part of the template is occupied first if (tmpl.OccupancyMap[ty, tx]) aterMap[ty + (int)tile.ty - Bounds.Y, tx + (int)tile.tx - Bounds.X] = tmpl.TerrainMap[ty, tx]; } } } } if (mi is Wall) { int tx = (int)mi.tx - Bounds.X; int ty = (int)mi.ty - Bounds.Y; if (tx < 0 || tx >= Bounds.Width) continue; if (ty < 0 || ty >= Bounds.Height) continue; aterMap[ty, tx] = TerrainTypes.Blocked; } } return aterMap; }
public TerrainEventArgs(HexCoord hexCoord, TerrainTypes terrainType) : base(hexCoord) { HexType = terrainType; }
public static Texture2D GetTexture(TerrainTypes terrainType) { return _textures[terrainType]; }
private static string GetTerrainImageKey(TerrainTypes terrainType, PlotTypes plotType, FeatureTypes featureType) { if (plotType == PlotTypes.PEAK) return "PEAK"; else if (featureType == FeatureTypes.FEATURE_ICE) return "ICE"; else if (featureType == FeatureTypes.FEATURE_OASIS) return "OASIS"; string key = ""; if (featureType == FeatureTypes.FEATURE_JUNGLE) key = "JUNGLE"; else key = terrainType.ToString().Replace("TERRAIN_", ""); if ((terrainType == TerrainTypes.TERRAIN_GRASS || terrainType == TerrainTypes.TERRAIN_PLAINS || terrainType == TerrainTypes.TERRAIN_TUNDRA) && featureType == FeatureTypes.FEATURE_FOREST) key += "_FOREST"; if ((terrainType == TerrainTypes.TERRAIN_GRASS || terrainType == TerrainTypes.TERRAIN_PLAINS || terrainType == TerrainTypes.TERRAIN_TUNDRA || terrainType == TerrainTypes.TERRAIN_SNOW || terrainType == TerrainTypes.TERRAIN_DESERT) && plotType == PlotTypes.HILL) key += "_HILL"; return key; }
private static Brush GetTerrainBrush(TerrainTypes terrainType, PlotTypes plotType, FeatureTypes featureType, bool isEmpty) { if (isEmpty) return new SolidColorBrush(Colors.Transparent); string key = GetTerrainImageKey(terrainType, plotType, featureType); Image img = App.Current.Resources[key] as Image; if (img != null) return new ImageBrush(img.Source); return new SolidColorBrush(Color.FromRgb(0, 0, 0)); }
float CalculateTravelTime(TerrainTypes terrainType, bool cautiousSpeed = false, bool inn = false, bool horse = false, bool cart = false, bool ship = false) { float time = 0; switch (terrainType) { case TerrainTypes.None: time += BaseTemperateTravelTime; break; case TerrainTypes.ocean: time += BaseOceanTravelTime; break; case TerrainTypes.Desert: time += BaseDesert224_225TravelTime; break; case TerrainTypes.Desert2: time += BaseDesert224_225TravelTime; break; case TerrainTypes.Mountain: time += BaseMountain226TravelTime; break; case TerrainTypes.Swamp: time += BaseSwamp227_228TravelTime; break; case TerrainTypes.Swamp2: time += BaseSwamp227_228TravelTime; break; case TerrainTypes.Desert3: time += BaseDesert229TravelTime; break; case TerrainTypes.Mountain2: time += BaseMountain230TravelTime; break; case TerrainTypes.Temperate: time += BaseTemperateTravelTime; break; case TerrainTypes.Temperate2: time += BaseTemperateTravelTime; break; default: time += BaseTemperateTravelTime; break; } if (cautiousSpeed) time = time * 2; if (terrainType == TerrainTypes.ocean && PlayerHasShip) time *= ShipMod; else if (terrainType != TerrainTypes.ocean) { if (inn) time *= InnModifier; if (PlayerHasCart) time *= CartMod; else if (PlayerHasHorse) time *= HorseMod; } //Debug.Log(string.Format("Time Cost: {0} Terrain Type: {1} Inn: {2} PlayerHasShip {3} PlayerHasCart: {4} PlayerHasHorse: {5}", time, terrainType.ToString(), inn, PlayerHasShip, PlayerHasCart, PlayerHasHorse)); return time; }
public Hex(TerrainTypes terrainType) { Type = terrainType; }
public static Texture GetTexture(TerrainTypes type) { return GetTexture("terrain_"+type.ToString()); }
// private bool HasTransitions {get; protected set;} public TerrainTexture(TerrainTypes terrain, Texture2D texture) { }
public TerrainMap(TerrainTypes[,] aterMap) { m_aterMap = aterMap; }
public TerrainEntity(TerrainTypes type) { this.textype = type; }
// Update the map sizes to reflect the new bitmap private void UpdateMaps() { int ctx = Bitmap.Width / Doc.TileSize.Width; int cty = Bitmap.Height / Doc.TileSize.Height; // Try to copy what we can of the old terrain map TerrainTypes[,] ater = new TerrainTypes[cty, ctx]; if (TerrainMap != null) { int ctyOld = TerrainMap.GetLength(0); int ctxOld = TerrainMap.GetLength(1); for (int tx = 0; tx < ctx && tx < ctxOld; tx++) { for (int ty = 0; ty < cty && ty < ctyOld; ty++) { ater[ty, tx] = TerrainMap[ty, tx]; } } } TerrainMap = ater; // Create a new occupancy map. Old one not relevant. bool[,] afOcc = new bool[cty, ctx]; for (int tx = 0; tx < ctx; tx++) { for (int ty = 0; ty < cty; ty++) { afOcc[ty, tx] = true; Color clr = Bitmap.GetPixel(tx * Doc.TileSize.Width, ty * Doc.TileSize.Height); if (clr.A == 0) afOcc[ty, tx] = false; } } OccupancyMap = afOcc; }
public long this[TerrainTypes type] { get { return m_tileCount[type]; } }
public static TerrainMap Load(MemoryStream stm) { BinaryReader brdr = new BinaryReader(stm); int ctx = (int)Misc.SwapUShort(brdr.ReadUInt16()); int cty = (int)Misc.SwapUShort(brdr.ReadUInt16()); TerrainTypes[,] map = new TerrainTypes[cty, ctx]; for (int ty = 0; ty < cty; ty++) { for (int tx = 0; tx < ctx; tx++) { byte b = brdr.ReadByte(); switch (b) { case 0: // Area map[ty, tx] = TerrainTypes.Area; break; case 1: // Open map[ty, tx] = TerrainTypes.Open; break; case 2: // Wall map[ty, tx] = TerrainTypes.Wall; break; case 3: // Blocked map[ty, tx] = TerrainTypes.Blocked; break; default: // Default to Open map[ty, tx] = TerrainTypes.Open; break; } } } brdr.Close(); return new TerrainMap(map); }
protected void OnHexCreated(Point point, HexCoord hexCoord, TerrainTypes terrainType) { var handler = HexCreated; if (handler != null) handler(this, new HexEventArgs(point, hexCoord, terrainType)); }