public void Initialize(Player player, PersonProvider provider) { this.player = player; this.provider = provider; var col = GetComponent <CircleCollider2D>(); collider = col.GetComponent <Collider2D>(); render = GetComponent <SpriteRenderer>(); radius = col.radius; col.enabled = false; mitsuCount = provider.MitsuCount; safeTime = provider.KillTime; restExecteTime = provider.KillTime; provider.OnPause .Subscribe(x => { if (x) { audioSource.Pause(); } else { audioSource.UnPause(); } }).AddTo(gameObject); }
public override void Initialize(PersonProvider provider) { base.Initialize(provider); this.provider = provider; killSelfTime = provider.KillTime; InMitsu.Subscribe(x => { if (!x) { currentVelocityBonus = velocityDefaultE; direction.Value = new Vector2(Random.Range(-1, 1), Random.Range(-1, 1)); } }).AddTo(gameObject); direction .Select(x => x * currentVelocityBonus) .Subscribe(dir => rb2D.velocity = dir).AddTo(gameObject); DiedAsync.First().Subscribe(async _ => { anim.Play("Die"); provider.people.Remove(this); await UniTask.Delay(System.TimeSpan.FromMilliseconds(1100)); Destroy(gameObject); }, () => { }).AddTo(gameObject); transform.ObserveEveryValueChanged(t => t.position) .Where(p => p.x > 32 || p.x < -32 || p.y > 24 || p.y < -24) .Subscribe(_ => { // エリアから出たら、原点(0. 0)あたりにもどる var pos = new Vector2(Random.Range(-20, 20), Random.Range(-10, 10)); direction.Value = (pos - (Vector2)transform.position).normalized; }).AddTo(gameObject); isCatastorophy.Where(x => x).Subscribe(_ => transform.DOLocalMove(Vector3.zero, 10)).AddTo(gameObject); }
public virtual void Initialize(PersonProvider provider) { socialDistance = provider.SocialDistance; mitsuCount = provider.MitsuCount; }
private void Awake() { provider = GetComponent <PersonProvider>(); tutrialController = GetComponent <TutrialController>(); }