Example #1
0
    /// <summary>
    /// 加载地图碰撞数据
    /// </summary>
    /// <param name="mapId"></param>
    /// <returns></returns>
    public MapDataNode LoadMapCollider(int mapId)
    {
        if (!m_mapDataDic.ContainsKey(mapId))
        {
            UnityEngine.Debug.Log("MapDataManage.cs  --- 22 !m_mapDataDic.ContainsKey(mapId)");
            return(null);
        }
        MapDataNode mapdata = m_mapDataDic[mapId];

        UnityEngine.Debug.Log("MapDataManage.cs  ---  mapdata" + mapId + ":" + mapdata.Name);
        // 读地图Collider
        InfoNodeList viList = InfoNodeHelper.ReadFromCSV(GlobalVarFun.m_streamAssets + "MAP/" + mapId + ".csv");

        string[] arrKeys = viList.m_nodeList.Keys.ToArray();
        for (int i = 0; i < viList.Count; i++)
        {
            InfoNode vi = viList.m_nodeList[arrKeys[i]];
            if (vi != null)
            {
                mapdata.CreateCollider(vi);
            }
        }
        mapdata.HasLoaded = true;
        return(mapdata);
    }
Example #2
0
    /// <summary>
    /// 加载单个地图数据
    /// </summary>
    /// <param name="mapId"></param>
    /// <returns></returns>
    public MapDataNode LoadCurrentMapData(int mapId)
    {
        if (!m_mapDataDic.ContainsKey(mapId))
        {
            UnityEngine.Debug.Log("MapDataManage.cs  ---  !m_mapDataDic.ContainsKey(mapId)");
            return(null);
        }
        MapDataNode mapdata = m_mapDataDic[mapId];

        UnityEngine.Debug.Log("MapDataManage.cs  ---  mapdata 11 : " + mapId + " : " + mapdata);
        if (mapdata != null)
        {
            UnityEngine.Debug.Log("MapDataManage.cs  ---  mapdata != null");
            if (mapdata.HasLoaded == false)
            {
                UnityEngine.Debug.Log("MapDataManage.cs  ---  mapdata.HasLoaded == false");
                mapdata = LoadMapCollider(mapId);
                return(mapdata);
            }
            else
            {
                return(mapdata);
            }
        }
        return(null);
    }
Example #3
0
    public virtual bool Init(MapDataNode mapData)
    {
        if (mapData == null)
        {
            return(false);
        }

        this.mapData = mapData;

        b2World = new World(new Vector2(0f, 0f)); // 2.5D 不需要重力

        b2World.JointRemoved                += OnB2JointRemoved;
        b2World.ContactManager.PreSolve     += OnB2PreSolve;
        b2World.ContactManager.PostSolve    += OnB2PostSolve;
        b2World.ContactManager.BeginContact += OnB2BeginContact;
        b2World.ContactManager.EndContact   += OnB2EndContact;

        baseCollision = new MapCollider();
        baseCollision.InitB2Body(this, 0, 0, 1, 1);
        MapFunctions.SetCollisionGroup(baseCollision.m_body, 0, VelcroPhysics.Collision.Filtering.Category.None, VelcroPhysics.Collision.Filtering.Category.None); // 不与任何碰撞

        colliderDic.Clear();
        speColliderDic.Clear();

        return(true);
    }
Example #4
0
 /// <summary>
 /// 清除当前地图数据
 /// </summary>
 public void ClearCurMap()
 {
     updateFuncDic.Clear();
     removeUpdateFuncIds.Clear();
     curMapData = null;
     curMapWorld.Dispose();
     m_bHasCurMap = false;
 }
Example #5
0
    /// <summary>
    /// 初始化MapDataManage 其实是加载AllMapData文件(暂不用)
    /// </summary>
    public void Init()
    {
        // 读取数据
        InfoNodeList viList = InfoNodeHelper.ReadFromCSV(GlobalVarFun.m_streamAssets + "Map/AllMapData.csv");

        string[] arrKeys = viList.m_nodeList.Keys.ToArray();
        for (int i = 0; i < viList.Count; i++)
        {
            InfoNode vi = viList.m_nodeList[arrKeys[i]];
            if (vi != null)
            {
                MapDataNode mapdata = new MapDataNode(vi);
                m_mapDataDic.Add(mapdata.ID, mapdata);

                //UnityEngine.Debug.Log("MapDataManage.cs  ---  LoadAllMapData : " + mapdata.ID + " : " + mapdata.Name);
            }
        }
        m_bIsInited = true;
    }
Example #6
0
    public bool LoadNewMap(int mapId)
    {
        if (MapDataManager.Instance == null)
        {
            Debug.Log("MapManage.cs  ---  MapDataManager.Instance == null");
            return(false);
        }

        curMapData = MapDataManager.Instance.LoadCurrentMapData(mapId);
        if (curMapData == null)
        {
            Debug.Log("MapManage.cs  ---  mapData == null");
            return(false);
        }
        else
        {
            CreateNewWorld();
        }

        m_bHasCurMap = true;
        return(true);
    }