コード例 #1
0
ファイル: Dog.cs プロジェクト: TORISOUP/GGJ2020_Akiba_team2
        private void Start()
        {
            _players     = pm.Players.Select(x => x.transform).ToArray();
            _rigidbody2D = GetComponent <Rigidbody2D>();

            _spriteRenderer = GetComponent <SpriteRenderer>();

            shake       = Camera.main.GetComponent <Shake>();
            source      = GetComponent <AudioSource>();
            source.clip = attack;

            this.OnCollisionEnter2DAsObservable()
            .Select(x => x.gameObject.GetComponent <IDamageApplicable>())
            .Where(x => x != null)
            .Subscribe(x =>
            {
                _isLatestHitPlayer = true;
                x.ApplyDamage(new Damage(1.0f));
                source.Play();
                shake.ShakeMe(.2f, .1f);
                _rigidbody2D.velocity = Vector2.zero;
            })
            .AddTo(this);

            LoopAsync(this.GetCancellationTokenOnDestroy()).Forget();

            AnimLoopAsync(this.GetCancellationTokenOnDestroy()).Forget();
        }