Пример #1
0
 private void UpdateIdle()
 {
     _currentTarget = MarbleContainer.instance.GetCloseMarbleToPosition(this.transform.position);
     if (_currentTarget != null)
     {
         _currentState = State.Hunting;
     }
 }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        marbleHealth         = 100f;
        goalsCollected       = 0;
        winScreen.enabled    = false;
        defeatScreen.enabled = false;
        restartButton.gameObject.SetActive(false);

        marble = GetComponent <MarbleBehavior>();
    }
Пример #3
0
    private void UpdateMoving()
    {
        if (_currentTarget.WasClaimed)
        {
            _currentTarget = null;
            _currentState  = State.Idle;
            return;
        }

        var thisToTarget          = _currentTarget.transform.position - this.transform.position;
        var thisToTargetDirection = thisToTarget.normalized;

        this.transform.position += thisToTargetDirection * 10 * Time.deltaTime;

        if (thisToTarget.magnitude < 0.1f)
        {
            _currentTarget.Claim();
            _currentTarget = null;
            _currentState  = State.Idle;
        }
    }