Пример #1
0
    public override BaseBTNode.NodeStatus Activate()
    {
        if (status.GetNotUseWeapon())
        {
            return(BaseBTNode.NodeStatus.STATUS_RUNNING);
        }

        if (intervalTimer > thresholdTime)
        {
            anim.SetBool("Attack", true);
            anim.SetTrigger("Attacking");
            shootCount++;
            intervalTimer = 0;
            Vector3 dir = status.player.position - transform.position;
            dir.y = 0;

            eneTree.SetLookAtPos(transform.position + dir);
            GameObject ins = Instantiate(bulletPrefab, weaponStat.weaponInstancePosition.position,
                                         this.gameObject.transform.rotation);
        }
        intervalTimer += Time.fixedDeltaTime;

        if (shootCount >= 3)
        {
            return(BaseBTNode.NodeStatus.STATUS_SUCCESS);
        }

        return(BaseBTNode.NodeStatus.STATUS_RUNNING);
    }
Пример #2
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);
    }
Пример #3
0
    public override void Enter()
    {
        //ドーナツ型のランダムな値を設定する
        Vector2 nextPos2 = 0.1f * UnityEngine.Random.insideUnitCircle;

        if (nextPos2.x >= 0)
        {
            nextPos2.x += cMinInsideCircle.x;
        }
        else
        {
            nextPos2.x -= cMinInsideCircle.x;
        }
        if (nextPos2.y >= 0)
        {
            nextPos2.y += cMinInsideCircle.y;
        }
        else
        {
            nextPos2.y -= cMinInsideCircle.y;
        }

        nextPosition = new Vector3(nextPos2.x, 0, nextPos2.y) + transform.position;
        velocity     = (nextPosition - transform.position).normalized * status.GetWanderSpeed();

        velocity.y = 0;
        eneTree.SetLookAtPos(transform.position + velocity);

        anim.SetBool("Run", true);
    }
Пример #4
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);
    }
Пример #5
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);
    }
Пример #6
0
    public override void Enter()
    {
        Vector3 plane_playerPos = status.player.position;

        plane_playerPos.y = 0;
        Vector3 plane_enemyPos = transform.position;

        plane_enemyPos.y = 0;
        Vector3 dir = plane_playerPos - plane_enemyPos;

        eneTree.SetLookAtPos(transform.position + dir);

        if (attackCol == null)
        {
            attackCol = status.GetAttackCol();
        }
        attackCol.enabled = true;
        anim.SetBool("Attack", true);
    }