Esempio n. 1
0
        public bool FillDate(Template[] temp)
        {
            Point3d pointRefence = new Point3d();
            bool canRefence = GetRefencePoint(temp, ref pointRefence);

            for (int i = 0; i < temp.Length; ++i)
            {
                if (temp[i].bIsRefenceMe)
                {
                    continue;
                }
                else if (temp[i].bNeedRefence && canRefence)
                {
                    FillOneTemplate(ref temp[i], true, pointRefence);
                }
                else
                {
                    FillOneTemplate(ref temp[i], false, pointRefence);
                }                
            }
                return true;
        }
Esempio n. 2
0
        private bool GetRefencePoint(Template[] temps, ref Point3d pointRet)
        {
            bool bRet = false;

            for (int i = 0; i < temps.Length; ++i)
            {
                if (temps[i].nQuestColumnValue != 0 && temps[i].bIsRefenceMe)
                {
                    FillOneTemplate(ref temps[i], false, new Point3d());
                    pointRet = temps[i].pointFinal;
                    bRet = true;
                    break;
                }
            }            
            return bRet;

        }
Esempio n. 3
0
 private void FillOneTemplate(ref Template OneTemplate, bool needRefence, Point3d pointRefence)
 {
     int nTemplateId = 0;
     TemplateType type = TemplateType.NONE;
     
     nTemplateId = OneTemplate.nQuestColumnValue;
     type = OneTemplate.type;
     if (nTemplateId == 0 || type == TemplateType.NONE)
     {
         return;
     }
     if( !UpdateCurrentMapName(nTemplateId, type))
     {
         return;
     }            
     OneTemplate.nMapId = (int)m_htMapId[m_strCurrentMapName];
     Point3d pointFinal;
     pointFinal = GetFinalPoint(nTemplateId, type, needRefence, pointRefence);
     OneTemplate.pointFinal = pointFinal;
 }
Esempio n. 4
0
        /// <summary>
        /// 获取一个id在logical文件里的最终坐标
        /// </summary>
        /// <param name="mapName">所属地图名称</param>
        /// <param name="templateId">模块id</param>
        /// <param name="templatetype">模块类型</param>
        /// <returns></returns>
        private Point3d GetFinalPoint(int templateId, TemplateType templatetype, bool needRefence, Point3d pointRefence)
        {
            Point3d pointRet;
            MapInfo4Quest mapInfo;

            pointRet.nX = -1;
            pointRet.nY = -1;
            pointRet.nZ = -1;
            if (m_htMapInfo4Quest.ContainsKey(m_strCurrentMapName))
            {
                mapInfo = (MapInfo4Quest)m_htMapInfo4Quest[m_strCurrentMapName];
            }
            else
            {
                string strLogicalFilePath = string.Format("{0}/data/source/maps/{1}/{1}.Map.Logical", m_strRootDir, m_strCurrentMapName);
                mapInfo = new MapInfo4Quest(strLogicalFilePath);
                if (mapInfo.Init())
                {
                    m_htMapInfo4Quest[m_strCurrentMapName] = mapInfo;
                }
            }
            if (mapInfo.IsAvailabel)
            {
                pointRet = mapInfo.GetFinalPoint(templateId, templatetype, needRefence, pointRefence);
            }
            return pointRet;
        }
Esempio n. 5
0
        private Point3d GetNearPoint(ArrayList arrPoint, Point3d refencePoint)
        {
            float fDistance = 0.0f;
            float fMinDistance = 0.0f;
            Point3d point = (Point3d)(arrPoint[0]);

            fDistance = (refencePoint.nX - point.nX) * (refencePoint.nX - point.nX) + (refencePoint.nY - point.nY) * (refencePoint.nY - point.nY);
            fMinDistance = fDistance;

            int MinDistancePointIndex = 0;

            for (int i = 1; i < arrPoint.Count; ++i)
            {                
                point = (Point3d)(arrPoint[i]);
                fDistance = (refencePoint.nX - point.nX) * (refencePoint.nX - point.nX) + (refencePoint.nY - point.nY) * (refencePoint.nY - point.nY);
                if (fMinDistance > fDistance)
                {
                    fMinDistance = fDistance;
                    MinDistancePointIndex = i;
                }
            }
            point = (Point3d)(arrPoint[MinDistancePointIndex]);
            
            return point;
        }
Esempio n. 6
0
        private Point3d CalculateFinalPoint(ArrayList arrPoint, bool needRefence, Point3d pointRefence)
        {
            Point3d pointRet;
            if (arrPoint == null || arrPoint.Count == 0)
            {
                pointRet.nX = -1;
                pointRet.nY = -1;
                pointRet.nZ = -1;
            }
            else if (arrPoint.Count == 1)
            {
                pointRet = (Point3d)arrPoint[0];
            }
            else if (arrPoint.Count <= 3 && needRefence)
            {

                pointRet = GetNearPoint(arrPoint, pointRefence);
            }
            else
            {
                pointRet = GetFocusPoint(arrPoint);
            }
            return pointRet;
        }
Esempio n. 7
0
 /// <summary>
 /// 从表htQurey查询nTemplateId对应的最终坐标,
 /// 如果htQurey里没有,则从表里取出对应的坐标列表生成最终坐标,并把最终坐标保存到htQurey表里
 /// </summary>
 /// <param name="htQurey"></param>
 /// <param name="htInfo"></param>
 /// <param name="nTemplateId"></param>
 /// <returns></returns>
 private Point3d CheckFinalPoint(Hashtable htQurey, Hashtable htInfo, int nTemplateId, bool needRefence, Point3d pointRefence)
 {
     Point3d pointRet;
     if (htInfo.ContainsKey(nTemplateId))
     {
         ArrayList arrPointlist = htInfo[nTemplateId] as ArrayList;
         int pointNum = arrPointlist.Count;
         if ((pointNum == 1 && pointNum >= GroupMinNum) &&
             htQurey.ContainsKey(nTemplateId)
             )
         {
             pointRet = (Point3d)htQurey[nTemplateId];
         }
         else
         {
             pointRet = CalculateFinalPoint(arrPointlist, needRefence, pointRefence);
             htQurey[nTemplateId] = pointRet;
         }
     }            
     else  //在逻辑文件里不存在该类型(npc,doodad)的该nTempleteId
     {
         pointRet.nX = -1;
         pointRet.nY = -1;
         pointRet.nZ = -1;
     }
     return pointRet;
 }
Esempio n. 8
0
        public Point3d GetFinalPoint(int nTemplateId, TemplateType type, bool needRefence, Point3d pointRefence)
        {
            Point3d pointRet;
            switch (type)
            {
                case TemplateType.NPC_TEMPLATE:
                    pointRet = CheckFinalPoint(m_htNpcDirectPoint, m_htNpcs, nTemplateId, needRefence, pointRefence);
                    break;
                case TemplateType.DOODAD_TEMPLATE:
                    pointRet = CheckFinalPoint(m_htDoodadDirectPoint, m_htDoodads, nTemplateId, needRefence, pointRefence);
                    break;
                default:
                    pointRet.nX = -1;
                    pointRet.nY = -1;
                    pointRet.nZ = -1;
                    break;
            }

            return pointRet;
        }