private IEnumerable <IPoolable> InstantiateBullet(InteractiveData interactiveData, UnityAction onInteractHandler) { var bullet = Instantiate(bulletPrefab); bullet.name = "bullet"; bullet.GetComponent <ISetData <InteractiveData> >().SetData(interactiveData); bullet.GetComponent <ISubscribedInteract>().OnInteracted.Subscribe(onInteractHandler); var poolable = new Poolable(bullet); poolable.OnFloated.Subscribe ( () => { spriteRenderer.sprite = withoutBullet; bullet.transform.position = transform.position; bullet.transform.rotation = transform.rotation; var rigitbody = bullet.GetComponent <Rigidbody2D>(); rigitbody.velocity = Vector2.zero; rigitbody.AddForce(accelerate); StartCoroutine(CoroutineT.Single ( () => spriteRenderer.sprite = withBullet, shootingReload / 2) ); } ); yield return(poolable); }
private void Shoot() { bulletsPool.PoolObject(); for (int i = 1; i < bulletCount; i++) { CoroutineT.Single(bulletsPool.PoolObject, i * shootingTime).Start(this); } }
public void Repool() { scaleAnimation.Show(); StartCoroutine(CoroutineT.Single ( () => gameObject.SetActive(false), damagedTime )); }
public void DenyAt(MonoBehaviour coroutineSource, float time, UnityAction denyActions = null) { state++; CoroutineT.Single(() => { RemoveState(); denyActions?.Invoke(); }, time).Start(coroutineSource); }
public void Interact(PlayerCharacterLogic playerCharacter) { playerCharacter.CanGetDamage.Update(); CoroutineT.Single ( () => playerCharacter .Damage(999999, DamageType.magic) .AddColorBy(Color.red, 1), 0.2f ).Start(this); }
private IEnumerator AsyncLoadScene(float delay) { var asyncOperator = SceneManager.LoadSceneAsync((int)scene); asyncOperator.allowSceneActivation = false; while (asyncOperator.progress < .9f) { yield return(null); } CoroutineT.Single(() => asyncOperator.allowSceneActivation = true, delay).Start(this); }
public void OnPointerClick(PointerEventData eventData) { if (!draged) { clickedCount++; if (clickedCount <= 2) { CoroutineT.Single(CheckClick, clickDelay).Start(this); } } }
private IEnumerable <IPoolable> InstansiateWave() { var wave = Instantiate(wavePrefab); wave.name = "Wave"; waveTransform = wave.GetComponent <Transform>(); var poolable = new Poolable(wave); poolable.OnFloated .Subscribe ( () => CoroutineT.Single(() => wave.SetActive(false), waveLivingTime) .Start(this) ); yield return(poolable); }
private void Shoot() { float time = 0.0f; bulletsPool.PoolObject(); for (int i = 1; i < bulletsPool.Length; i++) { if (i + 1 < bulletsPool.Length) { time += i % countIn1Queue == 0 ? timeBetweenQueues : reloadingTimeBetweenShoots; } else { time += reloadingTimeBetweenShoots; } CoroutineT.Single(bulletsPool.PoolObject, time).Start(this); } CoroutineT.Single(OnReloadingStart.Invoke, time).Start(this); }
public void ReflectPause() { if (IsPouse) { Time.timeScale = 1; StartCoroutine(CoroutineT.Single ( () => { IsPouse = false; PauseChanged(); }, 0.1f )); } else { Time.timeScale = 0; IsPouse = true; PauseChanged(); } }
private IEnumerable <IPoolable> InstantiateRay(InteractiveData interactiveData) { var ray = Instantiate(rayPrefab, transform.position, transform.rotation); ray.name = "Lazer Ray"; var rayComponent = ray.GetComponent <LazerRay>(); rayComponent.SetData(interactiveData); ray.GetComponent <ILinkWithShower>().EffectShower = EffectShower; var poolable = new Poolable(ray); poolable.OnFloated.Subscribe ( () => { ray.transform.position = transform.position; ray.transform.rotation = transform.rotation; float y = movingObject.Speed.y; movingObject.Speed = movingObject.Speed.Change(y: 0); movingObject.UpdateSpeedAndDelta(); rayComponent.StartCoroutine(CoroutineT.Single ( () => { ray.SetActive(false); movingObject.Speed = movingObject.Speed.Change(y: y); movingObject.UpdateSpeedAndDelta(); }, rayLivingTime )); } ); yield return(poolable); }
public void Interact() { spriteRenderer.sprite = activeMine; StartCoroutine(CoroutineT.Single(Explode, activeTime.Randomize(1.4f))); }
public void Repool() { StopAllCoroutines(); StartCoroutine(CoroutineT.Single(Shoot, 2)); }
private void ShowShieldAt(float time) { shield.SetActive(true); CoroutineT.Single(() => shield.SetActive(false), time).Start(this); }
public void Repool() { rigidbody2D.constraints = RigidbodyConstraints2D.FreezeRotation; StartCoroutine(CoroutineT.Single(Explode, activeTime.Randomize(3))); }
public void Interact() { StopAllCoroutines(); StartCoroutine(CoroutineT.Single(Explode, hittedActiveTime)); }