/// <summary> /// add or update static check points. /// </summary> /// <param name="pPointList">the new list of checkpoints</param> public void addOrUpdateStaticCheckPoints(LinkedList <WarFog_CheckPoint> pPointList) { LinkedList <WarFog_CheckPoint> calulateList = new LinkedList <WarFog_CheckPoint>(); var pointNode = pPointList.First; while (pointNode != null) { int hashKey = pointNode.Value.X * WarFog_Caculate_Parments.MultiplyX + pointNode.Value.Y; if (!(m_StaticCheckPointDic.ContainsKey(hashKey) && m_StaticCheckPointDic[hashKey].ValidDistance == pointNode.Value.Radius)) { if (m_StaticCheckPointDic.ContainsKey(hashKey)) { m_StaticCheckPointDic[hashKey].reset(); ScriptObjectPool <WarFog_CheckPointStoreElement> .getInstance().pushPoolObject(m_StaticCheckPointDic[hashKey]); m_StaticCheckPointDic.Remove(hashKey); } var oneCheckPoint = ScriptObjectPool <WarFog_CheckPoint> .getInstance().getPoolObject(); oneCheckPoint.setCheckPoint(pointNode.Value.X, pointNode.Value.Y, pointNode.Value.Radius); calulateList.AddLast(oneCheckPoint); } pointNode = pointNode.Next; } WarFog_CheckPoint.clearLinkList(pPointList); caculateFogData(calulateList, m_StaticCheckPointDic); assemblyStaticCheckPoints(m_StaticCheckPointDic, m_StaticCheckData); }
/// <summary> /// remove not used static checkpoints. /// </summary> /// <param name="pPointList"></param> public void removeStaticCheckPoints(LinkedList <WarFog_CheckPoint> pPointList) { var pointNode = pPointList.First; while (pointNode != null) { int hashKey = pointNode.Value.X * WarFog_Caculate_Parments.MultiplyX + pointNode.Value.Y; if (m_StaticCheckPointDic.ContainsKey(hashKey)) { m_StaticCheckPointDic[hashKey].reset(); ScriptObjectPool <WarFog_CheckPointStoreElement> .getInstance().pushPoolObject(m_StaticCheckPointDic[hashKey]); m_StaticCheckPointDic.Remove(hashKey); } pointNode = pointNode.Next; } WarFog_CheckPoint.clearLinkList(pPointList); assemblyStaticCheckPoints(m_StaticCheckPointDic, m_StaticCheckData); }
public void caculateFogData(LinkedList <WarFog_CheckPoint> pCaculateList, Dictionary <int, WarFog_CheckPointStoreElement> pStoreDic) { var pointNode = pCaculateList.First; while (pointNode != null) { if (pStoreDic != null) { int hashKey = pointNode.Value.X * WarFog_Caculate_Parments.MultiplyX + pointNode.Value.Y; var oneCheckPointElement = ScriptObjectPool <WarFog_CheckPointStoreElement> .getInstance().getPoolObject(); var oneWarElement = ScriptObjectPool <WarFog_Element> .getInstance().getPoolObject(); oneWarElement.setElement(pointNode.Value.X, pointNode.Value.Y, false); List <WarFog_Element> fogData = new List <WarFog_Element>() { oneWarElement }; oneCheckPointElement.setData(pointNode.Value.X, pointNode.Value.Y, pointNode.Value.Radius, fogData); pStoreDic.Add(hashKey, oneCheckPointElement); } else { this.CurrentFogData[pointNode.Value.X, pointNode.Value.Y] = false; } caculateOneCorner(pointNode.Value, 1, 1, 1, true, 0, 1.0f, true, true, pStoreDic); caculateOneCorner(pointNode.Value, 1, 1, 1, false, 0, 1.0f, true, true, pStoreDic); caculateOneCorner(pointNode.Value, 1, 1, -1, true, 0, 1.0f, true, true, pStoreDic); caculateOneCorner(pointNode.Value, 1, 1, -1, false, 0, 1.0f, true, true, pStoreDic); caculateOneCorner(pointNode.Value, 1, -1, 1, true, 0, 1.0f, true, true, pStoreDic); caculateOneCorner(pointNode.Value, 1, -1, 1, false, 0, 1.0f, true, true, pStoreDic); caculateOneCorner(pointNode.Value, 1, -1, -1, true, 0, 1.0f, true, true, pStoreDic); caculateOneCorner(pointNode.Value, 1, -1, -1, false, 0, 1.0f, true, true, pStoreDic); pointNode = pointNode.Next; } WarFog_CheckPoint.clearLinkList(pCaculateList); }