示例#1
0
 public void Hitted(HitKey hitKey, SwipeType type)
 {
     if (hitKey.Type != type)
     {
         Missed(MissType.WrongDirection);
     }
     else
     {
         TotalPoints += hitKey.points;
         OnPointsChanged?.Invoke(TotalPoints);
         OnHit?.Invoke(PointsPercentage);
         OnHitfeedback?.Play(Vector3.zero);
     }
 }
示例#2
0
    public void Initialize(HitKey hitKey, float radius, float speed)
    {
        _radius     = radius;
        _speed      = speed;
        this.hitKey = hitKey;

        _renderer        = gameObject.GetComponent <SVGImage>();
        _renderer.sprite = hitKey.Sprite;

        _collider        = gameObject.AddComponent <CircleCollider2D>();
        _collider.radius = radius;

        _rigidbody = gameObject.AddComponent <Rigidbody2D>();
        _rigidbody.freezeRotation = true;
        _rigidbody.isKinematic    = true;
        _rigidbody.constraints    = RigidbodyConstraints2D.FreezePositionY;
        _rigidbody.velocity       = new Vector2(-_speed, 0f);

        _isInitialized = true;
    }