Пример #1
0
    /// <summary>
    /// 检查移除障碍物
    /// </summary>
    /// <param name="tile"></param>
    /// <returns></returns>
    public bool CheckRemoveObstacles(MapTile tile)
    {
        // block 为5*5建筑
        if (tile == null || tile.blocked == false)
        {
            return(false);
        }
        IntVector2 pos = tile.Pos;

        foreach (IntVector2 p in obstacles.Keys)
        {
            if (Mathf.Abs(pos.x - p.x) <= 2 && Mathf.Abs(pos.y - p.y) <= 2)
            {
                List <MapTile> l = new List <MapTile>();
                if (TileHelp.GetAreaTile(p, 2, true, ref l) == true)
                {
                    Destroy(obstacles[p]);
                    obstacles.Remove(p);
                    MapChangeManger.UnBlockTile(l);
                    return(true);
                }
            }
        }
        return(false);
    }
Пример #2
0
    /// <summary>
    /// 测试动态挡格,以tile为中心5 * 5的添加动态挡格
    /// </summary>
    /// <param name="tile"></param>
    /// <returns></returns>
    public float TestRemoveBlock(MapTile tile)
    {
        List <MapTile> l = new List <MapTile>();

        if (TileHelp.GetAreaTile(tile.Pos, 2, false, ref l) == true)
        {
            MapChangeManger.UnBlockTile(l);
        }
        Stopwatch sw = new Stopwatch();

        sw.Start();
        MapChangeManger.InputChanges();
        sw.Stop();
        return(sw.ElapsedTicks / 10000.0f);
    }
Пример #3
0
    /// <summary>
    /// 测试动态挡格,以tile为中心5 * 5的添加动态挡格
    /// </summary>
    /// <param name="tile"></param>
    /// <returns></returns>
    public float TestAddBlock(MapTile tile)
    {
        List <MapTile> l = new List <MapTile>();

        if (TileHelp.GetAreaTile(tile.Pos, 2, false, ref l) == true)
        {
            MapChangeManger.BlockTile(l);
        }
        Stopwatch sw = new Stopwatch();

        sw.Start();
        Profiler.BeginSample("TestMethod");
        MapChangeManger.InputChanges();
        Profiler.EndSample();
        sw.Stop();
        return(sw.ElapsedTicks / 10000.0f);
    }
Пример #4
0
    /// <summary>
    /// 检查添加障碍物
    /// </summary>
    /// <param name="tile"></param>
    /// <returns></returns>
    public bool CheckAddObstacles(MapTile tile)
    {
        if (tile == null || tile.blocked == true)
        {
            return(false);
        }
        List <MapTile> l = new List <MapTile>();

        if (TileHelp.GetAreaTile(tile.Pos, 2, false, ref l) == true)
        {
            GameObject b = Instantiate(unitblock, PathFind.instance.m_map.GetMapTileWorldPos(tile), Quaternion.identity) as GameObject;
            b.transform.parent = transform;
            obstacles.Add(tile.Pos, b);
            MapChangeManger.BlockTile(l);
            return(true);
        }
        return(false);
    }