Esempio n. 1
0
        public void SetJungleMonsterBeAtkVoice()
        {
            int           id   = (int)ObjTypeID;
            NpcConfigInfo info = ConfigReader.GetNpcInfo(id);

            if (entityType != EntityType.Monster || Hp < hpLimit || AudioManager.Instance.HeroLinesAudioDict.ContainsKey(GameObjGUID))
            {
                return;
            }
            List <float> ifPlaySoundList = new List <float>();

            for (int i = 0; i < ifPlayMonsterSound.Length; i++)
            {
                ifPlaySoundList.Add(ifPlayMonsterSound[i]);
            }
            int indexPlay = GameMethod.RandProbablityIndex(ifPlaySoundList);//获得是否播放下标

            if (indexPlay == 1)
            {
                return;
            }
            if (HasSameTypeNpcPlaySoundIsPlaying())
            {
                return;
            }

            if (info.n32Script1Rate == null)
            {
                return;
            }

            List <float> probabilityList = GameMethod.ResolveToFloatList(info.n32Script1Rate);//获得概率集合

            for (int i = 0; i < probabilityList.Count; i++)
            {
                probabilityList[i] = (float)(probabilityList[i] - 90000) / 100f;
            }
            int           index     = GameMethod.RandProbablityIndex(probabilityList); //获得概率下标
            List <string> voiceList = GameMethod.ResolveToStrList(info.un32Script1);
            string        name      = voiceList[index];                                //获得概率下标对应的声音
            string        path      = AudioDefine.PATH_JUNGLE_MONSTER_BE_ATK_SOUND + name;

            //AudioClip clip = Resources.Load(path) as AudioClip;
            ResourceItem clipUnit = ResourcesManager.Instance.loadImmediate(path, ResourceType.ASSET);
            AudioClip    clip     = clipUnit.Asset as AudioClip;


            AudioManager.Instance.PlayHeroLinesAudio(GameObjGUID, clip);
        }
    public ReadGuideRewardTaskConfig(string xmlFilePath)
    {
        //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset;
        ResourceItem xmlfileUnit = ResourcesManager.Instance.loadImmediate(xmlFilePath, ResourceType.ASSET);
        TextAsset    xmlfile     = xmlfileUnit.Asset as TextAsset;

        if (!xmlfile)
        {
            Debug.LogError(" error infos: 没有找到指定的xml文件:" + xmlFilePath);
        }

        xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(xmlfile.text);

        XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("Award").ChildNodes;

        for (int i = 0; i < infoNodeList.Count; i++)     //(XmlNode xNode in infoNodeList)
        {
            if ((infoNodeList[i] as XmlElement).GetAttributeNode("id") == null)
            {
                continue;
            }

            string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("id").InnerText;

            CRewardTask rewardInfo = new CRewardTask();
            rewardInfo.TaskId   = Convert.ToInt32(typeName);
            rewardInfo.TaskType = GuideTaskType.RewardTipTask;
            foreach (XmlElement xEle in infoNodeList[i].ChildNodes)
            {
                #region 搜索
                switch (xEle.Name)
                {
                case "award":
                    rewardInfo.RewardType = (RewardTaskType)Convert.ToInt32(xEle.InnerText);
                    break;

                case "quantity":
                    rewardInfo.RewardResult = Convert.ToInt32(xEle.InnerText);
                    break;

                case "pos":
                    string pos = Convert.ToString(xEle.InnerText);
                    if (pos.Length == 1)
                    {
                        rewardInfo.EffectPos = Vector3.zero;
                    }
                    else
                    {
                        List <float> posList = GameMethod.ResolveToFloatList(Convert.ToString(xEle.InnerText), ';');
                        rewardInfo.EffectPos = new Vector3(posList[0], posList[1], posList[2]);
                    }
                    break;

                case "path":
                    rewardInfo.EffectPath = Convert.ToString(xEle.InnerText);
                    break;
                }
                #endregion
            }
            CTaskBase.rewardTaskDic.Add(rewardInfo.TaskId, rewardInfo);
        }
    }