コード例 #1
0
ファイル: Edge.cs プロジェクト: anviettrung/Hexagon-Valley
    public void SetPositionInWorldCoordinate()
    {
        worldPosition = (linkedHexpoint[0].worldPosition + linkedHexpoint[1].worldPosition) * 0.5f;
        Vector2Int direct = linkedHexpoint[0].positionInBoard - linkedHexpoint[1].positionInBoard;

        int res = ExdMath.FindInDirectionSix(direct);

        if (res == -1)
        {
            Debug.LogError("KJ^%&^$&DFG");
        }

        transform.rotation = Quaternion.Euler(ExdMath.ROTATION_SIX[res]);
        transform.position = worldPosition;
    }
コード例 #2
0
ファイル: Edge.cs プロジェクト: anviettrung/Hexagon-Valley
    public void UpdateLink()
    {
        if (linkedHexpoint[0] == null || linkedHexpoint[1] == null)
        {
            return;
        }

        Vector2Int direct = linkedHexpoint[1].positionInBoard - linkedHexpoint[0].positionInBoard;

        int res = ExdMath.FindInDirectionSix(direct);

        if (res == -1)
        {
            Debug.LogError("KJ^%&^$&DFG");
        }

        byte setVal = state == State.WIREFRAME ? (byte)0 : (byte)1;         // if normal then set to 1

        linkedHexpoint[0].edges[res]           = setVal;
        linkedHexpoint[1].edges[(res + 3) % 6] = setVal;         // opposite direction
    }
コード例 #3
0
    public int PathStraight(HexPoint startPoint, Vector2Int direct, int step, MovementFilter filter, out HexPoint[] path)
    {
        int pathLength = 0;

        path    = new HexPoint[step + 1];
        path[0] = startPoint;

        if (startPoint == null)
        {
            return(pathLength);            // Error
        }
        int k = ExdMath.FindInDirectionSix(direct);

        if (k == -1)            // Not exist this direct
        {
            return(pathLength); // Error
        }
        for (int res = 1; res <= step; res++)
        {
            HexPoint nextPoint = GetPoint(path[res - 1].positionInBoard + direct);
            if (nextPoint == null)
            {
                return(pathLength);
            }
            if (nextPoint.canStay == false)
            {
                return(pathLength);
            }
            if (filter.walkthroughWall == false && path[res - 1].edges[k] == 1)
            {
                return(pathLength);
            }

            path[res] = nextPoint;
            pathLength++;
        }


        return(pathLength);
    }