void parseAnimSound(StreamReader dataStream, GfxSkill skill) { //AnimationSound* sound = skill->addAnimationSound(); //assert(sound); //// Parse emitter details //String line; //while (!stream->eof()) //{ // line = stream->getLine(); // ++mWrongLineNum; // // Ignore comments & blanks // if (!(line.length() == 0 || line.substr(0, 2) == "//")) // { // if (line == "}") // { // // Finished emitter // break; // } // else // { // // Attribute // // Ogre::StringUtil::toLowerCase(line); // parseAnimSoundAttrib(line, sound); // } // } //} }
void parseHitGroundEffectInfo(StreamReader dataStream, GfxSkill skill) { GfxSkillHitGroundEffect HitGroundEffect = new GfxSkillHitGroundEffect(); skill.HitGroundEffect = HitGroundEffect; string line; while (!dataStream.EndOfStream) { line = dataStream.ReadLine(); // Ignore comments & blanks if (!(line.Length == 0 || line.Substring(0, 2) == "//")) { string delim = "\t"; string spaceDelim = " "; line = line.TrimStart(spaceDelim.ToCharArray()); line = line.TrimEnd(spaceDelim.ToCharArray()); string strline = line.Trim(delim.ToCharArray()); if (strline == "}") { // Finished emitter break; } else { // Attribute parseHitGroundEffectInfoAttrib(strline, HitGroundEffect); } } } }
void addSkill() { GUILayout.BeginHorizontal("box"); GUILayout.Label("AnimateName"); if (mSkillAnimateNameIndex >= getCurrentAnimateList().Count) { EditorGUILayout.Popup(getCurrentAnimateList().Count - 1, getCurrentAnimateList().ToArray()); } else { mSkillAnimateNameIndex = EditorGUILayout.Popup(mSkillAnimateNameIndex, getCurrentAnimateList().ToArray()); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); GUILayout.Label("SkillName"); mSkillName = GUILayout.TextField(mSkillName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("OK")) { GFX.GfxSkill newSkill = actor.createSkill(mSkillName); if (newSkill != null) { if (getCurrentSkillAnimateName() == "none") { newSkill.setAnimateName(""); } else { newSkill.setAnimateName(getCurrentSkillAnimateName()); } addSkill(mSkillName); } lastSkillIndex = 0; if (skillIndex != 0) { stat = GUI_STATUS.CHECKING; } else { stat = GUI_STATUS.NONE; } } if (GUILayout.Button("Cancel")) { lastSkillIndex = 0; if (skillIndex != 0) { stat = GUI_STATUS.CHECKING; } else { stat = GUI_STATUS.NONE; } } GUILayout.EndHorizontal(); }
public void removeSkill(GfxSkill skill) { if (skill != null) { skill.shutDown(); } }
void addSkill() { GUILayout.BeginHorizontal("box"); GUILayout.Label("AnimateName"); // mAnimateName = GUILayout.TextField(mAnimateName); mSkillAnimateNameIndex = EditorGUILayout.Popup(mSkillAnimateNameIndex, AnimNames.ToArray()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); GUILayout.Label("SkillName"); mSkillName = GUILayout.TextField(mSkillName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("OK")) { GFX.GfxSkill newSkill = GFX.GfxSkillManager.Instance.createSkillTemplate(mSkillName); if (newSkill != null) { if (AnimNames[mSkillAnimateNameIndex] == "none") { newSkill.setAnimateName(""); } else { newSkill.setAnimateName(AnimNames[mSkillAnimateNameIndex]); } SkillNames.Add(mSkillName); } lastSkillIndex = 0; if (skillIndex != 0) { stat = GUI_STATUS.CHECKING; } else { stat = GUI_STATUS.NONE; } } if (GUILayout.Button("Cancel")) { lastSkillIndex = 0; if (skillIndex != 0) { stat = GUI_STATUS.CHECKING; } else { stat = GUI_STATUS.NONE; } } GUILayout.EndHorizontal(); }
public GfxSkill createAndParseSkillTemplate(string skillName) { GfxSkill skill = null; if (!mSkillMap.ContainsKey(skillName)) { parseSkillFile(skillName); } if (!mSkillMap.TryGetValue(skillName, out skill)) { return(null); } return(skill); }
public GfxSkill(GfxSkill skill) { mSkillName = skill.mSkillName; mRepeatEffect = skill.mRepeatEffect; mAnimateName = skill.mAnimateName; mHitTimeArray = new List <float>(); mBreakTimeArray = new List <float>(); mShakeTimeArray = new List <float>(); for (int i = 0; i < skill.mHitTimeArray.Count; i++) { mHitTimeArray.Add(skill.mHitTimeArray[i]); } for (int i = 0; i < skill.mBreakTimeArray.Count; i++) { mBreakTimeArray.Add(skill.mBreakTimeArray[i]); } for (int i = 0; i < skill.mShakeTimeArray.Count; i++) { mShakeTimeArray.Add(skill.mShakeTimeArray[i]); } mSkillEffects = new List <GfxSkillEffect>(); for (int i = 0; i < skill.mSkillEffects.Count; i++) { GfxSkillEffect newSkillEffect = new GfxSkillEffect(); newSkillEffect.Attach = skill.mSkillEffects[i].Attach; newSkillEffect.AttachPoint = skill.mSkillEffects[i].AttachPoint; newSkillEffect.AttachTime = skill.mSkillEffects[i].AttachTime; newSkillEffect.EffectName = skill.mSkillEffects[i].EffectName; newSkillEffect.OffsetPos = skill.mSkillEffects[i].OffsetPos; newSkillEffect.OffsetRotation = skill.mSkillEffects[i].OffsetRotation; newSkillEffect.OffsetScale = skill.mSkillEffects[i].OffsetScale; mSkillEffects.Add(newSkillEffect); } if (skill.mHitGroundEffect != null) { mHitGroundEffect = new GfxSkillHitGroundEffect(); mHitGroundEffect.OffsetPos = skill.mHitGroundEffect.OffsetPos; mHitGroundEffect.OffsetRotation = skill.mHitGroundEffect.OffsetRotation; mHitGroundEffect.AttachTime = skill.mHitGroundEffect.AttachTime; mHitGroundEffect.AttachPoint = skill.mHitGroundEffect.AttachPoint; mHitGroundEffect.EffectName = skill.mHitGroundEffect.EffectName; mHitGroundEffect.Attach = skill.mHitGroundEffect.Attach; mHitGroundEffect.AnimateName = skill.mHitGroundEffect.AnimateName; mHitGroundEffect.ShakeTime = skill.mHitGroundEffect.ShakeTime; } }
public GfxSkill createSkillTemplate(string skillName) { GfxSkill ret = null; if (!mSkillMap.ContainsKey(skillName)) { ret = new GfxSkill(skillName); mSkillMap[skillName] = ret; } else { Debug.LogWarning("skill template with name already exists! ,EffectManager::createSkillTemplate"); } return(ret); }
//void parseAnimSoundAttrib(string line, AnimationSound sound) //{ // // 设置element的属性 // string[] vecparams = line.Split(new string[1] { "\t" }, StringSplitOptions.None); // if (vecparams.Length != 2 || false == sound.setParameter(vecparams[0], vecparams[1])) // { // Debug.LogError("Bad Anim sound attribute line EffectManager::parseAnimSoundAttrib"); // } //} void parseSkillAttrib(string line, GfxSkill skill) { // 设置element的属性 string[] szTemp = line.Split(new string[1] { " " }, StringSplitOptions.None); if (szTemp.Length <= 0) { Debug.LogError("the number of parameters must be >0! parseSkillAttrib " + line); return; } if (szTemp.Length == 2) { if (false == skill.setParameter(szTemp[0], szTemp[1])) { Debug.LogError("Bad Anim Effect Info attribute line parseSkillAttrib " + line); } } else { string valueString = ""; for (int i = 1; i < szTemp.Length; i++) { valueString += szTemp[i]; if (i + 1 < szTemp.Length) { valueString += " "; } } if (false == skill.setParameter(szTemp[0], valueString)) { Debug.LogError("Bad Anim Effect Info Complex attribute line parseSkillAttrib " + line); } } }
protected bool parseSkillFile(string skillName) { if (skillName == null || skillName.Length == 0) { return(false); } StreamReader skillDataReader = null; MemoryStream skillData = null; if (Application.platform == RuntimePlatform.WindowsEditor) { FileInfo fileInfo = new FileInfo("Assets/Resources/Skill/" + skillName + ".txt"); if (fileInfo.Exists) { skillDataReader = new StreamReader("Assets/Resources/Skill/" + skillName + ".txt"); } else { return(false); } } else { TextAsset skillFile = null; if (GfxSkillManager.AllSkillAsset != null) { if (GfxSkillManager.AllSkillAsset.Contains(skillName)) { skillFile = GfxSkillManager.AllSkillAsset.Load(skillName) as TextAsset; if (skillFile == null) { LogManager.LogError("skillName " + "does not exists"); return(false); } } } else { LogManager.LogError("Skill AssetBundle does not bind"); return(false); } if (skillFile == null) { return(false); } skillData = new MemoryStream(skillFile.bytes); skillDataReader = new StreamReader(skillData); } string line; GfxSkill skill = null; int lineNO = 0; while ((line = skillDataReader.ReadLine()) != null) { lineNO++; //Debug.LogWarning("LineNO:" + lineNO); if (skill == null) { if (!(line.Length == 0 || line.Substring(0, 2) == "//")) { string[] szTemp = line.Split(new string[1] { " " }, StringSplitOptions.None); if (szTemp[0] != "skill" || szTemp.Length != 2) { Debug.LogError("Wrong skill name line parseSkillFile"); continue; } skill = createSkillTemplate(szTemp[1]); skipToNextOpenBrace(skillDataReader); } } else { string delim = "\t"; string spaceDelim = " "; line = line.TrimStart(spaceDelim.ToCharArray()); line = line.TrimEnd(spaceDelim.ToCharArray()); string strline = line.Trim(delim.ToCharArray()); if (strline == "}") { skill = null; } else if (strline == "AnimEffect") { skipToNextOpenBrace(skillDataReader); parseAnimEffectInfo(skillDataReader, skill); } else if (strline == "Sound") { //skipToNextOpenBrace(skillDataReader); //parseAnimSound(skillDataReader,skill); parseInvalidSection(skillDataReader); } else if (strline == "Ribbon") { parseInvalidSection(skillDataReader); } else if (strline == "SceneLight") { parseInvalidSection(skillDataReader); } else if (strline == "HitGroundEffect") { skipToNextOpenBrace(skillDataReader); parseHitGroundEffectInfo(skillDataReader, skill); } else { parseSkillAttrib(strline, skill); } } } ; skillDataReader.Close(); if (skillData != null) { skillData.Close(); } return(true); }
void DisplaySkillGUI() { List <string> skillList = getCurrrentSkillList(); GUILayout.BeginHorizontal("box"); GUILayout.Label("Skill"); if (skillList.Count <= skillIndex) { skillIndex = 0; } skillIndex = EditorGUILayout.Popup(skillIndex, skillList.ToArray()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (!GUILayout.Button("AddSkill")) { if (skillList[skillIndex] != "none") { if (lastSkillIndex != skillIndex) { string skillName = getCurrentSkillName(); actor.getSkill(skillName); GFX.GfxSkill curSkill = actor.Skill; if (curSkill != null) { stat = GUI_STATUS.CHECKING; refreshSkillEffectList(); string curAnimateName = curSkill.getParameter("Animation"); mSkillAnimateNameIndex = getCurrentAnimateList().IndexOf(curAnimateName); if (mSkillAnimateNameIndex == -1) { mSkillAnimateNameIndex = 0; } mBreakTime = curSkill.getParameter("BreakTime"); mHitTime = curSkill.getParameter("HitTime"); mShakeTime = curSkill.getParameter("ShakeTime"); mRepeatEffect = curSkill.RepeatEffect; mEnableRibbon = curSkill.EnableRibbon; lastEffectIndex = 0; openHitGroundEffect = curSkill.isHitGroundEffectExist(); } } lastSkillIndex = skillIndex; } } else { stat = GUI_STATUS.ADDSKILL; } if (GUILayout.Button("RemoveSkill")) { removeSkill(); } GUILayout.EndHorizontal(); switch (stat) { case GUI_STATUS.ADDEFFECT: addSkillEffect(); break; case GUI_STATUS.ADDSKILL: addSkill(); break; case GUI_STATUS.CHECKING: { showSkill(); showSkillEffect(); ShowHitGroundEffect(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("SetSkill")) { if (getCurrentSkillAnimateName() == "none") { actor.Skill.setParameter("Animation", ""); } else { actor.Skill.setParameter("Animation", getCurrentSkillAnimateName()); } actor.Skill.setParameter("BreakTime", mBreakTime); actor.Skill.setParameter("HitTime", mHitTime); actor.Skill.setParameter("ShakeTime", mShakeTime); actor.Skill.RepeatEffect = mRepeatEffect; actor.Skill.EnableRibbon = mEnableRibbon; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); bool changed = EditorGUILayout.Toggle("Play", this.isPlaying); if (changed != this.isPlaying) //if (GUILayout.Button(GetActionName())) { SetAction(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("Save")) { Save(); } GUILayout.EndHorizontal(); } break; } }
void DisplaySkillGUI() { GUILayout.BeginHorizontal("box"); GUILayout.Label("Skill"); skillIndex = EditorGUILayout.Popup(skillIndex, SkillNames.ToArray()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (!GUILayout.Button("AddSkill")) { if (SkillNames[skillIndex] != "none") { if (lastSkillIndex != skillIndex) { GFX.GfxSkill curSkill = GFX.GfxSkillManager.Instance.createAndParseSkillTemplate(SkillNames[skillIndex]); if (curSkill != null) { mSkill = curSkill; stat = GUI_STATUS.CHECKING; refreshSkillEffectList(); string curAnimateName = mSkill.getParameter("Animation"); mSkillAnimateNameIndex = AnimNames.IndexOf(curAnimateName); if (mSkillAnimateNameIndex == -1) { mSkillAnimateNameIndex = 0; } mBreakTime = mSkill.getParameter("BreakTime"); mHitTime = mSkill.getParameter("HitTime"); mShakeTime = mSkill.getParameter("ShakeTime"); mRepeatEffect = mSkill.getParameter("RepeatEffect"); lastEffectIndex = 0; } } lastSkillIndex = skillIndex; } } else { stat = GUI_STATUS.ADDSKILL; } if (GUILayout.Button("RemoveSkill")) { removeSkill(); } GUILayout.EndHorizontal(); switch (stat) { case GUI_STATUS.ADDEFFECT: addSkillEffect(); break; case GUI_STATUS.ADDSKILL: addSkill(); break; case GUI_STATUS.CHECKING: { showSkill(); showSkillEffect(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("SetSkill")) { if (AnimNames[mSkillAnimateNameIndex] == "none") { mSkill.setParameter("Animation", ""); } else { mSkill.setParameter("Animation", AnimNames[mSkillAnimateNameIndex]); } mSkill.setParameter("BreakTime", mBreakTime); mSkill.setParameter("HitTime", mHitTime); mSkill.setParameter("ShakeTime", mShakeTime); mSkill.setParameter("RepeatEffect", mRepeatEffect); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button(GetActionName())) { SetAction(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("Save")) { Save(); } GUILayout.EndHorizontal(); } break; } }
public GFX.GfxSkill getSkill(string skillName) { mSkill = GFX.GfxSkillManager.Instance.createAndParseSkillTemplate(skillName); return(mSkill); }