public void Handle_FishKilled(Player killer, Bullet b, Fish sameTypeBomb) { //找出死亡同类鱼的 int numTypeToBomb = sameTypeBomb.Prefab_SameTypeBombAffect.Length; List <Fish> fishNormalDie = new List <Fish>(); for (int i = 0; i != numTypeToBomb; ++i) { Dictionary <int, Fish> allFishDict = GameMain.Singleton.FishGenerator.FishTypeIndexMap[sameTypeBomb.Prefab_SameTypeBombAffect[i].TypeIndex]; if (allFishDict != null) { foreach (Fish f in allFishDict.Values) { fishNormalDie.Add(f); } } } GameObject goSameTypeBombDie = new GameObject("goSameTypeBombDie"); Transform goSameTypeBombDieTs = goSameTypeBombDie.transform; Ef_DestroyDelay efDestroyDelay = goSameTypeBombDie.AddComponent <Ef_DestroyDelay>(); efDestroyDelay.delay = 2F; GameObject tmpGO; Transform tmpTS; Vector3 tmpScale; Vector3 tmpPos; int currInstanceLineNum = 0; foreach (Fish f in fishNormalDie) { tmpGO = Instantiate(Prefab_EffectLine) as GameObject; tmpTS = tmpGO.transform; tmpTS.parent = goSameTypeBombDieTs; Vector3 dir = f.transform.position - mTs.position; float dirLen = dir.magnitude; tmpScale.x = tmpTS.localScale.x * ScaleToUnit.x * EffectWidthScale; tmpScale.y = tmpTS.localScale.y * ScaleToUnit.y * dirLen; tmpScale.z = tmpTS.localScale.z * ScaleToUnit.z; tmpTS.rotation = Quaternion.LookRotation(Vector3.forward, dir); tmpTS.localScale = tmpScale; tmpPos = mTs.position + (tmpTS.rotation * Vector3.Scale(PositionOffset, tmpScale)); tmpPos.z = Defines.GlobleDepth_BombParticle; tmpTS.position = tmpPos; ++currInstanceLineNum; if (currInstanceLineNum > MaxInstanceEffectLine) { break; } } }
public void Handle_FishKilled(Player killer, Bullet b, Fish f) { GameObject goDieAnimation = new GameObject("goSameTypeBombDieAni"); goDieAnimation.transform.parent = GameMain.Singleton.FishGenerator.transform; goDieAnimation.transform.position = new Vector3(mTs.position.x, mTs.position.y, Defines.GlobleDepth_DieFish); goDieAnimation.transform.rotation = mTs.rotation; for (int i = 0; i != Prefab_FishInstanced.Length; ++i) { //生成鱼动画 GameObject goAni = Instantiate(Prefab_FishInstanced[i].Prefab_AniDie) as GameObject; goAni.transform.parent = goDieAnimation.transform; Vector3 pos = new Vector3(TsLocalPos[i].position.x, TsLocalPos[i].position.y, Defines.GlobleDepth_DieFish - 0.0001f); goAni.transform.position = pos; goAni.transform.rotation = TsLocalPos[i].rotation; } Ef_DestroyDelay fishDestroyDelay = goDieAnimation.AddComponent <Ef_DestroyDelay>(); fishDestroyDelay.delay = mFish.TimeDieAnimation; }