コード例 #1
0
ファイル: MazeMapManager.cs プロジェクト: LiuFeng1011/Diablo
    //从地图中删除一个障碍
    public void DelMapObj(Vector3 pos, MapObjConf conf)
    {
        Vector2 startMapPos = GameCommon.GetMapPos(pos);

        int startX = (int)startMapPos.x;
        int startY = (int)startMapPos.y;


        InGameMapPointData data = map[startX, startY];

        for (int i = 0; i < data.objList.Count; i++)
        {
            MapPointObj mapPointObj = data.objList[i];
            if (mapPointObj.obj == null)
            {
                if (mapPointObj.conf.id == conf.id)
                {
                    AddPoolObj(conf.id, mapPointObj.obj);
                    data.objList.RemoveAt(i);

                    if (map[startX, startX].type == MazeCreate.PointType.wallfull)
                    {
                        continue;
                    }
                    if (mapPointObj.conf.depth >= 3)
                    {
                        map[startX, startX].type   = MazeCreate.PointType.wallfull;
                        astarArray[startX, startX] = 0;
                    }
                    else
                    {
                        map[startX, startX].type   = MazeCreate.PointType.way;
                        astarArray[startX, startX] = 1;
                    }
                }
            }
        }
    }
コード例 #2
0
ファイル: MazeMapManager.cs プロジェクト: LiuFeng1011/Diablo
 public void AddObj(MapPointObj obj)
 {
     objList.Add(obj);
 }
コード例 #3
0
ファイル: MazeMapManager.cs プロジェクト: LiuFeng1011/Diablo
    //动态生成地面
    public override void Update()
    {
        smallMap.Update();

        Vector2 startPos = InGameManager.GetInstance().inGameCameraManager.GetCameraPos();

        Vector2 startMapPos = GameCommon.GetMapPos(startPos);

        int startX = (int)startMapPos.x - UPDATE_MAP_SIZE / 2;
        int startY = (int)startMapPos.y - UPDATE_MAP_SIZE / 2;

        for (int i = 0; i < lastScreenObj.Count; i++)
        {
            Vector2 pos = lastScreenObj[i].pos;
            if (pos.x >= startX && pos.x < startX + UPDATE_MAP_SIZE &&
                pos.y >= startY && pos.y < startY + UPDATE_MAP_SIZE)
            {
                continue;
            }

            List <MapPointObj> _list = lastScreenObj[i].objList;
            for (int j = 0; j < _list.Count; j++)
            {
                if (_list[j].obj == null)
                {
                    continue;
                }
                AddPoolObj(_list[j].conf.id, _list[j].obj);
                _list[j].obj = null;
            }
        }

        lastScreenObj.Clear();

        for (int x = 0; x < UPDATE_MAP_SIZE; x++)
        {
            for (int y = 0; y < UPDATE_MAP_SIZE; y++)
            {
                int sx = startX + x;
                int sy = startY + y;

                int _x = UPDATE_MAP_SIZE / 2 - x;
                int _y = UPDATE_MAP_SIZE / 2 - y;

                if (sx < 0 || sx >= map.GetLength(0))
                {
                    break;
                }
                if (sy < 0 || sy >= map.GetLength(1))
                {
                    continue;
                }

                bool isopen = false;
                //小地图中的点是否打开,如果已经打开 则不用计算距离
                if (!smallMap.IsOpenPoint(sx, sy))
                {
                    if (Mathf.Sqrt(_x * _x + _y * _y) <= UPDATE_MAP_SIZE / 2)
                    {
                        isopen = true;
                    }
                }

                InGameMapPointData data = map[sx, sy];
                if (data == null)
                {
                    if (isopen)
                    {
                        smallMap.OpenUnit(sx, sy, MazeCreate.PointType.nullpoint);
                    }
                    continue;
                }

                if (isopen)
                {
                    smallMap.OpenUnit(sx, sy, data.type);
                }

                for (int i = 0; i < data.objList.Count; i++)
                {
                    if (data.objList[i].obj == null)
                    {
                        MapPointObj      mapPointObj = data.objList[i];
                        InGameBaseMapObj obj         = GetPoolObj(mapPointObj.conf);
                        obj.transform.position = GameCommon.GetWorldPos(mapPointObj.pos) + new Vector2(0, Random.Range(0, 0.1f));

                        obj.transform.localScale = mapPointObj.scale;

                        GameCommon.SetObjZIndex(obj.gameObject, mapPointObj.conf.depth);
                        mapPointObj.obj = obj;

                        obj.Show();
                        mapObjActionList.Add(obj);
                    }
                }
                lastScreenObj.Add(data);
            }
        }


        //处理mapobj 动画

        for (int i = mapObjActionList.Count - 1; i >= 0; i--)
        {
            InGameBaseMapObj obj = mapObjActionList[i];
            obj.ActionUpdate();
            if (!obj.isAction)
            {
                mapObjActionList.RemoveAt(i);
            }
        }
    }