コード例 #1
0
    void DrawDebugCellGrid()
    {
        Color    color       = new Color(1, 0, 0, 0.3f);
        Color    freeColor   = new Color(1, 1, 1, 0.03f);
        Vector2i pos         = Iso.Snap(Iso.MapToIso(Camera.main.transform.position));
        int      debugWidth  = 100;
        int      debugHeight = 100;

        pos.x -= debugWidth / 2;
        pos.y -= debugHeight / 2;
        int index = instance.MapToIndex(pos);

        for (int y = 0; y < debugHeight; ++y)
        {
            for (int x = 0; x < debugWidth; ++x)
            {
                if (index + x < 0 || index + x >= instance.map.Length)
                {
                    continue;
                }

                if (!instance.map[index + x].passable)
                {
                    Iso.DebugDrawTile(pos + new Vector3(x, y), color, 0.9f);
                }
                else
                {
                    Iso.DebugDrawTile(pos + new Vector3(x, y), freeColor, 0.9f);
                }
            }
            index += width;
        }
    }
コード例 #2
0
ファイル: CollisionMap.cs プロジェクト: D7tila/Diablerie
    public static Cell GetCell(Vector3 pos)
    {
        var tilePos = Iso.Snap(pos);
        int index   = instance.MapToIndex(tilePos);

        return(instance.map[index]);
    }