Exemplo n.º 1
0
        public override void Update(UEntity uEntity)
        {
            base.Update(uEntity);
            Vector3 pos      = uEntity.GetComponent <ZoologyComponent> ().mPosition;
            float   maxRiaus = Mathf.Max(uEntity.GetComponent <ZoologyComponent>().mSize.x, uEntity.GetComponent <ZoologyComponent>().mSize.y);

            SimpleAI[]          tSimpleAIs = SimpleAISetSingleton.getInstance().GetComponent <SimpleAISet> ().FindAIsWithRiaus(pos, maxRiaus, 1 << LayerMask.NameToLayer("Default"), "AI");
            List <GAPopulation> tList      = new List <GAPopulation> ();

            for (int i = 0; i < tSimpleAIs.Length; i++)
            {
                if (!tList.Contains(GAPopulation.allDic[tSimpleAIs[i].mType]))
                {
                    tList.Add(GAPopulation.allDic[tSimpleAIs[i].mType]);
                }
            }
            float avgRate = 0.0f;

            foreach (var v in tList)
            {
                avgRate += v.lifeRate;
            }
            avgRate /= tList.Count;
            if (avgRate < 0.2f)
            {
                uEntity.GetComponent <ZoologyComponent> ().mState = false;
            }
            else
            {
                uEntity.GetComponent <ZoologyComponent> ().mState = true;
            }
        }
Exemplo n.º 2
0
        public override void Update(UEntity uEntity)
        {
            base.Update(uEntity);

            int lod = uEntity.GetComponent <LODComponent>().mLOD;

            if (lod > LODComponent.maxLOD / 2)
            {
                return;
            }

            if (uEntity.GetComponent <AIEmotion> ().timer < 1.0f)
            {
                uEntity.GetComponent <AIEmotion> ().timer += Time.deltaTime;
                return;
            }

            // update emotion
            uEntity.GetComponent <AIEmotion> ().timer = 0.0f;

            for (int i = 0; i < uEntity.GetComponent <AIEmotion> ().mEmotion.Count; i++)
            {
                EmotionExecuter tEmotionExecuter = uEntity.GetComponent <AIEmotion> ().mEmotion[i].mEmotionExecuter;
                float           tactive          = tEmotionExecuter((AIEntity)(uEntity));
                if (Random.Range(0.0f, 1.0f) < tactive)
                {
                    uEntity.GetComponent <AIEmotion> ().mtempID = uEntity.GetComponent <AIEmotion> ().mEmotion[i].id;
                    break;
                }
            }
        }
Exemplo n.º 3
0
 public override void Update(UEntity uEntity)
 {
     base.Update(uEntity);
     if (uEntity.GetComponent <staComponent> ().staRate >= 0.0f)
     {
         uEntity.GetComponent <staComponent> ().staRate -= Time.deltaTime;
     }
     else
     {
         if (uEntity.GetComponent <AIEmotion> ().mtempName == "Excited")
         {
             uEntity.GetComponent <staComponent> ().staNow = Mathf.Min(
                 uEntity.GetComponent <staComponent> ().staMax,
                 uEntity.GetComponent <staComponent> ().staNow +
                 uEntity.GetComponent <staComponent> ().staExcited);
         }
         else
         {
             uEntity.GetComponent <staComponent> ().staNow = Mathf.Min(
                 uEntity.GetComponent <staComponent> ().staMax,
                 uEntity.GetComponent <staComponent> ().staNow +
                 uEntity.GetComponent <staComponent> ().staRecover);
         }
         uEntity.GetComponent <staComponent> ().staRate =
             uEntity.GetComponent <staComponent> ().staRateInit;
     }
 }
