void Awake() { m_tileMap = GameObject.Find("TileMap").GetComponent <TileMapBehaviour>(); // TODO add keyboard input, calling UpdateVision after each change in position //m_input = GetComponent<KeyboardInputBehaviour>(); }
private void Awake() { // Find the tilemap game object and cache the behaviour. m_tileMap = GameObject.Find("TileMap").GetComponent <TileMapBehaviour>(); if (m_tileMap == null) { Debug.LogError("TileMapBehaviour not found"); return; } // Rather than hardcode the resolution of a tile, use the size of the first sprite. var tileSheet = m_tileMap.TileSheet; if (tileSheet.Count == 0) { Debug.LogError("Add some sprites before running the game"); return; } var spriteSize = tileSheet.Get(0).rect; // Define and apply the settings for the tilemap. var settings = new TileMeshSettings(SizeX, SizeY, (int)spriteSize.width); m_tileMap.MeshSettings = settings; // Map type of tile to sprite m_tiles = new TileEnumMapper <TileType>(m_tileMap); m_tiles.Map(TileType.Wall, "Wall2"); m_tiles.Map(TileType.Floor, "Floor"); m_tiles.Map(TileType.StairsUp, "StairsUp"); m_tiles.Map(TileType.StairsDown, "StairsDown"); }
// Use this for initialization private void Start() { m_tileMap = GameObject.Find("TileMap").GetComponent <TileMapBehaviour>(); if (m_tileMap == null) { Debug.LogError("TileMapBehaviour not found"); } }
private void Awake() { m_tileMapBehaviour = GetComponent <TileMapBehaviour>(); if (m_tileMapBehaviour == null) { Debug.LogError("TileMapBehaviour not found"); } }
public TilePainter(TileMapBehaviour tileMap) { if (tileMap == null) { throw new ArgumentNullException("tileMap"); } m_tileMap = tileMap; }
private void Awake() { // Find the tilemap game object and cache the behaviour. m_tileMap = GameObject.Find("TileMap").GetComponent <TileMapBehaviour>(); if (m_tileMap == null) { Debug.LogError("TileMapBehaviour not found"); } }
// Use this for initialization void Start() { // The TileMapVisibilityBehaviour should be created by the TileMapBehaviour as a child m_tileMap = transform.parent.GetComponent <TileMapBehaviour>(); if (m_tileMap == null) { throw new InvalidOperationException("TileMapVisibility GameObject is not a child of TileMap, did you create it yourself?"); } AttachToTileMap(m_tileMap); }
public void AttachToTileMap(TileMapBehaviour tileMap) { m_tileMap = tileMap; // position the visibility graphics to match the tile map // TODO doesnt support moving the tile map after visibility has been attached transform.position = m_tileMap.transform.position; // create the texture that will cover the unseen parts of the map with black, one pixel per tile // TODO add support for resizing map after its been attached m_texture = new Texture2D( m_tileMap.MeshSettings.TilesX, m_tileMap.MeshSettings.TilesY, TextureFormat.RGBA32, false); m_texture.name = "TileMapVisibilityTexture"; m_texture.filterMode = FilterMode.Point; // TODO filter mode selected by user? //m_texture.alphaIsTransparency = true; // setup the grid to cache status, so we dont draw on the texture when we dont have to m_visible = new Grid <bool>(); m_visible.SetSize(m_texture.width, m_texture.height, true); // paint all tiles invisible initially for (int x = 0; x < m_texture.width; x++) { for (int y = 0; y < m_texture.height; y++) { SetTileVisible(x, y, false); } } m_texture.Apply(); // create a sprite that will cover the map, upscaling each pixel to cover a tile var textureRect = new Rect(0, 0, m_texture.width, m_texture.height); var sprite = Sprite.Create(m_texture, textureRect, Vector2.zero); sprite.name = "TileMapVisibilitySprite"; m_spriteRenderer.sprite = sprite; // scale to cover tilemap transform.localScale = new Vector3(100, 100, 0f); // TODO is this because 100 pixels per unit? // setup the grid to cache status, so we dont draw on the texture when we dont have to m_visible = new Grid <bool>(); m_visible.SetSize(m_texture.width, m_texture.height, false); }
private void OnEnable() { m_tileMap = (TileMapBehaviour)target; m_tileSheet = m_tileMap.TileSheet; var meshSettings = m_tileMap.MeshSettings; if (meshSettings != null) { m_tilesX = meshSettings.TilesX; m_tilesY = meshSettings.TilesY; m_tileResolution = meshSettings.TileResolution; m_tileSize = meshSettings.TileSize; m_meshMode = meshSettings.MeshMode; m_textureFormat = meshSettings.TextureFormat; } m_activeInEditMode = m_tileMap.ActiveInEditMode; }
private void Start() { m_cam = GameObject.FindGameObjectWithTag("MapEditorCamera").GetComponent <Camera>(); m_tileMapGrid = FindObjectOfType <TileMapGrid>(); m_tileMap = FindObjectOfType <TileMapBehaviour>(); m_tileSheet = m_tileMap.TileSheet; m_tempTexture = new Texture2D(64, 64); m_tileSheetIds = m_tileSheet.Ids.ToArray(); m_tileMeshSettings = m_tileMap.MeshSettings; m_tileMap.GetComponentInChildren <TileMeshBehaviour>().transform.localPosition = Vector3.zero; RefreshTiles(); StartCoroutine(IUpdateMouseHit()); // FormatMap(); }
// Use this for initialization private void Start() { var tileMapGameObject = GameObject.Find("TileMap"); m_tileMap = tileMapGameObject.GetComponent <TileMapBehaviour>(); if (m_tileMap == null) { Debug.LogError("TileMapBehaviour not found"); } m_levelBehaviour = tileMapGameObject.GetComponent <LevelBehaviour>(); if (m_levelBehaviour == null) { Debug.LogError("LevelBehaviour not found"); } m_sceneFadeInOut = GameObject.Find("SceneFader").GetComponent <SceneFadeInOut>(); if (m_sceneFadeInOut == null) { Debug.LogError("SceneFadeInOut not found"); } }
void Start() { m_tileMap = FindObjectOfType <TileMapBehaviour>(); m_tileMapGame = FindObjectOfType <TileMapGameBahaviour>(); }
void Awake() { // TODO a general way to find and attach to a tile map m_tileMap = GameObject.Find("TileMap").GetComponent <TileMapBehaviour>(); }