Beispiel #1
0
    static public bool DrawCell(MapObject mapObject, Vector3 centerPos, int MapSizeX, int MapSizeZ, Transform parent = null)
    {
        Vector3 topLeftCellPos = MapUtility.CalTopLeftCellPosition(centerPos, MapSizeX, MapSizeZ);

        DrawCellByTopLeftCellPosition(mapObject, topLeftCellPos, MapSizeX, MapSizeZ, parent);
        return(true);
    }
Beispiel #2
0
    /// <summary>
    /// 依照3d位置,取得此cell的3d位置
    /// </summary>
    /// <param name="xIndex"></param>
    /// <param name="zIndex"></param>
    /// <param name="assetSize"></param>
    /// <returns></returns>
    public Vector3 GetCellPosition(int xIndex, int zIndex, Vector3 assetSize)
    {
        if (xIndex < 0 || zIndex < 0 || xIndex >= MapSizeX || zIndex >= MapSizeZ)
        {
            return(Vector3.zero);
        }

        return(MapUtility.CalCellPosition(MapDataCollection, MapUtility.CalTopLeftCellPosition(CenterPosition, MapSizeX, MapSizeZ), xIndex, zIndex, assetSize));
    }
Beispiel #3
0
    static public void DrawCells(IEnumerator mapObjectItr, int MapSizeX, int MapSizeZ, Vector3 centerPos, GameObject parent)
    {
        Vector3 topLeftCellPos = MapUtility.CalTopLeftCellPosition(centerPos, MapSizeX, MapSizeZ);

        while (mapObjectItr.MoveNext())
        {
            MapObject mapObj = mapObjectItr.Current as MapObject;
            DrawCellByTopLeftCellPosition(mapObj, topLeftCellPos, MapSizeX, MapSizeZ, parent.transform);
        }
    }
Beispiel #4
0
    bool updateGoPosition(GameObject go, bool isForceUpdate)
    {
        int xIndex = -1;
        int zIndex = -1;

        MapUtility.CalCellIndexByMousePosition(mapController.CenterPosition, mapController.MapSizeX, mapController.MapSizeZ,
                                               rayCastLayer, ref xIndex, ref zIndex);

        if ((xIndex >= 0 && zIndex >= 0 && xIndex < mapController.MapSizeX && zIndex < mapController.MapSizeZ &&
             (isForceUpdate || xIndex != curCellIndexX || zIndex != curCellIndexZ)))
        {
            go.transform.position = MapUtility.CalCellPosition(mapController.MapDataCollection,
                                                               MapUtility.CalTopLeftCellPosition(mapController.CenterPosition, mapController.MapSizeX, mapController.MapSizeZ),
                                                               xIndex, zIndex, curCellData.Size);
            go.transform.position = MapUtility.CalCellHeightPosition(mapController.MapDataCollection, xIndex, zIndex, curCellData, go.transform.position);
            curCellIndexX         = xIndex;
            curCellIndexZ         = zIndex;
            return(true);
        }

        return(false);
    }
Beispiel #5
0
    static public GameObject DrawMapObjectData(MapObject mapObject, MapObject.ObjectData o, Vector3 centerPos, int MapSizeX, int MapSizeZ, int xIndex, int zIndex, Transform parent = null)
    {
        Vector3 topLeftCellPos = MapUtility.CalTopLeftCellPosition(centerPos, MapSizeX, MapSizeZ);

        return(DrawMapObjectDataTopLeftCellPosition(mapObject, o, topLeftCellPos, xIndex, zIndex, parent));
    }