Exemplo n.º 4
0
        // feedback finish,you should compute the avg of the 10 frame data
        public override void Update(UEntity uEntity)
        {
            if (uEntity.GetComponent <AIState> ().mFeedbackerState)
            {
                float sum = 0.0f;
                for (int i = 0; i < 10; i++)
                {
                    sum += uEntity.GetComponent <AIState> ().mframebuffer [i];
                }
                sum /= 10.0f;
                for (int i = 0; i < uEntity.GetComponent <AIState> ().mPowerEdge [uEntity.GetComponent <AIState> ().mid_fir].Count; i++)
                {
                    if (uEntity.GetComponent <AIState> ().mPowerEdge [uEntity.GetComponent <AIState> ().mid_fir] [i].id == uEntity.GetComponent <AIState> ().mid_sec)
                    {
                        PowerNode tpn = new PowerNode();
                        tpn.id    = uEntity.GetComponent <AIState> ().mPowerEdge [uEntity.GetComponent <AIState> ().mid_fir] [i].id;
                        tpn.power = uEntity.GetComponent <AIState> ().mPowerEdge [uEntity.GetComponent <AIState> ().mid_fir] [i].power + sum;
                        if (tpn.power > 3.0f)
                        {
                            tpn.power = 3.0f;
                        }
                        if (tpn.power < 0.3f)
                        {
                            tpn.power = 0.3f;
                        }
                        uEntity.GetComponent <AIState> ().mPowerEdge [uEntity.GetComponent <AIState> ().mid_fir] [i] = tpn;
                        Debug.Log(uEntity.GetComponent <AIState> ().mid_fir + " " + uEntity.GetComponent <AIState> ().mPowerEdge [uEntity.GetComponent <AIState> ().mid_fir] [i].power + " " + uEntity.GetComponent <AIState> ().mPowerEdge [uEntity.GetComponent <AIState> ().mid_fir] [i].id);
                        break;
                    }
                }

                uEntity.GetComponent <AIState> ().mFeedbackerState = false;
            }
        }
Exemplo n.º 5
0
        public override void Update(UEntity uEntity)
        {
            int      lod       = uEntity.GetComponent <LODComponent> ().mLOD;
            Animator tAnimator = uEntity.GetComponent <AIAnimation> ().mAnimator;

            if (tAnimator == null)
            {
                return;
            }
            // get lod value
            if (lod > ((float)LODComponent.maxLOD) / 3.0f * 2.0f)
            {
                tAnimator.enabled = false;
            }
            else
            {
                tAnimator.enabled = true;
            }

            /*
             * if (lod > (LODComponent.maxLOD)/2.0f)
             *      return;
             */
            AnimationPlay tAnim = uEntity.GetComponent <AIAnimation> ().Get(uEntity.GetComponent <AIAnimation>().mtempAnim);

            // update animation
            tAnim(tAnimator);
        }
Exemplo n.º 6
0
        public override void Update(UEntity uEntity)
        {
            base.Update(uEntity);

            if (((AIEntity)uEntity).mDissloveTimer > 0.0f)
            {
                ((AIEntity)uEntity).mDissloveTimer -= Time.deltaTime;
            }

            if (((AIEntity)uEntity).isGrouping)
            {
                uEntity.GetComponent <AIState> ().isEnable      = false;
                uEntity.GetComponent <AIGroupState> ().isEnable = true;
                uEntity.GetComponent <AIStrategy> ().isEnable   = false;
            }
            else
            {
                uEntity.GetComponent <AIState> ().isEnable    = true;
                uEntity.GetComponent <AIStrategy> ().isEnable = true;
                if (uEntity.GetComponent <AIGroupState>() != null)
                {
                    uEntity.GetComponent <AIGroupState> ().isEnable = false;
                }
            }
        }
Exemplo n.º 7
0
        public override void Update(UEntity uEntity)
        {
            //	Debug.Log ("UpdateAntSystem");

            base.Update(uEntity);


            List <AntPopulation> tList = uEntity.GetComponent <AntPopulationComponent> ().mAntPopulationSet;

            for (int i = 0; i < AntPopulation.mNowListCount; i++)
            {
                if (tList [i].isStartFind)
                {
                    if (tList[i].shouldWhat == 0)
                    {
                        InfluenceMap.getInstance().Show(3);
                    }
                    else if (tList[i].shouldWhat == 1)
                    {
                        InfluenceMap.getInstance().Show(4);
                    }
                    UpdateAntPopulation(tList [i]);
                }
            }
        }
