コード例 #1
0
    public override void Update()
    {
        _elapseTime += Time.deltaTime;

        if (_elapseTime >= _hideTime)
        {
            _owner.SwitchState(StateDefinition.StateName.GetBall);
        }

        if (CloseBall())
        {
            _owner.SwitchState(StateDefinition.StateName.GetBall);
        }

        // if at position, go to a different one //
        if (Vector3.Distance(_targetLocation, _owner.transform.position) < 0.3f)
        {
            _targetLocation = GetNewLocation();
        }

        // move to hide position //
        Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _targetLocation);

        _owner.MoveForward(direction.normalized);
    }
コード例 #2
0
    public override void OnUpdate()
    {
        _elapseTime += Time.deltaTime;

        Transform closestBall = NearestBall(_owner.balls);

        _owner.targetBall = closestBall;

        if (_owner.targetBall != null)
        {
            Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _owner.targetBall.position);

            if (!_owner.hasBall)
            {
                _owner.MoveForward(direction.normalized);
                if (Vector3.Distance(_owner.transform.position, _owner.targetBall.position) < 1.5f)
                {
                    _owner.Pickup();
                    _owner.SwitchState(Definitions.StateName.Attack);
                }
            }
        }

        if (!closestBall)
        {
            //_owner.SwitchState(Definitions.StateName.Defense);
        }
    }
コード例 #3
0
    public override void OnUpdate()
    {
        _elapseTime += Time.deltaTime;

        Transform closestTarget = NearestTarget(_owner.targets);

        _owner.targetAgent = closestTarget;

        if (_owner.targetAgent != null)
        {
            if (Vector3.Distance(_owner.transform.position, _owner.targetAgent.position) < Mathf.Infinity)
            {
                Throw();
                _owner.SwitchState(Definitions.StateName.Defense);
            }
            else
            {
                Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _owner.targetBall.position);
                _owner.MoveForward(direction);
            }
        }
    }
コード例 #4
0
    public override void Update()
    {
        _elapsedTime += Time.deltaTime;

        Transform closestBall = GetClosestBall();

        if (closestBall == null)
        {
            _owner.SwitchState(StateDefinition.StateName.Hide);
        }

        _owner.targetBall = closestBall;

        if (_owner.targetBall != null)
        {
            Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _owner.targetBall.position);

            if (!_owner.hasBall)
            {
                _owner.MoveForward(direction.normalized);
                CanGrabBall();
            }
        }
    }