Exemplo n.º 1
0
    //加载地图
    private void LoadMap()
    {
        // //设置地图区域的位置
        UIFunction.SetPosition(MapPanel, new Vector2(0, 0));
        //设置地图区域的大小
        UIFunction.SetSize(MapPanel, new Vector2(BaseLength, BaseLength));

        int     line = LocalMessage.Map.Length, column = LocalMessage.Map[0].Length;
        float   width = BaseLength / column, height = BaseLength / line, halfWidth = width / 2, halfHeight = height / 2;
        Vector3 scale = new Vector3(width, height, 0.01f);

        for (int i = 0; i < line; i++)
        {
            for (int j = 0; j < column; j++)
            {
                string temp = Floor[LocalMessage.Map[i][j]];
                if (i == LocalMessage.StartGrid.line && j == LocalMessage.StartGrid.column)
                {
                    temp = Floor[3];
                }
                else if (i == LocalMessage.EndGrid.line && j == LocalMessage.EndGrid.column)
                {
                    temp = Floor[4];
                }
                GameObject go = (GameObject)Instantiate(Resources.Load(temp));
                go.transform.localEulerAngles = new Vector3(0, 0, 180);
                go.transform.SetParent(MapPanel.transform);
                go.name = go.name.Replace("(Clone)", "");
                UIFunction.SetScale(go, scale);
                UIFunction.Set3DPosition(go, new Vector3(halfHeight + j * height + x_offset, -(halfWidth + i * width) + y_offset, -0.09f));
            }
        }
        LocalMessage.grid.width  = width;
        LocalMessage.grid.height = height;
    }
Exemplo n.º 2
0
    /* 获取到房间信息列表
     * param[list]:包含版本号和类别号
     */
    private void GetRoomMsgList(byte[] list)
    {
        int i = 2;

        for (i = 2; i < list.Length - 4; i += 4)
        {
            uint temp_num = BitConverter.ToUInt32(list, i);
            if (temp_num == 0)
            {
                break;
            }
            RoomMessage temp_room     = new RoomMessage(temp_num);
            ushort      temp_room_num = temp_room.GetRoomNumber();
            GameObject  temp_go       = null;
            if (RoomContainer2.ContainsKey(temp_room_num))
            {
                temp_go = RoomContainer2[temp_room_num];
                UIFunction.SetRoomMessage(temp_go, temp_room);
            }
            else
            {
                //创建新的物体
                temp_go = (GameObject)Instantiate(Resources.Load("Prefabs/RoomBar"));
                temp_go.transform.parent = RoomListPanel.transform;
                UIFunction.SetPosition(temp_go, new Vector2(0, 0));
                temp_go.transform.localScale = new Vector3(1, 1, 1);
                UIFunction.SetRoomMessage(temp_go, temp_room, RoomClick);
                RoomContainer2.Add(temp_room_num, temp_go);
                RoomContainer1.Add(temp_go, temp_room_num);
            }
        }
    }