Ejemplo n.º 1
0
    //设置墙与地板的索引,输入 墙的对象,地块的世界坐标,墙在地板中的位置
    private void setWallIndex(GameObject wallObj, Vector3Int placePos, WallPos tmpWallPos)
    {
        placeWall tmpSpaceWall = placeGrid[placePos]; //获得地块对象

        if (tmpSpaceWall != null)
        {
            switch (tmpWallPos)
            {
            case WallPos.Top: { tmpSpaceWall.topWall = wallObj;
                                wallObj.name         = tmpSpaceWall.gameObject.name + "Top"; } break;

            case WallPos.Bottom: { tmpSpaceWall.bottomWall = wallObj;
                                   wallObj.name            = tmpSpaceWall.gameObject.name + "Bottom"; } break;

            case WallPos.Left: { tmpSpaceWall.leftWall = wallObj;
                                 wallObj.name          = tmpSpaceWall.gameObject.name + "Left"; } break;

            case WallPos.Right: { tmpSpaceWall.rightWall = wallObj;
                                  wallObj.name           = tmpSpaceWall.gameObject.name + "Right"; } break;
                // default: { } break;
            }
        }
        else
        {
            string msg = "setWallIndex error! Wall not find ! pos " + DebugMsg.instance.Msg(placePos) + "\n";
            Debug.LogError(msg);
        }
    }
Ejemplo n.º 2
0
    //把YZ值相同的,X相交集的墙隐藏, 默认Y的都是同一层为0
    private void setHideWallByX(Vector3Int pLeft, Vector3Int pRight, bool pIsRoomOrHillWay1, bool pIsRoomOrHillWay2)
    {
        if (pIsRoomOrHillWay1)
        {
            placeWall pLeftPlaceWallObj = getPlaceWallByPos(pLeft);
            pLeftPlaceWallObj.rightWall.SetActive(false);
        }

        if (pIsRoomOrHillWay2)
        {
            placeWall pRightPlaceWallObj = getPlaceWallByPos(pRight);
            pRightPlaceWallObj.leftWall.SetActive(false);
        }
    }
Ejemplo n.º 3
0
    //把XY值相同的,Z相交集的墙隐藏,
    private void setHideWallByZ(Vector3Int pTop, Vector3Int pBottom, bool pIsRoomOrHillWay1, bool pIsRoomOrHillWay2)
    {
        if (pIsRoomOrHillWay1)
        {
            placeWall pTopPlaceWallObj = getPlaceWallByPos(pTop);
            pTopPlaceWallObj.bottomWall.SetActive(false);
        }

        if (pIsRoomOrHillWay2)
        {
            placeWall pBottomPlaceWallObj = getPlaceWallByPos(pBottom);
            pBottomPlaceWallObj.topWall.SetActive(false);
        }
    }
Ejemplo n.º 4
0
    //输入三维坐标,返回是否有个房间
    private bool isRoomByPos(Vector3Int pos, out placeWall pPlaceWall)
    {
        bool res = false;

        pPlaceWall = null;
        if (isRoomOrHillWay(pos))   //过道 或 房间
        //Room pRoom = grid.getGridDataObj(pos);
        {
            pPlaceWall = placeGrid[pos];
            res        = true;
        }

        return(res);
    }
Ejemplo n.º 5
0
    /*
     * private void flagPlacePos(GameObject pObj, int x, int y, int z)
     * {
     *  Vector3Int tmpPos = new Vector3Int(x, y, z);
     *  placeLst[tmpPos] = pObj;
     * }
     */
    //获得地板对应的墙
    public placeWall getSpaceWall()
    {
        placeWall tmpSpaceWall = null;

        if (placeGrid[pos] != null)
        {
            tmpSpaceWall = placeGrid[pos].GetComponent <placeWall>();
            return(tmpSpaceWall);
        }
        else
        {
            string msg = "getSpaceWall not find plance pos:" + DebugMsg.instance.Msg(pos);
            Debug.LogError(msg);
        }
        return(tmpSpaceWall);
    }
Ejemplo n.º 6
0
    public placeWall getSpaceWall()
    {
        placeWall tmpSpaceWall = null;

        if (placeGrid[pos] != null)
        {
            tmpSpaceWall = placeGrid[pos].GetComponent <placeWall>();
            return(tmpSpaceWall);
        }
        else
        {
            Vector3Int tmpPos = new Vector3Int(pos.x, csPosY, pos.y);
            string     msg    = "getSpaceWall not find plance pos:" + DebugMsg.instance.Msg(tmpPos);
            Debug.LogError(msg);
        }
        return(tmpSpaceWall);
    }
