Example #1
0
    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);
    }
Example #2
0
 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);
 }
Example #5
0
 public void Interact(PlayerCharacterLogic playerCharacter)
 {
     playerCharacter.CanGetDamage.Update();
     CoroutineT.Single
     (
         () => playerCharacter
         .Damage(999999, DamageType.magic)
         .AddColorBy(Color.red, 1), 0.2f
     ).Start(this);
 }
Example #6
0
    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);
    }
Example #7
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (!draged)
        {
            clickedCount++;

            if (clickedCount <= 2)
            {
                CoroutineT.Single(CheckClick, clickDelay).Start(this);
            }
        }
    }
Example #8
0
    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);
    }
Example #10
0
 public void ReflectPause()
 {
     if (IsPouse)
     {
         Time.timeScale = 1;
         StartCoroutine(CoroutineT.Single
                        (
                            () =>
         {
             IsPouse = false;
             PauseChanged();
         }, 0.1f
                        ));
     }
     else
     {
         Time.timeScale = 0;
         IsPouse        = true;
         PauseChanged();
     }
 }
Example #11
0
    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);
    }
Example #12
0
 public void Interact()
 {
     spriteRenderer.sprite = activeMine;
     StartCoroutine(CoroutineT.Single(Explode, activeTime.Randomize(1.4f)));
 }
Example #13
0
 public void Repool()
 {
     StopAllCoroutines();
     StartCoroutine(CoroutineT.Single(Shoot, 2));
 }
Example #14
0
 private void ShowShieldAt(float time)
 {
     shield.SetActive(true);
     CoroutineT.Single(() => shield.SetActive(false), time).Start(this);
 }
Example #15
0
 public void Repool()
 {
     rigidbody2D.constraints = RigidbodyConstraints2D.FreezeRotation;
     StartCoroutine(CoroutineT.Single(Explode, activeTime.Randomize(3)));
 }
Example #16
0
 public void Interact()
 {
     StopAllCoroutines();
     StartCoroutine(CoroutineT.Single(Explode, hittedActiveTime));
 }