예제 #1
0
    public void OnEndDrag(PointerEventData eventData)
    {
        m_canDrag = true;
        Ray ray = eventData.pressEventCamera.ScreenPointToRay(Input.mousePosition);

        RaycastHit[] rayHit = Physics.RaycastAll(ray);
        for (int i = 0; i < rayHit.Length; i++)
        {
            MapSingle aa = rayHit[i].transform.gameObject.GetComponent <MapSingle>();
            if (aa != null)
            {
                Vector3 zz = Camera.main.ScreenToWorldPoint(eventData.position);
                if (Math.Abs(zz.x - rayHit[i].transform.position.x) <= 0.5 && Math.Abs(zz.y - rayHit[i].transform.position.y) <= 0.5)
                {
                    this.transform.parent        = rayHit[i].transform;
                    this.transform.localPosition = new Vector3(0, 0, -20);
                    if (aa.mapId != -1)
                    {
                        m_nodeId = aa.mapId;
                        return;
                    }
                }
            }
        }

        MapSingleDate oldMapSingle = MapManager.Instance.GetMapSingleInfoById(m_nodeId);

        if (oldMapSingle.MapSingleDateInfo == null)
        {
            Debug.LogError("oldmapsingle is null " + m_nodeId);
            return;
        }
        this.transform.parent        = oldMapSingle.MapSingleDateInfo.transform;
        this.transform.localPosition = new Vector3(0, 0, -20);
    }
예제 #2
0
    public Dictionary <int, MapSingleDate> m_allMapInfoDic = new Dictionary <int, MapSingleDate>();//地图每个格子的基本信息

    //通过读表把地图信息加载
    public void SetMapInfo(int mapFloorId, MapSingleDate mapSingleDate)
    {
        if (m_allMapInfoDic.ContainsKey(mapFloorId))
        {
            m_allMapInfoDic[mapFloorId] = mapSingleDate;
        }
        else
        {
            m_allMapInfoDic.Add(mapFloorId, mapSingleDate);
        }
    }
예제 #3
0
    //实例化地图数据  并且显示层  数据层   怪物层分离加入manager,识别使用唯一的key。
    void InstanceMapFloor(Dictionary <int, MapConfigAchieveItem> mapconfig)
    {
        GameObject mapObj    = (GameObject)Resources.Load("Prefab/MapObj");
        GameObject cardObj   = (GameObject)Resources.Load("Prefab/CardObj");
        Transform  mapParent = this.transform.Find("MapSystemObj");

        if (mapObj == null)
        {
            Debug.LogError("mapobj is null");
            return;
        }
        if (mapParent == null)
        {
            Debug.LogError("mapparent is null");
            return;
        }

        foreach (var a in mapconfig)
        {
            int        x              = a.Value.RacePosX;
            int        y              = a.Value.RacePosY;
            GameObject floorObj       = GameObject.Instantiate <GameObject>(mapObj);
            MapSingle  floorMapSingle = floorObj.GetComponent <MapSingle>();
            if (floorMapSingle == null)
            {
                continue;
            }

            floorObj.name               = (a.Key).ToString();
            floorObj.transform.parent   = mapParent;
            floorObj.transform.position = new Vector3(x, y, 0);

            if (a.Key == 10 && m_masterTran != null)
            {
                GameObject masterObj = GameObject.Instantiate <GameObject>(cardObj);
                masterObj.name             = "master";
                masterObj.transform.parent = floorObj.transform;
                UIDrag floorDrag = masterObj.GetComponent <UIDrag>();
                masterObj.transform.localPosition = new Vector3(0, 0, -20);
                if (floorDrag != null)
                {
                    floorDrag.SetInfo(a.Key, true, true);
                }
            }

            floorMapSingle.SetMapSingleDate(a.Key);
            MapSingleDate mapSingleDate = new MapSingleDate();
            mapSingleDate.MapObjId          = a.Key;
            mapSingleDate.MapSingleDateInfo = floorMapSingle;
            MapManager.Instance.SetMapInfo(a.Key, mapSingleDate);
        }
    }