Last active
June 4, 2018 07:10
-
-
Save allencoded/4f91454e52fdbc5b426b3c397d4e0145 to your computer and use it in GitHub Desktop.
Test our Tile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Tilemaps; | |
public class TestOurTile : MonoBehaviour { | |
private WorldTile _tile; | |
// Update is called once per frame | |
private void Update () { | |
if (Input.GetMouseButtonDown(0)) | |
{ | |
Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition); | |
var worldPoint = new Vector3Int(Mathf.FloorToInt(point.x), Mathf.FloorToInt(point.y), 0); | |
var tiles = GameTiles.instance.tiles; // This is our Dictionary of tiles | |
if (tiles.TryGetValue(worldPoint, out _tile)) | |
{ | |
print("Tile " + _tile.Name + " costs: " + _tile.Cost); | |
_tile.TilemapMember.SetTileFlags(_tile.LocalPlace, TileFlags.None); | |
_tile.TilemapMember.SetColor(_tile.LocalPlace, Color.green); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment