Exemple #1
0
        /*
         *
         * 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);
        }
Exemple #2
0
        /*
         * @param pEntity: Find center Entity
         * @param riaus:Find riaus
         *
         * get all AIEntity in the riaus by the center of Entity
         *
         * @return:the OK AIEntity set
         *
         */

        public static AIEntity[] getAllEntityWithSphere(AIEntity pEntity, float riaus)
        {
            Collider[]      tColliders = Physics.OverlapSphere(pEntity.AIPos, riaus);
            List <AIEntity> tList      = new List <AIEntity> ();

            for (int i = 0; i < tColliders.Length; i++)
            {
                foreach (AIEntity aie in AIEntity.getList())
                {
                    if (aie.GetComponent <BaseAIComponent>().mAIRT == tColliders [i].gameObject && aie.GetComponent <BaseAIComponent>().mAIRT != pEntity.GetComponent <BaseAIComponent>().mAIRT)
                    {
                        tList.Add(aie);
                        break;
                    }
                }
            }
            return(tList.ToArray());
        }
Exemple #3
0
 public void Destroy()
 {
     AIEntity.getList().Remove(this);
     GameObject.Destroy(mAI);
     Release();
 }