diff --git a/Assets/Src/GameLogic/Battle/FighterManager/FighterManager.cs b/Assets/Src/GameLogic/Battle/FighterManager/FighterManager.cs index fff12c354..4e66c7b8c 100644 --- a/Assets/Src/GameLogic/Battle/FighterManager/FighterManager.cs +++ b/Assets/Src/GameLogic/Battle/FighterManager/FighterManager.cs @@ -121,28 +121,28 @@ public class FighterManager if (TeamFighters.Count == 0) return Vector3.forward; return TeamFighters[0].Ctrl != null ? TeamFighters[0].Ctrl.transform.forward : TeamFighters[0].Forward; - } + } } } #endregion - public FighterManager (BaseBattle battle) - { - mBattle = battle; - IsDisposed = false; - } + public FighterManager(BaseBattle battle) + { + mBattle = battle; + IsDisposed = false; + } FighterManager() { HasInitializedFighters = false; } - + public void SetPveMark() { for (int idx = 0; idx < mAllFighters.Count; idx++) { Fighter f = mAllFighters[idx]; - if(f.IsTeamMember) + if (f.IsTeamMember) { f.AddPveMark(); } @@ -150,105 +150,31 @@ public class FighterManager } - public void InitializeCurrentSceneFighters () - { - if (mBattle == null || HasInitializedFighters) - return; - - List fighterInfos = mBattle.MyFighters; - for (int i = 0; i < fighterInfos.Count; i++) { - AddFighter(fighterInfos[i], eTeamType.Friend); - } - - fighterInfos = mBattle.EnemyFighters; - for (int i = 0; i < fighterInfos.Count; i++) { - AddFighter(fighterInfos[i], eTeamType.Enemy); - } - - - //初始化召唤物 - for(int idx =0; idx < mAllFighters.Count;idx++) - { - Fighter f = mAllFighters[idx]; - if (f.Skills == null || f.Skills.Length == 0) continue; - - if (f.RageCloneBossId > 0) - { - ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100,idx), f.RageCloneBossId, 1); - ad.PositionValue = f.PositionValue; - - f.RageCloneBoss = Fighter.CreateFighter(this, ad, f.TeamSide, f); - mAllFighters.Add(f.RageCloneBoss); - } - - for (int jdx =0; jdx < f.Skills.Length;jdx++) - { - BaseSkill skill = f.Skills[jdx]; - if(skill != null && skill.IsValid && (skill.SummonActors!=null || skill.SummonBosses!=null)) - { - if(skill.SummonActors!=null) - { - for (int i =0; i < skill.SummonActors.Count;i++) - { - ValType sa = skill.SummonActors[i]; - - ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), sa.id, 1); - ad.PositionValue = sa.val; - - Fighter summon = Fighter.CreateFighter(this, ad, f.TeamSide, f); - mAllFighters.Add(summon); - skill.AddSummonActor(summon); - } - } - - if(skill.SummonBosses!=null) - { - for(int i =0; i < skill.SummonBosses.Count;i++) - { - ValType sa = skill.SummonActors[i]; - - ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), sa.id, 1); - ad.PositionValue = sa.val; - - Fighter summon = Fighter.CreateFighter(this, ad, f.TeamSide, f); - mAllFighters.Add(summon); - skill.AddSummonActor(summon); - } - } - } - } - } - HasInitializedFighters = true; - } - - public void InitFighters() + public void InitializeCurrentSceneFighters() { if (mBattle == null || HasInitializedFighters) return; - if(mBattle.TeamActors!=null) + List fighterInfos = mBattle.MyFighters; + for (int i = 0; i < fighterInfos.Count; i++) { - for (int idx = 0; idx < mBattle.TeamActors.Count;idx++) - { - AddFighter(mBattle.TeamActors[idx], eTeamType.Friend); - } + AddFighter(fighterInfos[i], eTeamType.Friend); } - if(mBattle.EnemyActors!=null) + fighterInfos = mBattle.EnemyFighters; + for (int i = 0; i < fighterInfos.Count; i++) { - for(int idx =0; idx < mBattle.EnemyActors.Count;idx++) - { - AddFighter(mBattle.EnemyActors[idx], eTeamType.Enemy); - } + AddFighter(fighterInfos[i], eTeamType.Enemy); } + //初始化召唤物 for (int idx = 0; idx < mAllFighters.Count; idx++) { Fighter f = mAllFighters[idx]; if (f.Skills == null || f.Skills.Length == 0) continue; - if(f.RageCloneBossId > 0) + if (f.RageCloneBossId > 0) { ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), f.RageCloneBossId, 1); ad.PositionValue = f.PositionValue; @@ -264,7 +190,83 @@ public class FighterManager { if (skill.SummonActors != null) { - for (int i = 0; i < skill.SummonActors.Count;i++) + for (int i = 0; i < skill.SummonActors.Count; i++) + { + ValType sa = skill.SummonActors[i]; + + ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), sa.id, 1); + ad.PositionValue = sa.val; + + Fighter summon = Fighter.CreateFighter(this, ad, f.TeamSide, f); + mAllFighters.Add(summon); + skill.AddSummonActor(summon); + } + } + + if (skill.SummonBosses != null) + { + for (int i = 0; i < skill.SummonBosses.Count; i++) + { + ValType sa = skill.SummonActors[i]; + + ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), sa.id, 1); + ad.PositionValue = sa.val; + + Fighter summon = Fighter.CreateFighter(this, ad, f.TeamSide, f); + mAllFighters.Add(summon); + skill.AddSummonActor(summon); + } + } + } + } + } + HasInitializedFighters = true; + } + + public void InitFighters() + { + if (mBattle == null || HasInitializedFighters) + return; + + if (mBattle.TeamActors != null) + { + for (int idx = 0; idx < mBattle.TeamActors.Count; idx++) + { + AddFighter(mBattle.TeamActors[idx], eTeamType.Friend); + } + } + + if (mBattle.EnemyActors != null) + { + for (int idx = 0; idx < mBattle.EnemyActors.Count; idx++) + { + AddFighter(mBattle.EnemyActors[idx], eTeamType.Enemy); + } + } + + //初始化召唤物 + for (int idx = 0; idx < mAllFighters.Count; idx++) + { + Fighter f = mAllFighters[idx]; + if (f.Skills == null || f.Skills.Length == 0) continue; + + if (f.RageCloneBossId > 0) + { + ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), f.RageCloneBossId, 1); + ad.PositionValue = f.PositionValue; + + f.RageCloneBoss = Fighter.CreateFighter(this, ad, f.TeamSide, f); + mAllFighters.Add(f.RageCloneBoss); + } + + for (int jdx = 0; jdx < f.Skills.Length; jdx++) + { + BaseSkill skill = f.Skills[jdx]; + if (skill != null && skill.IsValid && (skill.SummonActors != null || skill.SummonBosses != null)) + { + if (skill.SummonActors != null) + { + for (int i = 0; i < skill.SummonActors.Count; i++) { ValType sa = skill.SummonActors[i]; ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), sa.id, 1); @@ -278,7 +280,7 @@ public class FighterManager if (skill.SummonBosses != null) { - for (int i = 0; i < skill.SummonBosses.Count;i++) + for (int i = 0; i < skill.SummonBosses.Count; i++) { ValType sa = skill.SummonBosses[i]; ActorData ad = ActorData.CreateNpcPlayerActor(CommonUtil.CalcSummonNpcUniqueId(100, idx), sa.id, 1); @@ -298,24 +300,24 @@ public class FighterManager public void ParseLoad() { - for(int idx =0; idx < mAllFighters.Count;idx++) + for (int idx = 0; idx < mAllFighters.Count; idx++) { Fighter fighter = mAllFighters[idx]; fighter.Ctrl.ParseLoad(); } } - public Fighter AddFighter (ActorData actor, eTeamType side) - { - Fighter fighter = GetFighterByID(actor.ID,side); + public Fighter AddFighter(ActorData actor, eTeamType side) + { + Fighter fighter = GetFighterByID(actor.ID, side); if (fighter != null) return fighter; - fighter = Fighter.CreateFighter (this, actor,side); - if(fighter.IsTeamMember) + fighter = Fighter.CreateFighter(this, actor, side); + if (fighter.IsTeamMember) { mTeamFigters.Add(fighter); - if(fighter.IsPet) + if (fighter.IsPet) { mTeamPetFighters.Add(fighter); } @@ -328,15 +330,16 @@ public class FighterManager { mEnemyFighters.Add(fighter); } - mAllFighters.Add (fighter); + mAllFighters.Add(fighter); - return fighter; - } + return fighter; + } - public void AddFighters (ActorData[] actors, eTeamType side) - { - for (int i = 0; i < actors.Length; i++) { - AddFighter (actors [i], side); + public void AddFighters(ActorData[] actors, eTeamType side) + { + for (int i = 0; i < actors.Length; i++) + { + AddFighter(actors[i], side); } } @@ -349,7 +352,7 @@ public class FighterManager { mCacheTeamFighters.Clear(); mCacheTeamFighters.AddRange(mTeamFigters); - for(int idx =0; idx < mCacheTeamFighters.Count;idx++) + for (int idx = 0; idx < mCacheTeamFighters.Count; idx++) { RemoveFighter(mCacheTeamFighters[idx]); } @@ -357,14 +360,14 @@ public class FighterManager public void RestoreTeamFighters() { - for(int idx = mTeamFigters.Count-1;idx>=0;idx--) + for (int idx = mTeamFigters.Count - 1; idx >= 0; idx--) { Fighter f = mTeamFigters[idx]; RemoveFighter(f); f.Destroy(); } - for(int idx =0; idx < mCacheTeamFighters.Count;idx++) + for (int idx = 0; idx < mCacheTeamFighters.Count; idx++) { AddTeamFighter(mCacheTeamFighters[idx]); } @@ -373,36 +376,37 @@ public class FighterManager private void AddTeamFighter(Fighter f) { - if(!mTeamFigters.Contains(f)) + if (!mTeamFigters.Contains(f)) mTeamFigters.Add(f); - - if(!mAllFighters.Contains(f)) + + if (!mAllFighters.Contains(f)) mAllFighters.Add(f); - if(f.IsPet) + if (f.IsPet) { - if(!mTeamPetFighters.Contains(f)) + if (!mTeamPetFighters.Contains(f)) mTeamPetFighters.Add(f); } else { - if(!mTeamHeroFighters.Contains(f)) + if (!mTeamHeroFighters.Contains(f)) mTeamHeroFighters.Add(f); } } - public void FixedUpdate (float deltaTime) - { + public void FixedUpdate(float deltaTime) + { #if PROFILE UnityEngine.Profiling.Profiler.BeginSample("FighterManager FixedUpdate1111"); #endif for (int i = 0; i < mBattleFieldFighters.Count; i++) { Fighter fighter = mBattleFieldFighters[i]; - if (fighter.IsSpawned && !fighter.IsDisposed && !fighter.IsDisposed) { - fighter.FixedUpdate (deltaTime); - } - } + if (fighter.IsSpawned && !fighter.IsDisposed && !fighter.IsDisposed) + { + fighter.FixedUpdate(deltaTime); + } + } #if PROFILE UnityEngine.Profiling.Profiler.EndSample(); #endif @@ -429,7 +433,7 @@ public class FighterManager UnityEngine.Profiling.Profiler.EndSample(); #endif - } + } #if UNITY_EDITOR public void FixedUpdateByEditor(float deltaTime) @@ -457,89 +461,103 @@ public class FighterManager } } #endif - public void Dispose () - { - if (IsDisposed) - return; + public void Dispose() + { + if (IsDisposed) + return; - try - { - for (int i = 0; i < mAllFighters.Count; i++) - { - var fighter = mAllFighters[i]; - if (fighter != null) - { + try + { + for (int i = 0; i < mAllFighters.Count; i++) + { + var fighter = mAllFighters[i]; + if (fighter != null) + { fighter.Destroy(); } - } + } RemoveAllFighters(); LeftCaptain = null; - RightCaptain = null; + RightCaptain = null; - HasInitializedFighters = false; + HasInitializedFighters = false; - mBattle = null; - } - catch (System.Exception e) { - DebugHelper.Log ("error: {0}: {1}", e.Message, e.StackTrace); - } + mBattle = null; + } + catch (System.Exception e) + { + DebugHelper.Log("error: {0}: {1}", e.Message, e.StackTrace); + } - IsDisposed = true; - } + IsDisposed = true; + } - public void OnFighterSpawned (Fighter fighter) - { - } + public void OnFighterSpawned(Fighter fighter) + { + } - public void OnFighterDie (Fighter fighter) + public void OnFighterDie(Fighter fighter) { Debug.Log("tzy_角色死亡_1"); if (mBattle.IsNormalBattle) Debug.Log("tzy_角色死亡_2 " + fighter); if (mBattle.IsNormalBattle && fighter.IsNpc) Debug.Log("tzy_角色死亡_3 "); if (mBattle.IsNormalBattle && fighter.IsNpc) { - Vector3 startpos,goldpos, emptypos; - startpos = fighter.Position; + Vector3 startpos, goldpos, emptypos; + + startpos = fighter.Ctrl.GetUIPointPos(); + startpos += fighter.Actor.AvatarData.bloodBarPos; + startpos = Camera.main.WorldToViewportPoint(startpos); + Vector3 startpos2 = new Vector3( + (startpos.x - 0.5f) * UIMgr.SCREEN_WIDTH, + (startpos.y - 0.5f) * UIMgr.SCREEN_HEIGHT, + 0 + ); + + Debug.Log("tzy_ " + startpos2); + goldpos = new Vector3(421, -241, 0); emptypos = new Vector3(0, 0, 0); - BattleDropMgr.Instance.GenerateDropItems(startpos, true, goldpos, false, emptypos, false, emptypos, false, emptypos - ,null, 0.05f, 0.25f); + BattleDropMgr.Instance.GenerateDropItems(startpos2, true, goldpos, false, emptypos, false, emptypos, false, emptypos + , null, 0.05f, 0.25f); } } - public void OnFighterRelive (Fighter fighter) - { - } + public void OnFighterRelive(Fighter fighter) + { + } - public List GetUnSpawnedFighters (int wave) - { - return mAllFighters.FindAll (a => !a.IsSpawned && a.TeamSide == eTeamType.Enemy); - } + public List GetUnSpawnedFighters(int wave) + { + return mAllFighters.FindAll(a => !a.IsSpawned && a.TeamSide == eTeamType.Enemy); + } - public List GetAllLeftSortedFighters () - { - List result = mAllFighters.FindAll (a => a.TeamSide == eTeamType.Friend); - CommonUtil.SortList(result, (lhs, rhs) => rhs.PositionValue - lhs.PositionValue); - return result; - } + public List GetAllLeftSortedFighters() + { + List result = mAllFighters.FindAll(a => a.TeamSide == eTeamType.Friend); + CommonUtil.SortList(result, (lhs, rhs) => rhs.PositionValue - lhs.PositionValue); + return result; + } - public Fighter GetFighterByID (long id, eTeamType teamid, int idx = 0) - { - for (int i = 0; i < mAllFighters.Count; i++) { - if (mAllFighters [i].TeamSide == teamid && mAllFighters [i].Id == id) { - return mAllFighters [i]; - } - } + public Fighter GetFighterByID(long id, eTeamType teamid, int idx = 0) + { + for (int i = 0; i < mAllFighters.Count; i++) + { + if (mAllFighters[i].TeamSide == teamid && mAllFighters[i].Id == id) + { + return mAllFighters[i]; + } + } return null; - } + } public Fighter GetFighterByBaseId(int baseId, eTeamType teamId) { - for(int idx =0; idx < mAllFighters.Count;idx++) - { - if(mAllFighters[idx].TeamSide == teamId && mAllFighters[idx].Actor.BaseId == baseId) + for (int idx = 0; idx < mAllFighters.Count; idx++) + { + if (mAllFighters[idx].TeamSide == teamId && mAllFighters[idx].Actor.BaseId == baseId) { return mAllFighters[idx]; } @@ -547,18 +565,19 @@ public class FighterManager return null; } - public Fighter GetFighterByInstanceID (ulong instanceid) - { - for (int i = 0; i < mAllFighters.Count; i++) { - if (mAllFighters [i].InstanceId == instanceid) - return mAllFighters [i]; - } - return null; - } + public Fighter GetFighterByInstanceID(ulong instanceid) + { + for (int i = 0; i < mAllFighters.Count; i++) + { + if (mAllFighters[i].InstanceId == instanceid) + return mAllFighters[i]; + } + return null; + } public Fighter GetTeamMemberById(long id) { - for(int idx =0; idx < mTeamFigters.Count;idx++) + for (int idx = 0; idx < mTeamFigters.Count; idx++) { if (mTeamFigters[idx].Id == id) return mTeamFigters[idx]; @@ -568,10 +587,10 @@ public class FighterManager public Fighter GetNpcByBaseId(int baseId) { - for(int idx =0; idx < mAllFighters.Count; idx++) + for (int idx = 0; idx < mAllFighters.Count; idx++) { Fighter fighter = mAllFighters[idx]; - if(fighter.Actor.IsNpc && fighter.Actor.BaseId == baseId) + if (fighter.Actor.IsNpc && fighter.Actor.BaseId == baseId) { return fighter; } @@ -613,7 +632,7 @@ public class FighterManager public bool HasTeamHero(long id) { - for(int idx =0; idx < mTeamHeroFighters.Count;idx++) + for (int idx = 0; idx < mTeamHeroFighters.Count; idx++) { if (mTeamHeroFighters[idx].Id == id) return true; } @@ -623,7 +642,7 @@ public class FighterManager public bool HasPet(long id) { - for(int idx =0; idx < mTeamPetFighters.Count;idx++) + for (int idx = 0; idx < mTeamPetFighters.Count; idx++) { if (mTeamPetFighters[idx].Id == id) return true; }