/// <summary>
        /// 卸载格子
        /// </summary>
        private void DoUnloadGrid()
        {
            if (m_NeedUnLoadGrids != null && m_NeedUnLoadGrids.Count > 0)
            {
                for (int iGrid = 0; iGrid < m_NeedUnLoadGrids.Count; iGrid++)
                {
                    Vector3Int v3Int      = m_NeedUnLoadGrids[iGrid];
                    long       gridHashId = AreaLayerInfo.GetHashCode(v3Int);
                    if (m_GridIndexs.ContainsKey(gridHashId))
                    {
                        int index = m_GridIndexs[gridHashId];

                        if (m_AreaLayerInfo.AreaVirtualGridInfos.Count > index)
                        {
                            AreaVirtualGridInfo gridInfo   = m_AreaLayerInfo.AreaVirtualGridInfos[index];
                            List <int>          unitIndexs = gridInfo.m_UnitIndexs;
                            if (unitIndexs != null && unitIndexs.Count > 0)
                            {
                                for (int iUnit = 0; iUnit < unitIndexs.Count; iUnit++)
                                {
                                    m_UnitController.RemoveUnit(unitIndexs[iUnit]);
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.LogError("不存在gridHashId:" + gridHashId);
                    }
                }
                m_NeedUnLoadGrids.Clear();
            }
        }
示例#2
0
        public void DeSerialize(BinaryReader reader)
        {
            m_Priority = reader.ReadInt32();
            m_GridSize = reader.ReadInt32();
            m_Offest   = reader.ReadInt32();

            int indexCount = reader.ReadInt32();

            if (indexCount > 0)
            {
                AreaVirtualGridIndexs = new List <long>();
                for (int iIndex = 0; iIndex < indexCount; iIndex++)
                {
                    AreaVirtualGridIndexs.Add(reader.ReadInt64());
                }
            }

            int gridCount = reader.ReadInt32();

            if (gridCount > 0)
            {
                AreaVirtualGridInfos = new List <AreaVirtualGridInfo>();
                for (int iGrid = 0; iGrid < gridCount; iGrid++)
                {
                    AreaVirtualGridInfo gridInfo = new AreaVirtualGridInfo();
                    gridInfo.DeSerialize(reader);

                    m_MinIndexX = Mathf.Min(gridInfo.m_IndexX, m_MinIndexX);
                    m_MaxIndexX = Mathf.Max(gridInfo.m_IndexX, m_MaxIndexX);

                    m_MinIndexY = Mathf.Min(gridInfo.m_IndexY, m_MinIndexY);
                    m_MaxIndexY = Mathf.Max(gridInfo.m_IndexY, m_MaxIndexY);

                    m_MinIndexZ = Mathf.Min(gridInfo.m_IndexZ, m_MinIndexZ);
                    m_MaxIndexZ = Mathf.Max(gridInfo.m_IndexZ, m_MaxIndexZ);
                    AreaVirtualGridInfos.Add(gridInfo);
                }
            }


            int unitCount = reader.ReadInt32();

            if (unitCount > 0)
            {
                m_Units = new List <SceneUnitInfo>();
                for (int iUnit = 0; iUnit < unitCount; iUnit++)
                {
                    SceneUnitInfo sceneUnitInfo = new SceneUnitInfo();
                    sceneUnitInfo.DeSerialize(reader);
                    m_Units.Add(sceneUnitInfo);
                }
            }
        }
示例#3
0
        public void Serialize(BinaryWriter writer)
        {
            writer.Write(m_Priority);
            writer.Write(m_GridSize);
            writer.Write(m_Offest);

            List <long> areaVirtualGridIndexs = AreaVirtualGridIndexs;

            if (areaVirtualGridIndexs == null || areaVirtualGridIndexs.Count <= 0)
            {
                writer.Write(0);
            }
            else
            {
                writer.Write(areaVirtualGridIndexs.Count);
                for (int iIndex = 0; iIndex < areaVirtualGridIndexs.Count; iIndex++)
                {
                    writer.Write(areaVirtualGridIndexs[iIndex]);
                }
            }

            List <AreaVirtualGridInfo> areaVirtualGridInfos = AreaVirtualGridInfos;

            if (areaVirtualGridInfos == null || areaVirtualGridInfos.Count <= 0)
            {
                writer.Write(0);
            }
            else
            {
                writer.Write(areaVirtualGridInfos.Count);
                for (int iGrid = 0; iGrid < areaVirtualGridInfos.Count; iGrid++)
                {
                    AreaVirtualGridInfo gridInfo = areaVirtualGridInfos[iGrid];
                    gridInfo.Serialize(writer);
                }
            }

            List <SceneUnitInfo> units = m_Units;

            if (units == null || units.Count <= 0)
            {
                writer.Write(0);
            }
            else
            {
                writer.Write(units.Count);
                for (int iUnit = 0; iUnit < units.Count; iUnit++)
                {
                    SceneUnitInfo sceneUnitInfo = units[iUnit];
                    sceneUnitInfo.Serialize(writer);
                }
            }
        }
示例#4
0
        private void OnDrawGizmosSelected()
        {
            if (m_AreaLayerInfos != null && m_AreaLayerInfos.Length > 0)
            {
                for (int iLayer = 0; iLayer < m_AreaLayerInfos.Length; iLayer++)
                {
                    //if(m_ShowLayer[iLayer])
                    {
                        AreaLayerInfo layerInfo = m_AreaLayerInfos[iLayer];
                        if (layerInfo != null)
                        {
                            List <AreaVirtualGridInfo> areaVirtualGridInfos = layerInfo.AreaVirtualGridInfos;
                            if (areaVirtualGridInfos != null && areaVirtualGridInfos.Count > 0)
                            {
                                for (int iArea = 0; iArea < areaVirtualGridInfos.Count; iArea++)
                                {
                                    AreaVirtualGridInfo gridInfo = areaVirtualGridInfos[iArea];
                                    if (m_ShowLayer[iLayer])
                                    {
                                        Gizmos.color = m_Colors[iLayer];
                                        Gizmos.DrawWireCube(gridInfo.m_Position, new Vector3(layerInfo.m_GridSize, layerInfo.m_GridSize, layerInfo.m_GridSize));
                                    }

                                    if (m_ShowUnitAB[iLayer])
                                    {
                                        List <int> unitIndexs = gridInfo.m_UnitIndexs;
                                        if (unitIndexs != null && unitIndexs.Count > 0)
                                        {
                                            for (int iUnit = 0; iUnit < unitIndexs.Count; iUnit++)
                                            {
                                                SceneUnitInfo unitInfo = layerInfo.m_Units[unitIndexs[iUnit]];
                                                Gizmos.color = new Color(1, 1, 1, 0.2f);
                                                Gizmos.DrawWireCube(unitInfo._AABB.center, unitInfo._AABB.size);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        public void ShowSceneUI()
        {
            return;

            if (m_AreaLayerInfos != null && m_AreaLayerInfos.Length > 0)
            {
                for (int iLayer = 0; iLayer < m_AreaLayerInfos.Length; iLayer++)
                {
                    if (m_ShowLayer[iLayer])
                    {
                        AreaLayerInfo layerInfo = m_AreaLayerInfos[iLayer];
                        if (layerInfo != null)
                        {
                            List <AreaVirtualGridInfo> areaVirtualGridInfos = layerInfo.AreaVirtualGridInfos;
                            if (areaVirtualGridInfos != null && areaVirtualGridInfos.Count > 0)
                            {
                                for (int iArea = 0; iArea < areaVirtualGridInfos.Count; iArea++)
                                {
                                    AreaVirtualGridInfo gridInfo   = areaVirtualGridInfos[iArea];
                                    List <int>          unitIndexs = gridInfo.m_UnitIndexs;
                                    if (unitIndexs != null && unitIndexs.Count > 0)
                                    {
                                        for (int iUnit = 0; iUnit < unitIndexs.Count; iUnit++)
                                        {
                                            SceneUnitInfo unitInfo  = layerInfo.m_Units[unitIndexs[iUnit]];
                                            AssetInfo     assetInfo = m_AreaDetailInfo.AssetInfos[unitInfo.AssetIndex];
                                            Handles.Label(unitInfo.LocalPosition, assetInfo.AddressableKey);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }