/* * * add the must component to AIEntity * */ public override void Init() { BaseAIComponent tBAIComponent = new BaseAIComponent(); tBAIComponent.mAITemplate = mAI; tBAIComponent.bornPoint = AIPos; tBAIComponent.Init(); AIMove mAIMove = new AIMove(); AIAnimation mAIAnimation = new AIAnimation(); HPComponent hpc = new HPComponent(); AIState aiState = new AIState(); AIEmotion mEmotion = new AIEmotion(); AIStrategy mAIStrategy = new AIStrategy(); ObstacleComponent mObstacleComponent = new ObstacleComponent(); AIGroupState aiGroupState = new AIGroupState(); this.AddComponent <BaseAIComponent> (tBAIComponent); this.AddComponent <AIMove> (mAIMove); this.AddComponent <AIAnimation> (mAIAnimation); this.AddComponent <HPComponent> (hpc); this.AddComponent <AIState> (aiState); this.AddComponent <AIEmotion> (mEmotion); this.AddComponent <AIStrategy> (mAIStrategy); this.AddComponent <ObstacleComponent> (mObstacleComponent); this.AddComponent <AIGroupState> (aiGroupState); this.AddComponent <LODComponent> (new LODComponent()); mAIStrategy.Init(); aiGroupState.Init(); aiState.Init(); mAIAnimation.Init(); mEmotion.Init(); InfluenceMapTrigger tInfluenceMapTrigger = new InfluenceMapTrigger(); tInfluenceMapTrigger.maxInfluence = 4.0f; tInfluenceMapTrigger.mWhere = "friend"; tInfluenceMapTrigger.mGameObject = mAI; tInfluenceMapTrigger.mIMComputer = DefaultFunc.friendComputer; tInfluenceMapTrigger.Init(); UEntity tEntity = new UEntity(); tEntity.AddComponent <InfluenceMapTrigger> (tInfluenceMapTrigger); this.mWorld.registerEntityAfterInit(tEntity); AIEntity.getList().Add(this); }
// no using now public void InitAvoid(StateExecuter pStateExecuter, StateEnter pStateEnter, StateExit pStateExit, StateRecorder pStateRecorder, AIEntity pLast) { StrategyActioner AvoidActioner = ObstacleAvoidance.ActionFunc; StateExecuter AvoidState = ObstacleAvoidance.FSM_Avoid; AIState aiState = new AIState(); aiState.Init(); int id_battle = aiState.AddExecuter(pStateExecuter, pStateExit, pStateEnter); int id_avoid = aiState.AddExecuter(AvoidState, EmptyExitAndEnter.EmptyExit, EmptyExitAndEnter.EmptyEnter); aiState.AddAnimation(pStateExecuter, "Attack"); aiState.AddAnimation(AvoidState, "Walk"); aiState.tempID = id_avoid; StateTranfer tAvoid_Battle = ObstacleAvoidance.FSM_Avoid_Battle; StateTranfer tBattle_Avoid = ObstacleAvoidance.FSM_Battle_Avoid; aiState.AddEdge(tAvoid_Battle, EmptyFeedbacker.Run, id_avoid, id_battle); aiState.AddEdge(tBattle_Avoid, EmptyFeedbacker.Run, id_battle, id_avoid); StrategyEnter tAvoidEnter = ObstacleAvoidance.Strategy_Enter; aiState.mStateRecorder = pStateRecorder; aiState.LastEntityData = pLast; AddStrategy(AvoidActioner, tAvoidEnter, EmptyStrategyExit.Run, EmptyStrategyFeedbacker.Run, aiState); }