Exemplo n.º 8
0
        public override void OnLoginAuthed(int code, byte[] secret, string dummy)
        {
            if (code == 200)
            {
                int uid   = _ctx.U.Uid;
                int subid = _ctx.U.Subid;

                AppContext ctx = _ctx as AppContext;
                EntityMgr  mgr = ctx.GetEntityMgr();
                UEntity    e   = new UEntity(_ctx, (uint)uid);
                mgr.AddEntity(e);
                mgr.MyEntity = e;

                _loginActor.ShowTips("提示:成功登陆");
            }
            else if (code == 401)
            {
                _loginActor.EnableCommitOk();
                _loginActor.ShowTips("错误吗:401 提示:没有授权成功");
            }
            else if (code == 403)
            {
                _loginActor.EnableCommitOk();
                _loginActor.ShowTips("错误吗:403 提示:登陆不陈宫");
            }
        }
Exemplo n.º 9
0
        /*
         * @param uEntity: Entity having LODComponent in temp World
         * Compute LOD for this AI
         */

        public override void Update(UEntity uEntity)
        {
            base.Update(uEntity);
            if (lodDistance.Length == 0)
            {
                return;
            }
            if (mPlayer == null)
            {
                return;
            }
            if (!uEntity.GetComponent <LODComponent> ().isUse)
            {
                uEntity.GetComponent <LODComponent> ().mLOD = 1;
                return;
            }
            GameObject tObject = getObjectByEntity(uEntity);
            // Compute by Distance with Player(Camera)
            float dis = Vector3.Distance(mPlayer.transform.position, tObject.transform.position);

            for (int i = 0; i < lodDistance.Length; i++)
            {
                if (dis < lodDistance [i])
                {
                    uEntity.GetComponent <LODComponent> ().mLOD = i + 1;
                    return;
                }
            }
            uEntity.GetComponent <LODComponent> ().mLOD = lodDistance.Length + 1;
        }
Exemplo n.º 10
0
    public static float round2runaway(UEntity uEntity)
    {
        GameObject    aiRT = uEntity.GetComponent <BaseAIComponent> ().mAIRT;
        TestCollision tc   = null;

        if (aiRT.GetComponent <TestCollision> () != null)
        {
            tc = aiRT.GetComponent <TestCollision> ();
        }
        else if (aiRT.GetComponentInChildren <TestCollision> () != null)
        {
            tc = aiRT.GetComponent <TestCollision> ();
        }

        if (tc.TriggerObject == null)
        {
            return(0.0f);
        }

        if (tc.isTriggerEnter == true && tc.TriggerObject.name == "Boom")
        {
            Debug.Log(tc.TriggerObject.name);
            return(1.0f);
        }
        else
        {
            return(0.0f);
        }
    }
Exemplo n.º 11
0
 public override void Update(UEntity uEntity)
 {
     //Debug.Log ("asd");
     uEntity.GetComponent <MoveComponent> ().dir      = Vector3.zero;
     uEntity.GetComponent <MoveComponent> ().velocity = 0.0f;
     if (Input.GetKeyDown(KeyCode.Q))
     {
         uEntity.GetComponent <StateComponent> ().AttackState = true;
     }
     if (Input.GetKey(KeyCode.W))
     {
         uEntity.GetComponent <MoveComponent> ().dir     += Vector3.left;
         uEntity.GetComponent <MoveComponent> ().velocity = 3.0f;
     }
     if (Input.GetKey(KeyCode.A))
     {
         uEntity.GetComponent <MoveComponent> ().dir     += Vector3.up;
         uEntity.GetComponent <MoveComponent> ().velocity = 3.0f;
     }
     if (Input.GetKey(KeyCode.S))
     {
         uEntity.GetComponent <MoveComponent> ().dir     += Vector3.down;
         uEntity.GetComponent <MoveComponent> ().velocity = 3.0f;
     }
     if (Input.GetKey(KeyCode.D))
     {
         uEntity.GetComponent <MoveComponent> ().dir     += Vector3.right;
         uEntity.GetComponent <MoveComponent> ().velocity = 3.0f;
     }
 }