Ejemplo n.º 7
0
    //传入地板的世界坐标, 墙的位置, 返回墙的gameobject
    private GameObject getWallObj(Vector3Int pPos, WallPos pWallPos)
    {
        GameObject res          = null;
        placeWall  tmpPlaceWall = placeGrid[pPos];

        if (pWallPos == WallPos.Bottom)
        {
            res = tmpPlaceWall.bottomWall;
        }
        else if (pWallPos == WallPos.Top)
        {
            res = tmpPlaceWall.topWall;
        }
        else if (pWallPos == WallPos.Left)
        {
            res = tmpPlaceWall.leftWall;
        }
        else if (pWallPos == WallPos.Right)
        {
            res = tmpPlaceWall.rightWall;
        }

        return(res);
    }
Ejemplo n.º 8
0
    //获得坐标对应的地板
    private placeWall getPlaceWallByPos(Vector3Int pPos)
    {
        placeWall tmpPlaceWall = placeGrid[pPos];

        return(tmpPlaceWall);
    }
Ejemplo n.º 9
0
    //生成上坡或下坡的地板,输入当前色块的坐标
    private void makeHillPlace()
    {
        // GameObject hillPrefab = null;
        GameObject hill1Prefab = null;
        GameObject hill4Prefab = null;
        float      rotationY   = 0.0f;

        if (isUpHill)
        { //上坡
          // hillPrefab = upHillPrefab;
            hill1Prefab = upHillPrefab;
            hill4Prefab = downHillPrefab;
        }
        else
        { //下坡
          //  hillPrefab = downHillPrefab;
            hill1Prefab = downHillPrefab;
            hill4Prefab = upHillPrefab;
        }


        //Vector3Int preRoomPos = Vector3Int.zero;
        //Vector3Int currentRoomPos = Vector3Int.zero;


        placeWall preRoom       = null; // new placeWall();
        placeWall currentRoom   = null; // new placeWall();
        bool      preIsRoom     = isRoomByPos(prev, out preRoom);
        bool      currentIsRoom = isRoomByPos(current, out currentRoom);

        //默认是z轴正方向
        if (prev.z < current.z) //z轴正方向
        {
            rotationY = 0.0f;
            if (preIsRoom)
            {
                preRoom.topWall.SetActive(false);
            }
            if (currentRoom)
            {
                currentRoom.bottomWall.SetActive(false);
            }
        }

        else if (prev.x < current.x)  //x轴正方向
        {
            rotationY = 90.0f;
            if (preIsRoom)
            {
                preRoom.rightWall.SetActive(false);
            }
            if (currentRoom)
            {
                currentRoom.leftWall.SetActive(false);
            }
        }


        else if (prev.z > current.z) //z轴负方向
        {
            rotationY = 180.0f;
            if (preIsRoom)
            {
                preRoom.bottomWall.SetActive(false);
            }
            if (currentRoom)
            {
                currentRoom.topWall.SetActive(false);
            }
        }
        else if (prev.x > current.x)  //x轴负方向
        {
            rotationY = 270.0f;
            if (preIsRoom)
            {
                preRoom.leftWall.SetActive(false);
            }
            if (currentRoom)
            {
                currentRoom.rightWall.SetActive(false);
            }
        }

        // GameObject go = Instantiate(hillPrefab, new Vector3(staticStair.x +0.5f, staticStair.y, staticStair.z+0.5f), Quaternion.identity);
        GameObject go1 = Instantiate(hill1Prefab, new Vector3(PlaceStairs1.x, PlaceStairs1.y, PlaceStairs1.z), Quaternion.identity, parentObj.transform);

        go1.transform.eulerAngles = new Vector3(0.0f, rotationY, 0.0f);
        go1.name = csStairWayName + nameIndex.ToString() + "_1_";

        GameObject go4 = Instantiate(hill4Prefab, new Vector3(PlaceStairs4.x, PlaceStairs4.y, PlaceStairs4.z), Quaternion.identity, parentObj.transform);

        go4.transform.eulerAngles = new Vector3(0.0f, rotationY + 180.0f, 0.0f);
        go4.name = csStairWayName + nameIndex.ToString() + "_4_";
    }
Ejemplo n.º 10
0
    //标记地板的位置
    private void setPlaceIndex(GameObject pObj, Vector3Int tmpPos)
    {
        placeWall placeObj = pObj.GetComponent <placeWall>();

        placeGrid[tmpPos] = placeObj;
    }