完善了一下远程AI的连线
public class FarAIReg : MonoBehaviour {
public GameObject AI;
public GameObject player;
public Transform arrowSlot;
public GameObject arrowObject;
//动画
Animator animator;
AnimationPlay runAnim;
AnimationPlay walkAnim;
AnimationPlay relaxAnim;
AnimationPlay attackAnim;
StateRecorder mRecorder;
StateExecuter walkState;
StateExecuter relaxState;
StateExecuter runawayState;
StateExit runawayExit;
StateExecuter TraceState;
StateExit TraceExit;
StateExecuter arrowState;
StateExit arrowExit;
StateExecuter morearrowState;
StateExit morearrowExit;
StateTranfer anytorunaway;
StateTranfer walktotrace;
StateTranfer walktorelax;
StateTranfer runawaytoarrow;
StateTranfer runawaytorexlax;
StateTranfer runawaytowalk;
StateTranfer tracetoarrow;
StateTranfer tracetomore;
StateTranfer tracetorelax;
StateTranfer tracetowalk;
StateTranfer arrowtotrace;
StateTranfer moretotrace;
StateTranfer relaxtotrace;
StateTranfer relaxtowalk;
StateFeedbacker runIN;
StateFeedbacker runOUT;
StateFeedbacker hurtup;
EmotionExecuter fear;
EmotionExecuter happy;
HPComponent player_hp = new HPComponent();
AIEntity mAIEntity = new AIEntity();
UEntity mPlayer = new UEntity();
UEntity mPlayerLast = new UEntity ();
HPComponent playerLast_hp = new HPComponent ();
void Start(){
//在世界注册在另一个脚本中
runAnim=FarAI.Far_Run_Anim;
walkAnim = FarAI.Far_Walk_Anim;
relaxAnim = FarAI.Far_Relax_Anim;
attackAnim = FarAI.Far_Shoot_Anim;
mRecorder = FarAI.FarAI_Recorder;
runawayState = FarAI.FarAI_RunAway;
walkState = FarAI.FarAI_Walk;
arrowState = FarAI.FarAI_Arrow;
morearrowState = FarAI.FarAI_MoreArrow;
relaxState = FarAI.FarAI_Relax;
runawayExit = FarAI.Runaway_Exit;
morearrowExit = FarAI.MoreArrow_Exit;
arrowExit = FarAI.Arrow_Exit;
TraceExit = FarAI.Trace_Exit;
anytorunaway = FarAI.AnyTransferRunaway;
walktorelax = FarAI.WalkTransferRelax;
walktotrace = FarAI.WalkTransferTrace;
runawaytowalk = FarAI.RunawayTransferWalk;
runawaytorexlax = FarAI.RunawayTransferRelax;
runawaytoarrow = FarAI.RunawayTransferArrow;
tracetowalk = FarAI.TraceTransferWalk;
tracetoarrow = FarAI.TraceTransferAttack;
tracetomore = FarAI.TraceTransferMore;
tracetorelax = FarAI.TraceTransferRelax;
relaxtotrace = FarAI.RelaxTransferTrace;
relaxtowalk = FarAI.RelaxTransferWalk;
arrowtotrace = FarAI.AttackTransferTrace;
moretotrace = FarAI.MoreTransferTrace;
mAIEntity.mAI = AI;
mAIEntity.mPlayer = player;
mAIEntity.Init ();
mAIEntity.AddComponent<FarAIComponent> (new FarAIComponent ());
mAIEntity.GetComponent<BaseAIComponent> ().mAIRT.SetActive (true);
mAIEntity.PlayerEntity = mPlayer;
mAIEntity.GetComponent<HPComponent> ().allHP = 500;
mAIEntity.GetComponent<HPComponent> ().tempHP = 500;
animator = mAIEntity.GetComponent<BaseAIComponent> ().mAIRT.GetComponent<Animator> ();
mAIEntity.GetComponent<AIAnimation> ().mAnimator = animator;//这边传两遍同样的东西?
mAIEntity.GetComponent<AIAnimation> ().Add ("Run",runAnim);
mAIEntity.GetComponent<AIAnimation> ().Add ("Walk",walkAnim);
mAIEntity.GetComponent<AIAnimation> ().Add ("Idle",relaxAnim);
mAIEntity.GetComponent<AIAnimation> ().Add ("Shoot",attackAnim);
mAIEntity.GetComponent<AIAnimation>().tempAnim="Walk";
mAIEntity.GetComponent<AIEmotion> ().InsertEmotion ("Happy");
mAIEntity.GetComponent<AIEmotion> ().InsertEmotion ("Fear");
int id_trace=mAIEntity.GetComponent<AIState> ().AddExecuter (TraceState,TraceExit,EmptyExitAndEnter.EmptyEnter);
int id_walk=mAIEntity.GetComponent<AIState> ().AddExecuter (walkState,EmptyExitAndEnter.EmptyExit,EmptyExitAndEnter.EmptyEnter);
int id_relax=mAIEntity.GetComponent<AIState> ().AddExecuter (relaxState,EmptyExitAndEnter.EmptyExit,EmptyExitAndEnter.EmptyEnter);
int id_runaway=mAIEntity.GetComponent<AIState> ().AddExecuter (runawayState,runawayExit,EmptyExitAndEnter.EmptyEnter);
int id_arrow=mAIEntity.GetComponent<AIState> ().AddExecuter (arrowState,arrowExit,EmptyExitAndEnter.EmptyEnter);
int id_more=mAIEntity.GetComponent<AIState> ().AddExecuter (morearrowState,morearrowExit,EmptyExitAndEnter.EmptyEnter);
mAIEntity.GetComponent<AIState> ().AddAnywayTranfer (anytorunaway,runIN,id_runaway);
mAIEntity.GetComponent<AIState> ().AddEdge (tracetoarrow,hurtup,id_trace,id_more);
mAIEntity.GetComponent<AIState> ().AddEdge (tracetomore,hurtup,id_trace,id_more);
mAIEntity.GetComponent<AIState> ().AddEdge (arrowtotrace,runIN,id_arrow,id_trace);
mAIEntity.GetComponent<AIState> ().AddEdge (moretotrace,runIN,id_more,id_trace);
mAIEntity.GetComponent<AIState> ().AddEdge (tracetowalk,EmptyTranfer.Run,id_trace,id_walk);
mAIEntity.GetComponent<AIState> ().AddEdge (walktotrace,runIN,id_walk,id_trace);
//实在不太懂feedBacker是什么
mAIEntity.GetComponent<AIState> ().AddAnimation (runawayState,"Run");
mAIEntity.GetComponent<AIState> ().AddAnimation (TraceState,"Run");
mAIEntity.GetComponent<AIState> ().AddAnimation (walkState,"Walk");
mAIEntity.GetComponent<AIState> ().AddAnimation (relaxState,"Relax");
mAIEntity.GetComponent<AIState> ().AddAnimation (arrowState,"Shoot");
mAIEntity.GetComponent<AIState> ().AddAnimation (morearrowState,"Shoot");
mAIEntity.GetComponent<AIState> ().tempID = id_walk;
mAIEntity.GetComponent<AIState> ().mStateRecorder = mRecorder;
mAIEntity.GetComponent<AIState> ().LastEntityData.AddComponent<HPComponent> (new HPComponent());
mAIEntity.GetComponent<AIState> ().LastEntityData.PlayerEntity = mPlayerLast;
mPlayerLast.AddComponent<HPComponent> (playerLast_hp);
mAIEntity.GetComponent<FarAIComponent> ().arrow = arrowObject;
mAIEntity.GetComponent<FarAIComponent> ().arrowSplot = arrowSlot;
player_hp.allHP = 700;
player_hp.tempHP = 700;
mPlayer.AddComponent<HPComponent> (player_hp);
}
}