Exemplo n.º 1
0
        protected override int onExecute(TBTWorkingData wData)
        {
            AIEntityWorkingData thisData   = wData.As <AIEntityWorkingData>();
            Vector3             targetPos  = TMathUtils.Vector3ZeroY(thisData.entity.GetBBValue <Vector3>(AIEntity.BBKEY_NEXTMOVINGPOSITION, Vector3.zero));
            Vector3             currentPos = TMathUtils.Vector3ZeroY(thisData.entityTF.position);
            float distToTarget             = TMathUtils.GetDistance2D(targetPos, currentPos);

            if (distToTarget < 1f)
            {
                thisData.entityTF.position = targetPos;
                return(TBTRunningStatus.FINISHED);
            }
            else
            {
                int     ret        = TBTRunningStatus.EXECUTING;
                Vector3 toTarget   = TMathUtils.GetDirection2D(targetPos, currentPos);
                float   movingStep = 0.5f * thisData.deltaTime;
                if (movingStep > distToTarget)
                {
                    movingStep = distToTarget;
                    ret        = TBTRunningStatus.FINISHED;
                }
                thisData.entityTF.position = thisData.entityTF.position + toTarget * movingStep;
                return(ret);
            }
        }
Exemplo n.º 2
0
        public override bool IsTrue(TBTWorkingData wData)
        {
            AIEntityWorkingData thisData   = wData.As <AIEntityWorkingData>();
            Vector3             targetPos  = TMathUtils.Vector3ZeroY(thisData.entity.GetBBValue <Vector3>(AIEntity.BBKEY_NEXTMOVINGPOSITION, Vector3.zero));
            Vector3             currentPos = TMathUtils.Vector3ZeroY(thisData.entityTF.position);

            return(TMathUtils.GetDistance2D(targetPos, currentPos) < 1f);
        }
Exemplo n.º 3
0
        public override bool IsTrue(BtWorkingData workData)
        {
            AIEntityWorkingData this_data   = workData.As <AIEntityWorkingData>();
            Vector3             target_pos  = MathHelper.Vector3ZeroY(this_data.EntityAi.GetBbValue <Vector3>(BtEntityAi.BBKEY_NEXTMOVINGPOSITION, Vector3.zero));
            Vector3             current_pos = MathHelper.Vector3ZeroY(this_data.EntityAi.BaseEntity.EntityController.WroldPosition);
            bool result = TMathUtils.GetDistance2D(target_pos, current_pos) < 1f;

            return(result);
        }