Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
 private void Shoot()
 {
     bulletsPool.PoolObject();
     for (int i = 1; i < bulletCount; i++)
     {
         CoroutineT.Single(bulletsPool.PoolObject, i * shootingTime).Start(this);
     }
 }
Ejemplo n.º 3
0
 public void Repool()
 {
     scaleAnimation.Show();
     StartCoroutine(CoroutineT.Single
                    (
                        () => gameObject.SetActive(false),
                        damagedTime
                    ));
 }
Ejemplo n.º 4
0
 public void DenyAt(MonoBehaviour coroutineSource, float time, UnityAction denyActions = null)
 {
     state++;
     CoroutineT.Single(() =>
     {
         RemoveState();
         denyActions?.Invoke();
     }, time).Start(coroutineSource);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 7
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (!draged)
        {
            clickedCount++;

            if (clickedCount <= 2)
            {
                CoroutineT.Single(CheckClick, clickDelay).Start(this);
            }
        }
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 12
0
 public void Interact()
 {
     spriteRenderer.sprite = activeMine;
     StartCoroutine(CoroutineT.Single(Explode, activeTime.Randomize(1.4f)));
 }
Ejemplo n.º 13
0
 public void Repool()
 {
     StopAllCoroutines();
     StartCoroutine(CoroutineT.Single(Shoot, 2));
 }
Ejemplo n.º 14
0
 private void ShowShieldAt(float time)
 {
     shield.SetActive(true);
     CoroutineT.Single(() => shield.SetActive(false), time).Start(this);
 }
Ejemplo n.º 15
0
 public void Repool()
 {
     rigidbody2D.constraints = RigidbodyConstraints2D.FreezeRotation;
     StartCoroutine(CoroutineT.Single(Explode, activeTime.Randomize(3)));
 }
Ejemplo n.º 16
0
 public void Interact()
 {
     StopAllCoroutines();
     StartCoroutine(CoroutineT.Single(Explode, hittedActiveTime));
 }