Example #1
0
    void OnDrawGizmos()
    {
        // NOTE(Julian): For debug visualization in Unity editor
        if (!Application.isPlaying && WorldManager.g != null)
        {
            Rotatable       r = GetComponent <Rotatable>();
            MovementMachine m = GetComponent <MovementMachine>();
            Color           color;
            if (r != null)
            {
                color = Color.blue;
            }
            else if (m != null)
            {
                color = Color.green;
            }
            else
            {
                color = Color.white;
            }

            float tileSize = WorldManager.g.TileSize;
            var   all = AbsoluteLocations(_loc, _rotation);
            int   x, y, z;
            for (int i = 0; i < all.Count; i++)
            {
                x            = all [i].x;
                y            = all [i].y;
                z            = all [i].z;
                Gizmos.color = color;
                Gizmos.DrawCube(new Vector3(x + 0.5f, y + 0.5f, z + 0.5f) * tileSize, Vector3.one * tileSize * 0.90f);

                Gizmos.color = Color.black;

                Gizmos.DrawLine(new Vector3(tileSize * (x), tileSize * (y), 0f),
                                new Vector3(tileSize * (x + 1f), tileSize * (y + 1f), 0f));
                Gizmos.DrawLine(new Vector3(tileSize * (x), tileSize * (y + 1f), 0f),
                                new Vector3(tileSize * (x + 1f), tileSize * (y), 0f));

                Gizmos.DrawLine(new Vector3(0f, tileSize * (y), tileSize * (z)),
                                new Vector3(0f, tileSize * (y + 1f), tileSize * (z + 1f)));
                Gizmos.DrawLine(new Vector3(0f, tileSize * (y + 1f), tileSize * (z)),
                                new Vector3(0f, tileSize * (y), tileSize * (z + 1f)));
            }
        }
    }
Example #2
0
 void Awake()
 {
     _worldEntity     = GetComponent <WorldEntity>();
     _rotatable       = GetComponent <Rotatable>();
     _movementMachine = GetComponent <MovementMachine>();
 }