Exemplo n.º 12
0
    public override void InitialiseEntity()
    {
        string lTarget;

        if (GetValue("target", out lTarget))
        {
            UEntity lEnt = ReturnFirstTargetname(lTarget);

            Vector3 lToTarget = lEnt.transform.position - transform.position;
            lToTarget.y *= -1f;

            Vector3 lEndPos = lEnt.transform.position;

            RaycastHit lHit;

            if (Physics.Raycast(lEnt.transform.position, lToTarget.normalized, out lHit, lToTarget.magnitude, LayerMask.NameToLayer("Default"), QueryTriggerInteraction.Ignore))
            {
                lEndPos = lHit.point;
            }

            GameObject lGO = new GameObject("OffMeshLink");
            lGO.transform.parent        = transform;
            lGO.transform.localPosition = Vector3.zero;

            GameObject lGO2 = new GameObject("OffMeshLinkChild");
            lGO2.transform.parent   = lGO.transform;
            lGO2.transform.position = lEndPos;

            OffMeshLink lLink = lGO.AddComponent <OffMeshLink>();
            lLink.startTransform      = lGO.transform;
            lLink.endTransform        = lGO2.transform;
            lLink.autoUpdatePositions = true;
        }
    }
Exemplo n.º 13
0
        public void Add(UEntity fir, UEntity sec, int number)
        {
            HurtEvent he = new HurtEvent();

            he.fir        = fir;
            he.sec        = sec;
            he.hurtnumber = number;
            mHurtEventList.Enqueue(he);
        }
Exemplo n.º 14
0
        public override void Update(UEntity uEntity)
        {
            base.Update(uEntity);


            if (uEntity.GetComponent <LODComponent> () != null)
            {
                int lod = uEntity.GetComponent <LODComponent> ().mLOD;
                if (lod > LODComponent.maxLOD / 2)
                {
                    return;
                }
            }



            string       tWhere        = uEntity.GetComponent <InfluenceMapTrigger> ().mWhere;
            InfluenceMap tInfluenceMap = InfluenceMap.getInstance();
            int          index         = tInfluenceMap.mDictionary [tWhere];
            bool         isStatic      = tInfluenceMap.mDicStatic [index];

            if (!isStatic)
            {
                Vector3 position;
                Vector3 size;
                if (uEntity.GetComponent <InfluenceMapTrigger> ().mGameObject.GetComponent <MeshRenderer> ())
                {
                    position = uEntity.GetComponent <InfluenceMapTrigger>().mGameObject.GetComponent <MeshRenderer> ().bounds.center;
                    size     = uEntity.GetComponent <InfluenceMapTrigger>().mGameObject.GetComponent <MeshRenderer> ().bounds.size;
                }
                else
                {
                    position = uEntity.GetComponent <InfluenceMapTrigger>().mGameObject.GetComponentInChildren <MeshRenderer> ().bounds.center;
                    size     = uEntity.GetComponent <InfluenceMapTrigger>().mGameObject.GetComponentInChildren <MeshRenderer> ().bounds.size;
                }


                Vector2 LeftDown     = new Vector2(position.x - size.x / 2, position.z - size.z / 2);
                Vector2 tileLeftDown = InfluenceMap.getInstance().getTilefromPosition(LeftDown);
                Vector2 RightUp      = new Vector2(position.x + size.x / 2, position.z + size.z / 2);
                Vector2 tileRightUp  = InfluenceMap.getInstance().getTilefromPosition(RightUp);
                float   IMdata       = uEntity.GetComponent <InfluenceMapTrigger> ().mIMComputer(uEntity);
                float   maxInfluence = uEntity.GetComponent <InfluenceMapTrigger> ().maxInfluence;



                for (int i = (int)tileLeftDown.x; i <= tileRightUp.x; i++)
                {
                    for (int j = (int)tileLeftDown.y; j <= tileRightUp.y; j++)
                    {
                        Vector2 tTile = new Vector2(i, j);
                        fillTile(tTile, index, IMdata, maxInfluence);
                    }
                }
            }
        }
