コード例 #1
0
    public bool LoadShootSolutionSet(bool bForEditor)
    {
        //Reset();

        m_DistanceList = shootSolutionData.distanceList;
        m_AngleList    = shootSolutionData.angleList;

        int iNumSector = (m_DistanceList.Count + 1) * (m_AngleList.Count + 1);

        for (int idx = 0; idx < iNumSector; idx++)
        {
            if (shootSolutionData.shootSolutionSectors.ContainsKey(idx))
            {
                ShootSolutionSector sector = shootSolutionData.shootSolutionSectors[idx];
                if (sector != null)
                {
                    m_ShootSolutionSectors.Add(sector);
                }
            }
        }

        //if (bForEditor)
        //    CorrectSolutionSector();

        return(true);
    }
コード例 #2
0
    public ShootSolution GetShootSolution(int id)
    {
        int iSecId = id / 1000;
        ShootSolutionSector sector = m_ShootSolutionSectors[iSecId];
        ShootSolution       result = sector.success.Find((ShootSolution solution) => { return(solution.m_id == id); });

        if (result == null)
        {
            result = sector.fail.Find((ShootSolution solution) => { return(solution.m_id == id); });
        }
        return(result);
    }
コード例 #3
0
    //以下是编辑器*****************************************************
    public bool LoadShootSolutionSet(string path, bool bForEditor)
    {
        Reset();

        //读取以及处理XML文本的类
        XmlDocument xmlDoc;

        if (bForEditor)
        {
            xmlDoc = new XmlDocument();
            xmlDoc.Load("Assets/Resources/" + path + ".xml");
        }
        else
        {
            xmlDoc = CommonFunction.LoadXmlConfig(path);
        }
        //解析xml的过程
        XmlNodeList nodelist = xmlDoc.SelectNodes("root/distance_range/distance");

        foreach (XmlElement elem in nodelist)
        {
            IM.Number distance = IM.Number.Parse(elem.InnerText);
            m_DistanceList.Add(distance);
        }

        nodelist = xmlDoc.SelectNodes("root/angle_range/angle");
        foreach (XmlElement elem in nodelist)
        {
            IM.Number fAngle = IM.Number.Parse(elem.InnerText);
            m_AngleList.Add(fAngle);
        }

        int iNumSector = (m_DistanceList.Count + 1) * (m_AngleList.Count + 1);

        for (int idx = 0; idx < iNumSector; idx++)
        {
            path = string.Format("shoot_{0}", idx);
            ShootSolutionSector sector = _LoadShootSolutionSector(idx, path, bForEditor);
            if (sector != null)
            {
                m_ShootSolutionSectors.Add(sector);
            }
        }

        if (bForEditor)
        {
            CorrectSolutionSector();
        }

        return(true);
    }
コード例 #4
0
    ShootSolutionSector _LoadShootSolutionSector(int idx, string strFileName, bool bForEditor)
    {
        ShootSolutionSector sector = new ShootSolutionSector(idx);

        //读取以及处理XML文本的类
        XmlDocument xmlDoc;

        if (bForEditor)
        {
            xmlDoc = new XmlDocument();
            xmlDoc.Load("Assets/Resources/" + GlobalConst.DIR_XML_SHOOT_SOLUTION + strFileName + ".xml");
        }
        else
        {
            xmlDoc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_SHOOT_SOLUTION + strFileName);
        }
        //解析xml的过程

        int         iSolutionIdx = 0;
        XmlNodeList nodelist     = xmlDoc.SelectNodes("root/success");

        foreach (XmlElement elem in nodelist)
        {
            ShootSolution sucSolution = new ShootSolution(idx * 1000 + iSolutionIdx);
            if (!sucSolution.Create(elem, true, bForEditor))
            {
                continue;
            }
            sector.success.Add(sucSolution);
            iSolutionIdx++;
        }

        nodelist = xmlDoc.SelectNodes("root/fail");
        foreach (XmlElement elem in nodelist)
        {
            ShootSolution failSolution = new ShootSolution(idx * 1000 + iSolutionIdx);
            if (!failSolution.Create(elem, false, bForEditor))
            {
                continue;
            }
            sector.fail.Add(failSolution);
            iSolutionIdx++;
        }
        return(sector);
    }
コード例 #5
0
    public ShootSolution GetShootSolution(int iSector, bool bSuccess, int iIndex)
    {
        ShootSolutionSector sector = m_ShootSolutionSectors[iSector];

        if (sector == null)
        {
            return(null);
        }

        if (bSuccess)
        {
            return(sector.success[iIndex]);
        }
        else
        {
            return(sector.fail[iIndex]);
        }
    }
コード例 #6
0
    void ReadShootSolutionSector(int index, string filePath)
    {
        ShootSolutionSector sector = new ShootSolutionSector(index);

        //读取以及处理XML文本的类
        string text = ResourceLoadManager.Instance.GetConfigText(GlobalConst.DIR_XML_SHOOT_SOLUTION + filePath);

        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name + filePath);
            return;
        }
        XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_SHOOT_SOLUTION + filePath, text);
        //解析xml的过程

        int         iSolutionIdx = 0;
        XmlNodeList nodelist     = xmlDoc.SelectNodes("root/success");

        foreach (XmlElement elem in nodelist)
        {
            ShootSolution sucSolution = new ShootSolution(index * 1000 + iSolutionIdx);
            if (!sucSolution.Create(elem, true))
            {
                continue;
            }
            sector.success.Add(sucSolution);
            iSolutionIdx++;
        }

        nodelist = xmlDoc.SelectNodes("root/fail");
        foreach (XmlElement elem in nodelist)
        {
            ShootSolution failSolution = new ShootSolution(index * 1000 + iSolutionIdx);
            if (!failSolution.Create(elem, false))
            {
                continue;
            }
            sector.fail.Add(failSolution);
            iSolutionIdx++;
        }

        shootSolutionData.shootSolutionSectors.Add(index, sector);
    }
コード例 #7
0
 void CorrectSolutionSector(int index, ref List <ShootSolution> solutions)
 {
     for (int i = 0; i < solutions.Count;)
     {
         ShootSolution solution    = solutions[i];
         int           actualIndex = CalcSectorIdx(new IM.Vector3(IM.Number.zero, IM.Number.zero, new IM.Number(12, 800)), solution.m_vInitPos);
         if (index != actualIndex)
         {
             Debug.Log("Sector mismatching, saved index : " + index + " actual index: " + actualIndex + ". Corrected. Please save again.");
             ShootSolutionSector actualSector = m_ShootSolutionSectors.Find((ShootSolutionSector sector) => { return(sector.index == actualIndex); });
             actualSector.AddSolution(solution);
             solutions.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
 }