Example #1
0
 public void LoadBackEffect(int backidx)
 {
     if (m_BackEffectMapping[backidx] != null)
     {
         BackgroundIndexMapping backmapping = m_BackEffectMapping[backidx];
         m_LaunchEffectList = new GameObject[backmapping.EffectList.Length];
         for (int i = 0; i < m_LaunchEffectList.Length; ++i)
         {
             int        idx       = backmapping.EffectList[i];
             GameObject EffectObj = (GameObject)GameObject.Instantiate(m_BackEffectData[idx].EffectObj);
             EffectObj.transform.localPosition = m_BackEffectData[idx].Pos;
             m_LaunchEffectList[i]             = EffectObj;
         }
     }
 }
Example #2
0
        private void LoadBackEffect()
        {
            TextAsset ta =
                (TextAsset)
                ResManager.Instance.LoadObject("BackEffectSetting", "BuYu/SceneRes/BackEffectSetting/", ResType.SceneRes,
                                               typeof(TextAsset));
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(ta.text);
            XmlElement ele         = doc.DocumentElement;
            XmlNode    effectNodes = ele.SelectSingleNode("EffectList");

            m_BackEffectData = new BackgroundEffectData[effectNodes.ChildNodes.Count];
            for (int i = 0; i < m_BackEffectData.Length; ++i)
            {
                XmlNode node = effectNodes.ChildNodes[i];
                int     id   = int.Parse(node.Attributes["id"].Value);
                if (m_BackEffectData[id] != null)
                {
                    Debug.Log("存在相同的特效ID:" + id);
                }
                BackgroundEffectData effect = new BackgroundEffectData();
                effect.EffectObj = ResManager.Instance.LoadObject(node.Attributes["path"].Value,
                                                                  "SceneRes/BackEffectSetting/", ResType.SceneRes);
                effect.Pos = new Vector3(
                    float.Parse(node.Attributes["x"].Value),
                    float.Parse(node.Attributes["y"].Value),
                    float.Parse(node.Attributes["z"].Value));
                m_BackEffectData[id] = effect;
            }

            effectNodes = effectNodes.NextSibling;
            int backCount = effectNodes.ChildNodes.Count;

            m_BackEffectMapping = new BackgroundIndexMapping[backCount];
            for (int i = 0; i < backCount; ++i)
            {
                XmlNode curNode = effectNodes.ChildNodes[i];
                byte    index   = byte.Parse(curNode.Attributes["id"].Value);
                if (m_BackEffectMapping[index] != null)
                {
                    Debug.Log("存在相同的背景索引:" + index);
                }
                BackgroundIndexMapping backmapping = new BackgroundIndexMapping();
                m_BackEffectMapping[index] = backmapping;
                int count = curNode.ChildNodes.Count;
                if (count > 0)
                {
                    backmapping.EffectList = new byte[count];
                    for (int j = 0; j < curNode.ChildNodes.Count; ++j)
                    {
                        byte idx = byte.Parse(curNode.ChildNodes[j].Attributes["id"].Value);
                        if (idx >= m_BackEffectData.Length)
                        {
                            Debug.Log("不存在的特效索引:" + idx);
                        }
                        backmapping.EffectList[j] = idx;
                    }
                }
            }
            ResManager.Instance.UnloadObject(ta);
        }