Skip to content

Instantly share code, notes, and snippets.

@allencoded
Last active June 4, 2018 07:10
Show Gist options
  • Save allencoded/4f91454e52fdbc5b426b3c397d4e0145 to your computer and use it in GitHub Desktop.
Save allencoded/4f91454e52fdbc5b426b3c397d4e0145 to your computer and use it in GitHub Desktop.
Test our Tile
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