123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using UnityEngine;
- using CommonAI.ZoneClient;
- using CommonAI.Zone;
- using CommonAIClient.Unity.Utils;
- namespace CommonAIClient.Unity.Battle
- {
- public partial class ComAISpell : ComAICell
- {
- private ComAICell mLauncher;
- private ComAICell mTarget;
- protected ZoneSpell ZSpell { get { return ZObject as ZoneSpell; } }
- protected ComAICell Launcher { get { return mLauncher; } }
- protected ComAICell Target { get { return mTarget; } }
- public ComAISpell(BattleScene battleScene, ZoneSpell obj)
- : base(battleScene, obj)
- {
- if (ZSpell.Sender != null)
- {
- mLauncher = BattleScene.GetBattleObject(ZSpell.Sender.ObjectID);
- }
- if (ZSpell.Target != null)
- {
- mTarget = BattleScene.GetBattleObject(ZSpell.Target.ObjectID);
- }
- SyncState();
- if (!string.IsNullOrEmpty(ZSpell.Info.FileName))
- {
- BattleFactroy.Instance.GameObjectAdapter.Load(
- ZSpell.Info.FileName,
- System.IO.Path.GetFileNameWithoutExtension(ZSpell.Info.FileName),
- (succ, aoe) =>
- {
- if (succ)
- {
- if (IsDisposed)
- {
- BattleFactroy.Instance.GameObjectAdapter.Unload(aoe);
- return;
- }
- OnLoadModelSuccess(aoe);
- }
- });
- }
- }
- protected virtual GameObject GetBindingPart(ComAICell unit)
- {
- DummyNode node = unit.GetDummyNode("chest_buff");
- if (node == null)
- return unit.EffectRoot;
- return node.gameObject;
- }
-
- protected virtual void OnLoadModelSuccess(AssetObjectExt aoe)
- {
- DisplayCell.Model = aoe;
- if (this.ZSpell.Info.FileBodyScale != 0)
- {
- aoe.transform.localScale = new Vector3(
- this.ZSpell.Info.FileBodyScale,
- this.ZSpell.Info.FileBodyScale,
- this.ZSpell.Info.FileBodyScale);
- }
- SyncState();
- if (!string.IsNullOrEmpty(ZSpell.Info.FileNameSpawn))
- {
- LaunchEffect effect = new LaunchEffect();
- effect.Name = ZSpell.Info.FileNameSpawn;
- PlayEffect(effect, EffectRoot.Position(), EffectRoot.Rotation());
- }
- if (ZSpell.Info.BodyShape == SpellTemplate.Shape.LineToTarget
- && Launcher != null && !Launcher.IsDisposed
- && Target != null && !Target.IsDisposed)
- {
- //必须自己实现连接
- GameObject from = GetBindingPart(Launcher);
- GameObject to = GetBindingPart(Target);
- BattleFactroy.Instance.MakeDamplingJoint(aoe.gameObject, from, to);
- }
- }
- protected override void SyncState()
- {
- Vector3 pos = Extensions.ZonePos2NavPos(ZObject.Parent.Terrain.TotalHeight
- , ZObject.X, ZObject.Y, ZObject.Z);
- ObjectRoot.Position(new Vector3(pos.x, pos.y + ZSpell.LaunchHeight, pos.z));
- ObjectRoot.ZoneRot2UnityRot(ZObject.Direction);
- }
- protected override void OnDispose()
- {
- if (!string.IsNullOrEmpty(ZSpell.Info.FileNameDestory))
- {
- LaunchEffect effect = new LaunchEffect();
- effect.Name = ZSpell.Info.FileNameDestory;
- PlayEffect(effect, EffectRoot.Position(), EffectRoot.Rotation());
- }
- base.OnDispose();
- }
- }
- }
|