//Texture index for the bridge description //public int TextureIndex; //public string UseLink;//A trigger to fire when used. protected override void Start() { if (invis == 0) { TileMapRenderer.RenderBridge(GameWorldController.instance.SceneryModel, CurrentTileMap(), CurrentObjectList(), objInt().objectloaderinfo.index); } base.Start(); BoxCollider bx = this.GetComponent <BoxCollider>(); if (bx != null) { bx.center = new Vector3(0.08f, 0.006f, 0.08f); bx.size = new Vector3(1.2f, 0.18f, 1.2f); } if ( (ObjectTileX <= TileMap.TileMapSizeX) && (ObjectTileY <= TileMap.TileMapSizeY) ) { int TextureIndex = (enchantment << 3) | flags & 0x3F; if (TextureIndex < 2) { //Only flag the normal briges as such. CurrentTileMap().Tiles[ObjectTileX, ObjectTileY].hasBridge = true; } } }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("Regenerate")) { TileMapRenderer tilemap = (TileMapRenderer)target; tilemap.Build(); } }
public static void ReplaceMapTiles(this TileMapRenderer mapRenderer, uint mapGid, uint gid) { var tiles = mapRenderer.cache.GetTiles(mapGid); foreach (var kvp in tiles) { foreach (var tile in kvp.Value) { mapRenderer.SetTileID(kvp.Key, tile.x, tile.y, gid); } } }
void UpdateTile(int tileXToChange, int tileYToChange, short newFloorTexture) { TileInfo tileToChange = CurrentTileMap().Tiles[tileXToChange, tileYToChange]; if (tileToChange.floorTexture != newFloorTexture) { GameObject tile = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR); tileToChange.TileNeedsUpdate(); //Water xtileToChange.isWater = false; TileMapRenderer.UpdateTile(tileXToChange, tileYToChange, tileToChange.tileType, 18, newFloorTexture, tileToChange.wallTexture, false); Destroy(tile); } }
public void Awake() { tileMap = new TileMap(); _renderer = GetComponent <TileMapRenderer>(); _aStarControllerTile = GetComponent <MinimapController_Tile>(); _aStarControllerWaypoint = GetComponent <MinimapController_Waypoint>(); _startPointGO = GameObject.Instantiate(startPointPrefab); _startPointGO.transform.SetParent(transform); _endPointGO = GameObject.Instantiate(endPointPrefab); _endPointGO.transform.SetParent(transform); _guiState = GUIState.Normal; _worldRep = WorldRepresenation.Tile; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); TileMapRenderer mapRenderer = (TileMapRenderer)target; if (GUILayout.Button("Create Empty Map")) { mapRenderer.Clear(); mapRenderer.CreateEmptyMap(); } if (GUILayout.Button("Clear")) { mapRenderer.Clear(); } }
public Map(int width, int height, int tileSize) { Width = width; Height = height; TileSize = tileSize; // _tiles = new Tile[width * height]; for (var i = 0; i < _tiles.Length; i++) { _tiles[i] = new Tile(); } // _colliders = new List <Collider>(); // AddComponent(_mapRenderer = new TileMapRenderer(this)); _mapRenderer.Depth = -1; // Push behind most things }
void ChangeTileHeight(int tileX, int tileY, int newHeight) { TileInfo t = CurrentTileMap().Tiles[tileX, tileY]; //int curHeight = CurrentTileMap().Tiles[tileX, tileX].floorHeight; //Debug.Log("Changing height from " + curHeight + " to " + newHeight + " at " + owner); //int diff = newHeight - curHeight; t.floorHeight = (short)newHeight; GameObject platformTile = GameWorldController.FindTile(tileX, tileY, TileMap.SURFACE_FLOOR); TileVector = CurrentTileMap().getTileVector(tileX, tileY); Collider[] colliders = Physics.OverlapBox(TileVector, ContactArea); MoveObjectsInContact((float)(newHeight) * 0.15f, colliders); //CurrentTileMap().Tiles[tileX, tileX].TileNeedsUpdate(); DestroyImmediate(platformTile); TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel, t.tileX, t.tileY, t, false, false, false, true); //MoveTile(platformTile.transform, new Vector3(0f, (float)(diff) * 0.3f, 0f), 0.1f, tileX, tileY); }
public void UpdateTile(int tileXtoUpdate, int tileYtoUpdate, int TileTypeSelected, int FloorTextureSelected, int WallTextureSelected, int FloorHeight) { bool ReRenderNeighbours = false; if (!GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].NeedsReRender) { TileMapRenderer.DestroyTile(tileXtoUpdate, tileYtoUpdate); } GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].TileNeedsUpdate(); if (TileTypeSelected != -1) { switch (TileTypeSelected) { case TileMap.TILE_SLOPE_E: case TileMap.TILE_SLOPE_W: case TileMap.TILE_SLOPE_N: case TileMap.TILE_SLOPE_S: GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].shockSteep = 2; break; } GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].tileType = (short)TileTypeSelected; } if (FloorHeight != -1) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].floorHeight = (short)(FloorHeight * 2); } if (FloorTextureSelected != -1) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].floorTexture = (short)(FloorTextureSelected); int ActualTextureIndex = GameWorldController.instance.currentTileMap().texture_map[FloorTextureSelected + 48]; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].isWater = TileMap.isTextureWater(ActualTextureIndex); GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].isLava = TileMap.isTextureLava(ActualTextureIndex); } if (GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].wallTexture != WallTextureSelected) { if (GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].tileType == TileMap.TILE_SOLID) { if (WallTextureSelected != -1) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].North = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].South = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].East = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].West = (short)WallTextureSelected; } } if (WallTextureSelected != -1) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate].wallTexture = (short)WallTextureSelected; if (tileYtoUpdate > 0) { //Change its neighbour, only if the neighbour is not a solid if (GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate - 1].tileType > TileMap.TILE_SOLID) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate - 1].North = (short)WallTextureSelected; ReRenderNeighbours = true; } else if ((FollowMeMode) && (WallTextureSelected != -1)) { //Repaint neighouring solid walls in follow mode GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].wallTexture = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].North = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].South = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].East = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].West = (short)WallTextureSelected; ReRenderNeighbours = true; } } if (tileYtoUpdate < TileMap.TileMapSizeY) { //Change its neighbour, only if the neighbour is not a solid if (GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate + 1].tileType > TileMap.TILE_SOLID) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate + 1].South = (short)WallTextureSelected; ReRenderNeighbours = true; } else if ((FollowMeMode) && (WallTextureSelected != -1)) { //Repaint neighouring solid walls in follow mode GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate + 1].wallTexture = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate + 1].North = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate + 1].South = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate + 1].East = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate, tileYtoUpdate + 1].West = (short)WallTextureSelected; ReRenderNeighbours = true; } } if (tileXtoUpdate > 0) { //Change its neighbour, only if the neighbour is not a solid if (GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].tileType > TileMap.TILE_SOLID) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].East = (short)WallTextureSelected; ReRenderNeighbours = true; } else if ((FollowMeMode) && (WallTextureSelected != -1)) { //Repaint neighouring solid walls in follow mode GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].wallTexture = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].North = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].South = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].East = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate - 1, tileYtoUpdate].West = (short)WallTextureSelected; ReRenderNeighbours = true; } } if (tileXtoUpdate < TileMap.TileMapSizeX) { //Change its neighbour, only if the neighbour is not a solid if (GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate + 1, tileYtoUpdate].tileType > TileMap.TILE_SOLID) { GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate + 1, tileYtoUpdate].West = (short)WallTextureSelected; ReRenderNeighbours = true; } else if ((FollowMeMode) && (WallTextureSelected != -1)) { //Repaint neighouring solid walls in follow mode GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate + 1, tileYtoUpdate].wallTexture = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate + 1, tileYtoUpdate].North = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate + 1, tileYtoUpdate].South = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate + 1, tileYtoUpdate].East = (short)WallTextureSelected; GameWorldController.instance.currentTileMap().Tiles[tileXtoUpdate + 1, tileYtoUpdate].West = (short)WallTextureSelected; ReRenderNeighbours = true; } } } } if (ReRenderNeighbours) { for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { if (!((x == 0) && (y == 0))) //Not the middle { if ((x + tileXtoUpdate <= TileMap.TileMapSizeX) && (x + tileXtoUpdate >= 0)) { if ((y + tileYtoUpdate <= TileMap.TileMapSizeY) && (y + tileYtoUpdate >= 0)) { if (!GameWorldController.instance.currentTileMap().Tiles[x + tileXtoUpdate, y + tileYtoUpdate].NeedsReRender) { TileMapRenderer.DestroyTile(x + tileXtoUpdate, y + tileYtoUpdate); } GameWorldController.instance.currentTileMap().Tiles[x + tileXtoUpdate, y + tileYtoUpdate].TileNeedsUpdate(); } } } } } } }
/* * A change terrain trap changes a tile from one type to another. It works over a range of tiles that are set by the traps * x,y values. In Underworld these are set by the the relative position of the trap within the tile. * The tile it acts on is controlled by the trigger. * * Examples of it's usage * The Moonstone room on Level2 * The path to the sword hilt on Level3 * */ public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State) { Debug.Log(this.name); int textureQuality = (objInt().quality >> 1) & 0xf; for (short x = 0; x <= objInt().x; x++) { for (short y = 0; y <= objInt().y; y++) { short tileXToChange = (short)(x + triggerX); short tileYToChange = (short)(y + triggerY); GameObject tile = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR); if (tile != null) { TileInfo tileToChange = GameWorldController.instance.currentTileMap().Tiles[tileXToChange, tileYToChange]; //Destroy (tile); switch (_RES) { //I will probably have to change this again! //case GAME_UW2: // tileToChange.floorTexture=textureQuality; // break; default: if (textureQuality < 10) { tileToChange.floorTexture = (short)textureQuality; //+48; //tileToChange.floorTexture=GameWorldController.instance.currentTileMap().texture_map[textureQuality+48]; } break; } //currobj.zpos >> 2 //(objList[k].zpos >> 2); tileToChange.Render = true; for (int v = 0; v < 6; v++) { tileToChange.VisibleFaces[v] = true; } short tileTypeToChangeTo = (short)(objInt().quality & 0x01); short newTileHeight = (short)(objInt().zpos >> 2); short newWallTexture = tileToChange.wallTexture; if (_RES == GAME_UW2) { //Also the owner can be used to change wall texture. This means changing it's neighours. if (objInt().owner < 63) { newWallTexture = objInt().owner; } } //tileToChange.tileType=tileTypeToChangeTo; tileToChange.DimX = 1; tileToChange.DimY = 1; ////tileToChange.floorHeight=newTileHeight; //tileToChange.floorHeight=tileToChange.floorHeight;//DOUBLE CHECK THIS tileToChange.isWater = TileMap.isTextureWater(GameWorldController.instance.currentTileMap().texture_map[tileToChange.floorTexture]); //TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel,tileXToChange,tileYToChange,tileToChange,tileToChange.isWater,false,false,true); tileToChange.TileNeedsUpdate(); TileMapRenderer.UpdateTile(tileXToChange, tileYToChange, tileTypeToChangeTo, newTileHeight, tileToChange.floorTexture, newWallTexture, false); Destroy(tile); if (tileToChange.isDoor) { //The door may be rendered GameObject door = GameWorldController.findDoor(tileToChange.tileX, tileToChange.tileY); if (door != null) { string doorname = ObjectLoader.UniqueObjectName(door.GetComponent <ObjectInteraction>().objectloaderinfo); DestroyDoorPortion("front_leftside_" + doorname); DestroyDoorPortion("front_over_" + doorname); DestroyDoorPortion("front_rightside_" + doorname); DestroyDoorPortion("side1_filler_" + doorname); DestroyDoorPortion("over_filler_" + doorname); DestroyDoorPortion("side2_filler_" + doorname); DestroyDoorPortion("front_filler_" + doorname); DestroyDoorPortion("rear_leftside_" + doorname); DestroyDoorPortion("rear_over_" + doorname); DestroyDoorPortion("rear_rightside_" + doorname); DestroyDoorPortion(doorname); TileMapRenderer.RenderDoorwayFront( GameWorldController.instance.LevelModel, GameWorldController.instance.currentTileMap(), GameWorldController.instance.CurrentObjectList(), door.GetComponent <ObjectInteraction>().objectloaderinfo ); TileMapRenderer.RenderDoorwayRear( GameWorldController.instance.LevelModel, GameWorldController.instance.currentTileMap(), GameWorldController.instance.CurrentObjectList(), door.GetComponent <ObjectInteraction>().objectloaderinfo ); Vector3 objPos = door.transform.position; ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), door.GetComponent <ObjectInteraction>().objectloaderinfo, GameWorldController.instance.LevelModel, objPos ); } } } else { Debug.Log(this.name + " Unable to find tile for change terrain trap " + tileXToChange + " " + tileYToChange); } } } GameWorldController.WorldReRenderPending = true; // if ((objInt().owner<63) && (_RES==GAME_UW2)) // { //Now force re-render the tiles and their neighbours for (int x = -1; x <= objInt().x + 1; x++) { for (int y = -1; y <= objInt().y + 1; y++) { int tileXToChange = x + triggerX; int tileYToChange = y + triggerY; GameObject tile = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR); if (tile != null) { Destroy(tile); } if ((tileXToChange >= 0) && (tileXToChange <= 63) && (tileYToChange >= 0) && (tileYToChange <= 63)) { TileInfo tileToChange = GameWorldController.instance.currentTileMap().Tiles[tileXToChange, tileYToChange]; tileToChange.Render = true; for (int v = 0; v < 6; v++) { tileToChange.VisibleFaces[v] = true; } tileToChange.isWater = TileMap.isTextureWater(GameWorldController.instance.currentTileMap().texture_map[tileToChange.floorTexture]); //TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel,tileXToChange,tileYToChange,tileToChange,tileToChange.isWater,false,false,true); tileToChange.TileNeedsUpdate(); } } } //} }
protected override void ExitAction() { SetChunksToUpdate(); TileMapRenderer.RenderChunks(Parameters.ChunksToUpdate); //MapInteractionManager.Instance.ManuallyUpdateSelectionMesh(); }
public static void ApplyMeshTileChanges(this TileMapRenderer mapRenderer, int layerIndex) { mapRenderer.tileLayers[layerIndex].ApplyMeshTileChanges(); }
public static void SetTileID(this TileMapRenderer mapRenderer, int layerIndex, int x, int y, uint gid, bool flipX = false, bool flipY = false) { mapRenderer.tileLayers[layerIndex].SetTileID(x, y, gid, flipX, flipY); }