private void OnDestroy() { _LaserManager = null; _VisibleChecker = null; _RigidBody2D = null; _ShootPoint = null; _Shooter = null; _Animator = null; _Life.Dispose(); _Life = null; }
private void Start() { _Life.Where(life => life <= 0) .ThrottleFirst(TimeSpan.FromSeconds(1)) .Subscribe(_ => { if (!GetComponent <Boss> ()) { AudioManager.SoundEmitter.PlaySE(AudioManager.EnemySound.DestroySound); } _Animator.SetBool(AnimationParams.Dead, true); UIManager.Score.AddScore(_Score); }); _Shooter = new NwayGun(_ShootPoint); var rendere = GetComponent <SpriteRenderer> (); //TODO:ダメージ処理を別のクラスに this.OnTriggerEnter2DAsObservable() .Where(_ => new Rect(0, 0, 1, 1).Contains(Camera.main.WorldToViewportPoint(rendere.transform.position))) .ThrottleFirstFrame(1) .Subscribe(collision => { var damage = collision.GetComponent <IDamage> (); if (collision.GetComponent <IDamage> () != null) { _Animator.SetBool(AnimationParams.Damage, true); AddDamage(damage.Damage); } }); this.FixedUpdateAsObservable() .Subscribe(_ => { _RigidBody2D.MovePosition(_RigidBody2D.position + _Velocity * _SpeedRatio * TimeManager.EnemyFixedDeltaTime); }); this.LateUpdateAsObservable() .Where(_ => _DirectionChange) .Subscribe(_ => { if (_Velocity.x > 0) { gameObject.transform.localScale = new Vector3(-1, 1, 1); } else if (_Velocity.x < 0) { gameObject.transform.localScale = new Vector3(1, 1, 1); } }); Life.Where(value => value <= 0) .Subscribe(_ => _Velocity = Vector2.zero); }