Ejemplo n.º 1
0
    public override BaseBTNode.NodeStatus Activate()
    {
        if (awayPath.corners.Length == 0)
        {
            return(BaseBTNode.NodeStatus.STATUS_SUCCESS);
        }

        Vector3 curTargetPos = awayPath.corners[curIndex];

        if (Vector3.Distance(transform.position, curTargetPos) < 0.5f)
        {
            if (curIndex + 1 < awayPath.corners.Length)
            {
                curIndex++;
            }
            else
            {
                return(BaseBTNode.NodeStatus.STATUS_SUCCESS);
            }
        }

        Vector3 direction = (curTargetPos - transform.position).normalized;

        eneTree.SetMovePosition(direction * status.GetMoveSpeed() * Time.deltaTime);
        direction.y = 0;
        eneTree.SetLookAtPos(transform.position + direction);

        return(BaseBTNode.NodeStatus.STATUS_RUNNING);
    }
Ejemplo n.º 2
0
    public override BaseBTNode.NodeStatus Activate()
    {
        Vector3 movePosition = velocity * Time.fixedDeltaTime;

        eneTree.SetMovePosition(movePosition);

        if (Mathf.Abs((nextPosition - transform.position).magnitude) < 0.1f)
        {
            return(BaseBTNode.NodeStatus.STATUS_SUCCESS);
        }
        return(BaseBTNode.NodeStatus.STATUS_RUNNING);
    }
Ejemplo n.º 3
0
    public override BaseBTNode.NodeStatus Activate()
    {
        Vector3 directionToPlayer = (status.player.position - transform.position).normalized;

        Vector3 movePosition = Vector3.zero;

        movePosition = directionToPlayer * speed * Time.fixedDeltaTime;
        eneTree.SetMovePosition(movePosition);
        eneTree.SetLookAtPos(transform.position + movePosition);

        if ((status.player.transform.position - transform.position).magnitude < status.GetCloseToPlayerDistance())
        {
            return(BaseBTNode.NodeStatus.STATUS_SUCCESS);
        }

        return(BaseBTNode.NodeStatus.STATUS_RUNNING);
    }
Ejemplo n.º 4
0
    public override BaseBTNode.NodeStatus Activate()
    {
        if (belgianAI.IsInGridEnemies(this.gameObject))
        {
            //gridPositionから離れて2秒経っているなら追いかける
            if (belgianAI.IsInCloseToGriPos(this.gameObject))
            {
                anim.SetBool("Run", false); //近いなら止まる
                delayTimer = 0;
            }
            else
            {
                bool can_chase = false;
                if (delayTimer > delayThresholdTime)
                {
                    can_chase = true;
                    anim.SetBool("Run", true); //近くなく遅延時間が終わったら走る
                }
                else
                {
                    delayTimer += Time.fixedDeltaTime;
                }

                if (can_chase)
                {
                    Vector3 gridPlanePos = belgianAI.ComputeRegisteredGridPosition(this.gameObject);
                    gridPlanePos.y = 0;
                    Vector3 enemyPlanePos = transform.position;
                    enemyPlanePos.y = 0;
                    Vector3 dir          = (gridPlanePos - enemyPlanePos).normalized;
                    Vector3 movePosition = dir * status.GetMoveSpeed() * Time.fixedDeltaTime;
                    eneTree.SetMovePosition(movePosition);

                    eneTree.SetLookAtPos(transform.position + dir);
                }
            }
        }

        if (belgianAI.CanAttackPlayer(this.gameObject))
        {
            return(BaseBTNode.NodeStatus.STATUS_SUCCESS);
        }
        return(BaseBTNode.NodeStatus.STATUS_RUNNING);
    }