public void Init(SFXUnit SfxAttack, AttackDes attDef) { AttackDef = attDef; Attacker = SfxAttack; if (Attacker.mOwner != null) { Attacker.mOwner.IgnoreOthers(box); if (!Attacker.mOwner.HitList.Contains(this)) Attacker.mOwner.HitList.Add(this); } }
public void OnPlayDone(SFXUnit sfx) { sfxDoneCnt++; if (sfx != null && !loop) { sfx.Hide(); } if (sfxDoneCnt == (played.Count + (audioList.Count == 0 ? 0 : 1))) { if (loop) { for (int i = 0; i < played.Count; i++) { played[i].RePlay(); } if (audioUpdate) { audioUpdate = false; } if (audioList.Count != 0) { audioUpdate = true; } sfxDoneCnt = 0; playedTime = 0.0f; } else { for (int i = 0; i < played.Count; i++) { Destroy(played[i].gameObject); } played.Clear(); if (audioUpdate) { audioUpdate = false; } if (owner == null && tag != "SceneItemAgent") { DestroyObject(gameObject); } else { Destroy(this); } } } }
public void OnPlayDone(SFXUnit sfx) { sfxDoneCnt++; if (sfx != null && !loop) { sfx.Hide(); } if (sfxDoneCnt == (played.Count + (audioList.Count == 0 ? 0 : 1))) { if (loop) { for (int i = 0; i < played.Count; i++) { played[i].RePlay(); } if (audioPlayCorout != null) { StopCoroutine(audioPlayCorout); } if (audioList.Count != 0) { audioPlayCorout = StartCoroutine(PlayAudioEffect()); } sfxDoneCnt = 0; } else { for (int i = 0; i < played.Count; i++) { Destroy(played[i].gameObject); } played.Clear(); Destroy(this); } } }
public void Load(SfxFile effectFile, float timePlayed, bool preLoad = false) { loop = false; file = effectFile.strfile; var effectList = effectFile.effectList; playedTime = timePlayed; //必须看一下信息,才知道创建什么大小的预设,主要是网格可能大小不一样 SortedDictionary <int, SFXUnit> dic = new SortedDictionary <int, SFXUnit>(); for (int i = 0; i < effectList.Count; i++) { GameObject objSfx = null; SFXUnit sfx = null; if (effectList[i].EffectType.Equals("AUDIO")) { audioList.Add(effectList[i]); } else if (effectList[i].EffectType.Equals("BILLBOARD")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType.Equals("BOX")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType.Equals("PLANE")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType.Equals("DONUT")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType.Equals("MODEL")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType.Equals("SPHERE")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType.Equals("PARTICLE")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType.Equals("CYLINDER")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); } else if (effectList[i].EffectType.Equals("DRAG")) { objSfx = Instantiate(SfxUnit); sfx = objSfx.GetComponent <SFXUnit>(); } else { Debug.LogError("!!!"); } if (sfx != null) { dic.Add(i, sfx); //特效可以非角色发出. if (owner != null) { owner.AddAttackSFX(sfx);//因为这个特效可以做攻击 } sfx.name = effectList[i].EffectName; } } //第一次先创建,再初始化,否则先初始化的,如果要挂到后初始化的上面,会找不到对象 foreach (var each in dic) { if (each.Value != null) { played.Add(each.Value); } } //分2次循环,第一次让前面的可以找到后面的,第二次都开始初始化,就可以互相引用了 foreach (var each in dic) { if (each.Value != null) { each.Value.Init(effectList[each.Key], this, each.Key, timePlayed, preLoad); } } if (audioList.Count != 0) { audioUpdate = true; } }
public void Load(SfxFile effectFile, bool once = false) { loop = !once; file = effectFile.strfile; var effectList = effectFile.effectList; playedTime = 0.0f; //必须看一下信息,才知道创建什么大小的预设,主要是网格可能大小不一样 Dictionary <int, SFXUnit> dic = new Dictionary <int, SFXUnit>(); for (int i = 0; i < effectList.Count; i++) { GameObject objSfx = null; SFXUnit sfx = null; if (effectList[i].EffectType == "AUDIO") { audioList.Add(effectList[i]); } else if (effectList[i].EffectType == "BILLBOARD") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType == "BOX") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType == "PLANE") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType == "DONUT") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType == "MODEL") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType == "SPHERE") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType == "PARTICLE") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else if (effectList[i].EffectType == "CYLINDER") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); //objSfx = GameObject.Instantiate(Resources.Load("SFXCYLINDER")) as GameObject; //SFXCylinder sfxc = objSfx.GetComponent<SFXCylinder>(); //sfxc.Init(effectList[i], GetComponent<MeteorUnit>(), this); } else if (effectList[i].EffectType == "DRAG") { objSfx = GameObject.Instantiate(Resources.Load("SFXUnit")) as GameObject; sfx = objSfx.GetComponent <SFXUnit>(); //sfx.Init(effectList[i], this, i); } else { Debug.LogError("can not recognize"); } if (sfx != null) { dic.Add(i, sfx); //特效可以非角色发出. if (owner != null) { owner.AddAttackSFX(sfx);//因为这个特效可以做攻击 } sfx.name = effectList[i].EffectName; } } //第一次先创建,再初始化,否则先初始化的,如果要挂到后初始化的上面,会找不到对象 foreach (var each in dic) { if (each.Value != null) { played.Add(each.Value); } } //分2次循环,第一次让前面的可以找到后面的,第二次都开始初始化,就可以互相引用了 foreach (var each in dic) { if (each.Value != null) { each.Value.Init(effectList[each.Key], this, each.Key, 0); } } if (audioList.Count != 0) { audioPlayCorout = StartCoroutine(PlayAudioEffect()); } }