| | |
| | | |
| | | public void Init(BattleField _battleField) |
| | | { |
| | | Release(); |
| | | battleField = _battleField; |
| | | } |
| | | |
| | | public void Run() |
| | | { |
| | | List<BattleEffectPlayer> runList = new List<BattleEffectPlayer>(); |
| | | |
| | | foreach (KeyValuePair<int, List<BattleEffectPlayer>> kvPair in effectDict) |
| | | { |
| | | runList.AddRange(kvPair.Value); |
| | | } |
| | | |
| | | for (int i = runList.Count - 1; i >= 0; i--) |
| | | { |
| | | BattleEffectPlayer effectPlayer = runList[i]; |
| | | if (effectPlayer != null) |
| | | { |
| | | effectPlayer.Run(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void PauseGame() |
| | |
| | | } |
| | | } |
| | | |
| | | public BattleEffectPlayer PlayEffect(int ObjID, int effectId, Transform parent) |
| | | public BattleEffectPlayer PlayEffect(BattleObject layerDepender, int effectId, Transform parent, BattleCamp camp) |
| | | { |
| | | if (effectId <= 0) |
| | | { |
| | | BattleDebug.LogError("effect id <= 0"); |
| | | Debug.LogError("effect id <= 0"); |
| | | return null; |
| | | } |
| | | |
| | | var effectCfg = EffectConfig.Get(effectId); |
| | | if (null == effectCfg) |
| | | { |
| | | BattleDebug.LogError("effect config is null, effectId : " + effectId); |
| | | Debug.LogError("effect config is null, effectId : " + effectId); |
| | | return null; |
| | | } |
| | | |
| | |
| | | effectDict[effectId] = new List<BattleEffectPlayer>(); |
| | | } |
| | | |
| | | BattleEffectPlayer effectPlayer = BattleEffectPlayer.Create(effectId, battleField.battleRootNode.transform); |
| | | bool isRedCamp = camp == BattleCamp.Red; |
| | | |
| | | BattleEffectPlayer effectPlayer = BattleEffectPlayer.Create(effectId, battleField.battleRootNode.transform, isRedCamp); |
| | | // 设置特效缩放和方向 |
| | | |
| | | effectPlayer.transform.position = parent.position; |
| | | float effectScale = parent.transform.localScale.x; |
| | | effectPlayer.transform.localScale *= effectScale; |
| | | effectPlayer.onDestroy += OnEffectDestroy; |
| | | |
| | | |
| | | BattleObject temp = layerDepender; |
| | | effectPlayer.onDestroy += (efPlayer) => |
| | | { |
| | | OnEffectDestroy(efPlayer); |
| | | temp.layerMgr.RemoveEffect(efPlayer); |
| | | }; |
| | | |
| | | if (effectPlayer != null) |
| | | { |
| | | effectDict[effectId].Add(effectPlayer); |
| | | } |
| | | effectPlayer.Play(true); |
| | | |
| | | effectPlayer.SetSpeedRatio(battleField.speedRatio); |
| | | |
| | | var effectScale = effectPlayer.transform.localScale; |
| | | effectScale.x *= isRedCamp ? 1 : -1; |
| | | effectPlayer.transform.localScale = effectScale; |
| | | |
| | | if (null != layerDepender) |
| | | { |
| | | layerDepender.layerMgr.AddEffect(effectPlayer); |
| | | } |
| | | |
| | | return effectPlayer; |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | BattleDebug.LogError("could not find effect in list, effectid : " + effectId); |
| | | Debug.LogError("could not find effect in list, effectid : " + effectId); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public void HaveRest() |
| | | { |
| | | Release(); |
| | | } |
| | | |
| | | public void Release() |
| | | { |
| | | List<int> fKeys = effectDict.Keys.ToList(); |
| | | |
| | |
| | | effectDict.Clear(); |
| | | } |
| | | |
| | | public void Release() |
| | | public void SetSpeedRatio(float ratio) |
| | | { |
| | | foreach (var effect in effectDict) |
| | | foreach (var kvPair in effectDict) |
| | | { |
| | | foreach (var effectPlayer in effect.Value) |
| | | foreach (var effectPlayer in kvPair.Value) |
| | | { |
| | | if (effectPlayer != null) |
| | | { |
| | | GameObject.DestroyImmediate(effectPlayer.gameObject); |
| | | } |
| | | effectPlayer.SetSpeedRatio(ratio); |
| | | } |
| | | } |
| | | |
| | | effectDict.Clear(); |
| | | } |
| | | } |