public override void AddMapTile(MapTile t) { Vector2 position = new Vector2(0, 0); //IrrlichtLime.Core.Recti textureRect = new IrrlichtLime.Core.Recti(0, 0, 0, 0); Rectangle destSize = new Rectangle(); int fX = t.ScreenXPos - (int)(MapRendering.TileWidthHalf * MapRendering.Scale); int fY = t.ScreenYPos - (int)(MapRendering.TileHeight * MapRendering.Scale); position.X = fX; position.Y = fY; destSize.Width = (int)(MapRendering.TileWidth * MapRendering.Scale); destSize.Height = (int)(MapRendering.TileHeight * MapRendering.Scale); int iGfxTile = t.GfxIdx; int iRow = (iGfxTile / 9); int iTile = iGfxTile - (9 * (iGfxTile / 9)); int iStartU = 0 + (MapRendering.TileWidth * iTile); int iStartV = 0 + (MapRendering.TileHeight * iRow); MapRendering.AddTerrainBatch(t, position, new Rectangle(iStartU, iStartV, MapRendering.TileWidth, MapRendering.TileHeight)); }
public Unit(UnitData UnitData, MapTile MapTile) { this.UnitData = UnitData; this.MapTile = MapTile; UnitAnimation = new UnitAnimation(); }
public override void AddMapTile( MapTile t ) { Vector2 position = new Vector2(0, 0); //IrrlichtLime.Core.Recti textureRect = new IrrlichtLime.Core.Recti(0, 0, 0, 0); Rectangle destSize = new Rectangle(); int fX = t.ScreenXPos - ( TileWidthHalf / Scale ); int fY = t.ScreenYPos - ( TileHeightHalf / Scale ); position.X = fX; position.Y = fY; destSize.Width = TileWidth / Scale; destSize.Height = TileHeight / Scale; int iGfxTile = t.GfxIdx; int iRow = (iGfxTile / 9); int iTile = iGfxTile - (9 * (iGfxTile / 9)); int iStartU = 0 + ( TileWidth * iTile ); int iStartV = 0 + ( TileHeight * iRow ); if ( t.TerrainArt.Path != null ) //Terrain [ t.TerrainArt.Path ].AddBatch( position, new IrrlichtLime.Core.Recti( iStartU, iStartV, iStartU + TileWidth, iStartV + TileHeight ), destSize ); Terrain[t.TerrainArt.Path].AddBatch(new Rectangle((int)position.X, (int)position.Y, TileWidth, TileHeight), new Rectangle(iStartU, iStartV, iStartU + TileWidth, iStartV + TileHeight)); }
public override void AddRelief(MapTile t) { ReliefArt ReliefArt = ResourceInterface.ReliefArtData.Find(x => x.Type == t.ReliefType.ReliefArt); Vector2 position = new Vector2(0, 0); Rectangle destSize = new Rectangle(); int fX = t.ScreenXPos - (int)(MapRendering.TileWidthHalf * MapRendering.Scale); int fY = t.ScreenYPos - (int)(MapRendering.TileHeightHalf * MapRendering.Scale); fY -= ((ReliefArt.Height - 64)); position.X = fX; position.Y = fY; destSize.Width = (int)(ReliefArt.Width * MapRendering.Scale); destSize.Height = (int)(ReliefArt.Height * MapRendering.Scale); if (t.ReliefType.Index == 6) { MapTile MapTileNorthEast = t.NeighbouringTiles[MapTile.NeighbouringDirections.Northeast]; MapTile MapTileNorth = t.NeighbouringTiles[MapTile.NeighbouringDirections.North]; MapTile MapTileNorthWest = t.NeighbouringTiles[MapTile.NeighbouringDirections.Northwest]; int iStartCol = 1; int iStartRow = 1; //if (pMapTile->mRiverConnectionInfo & RIVER_CONNECTION_NORTH_WEST) //iStartRow += 1; //if (pMapTile->mRiverConnectionInfo & RIVER_CONNECTION_NORTH_EAST) //iStartRow += 2; //if (pMapTileNorthWest->mRiverConnectionInfo & RIVER_CONNECTION_NORTH_EAST) //iStartCol += 1; //if (pMapTileNorthEast->mRiverConnectionInfo & RIVER_CONNECTION_NORTH_WEST) //iStartCol += 2; if (iStartCol == 1 && iStartRow == 1) return; t.ReliefGfxIdx = ((iStartRow - 1) * 4) + (iStartCol - 1); fX = t.ScreenXPos - (int)(MapRendering.TileWidthHalf * MapRendering.Scale); fY = t.ScreenYPos - (int)(MapRendering.TileHeight * MapRendering.Scale); position.X = fX; position.Y = fY; } int iGfxTile = t.ReliefGfxIdx; int iRow = (iGfxTile / 4); int iTile = iGfxTile - (4 * (iGfxTile / 4)); int iStartU = 0 + (ReliefArt.Width * iTile); int iStartV = 0 + (ReliefArt.Height * iRow); MapRendering.AddReliefBatch(t, position, new Rectangle(iStartU, iStartV, ReliefArt.Width, ReliefArt.Height)); }
public override Unit AddUnit(UnitData UnitData, MapTile MapTile) { ActiveUnit = base.AddUnit(UnitData, MapTile); ActiveUnit.Owner = this; ActiveUnit.CenterOnMap(); return ActiveUnit; }
public virtual Unit AddUnit(UnitData UnitData, MapTile MapTile) { foreach (var Item in UnitList) { Item.Active = false; } Unit Unit = new Unit(UnitData, MapTile); Unit.Init(); Unit.ResetMoves(); Unit.Owner = this; Unit.Active = true; MapTile.AddUnit(Unit); UnitList.Add(Unit); return Unit; }
public static void AddReliefBatch(MapTile mapTile, Vector2 dest, Rectangle source ) { ReliefArt ReliefArt = ResourceInterface.ReliefArtData.Find(x => x.Type == mapTile.ReliefType.ReliefArt); Relief[ReliefArt.Index].AddBatch(dest, source); }
public override void SetTextures(MapTile MapTile) { int TerrainIdx = MapTile.TerrainType.Index; int[] Direction = {0, 0, 0}; Direction[0] = MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northeast] == null ? 0 : MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northeast].TerrainType.Index; Direction[1] = MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.North] == null ? 0 : MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.North].TerrainType.Index; Direction[2] = MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northwest] == null ? 0 : MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northwest].TerrainType.Index; List<TerrainArt> possibleTerrainArt = new List<TerrainArt>(); foreach ( string art in MapTile.TerrainType.TerrainArt ) { TerrainArt TerrainArt = ResourceInterface.TerrainArtData.Find(x => x.Type == art); TerrainData TerrainA = ResourceInterface.TerrainData.Find(x => x.Type == TerrainArt.Blend[0]); TerrainData TerrainB = ResourceInterface.TerrainData.Find(x => x.Type == TerrainArt.Blend[1]); TerrainData TerrainC = ResourceInterface.TerrainData.Find(x => x.Type == TerrainArt.Blend[2]); bool bFoundNorthWest = false; bool bFoundWest = false; bool bFoundSouthWest = false; if ( Direction[0] == TerrainA.Index || Direction[0] == TerrainB.Index || Direction[0] == TerrainC.Index ) bFoundNorthWest = true; if ( Direction[1] == TerrainA.Index || Direction[1] == TerrainB.Index || Direction[1] == TerrainC.Index ) bFoundWest = true; if ( Direction[2] == TerrainA.Index || Direction[2] == TerrainB.Index || Direction[2] == TerrainC.Index ) bFoundSouthWest = true; if (bFoundNorthWest == true && bFoundWest == true && bFoundSouthWest == true) possibleTerrainArt.Add(TerrainArt); } if ( possibleTerrainArt.Count > 0 ) { int idx = ( (MapTile.X+1) * (MapTile.Y+1) ) % (int)possibleTerrainArt.Count; TerrainArt TerrainArt = possibleTerrainArt[idx]; TerrainData TerrainA = ResourceInterface.TerrainData.Find(x => x.Type == TerrainArt.Blend[0]); TerrainData TerrainB = ResourceInterface.TerrainData.Find(x => x.Type == TerrainArt.Blend[1]); TerrainData TerrainC = ResourceInterface.TerrainData.Find(x => x.Type == TerrainArt.Blend[2]); int iStartCol = 0; int iStartRow = 0; if ( Direction[2] == TerrainA.Index ) iStartCol = 1; if ( Direction[2] == TerrainB.Index ) iStartCol = 4; if ( Direction[2] == TerrainC.Index ) iStartCol = 7; if ( TerrainIdx == TerrainA.Index ) iStartRow = 1; if ( TerrainIdx == TerrainB.Index ) iStartRow = 4; if ( TerrainIdx == TerrainC.Index ) iStartRow = 7; if ( Direction[0] == TerrainA.Index ) iStartRow += 0; if ( Direction[0] == TerrainB.Index ) iStartRow += 1; if ( Direction[0] == TerrainC.Index ) iStartRow += 2; if ( Direction[1] == TerrainA.Index ) iStartCol += 0; if ( Direction[1] == TerrainB.Index ) iStartCol += 1; if ( Direction[1] == TerrainC.Index ) iStartCol += 2; MapTile.GfxIdx = ((iStartRow - 1) * 9) + (iStartCol - 1); MapTile.Variation = TerrainArt.Index; } if (MapTile.ReliefType != null) { SetReliefTexture(MapTile); } }
public override void SetReliefTexture(MapTile MapTile) { bool[] bReliefDirectionIdx = { false, false, false, false }; bReliefDirectionIdx[0] = MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northwest] == null ? false : MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northwest].ReliefType != null ? true : false; bReliefDirectionIdx[1] = MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northeast] == null ? false : MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Northeast].ReliefType != null ? true : false; bReliefDirectionIdx[2] = MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Southwest] == null ? false : MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Southwest].ReliefType != null ? true : false; bReliefDirectionIdx[3] = MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Southeast] == null ? false : MapTile.NeighbouringTiles[Map.MapTile.NeighbouringDirections.Southeast].ReliefType != null ? true : false; int iStartRow = 1; int iStartCol = 1; if (bReliefDirectionIdx[2] == true) iStartRow = 2; if (bReliefDirectionIdx[3] == true) iStartRow = 3; if (bReliefDirectionIdx[2] == true && bReliefDirectionIdx[3] == true) iStartRow = 4; if (bReliefDirectionIdx[0] == true) iStartCol = 2; if (bReliefDirectionIdx[1] == true) iStartCol = 3; if (bReliefDirectionIdx[0] == true && bReliefDirectionIdx[1] == true) iStartCol = 4; MapTile.ReliefGfxIdx = ((iStartRow - 1) * 4) + (iStartCol - 1); }
public override void AddTerritory(MapTile t) { Vector2 position = new Vector2(0, 0); Rectangle destSize = new Rectangle(); int fX = t.ScreenXPos - (int)(MapRendering.TileWidthHalf * MapRendering.Scale); int fY = t.ScreenYPos - (int)(MapRendering.TileHeightHalf * MapRendering.Scale); fY -= ((72 - 64)); position.X = fX; position.Y = fY; destSize.Width = (int)(MapRendering.TileWidth * MapRendering.Scale); destSize.Height = (int)(72 * MapRendering.Scale); MapTile NorthWest = t.NeighbouringTiles[MapTile.NeighbouringDirections.Northwest]; MapTile NorthEast = t.NeighbouringTiles[MapTile.NeighbouringDirections.Northeast]; MapTile SouthWest = t.NeighbouringTiles[MapTile.NeighbouringDirections.Southwest]; MapTile SouthEast = t.NeighbouringTiles[MapTile.NeighbouringDirections.Southeast]; int iRow = 0; int iTile = 0; if (NorthWest != null && ( NorthWest.Owner == null || NorthWest.Owner != t.Owner ) ){ iRow = 0; iTile = 0; MapRendering.AddTerritoryBatch(t, position, new Rectangle(0 + (MapRendering.TileWidth * iTile), 0 + (72 * iRow), MapRendering.TileWidth, 72)); } if (NorthEast != null && (NorthEast.Owner == null || NorthEast.Owner != t.Owner)) { iRow = 1; iTile = 0; MapRendering.AddTerritoryBatch(t, position, new Rectangle(0 + (MapRendering.TileWidth * iTile), 0 + (72 * iRow), MapRendering.TileWidth, 72)); } if (SouthWest != null && (SouthWest.Owner == null || SouthWest.Owner != t.Owner)) { iRow = 2; iTile = 0; MapRendering.AddTerritoryBatch(t, position, new Rectangle(0 + (MapRendering.TileWidth * iTile), 0 + (72 * iRow), MapRendering.TileWidth, 72)); } if (SouthEast != null && (SouthEast.Owner == null || SouthEast.Owner != t.Owner)) { iRow = 3; iTile = 0; MapRendering.AddTerritoryBatch(t, position, new Rectangle(0 + (MapRendering.TileWidth * iTile), 0 + (72 * iRow), MapRendering.TileWidth, 72)); } }
public override void AddResource(MapTile t) { Vector2 position = new Vector2(0, 0); //IrrlichtLime.Core.Recti textureRect = new IrrlichtLime.Core.Recti(0, 0, 0, 0); Rectangle destSize = new Rectangle(); int fX = t.ScreenXPos - (int)(25 * MapRendering.Scale); int fY = t.ScreenYPos - (int)(25 * MapRendering.Scale); position.X = fX; position.Y = fY; destSize.Width = (int)(50 * MapRendering.Scale); destSize.Height = (int)(50 * MapRendering.Scale); int iGfxTile = t.ResourceType.Icon; int iRow = (iGfxTile / 6); int iTile = iGfxTile - (6 * (iGfxTile / 6)); int iStartU = 0 + (50 * iTile); int iStartV = 0 + (50 * iRow); MapRendering.AddResourceBatch(t, position, new Rectangle(iStartU, iStartV, 50, 50)); }
public override void SetTextures(MapTile MapTile) { }
public static void AddTerritoryBatch(MapTile maptile, Vector2 dest, Rectangle source) { Territory.AddBatch(dest, source, maptile.Owner.CivilizationData.Color); }
public static void AddTerrainBatch(MapTile mapTile, Vector2 dest, Rectangle source ) { Terrain[mapTile.Variation].AddBatch( dest, source); }
public static void AddResourceBatch(MapTile mapTile, Vector2 dest, Rectangle source) { Resource.AddBatch(dest, source); }
public override void AddRelief(MapTile t) { }
public override void AddMapTile(MapTile t) { }
public void PlayAnimation( UnitAnimation.EAnimStates animState, MapTile.NeighbouringDirections direction, IndieCivCore.Resources.UnitData unitData ) { AnimState = animState; switch ( AnimState ) { case EAnimStates.EAnimState_Default: this.CurrentFlc = unitData.GetUnitAnimation("UNIT_ART_DEFAULT"); break; } if ( this.CurrentFlc != null ) this.Start(direction); }
public void Start(MapTile.NeighbouringDirections Direction) { AnimDirection = Direction; CurrentFrame = StartFrame = (int)AnimDirection * (CurrentFlc.Civ3Header.animLength+1); //CurrentFrame = StartFrame = 0; //EndFrame = 14; EndFrame = StartFrame + CurrentFlc.Civ3Header.animLength; //EndFrame = ((int)AnimDirection * CurrentFlc.Civ3Header.animLength) + CurrentFlc.Civ3Header.animLength - 1; Speed = (float)CurrentFlc.FlcHeader.speed; }
public override bool SmoothTile(MapTile MapTile) { return false; }
public override bool SmoothTile(MapTile MapTile) { bool Changed = false; foreach ( var item in MapTile.NeighbouringTiles ) { MapTile Direction = MapTile.NeighbouringTiles[item.Key]; if (Direction != null) { if (CanBlend(MapTile, Direction) == false) { foreach ( var blend in MapTile.TerrainType.Blend ) { TerrainData From = ResourceInterface.TerrainData.Find(x => x.Type == blend.From); if (From == Direction.TerrainType) { Direction.TerrainType = ResourceInterface.TerrainData.Find(x => x.Type == blend.To); Changed = true; } } } } } return Changed; }
private bool CanBlend( MapTile MapTile, MapTile Blend ) { foreach ( string art in MapTile.TerrainType.TerrainArt ) { TerrainArt TerrainArt = ResourceInterface.TerrainArtData.Find(x => x.Type == art); foreach ( string b in TerrainArt.Blend ) { //TerrainData TerrainData = ResourceInterface.TerrainData.Find(x => x.Type == b); if ( b == Blend.TerrainType.Type ) return true; } } return false; }
public override bool PointInsideMapTile(MapTile t) { return true; }
public override void AddResource(MapTile t) { }
public override bool PointInsideMapTile(MapTile MapTile) { Vector2[] points = new Vector2[4]; Vector2 mouse; int xTile = MapTile.ScreenXPos;// +MapRendering.TileWidthHalf; int yTile = MapTile.ScreenYPos;// +MapRendering.TileHeightHalf; points[0] = new Vector2(xTile - MapRendering.TileWidthHalf, yTile); points[1] = new Vector2(xTile, yTile - MapRendering.TileHeightHalf); points[2] = new Vector2(xTile + MapRendering.TileWidthHalf, yTile ); points[3] = new Vector2(xTile , yTile + MapRendering.TileHeightHalf); int iMouseX = (int)MouseState.Position.X; int iMouseY = (int)MouseState.Position.Y; mouse = new Vector2(iMouseX, iMouseY); float nx, ny, x, y; for (int i = 0; i < 4; i++) { nx = points[(i + 1) % 4].Y - points[i].Y; ny = points[i].X - points[(i + 1) % 4].X; x = mouse.X - points[i].X; y = mouse.Y - points[i].Y; if ((x * nx) + (y * ny) > 0) return false; } return true; }
public override void AddTerritory(MapTile t) { }
public static void AddStartLocationBatch(MapTile maptile, Vector2 dest, Rectangle source) { StartLocation.AddBatch(dest, source); }