Skip to content

Instantly share code, notes, and snippets.

@erodozer
Created December 20, 2017 03:41
Show Gist options
  • Save erodozer/5f6c2ed4c52c1293c5193ddd81a00d14 to your computer and use it in GitHub Desktop.
Save erodozer/5f6c2ed4c52c1293c5193ddd81a00d14 to your computer and use it in GitHub Desktop.
Roguelike tile
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Adventure.Tilemaps
{
/// <summary>
/// RoguelikeTiles are an extension of regular Unity tiles, containing additional parameters
/// such as Density and Collision represented as a boolean, which are useful for traversing the
/// tilemap and providing FOV
/// </summary>
public class RoguelikeTile : Tile {
public float Density;
public bool Passable;
#if UNITY_EDITOR
// The following is a helper that adds a menu item to create a RoadTile Asset
[MenuItem("Assets/Create/RoguelikeTile")]
public static void CreateRoguelikeTile()
{
string path = EditorUtility.SaveFilePanelInProject("Save Roguelike Tile", "New Roguelike Tile", "Asset", "Save Roguelike Tile", "Assets");
if (path == "")
return;
AssetDatabase.CreateAsset(ScriptableObject.CreateInstance<RoguelikeTile>(), path);
}
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment