コード例 #1
0
ファイル: BossSeek.cs プロジェクト: Yunshiyue/ElementGame
    public override TaskStatus OnUpdate()
    {
        //执行seek
        movementComponent.Seek();

        return(TaskStatus.Running);
    }
コード例 #2
0
ファイル: AttackedSeek.cs プロジェクト: Yunshiyue/ElementGame
    public override TaskStatus OnUpdate()
    {
        //如果再次被打
        if (defenceComponent.getHpReduction() > 0 || attackComponent.isHitPlayer)
        {
            //上次被打时间重置
            movementComponent.lastAttackedTime = 0f;
            attackComponent.isHitPlayer        = false;
        }
        //movementComponent.isBeAttacked = true;
        movementComponent.lastAttackedTime += Time.deltaTime;

        //如果上次被打后时间大于脱战时间
        if (movementComponent.lastAttackedTime > attakedOffTime)
        {
            movementComponent.isBeAttacked = false;
            //状态结束
            //Debug.Log("close");
            return(TaskStatus.Failure);
        }

        //如果是有主动攻击的怪并且主角已在指定的攻击范围内 则success进入下一状态
        if (attackComponent.canActiveAttack && attackComponent.isInAttackLength)
        {
            return(TaskStatus.Success);
        }


        //执行seek
        //Debug.Log("seek");
        movementComponent.Seek();

        return(TaskStatus.Running);
    }
コード例 #3
0
    public override TaskStatus OnUpdate()
    {
        //如果是有主动攻击的怪并且主角已在指定的攻击范围内,并且不在遗失目标但在寻找状态 则success进入下一状态(攻击)
        if (attackComponent.canActiveAttack && attackComponent.isInAttackLength && !movementComponent.islostTargetButFind)
        {
            return(TaskStatus.Success);
        }

        //追踪逻辑
        clear();
        if (defenceComponent.getHpReduction() > 0)
        {
            movementComponent.isBeAttacked = true;
        }
        if (!movementComponent.isInMoveArea || movementComponent.isBeAttacked) //如果 超出移动范围||被攻击
        {
            //Debug.Log("enemyseek返回falseisin:" + movementComponent.isInMoveArea);
            lostTargetTime = 0f;
            movementComponent.islostTargetButFind  = false;
            movementComponent.isInSeePlayerControl = false;
            return(TaskStatus.Failure);
        }

        if (!movementComponent.isSeePlayer)//如果看不到主角continueSeekTime后,则进入下一行为
        {
            movementComponent.islostTargetButFind = true;
            lostTargetTime += Time.deltaTime;
            //Debug.Log("lostTargetTime:" + lostTargetTime);
            if (lostTargetTime > continueSeekTime)
            {
                lostTargetTime = 0f;
                movementComponent.islostTargetButFind  = false;
                movementComponent.isInSeePlayerControl = false;
                return(TaskStatus.Failure);
            }
        }
        else//看到主角则把目标消失时间清零
        {
            movementComponent.islostTargetButFind = false;
            lostTargetTime = 0f;
        }

        //执行seek
        movementComponent.Seek();

        return(TaskStatus.Running);
    }