Skip to content

Instantly share code, notes, and snippets.

View arun02139's full-sized avatar

arun02139

  • San Fransisco / Tokyo / Boston
View GitHub Profile
@arun02139
arun02139 / OffsetCoordinate.cs
Last active March 15, 2017 23:23
This struct is losing it's values; it should be serialized (private member marked [Serializable] in MyHexagon.cs)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// NOTE: this struct is assumed to be column ordered, i.e. compatable with even-q and odd-q offset coordinate layouts
public struct OffsetCoordinate
{
public int col { get { return _col; } }
public int row { get { return _row; } }
int _col;
@arun02139
arun02139 / MyHexagonInspector.cs
Created March 15, 2017 13:44
Custom inspector to look at the coordinate values (that should be getting serialized but aren't)
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(MyHexagon))]
public class MyHexagonInspector : Editor
{
public override void OnInspectorGUI()
{
var myHex = (MyHexagon)target;
@arun02139
arun02139 / MyHexagon.cs
Created March 15, 2017 13:37
Script attached to my hexagonal cell prefab, inherits from Hexagon
using UnityEngine;
public class MyHexagon : Hexagon
{
public void Start()
{
SetColor(Color.white);
SetOutlineColor(Color.black);
}
@arun02139
arun02139 / Hexagon.cs
Created March 15, 2017 13:34
Abstract class (inheriting from Cell) for all types of hexagonal cells
using System.Collections.Generic;
using UnityEngine;
using System;
// for now, let's simplify our possible representations to match the core examples
// in the link below; full set of layout options is: odd_r, even_r, odd_q, even_q
public enum HexGridType { odd_q }
// implementation of hexagonal cell
// helpful link: http://www.redblobgames.com/grids/hexagons/
@arun02139
arun02139 / Cell.cs
Created March 15, 2017 13:33
Abstract base class for a generic 'cell'
using UnityEngine;
using UnityEngine.Networking;
using System;
using System.Collections.Generic;
public abstract class Cell : NetworkBehaviour, IGraphNode, ITouchable
{
public OffsetCoordinate offsetCoord
{
get { return _offsetCoord; }
@arun02139
arun02139 / HexCellUI.cs
Created March 15, 2017 01:50
Single ui to display various cell coordinate systems
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Assertions;
public enum CoordinateType { Off, Cube, Offset, Index } // NOTE: offset coordinates are type 'even-q'
public class HexCellUI : MonoBehaviour
{
@arun02139
arun02139 / CellUIsMenu.cs
Created March 15, 2017 01:48
Menu options to add, remove, and alter cell ui settings
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Assertions;
public class CellUIsMenu : MonoBehaviour
{
[MenuItem ("Window/CellUIs/Add")]
static void Add()
{
@arun02139
arun02139 / BattleInspector.cs
Created March 9, 2017 03:02
Custom inspector trying to expose 'state' of battle at any time
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(Battle))]
public class BattleInspector : Editor
{
public override void OnInspectorGUI()
{
var battle = (Battle)target;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.Assertions;
using System.Collections;
public class LocalHostBootstrap : MonoBehaviour
{
string _debugString;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.Assertions;
using UnityEditor;
[InitializeOnLoad]
class EditorStartup
{