using System; 
 | 
using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
using DG.Tweening; 
 | 
using DG.Tweening.Core; 
 | 
using DG.Tweening.Plugins.Options; 
 | 
  
 | 
public enum BattleCamp 
 | 
{ 
 | 
    Friendly, 
 | 
    Enemy 
 | 
} 
 | 
  
 | 
public enum BattleState 
 | 
{ 
 | 
    None = 0, 
 | 
    Stunned = 1 << 0, 
 | 
    Poisoned = 1 << 1, 
 | 
    Bleeding = 1 << 2, 
 | 
    Silenced = 1 << 3, 
 | 
    Frozen = 1 << 4, 
 | 
    Burned = 1 << 5 
 | 
} 
 | 
  
 | 
public class BattleObject 
 | 
{ 
 | 
    public string BattleObjectId { get; protected set; } 
 | 
     
 | 
    public BattleCamp Camp { get; protected set; } = BattleCamp.Friendly; 
 | 
     
 | 
    public TeamCard teamCard { get; protected set; } 
 | 
  
 | 
    protected MotionBase motionBase; 
 | 
  
 | 
    protected GameObject cardGO; 
 | 
     
 | 
    public virtual void Init(TeamCard _teamCard) 
 | 
    { 
 | 
        this.teamCard = _teamCard; 
 | 
        motionBase = new MotionBase(); 
 | 
    } 
 | 
  
 | 
    protected void LoadCard() 
 | 
    { 
 | 
         
 | 
    } 
 | 
     
 | 
     
 | 
    #region 战斗相关函数 
 | 
     
 | 
    public virtual void AttackTarget(List<BattleObject> targets) 
 | 
    { 
 | 
        // 找离自己最近的 
 | 
  
 | 
        if (0 == targets.Count) return; 
 | 
  
 | 
        BattleObject target = targets[0]; 
 | 
  
 | 
        if (1 != targets.Count) 
 | 
        { 
 | 
            for (int i = 1; i < targets.Count; i++) 
 | 
            { 
 | 
                if (Vector3.Distance(cardGO.transform.position, targets[i].cardGO.transform.position) < Vector3.Distance(cardGO.transform.position, target.cardGO.transform.position)) 
 | 
                { 
 | 
                    target = targets[i]; 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        Vector3 tempPos = cardGO.transform.position; 
 | 
  
 | 
        motionBase.OnAttackAnimationComplete = () => { 
 | 
            // 攻击动画结束之后 回到原来的位置 
 | 
  
 | 
            cardGO.transform.DOMove(tempPos, 1f).OnComplete(() => { 
 | 
                // motionBase.ClearEvent();// = null; 
 | 
  
 | 
                //  通知本次攻击行动结束 
 | 
                //  通过battleFieldId来告知BattleFieldMgr 
 | 
            });   
 | 
        }; 
 | 
  
 | 
        cardGO.transform.DOMove(target.cardGO.transform.position, 1f).OnComplete(() => { 
 | 
            // 播放攻击动画 
 | 
            motionBase.OnAttackHitEvent = (int attackIndex) => { 
 | 
                for (int i = 0; i < targets.Count; i++) 
 | 
                { 
 | 
                    targets[i].UnderAttack(this); 
 | 
                } 
 | 
            }; 
 | 
  
 | 
            //普攻是hit1 
 | 
  
 | 
            motionBase.PlayAnimationEx(MotionName.atk1, false, new List<int>(){ 
 | 
                5//假设是5帧 目前还没有数据 
 | 
            }); 
 | 
        }); 
 | 
    } 
 | 
  
 | 
    public virtual void CastSkill(List<BattleObject> targets) 
 | 
    { 
 | 
        //  需不需要move 攻击目标是谁  
 | 
    } 
 | 
     
 | 
    public virtual float UnderAttack(BattleObject attacker) 
 | 
    { 
 | 
        return 0; 
 | 
    } 
 | 
     
 | 
    public virtual float HealTargets(List<BattleObject> targets) 
 | 
    { 
 | 
        return 0; 
 | 
    } 
 | 
     
 | 
    public virtual float BeHealed(BattleObject healer, float healAmount) 
 | 
    { 
 | 
        return 0; 
 | 
    } 
 | 
     
 | 
    public virtual bool Revive(BattleObject target) 
 | 
    { 
 | 
        return false; 
 | 
    } 
 | 
     
 | 
    public virtual bool BeRevived(BattleObject reviver, float healthPercent = 0.5f) 
 | 
    { 
 | 
        return false; 
 | 
    } 
 | 
     
 | 
    #endregion 
 | 
     
 | 
    #region 辅助函数 
 | 
     
 | 
    public virtual bool IsEnemy(BattleObject other) 
 | 
    { 
 | 
        if (other == null) return false; 
 | 
         
 | 
        return Camp != other.Camp; 
 | 
    } 
 | 
     
 | 
    public virtual bool IsFriendly(BattleObject other) 
 | 
    { 
 | 
        if (other == null) return false; 
 | 
         
 | 
        return Camp == other.Camp; 
 | 
    } 
 | 
  
 | 
    public virtual void Run() 
 | 
    { 
 | 
        motionBase.Run(); 
 | 
    } 
 | 
     
 | 
    #endregion 
 | 
} 
 |