Exemplo n.º 15
0
 public override void Update(UEntity uEntity)
 {
     base.Update(uEntity);
     while (uEntity.GetComponent <HurtManager> ().mHurtEventList.Count != 0)
     {
         HurtEvent the = uEntity.GetComponent <HurtManager> ().mHurtEventList.Dequeue();
         the.fir.GetComponent <HPComponent> ().tempHurt = the.hurtnumber;
         the.sec.GetComponent <HPComponent> ().tempHP  -= the.hurtnumber;
     }
 }
Exemplo n.º 16
0
        /*
         * @param uEntity: Entity
         *
         * @return: the AI GameObject with this Entity
         *
         */

        private GameObject getObjectByEntity(UEntity uEntity)
        {
            if (uEntity.GetComponent <BaseAIComponent> () != null)
            {
                return(uEntity.GetComponent <BaseAIComponent> ().mAIRT);
            }
            else
            {
                return(((SimpleAI)uEntity).mAIRT);
            }
        }
Exemplo n.º 17
0
 public override void Update(UEntity uEntity)
 {
     if (uEntity.GetComponent <DestroyComponent> ().DestroyTime > 0)
     {
         uEntity.GetComponent <DestroyComponent> ().DestroyTime -= Time.deltaTime;
     }
     else
     {
         uEntity.Release();
     }
 }
Exemplo n.º 18
0
    public override void Update(UEntity uEntity)
    {
        base.Update(uEntity);
        float headDamage = uEntity.GetComponent <bombAI> ().RigHead.GetComponent <enemyHit> ().damage;

        uEntity.GetComponent <bombAI> ().RigHead.GetComponent <enemyHit> ().damage = 0.0f;
        if (headDamage > 0.0f)
        {
            uEntity.GetComponent <getPlayer> ().engage = true;
        }
        uEntity.GetComponent <bombAI> ().HPNow -= headDamage;
    }
Exemplo n.º 19
0
        public override void Update(UEntity uEntity)
        {
            base.Update(uEntity);
            if (((AIEntity)uEntity).mPlayer != null)
            {
                ((AIEntity)uEntity).PlayerPos = ((AIEntity)uEntity).mPlayer.transform.position;
            }
            ((AIEntity)uEntity).AIPos = uEntity.GetComponent <BaseAIComponent> ().mAIRT.transform.position;
            GameObject tObject = uEntity.GetComponent <BaseAIComponent> ().mAIRT;

            uEntity.GetComponent <HPComponent> ().tempHurt = 0;
        }
Exemplo n.º 20
0
        private GameObject getGameObjectFromEntity(UEntity pEntity)
        {
            BaseAIComponent bAI = pEntity.GetComponent <BaseAIComponent> ();

            if (bAI != null)
            {
                return(bAI.mAIRT);
            }
            else
            {
                return(((SimpleAI)pEntity).mAIRT);
            }
        }
Exemplo n.º 21
0
 /*
  * if a transfer,then you should capture the next 10 frame with feedback function
  *
  */
 public override void Update(UEntity uEntity)
 {
     if (uEntity.GetComponent <AIState> ().mCaptureFrame != 0)
     {
         int   tIndex = uEntity.GetComponent <AIState> ().mCaptureFrame - 1;
         float tLast  = uEntity.GetComponent <AIState> ().mTempFeedbacker((AIEntity)uEntity.GetComponent <AIState>().LastEntityData, false);
         float tNow   = uEntity.GetComponent <AIState> ().mTempFeedbacker((AIEntity)uEntity, true);
         uEntity.GetComponent <AIState> ().mframebuffer [tIndex] = Mathf.Abs(tLast) - Mathf.Abs(tNow);
         uEntity.GetComponent <AIState> ().mCaptureFrame--;
         if (uEntity.GetComponent <AIState> ().mCaptureFrame == 0)
         {
             uEntity.GetComponent <AIState> ().mFeedbackerState = true;
         }
     }
 }
