public string HappenEvent(ICharactor c) { IParameter exp = c.Status()["EXP"]; exp.Add(expVolume); return(DecorateStyle("[Event]", "color") + $" Get {expVolume} Exp. You are lucky boy."); }
//计算被攻击后的生命值 public void GetRemainHp(ICharactor theAttacker) { //获取攻击者的攻击力 int atkValue = theAttacker.GetAtkValue(); //减少伤害值 atkValue -= _attrStrategy.GetDmgDesValue(this); //计算生命值 _nowHp -= atkValue; }
// Use this for initialization void Start() { p = new Human { Name = "Player" }; target = transform.position; offset = mainCamera.transform.position - target; }
//检测是否进入了进攻范围 public override bool TargetRange(ICharactor theNearTarget, int range) { float targetdist; targetdist = Vector3.Distance(TheTarget.transform.position, theNearTarget.transform.position); if (targetdist <= range) { return(true); } return(false); }
public override void Update(List <ICharactor> targets) { Vector3 nowPosition = CharactorAi.GetPosition(); ICharactor theNearTarget = null; float minDist = 999f; foreach (var target in targets) { if (target != null) { if (target.BKilled) { continue; } float dist = Vector3.Distance(nowPosition, target.transform.position); if (dist < minDist) { minDist = dist; theNearTarget = target; } } } Debug.Log(theNearTarget); if (theNearTarget == null) { return; } //如果检测到目标在攻击范围内,则切换到攻击状态 if (CharactorAi.TargetRange(theNearTarget, 2)) { CharactorAi.ChangeAiState(new AttackAIState(theAttackTarget: theNearTarget)); } else //如果不在攻击范围内则切换到追赶状态 { //在有效视野内才可以进行锁定追击 if (CharactorAi.UsefulView(theNearTarget) < 90) { CharactorAi.StopMove(); CharactorAi.ChangeAiState(new ChaseAiState(theTarget: theNearTarget)); } } }
//设置武器的拥有者 public void SetWeaponOwner(ICharactor theCharactor) { WeaponOwner = theCharactor; }
//武器攻击 public abstract void WeaponAttack(ICharactor theTarget);
//---------------------------------------------------------------------- #region Public_Methods //移除AI对象 public void RemoveAiTarget(ICharactor theTarget) { _aiState.RemoveTarget(theTarget); }
//是否在指定距离内 public virtual bool TargetRange(ICharactor theNearTarget, int range) { return(false); }
public float UsefulView(ICharactor theTarget) { return(TheTarget.UsefulView(theTarget)); }
protected IActionInterface(ActionManager am) { Am = am; CurAnimator = am.Charactor.MyAnimator; Charactor = am.Charactor; }
public ActionManager(ICharactor charactor) { Charactor = charactor; }
public void InvokeEvent(ICharactor c) { string outText = chipEvent.HappenEvent(c); PublishMessageLog(outText); }
public virtual void RemoveTarget(ICharactor target) { //移除目标 }
private readonly ICharactor _chasetarget = null; //追击的目标 #endregion //---------------------------------------------------------------------- #region Public_Methods //建造者 public ChaseAiState(ICharactor theTarget) { _chasetarget = theTarget; }
public AttackAIState(ICharactor theAttackTarget) { _attackTarget = theAttackTarget; }
public void SetCharactor(ICharactor charactor) { m_charactor = charactor; }
public virtual void InitState(ICharactor charactor, List <ICharactor> targets = null, string stateName = "") { m_charactor = charactor; m_targets = targets; m_stateName = stateName; }
// Update is called once per frame void Update() { ICharactor c = target.GetComponent <ICharactorable>().Charactor(); gui.SetText(c.ToString()); }
//Ai对象设置 public void SetAiCharactor(ICharactor theTarget) { TheTarget = theTarget; }
public override void WeaponAttack(ICharactor theTarget) { //声音 //粒子特效 //动作 }
//攻击目标 public void Attack(ICharactor theTarget) { TheTarget.Attack(theTarget); }
public void LookTarget(ICharactor theTarget) { TheTarget.LookTarget(theTarget); }
public string HappenEvent(ICharactor c) { return(""); }