Exemplo n.º 22
0
    void Start()
    {
        mUEntity = new UEntity();
        ECSWorld.MainWorld.registerEntityAfterInit(mUEntity);
        InfluenceMapTrigger tInfluenceMapTrigger = new InfluenceMapTrigger();

        tInfluenceMapTrigger.mWhere       = "friend";
        tInfluenceMapTrigger.maxInfluence = maxDistance;
        tInfluenceMapTrigger.mGameObject  = this.gameObject;
        tInfluenceMapTrigger.mIMComputer  = DefaultFunc.friendComputer;

        mUEntity.AddComponent <InfluenceMapTrigger> (tInfluenceMapTrigger);
        tInfluenceMapTrigger.Init();
        //	ECSWorld.MainWorld.registerEntityAfterInit (mUEntity);
    }
Exemplo n.º 23
0
 // 要注意到之后的逻辑,在节点中,只靠是否insight来进行判断的
 public override void Update(UEntity uEntity)
 {
     base.Update(uEntity);
     if (uEntity.GetComponent <showAll> ().singleTest)
     {
         uEntity.GetComponent <showAll> ().mAction.GetComponent <Text> ().text =
             "Action: " + uEntity.GetComponent <AIStrategy> ().mTempName;
         uEntity.GetComponent <showAll> ().mNode.GetComponent <Text> ().text =
             "Node: " + uEntity.GetComponent <AIState> ().mTempName;
         uEntity.GetComponent <showAll> ().mEmotion.GetComponent <Text> ().text =
             "Emotion: " + uEntity.GetComponent <AIEmotion> ().mtempName;
         uEntity.GetComponent <showAll> ().mAnimation.GetComponent <Text> ().text =
             "Animation: " + uEntity.GetComponent <AIAnimation> ().mtempAnim;
     }
 }
Exemplo n.º 24
0
 // the same as AIState
 public override void Update(UEntity uEntity)
 {
     base.Update(uEntity);
     if (uEntity.GetComponent <AIStrategy> ().mFrameCaptureCounter == 0)
     {
         float sum = 0.0f;
         for (int i = 0; i < 10; i++)
         {
             sum += uEntity.GetComponent <AIStrategy> ().bufferdata [i];
         }
         sum /= 10.0f;
         uEntity.GetComponent <AIStrategy> ().mPower [uEntity.GetComponent <AIStrategy> ().LastID] += sum;
         uEntity.GetComponent <AIStrategy> ().mFrameCaptureCounter = 10;
         uEntity.GetComponent <AIStrategy> ().mFrameCaptureStart   = false;
     }
 }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        public override void Update(UEntity uEntity)
        {
            base.Update(uEntity);


            if (uEntity.GetComponent <InfluenceMap> ().timer < 1.0f)
            {
                uEntity.GetComponent <InfluenceMap> ().timer += Time.deltaTime;
            }
            else
            {
                uEntity.GetComponent <InfluenceMap> ().timer = 0.0f;
                for (int i = 0; i < uEntity.GetComponent <InfluenceMap> ().allCount; i++)
                {
                    float tAtten = uEntity.GetComponent <InfluenceMap> ().mAttenuation [i];
                    if (!uEntity.GetComponent <InfluenceMap> ().mDicStatic [i] && tAtten != 0.0f)
                    {
                        for (int j = 0; j < uEntity.GetComponent <InfluenceMap> ().wtileCount; j++)
                        {
                            for (int k = 0; k < uEntity.GetComponent <InfluenceMap> ().htileCount; k++)
                            {
                                uEntity.GetComponent <InfluenceMap> ().IMData [i] [j] [k] *= tAtten;
                                if (uEntity.GetComponent <InfluenceMap> ().IMData [i] [j] [k] < 1.0f)
                                {
                                    uEntity.GetComponent <InfluenceMap> ().IMData [i] [j] [k] = 0.0f;
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < uEntity.GetComponent <InfluenceMap> ().allCount; i++)
            {
                float tAtten = uEntity.GetComponent <InfluenceMap> ().mAttenuation [i];
                if (!uEntity.GetComponent <InfluenceMap> ().mDicStatic [i] && tAtten == 0.0f)
                {
                    for (int j = 0; j < uEntity.GetComponent <InfluenceMap> ().wtileCount; j++)
                    {
                        for (int k = 0; k < uEntity.GetComponent <InfluenceMap> ().htileCount; k++)
                        {
                            uEntity.GetComponent <InfluenceMap> ().IMData [i] [j] [k] = 0.0f;
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
 // the some as AIState
 public override void Update(UEntity uEntity)
 {
     base.Update(uEntity);
     if (uEntity.GetComponent <AIStrategy> ().mFrameCaptureStart)
     {
         if (uEntity.GetComponent <AIStrategy> ().mFrameCaptureCounter == 0)
         {
             uEntity.GetComponent <AIStrategy> ().mFrameCaptureStart = false;
             return;
         }
         int tempID = uEntity.GetComponent <AIStrategy> ().LastID;
         StrategyFeedbacker tempFeedbacker = uEntity.GetComponent <AIStrategy> ().mStrategyFeedbacker [tempID];
         float rate1 = tempFeedbacker((AIEntity)uEntity);
         float rate2 = tempFeedbacker(uEntity.GetComponent <AIState>().LastEntityData);
         uEntity.GetComponent <AIStrategy> ().bufferdata [10 - uEntity.GetComponent <AIStrategy> ().mFrameCaptureCounter] = rate1 - rate2;
     }
 }
Exemplo n.º 28
0
 public override void Update(UEntity uEntity)
 {
     base.Update(uEntity);
     if (uEntity.GetComponent <trapComponent> ().trapNow == 1)
     {
         return;
     }
     if (uEntity.GetComponent <trapComponent> ().trapRate >= 0.0f)
     {
         uEntity.GetComponent <trapComponent> ().trapRate -= Time.deltaTime;
     }
     else
     {
         uEntity.GetComponent <trapComponent> ().trapCount--;
         uEntity.GetComponent <trapComponent> ().trapNow  = 1;
         uEntity.GetComponent <trapComponent> ().trapRate = 10.0f;
     }
 }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        UEntity mUEntity = new UEntity();

        ECSWorld.MainWorld.registerEntityAfterInit(mUEntity);
        RiskComponent rComponent = new RiskComponent();

        rComponent.riskrate = risk;
        mUEntity.AddComponent <RiskComponent> (rComponent);
        InfluenceMapTrigger tInfluenceMapTrigger = new InfluenceMapTrigger();

        tInfluenceMapTrigger.mWhere       = "Risk";
        tInfluenceMapTrigger.maxInfluence = maxDistance;
        tInfluenceMapTrigger.mGameObject  = this.gameObject;
        tInfluenceMapTrigger.mIMComputer  = DefaultFunc.RiskComputer;

        tInfluenceMapTrigger.Init();
        mUEntity.AddComponent <InfluenceMapTrigger> (tInfluenceMapTrigger);
    }
Exemplo n.º 30
0
        // init all array
        public override void Init()
        {
            mStateAnimation = new Dictionary <int, string> ();

            mExiter = new StateExit[25];

            mEnterer = new StateEnter[25];

            mExecuter = new StateExecuter[25];

            mTranfer = new List <TranferNode> [25];

            mStateName = new string[25];

            for (int i = 0; i < 25; i++)
            {
                mTranfer [i] = new List <TranferNode> ();
            }

            mFeedbacker = new List <FeedbackerNode> [25];
            for (int i = 0; i < 25; i++)
            {
                mFeedbacker [i] = new List <FeedbackerNode> ();
            }

            mPowerEdge = new List <PowerNode> [25];
            for (int i = 0; i < 25; i++)
            {
                mPowerEdge [i] = new List <PowerNode> ();
            }

            LastPlayerEntity = new UEntity();

            LastEntityData = new AIEntity();
            LastEntityData.PlayerEntity = LastPlayerEntity;
            if (mUEntity != null)
            {
                LastEntityData.mWorld = this.mUEntity.mWorld;
            }
            IAnyway = (uint)mtempCount;
            mtempCount++;
        }