Пример #1
0
        internal static void ExecuteCycle(Clock clock, float deltaTime = 0f)
        {
            if (clock != null)
            {
                var currentMsUpdate = clock.GetElapsedSeconds();
                if (currentMsUpdate == 0)
                {
                    Thread.Sleep(1);
                    currentMsUpdate = clock.GetElapsedSeconds();
                }

                Script.DeltaTime = (float)currentMsUpdate;
                clock.Reset();
            }
            else
            {
                Script.DeltaTime = deltaTime;
            }

            lock (RtUpdate)
            {
                RtUpdate?.Invoke();
            }
            lock (Updating)
            {
                Updating?.Invoke();
            }
            lock (Destroying)
            {
                Destroying?.Invoke();
            }
        }
Пример #2
0
 public void Destroy()
 {
     spriteRenderer.enabled = false;
     particles.Play();
     Destroying?.Invoke();
     Destroy(gameObject, particles.main.duration + particles.main.startLifetimeMultiplier);
 }
Пример #3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         Destroying?.Invoke(this, null);
     }
     base.Dispose(disposing);
 }
Пример #4
0
    public void DestroySelf()
    {
        ScoreManager.Instance.IncreaseScore();

        IsDestroying = true;
        Destroying?.Invoke();
        particles.Play();

        StartCoroutine(ReturnToSpawner(particles.main.duration));
    }
Пример #5
0
    private IEnumerator ReturnToSpawnPoint()
    {
        while (Vector3.Distance(SpawnPoint.position, transform.position) > 0.5f)
        {
            var direction = (SpawnPoint.position - transform.position).normalized;
            rb.MovePosition(transform.position + direction * Time.fixedDeltaTime * ThrowingSpeed);

            yield return(new WaitForFixedUpdate());
        }

        Destroying?.Invoke();
        Destroy(gameObject);
    }
Пример #6
0
    private IEnumerator BringCrateToSpawnPoint(Collision2D collision)
    {
        while (Vector3.Distance(SpawnPoint.position, transform.position) > 0.5f)
        {
            var direction = (SpawnPoint.position - transform.position).normalized;
            rb.MovePosition(transform.position + direction * Time.fixedDeltaTime * ThrowingSpeed);

            collision.transform.Translate(direction * Time.fixedDeltaTime * ThrowingSpeed);

            yield return(new WaitForFixedUpdate());
        }

        var points = collision.gameObject.GetComponent <Crate>().Points;

        ScoreManager.Instance.IncreaseScoreBy(points);

        collision.gameObject.GetComponent <Crate>().Destroy();
        Destroying?.Invoke();
        Destroy(gameObject);
    }
Пример #7
0
        public void DestroyAll(bool destroyTemplate = true)
        {
            lock (syncObject)
            {
                if (itemList.Count == 0)
                {
                    return;
                }

                RecycleAll();

                for (int i = 0; i < itemList.Count; ++i)
                {
                    PoolItem item = itemList[i];
                    if (item.instance != null)
                    {
                        item.poolItem?.OnDestroying();
                        Destroying?.Invoke(item.instance);
                        DestroyImpl(item.instance);
                    }
                }

                if (itemList != null)
                {
                    itemList.Clear();
                    itemList.Capacity = 0;
                }

                if (destroyTemplate && Template != null)
                {
                    DestroyImpl(Template);
                    Template = null;
                }

                version++;
                residueCount = 0;
            }
        }
Пример #8
0
        public void ChangeState(TileState state)
        {
            switch (state)
            {
            case TileState.Destroy:
            {
                TileState stateBeforeDestroy = this.State;
                if (Type == TileType.Bomb || Type == TileType.HorizontalLine || Type == TileType.VerticalLine)
                {
                    stateBeforeDestroy = TileState.Idle;
                }

                this.State = TileState.Destroy;
                Destroying?.Invoke(this, new TileEventArgs(PositionOnScreen, Type, stateBeforeDestroy, PositionConverter.GetCellByTilePosition(PositionOnScreen)));
                break;
            }

            default:
            {
                this.State = state;
                break;
            }
            }
        }
Пример #9
0
 /// <summary>
 /// Called before destroying a player.
 /// </summary>
 /// <param name="ev">The <see cref="DestroyingEventArgs"/> instance.</param>
 public static void OnDestroying(DestroyingEventArgs ev) => Destroying.InvokeSafely(ev);
Пример #10
0
 private void OnDestroy()
 {
     Destroying?.Invoke(gameObject);
 }
Пример #11
0
 public ItemTypeEnum GiveMeYourPowers()
 {
     Destroying?.Invoke();
     Destroy(this.gameObject);
     return(ItemType);
 }
Пример #12
0
 void IForceDestroyer.ForceDestroy()
 {
     Destroying?.Invoke();
     Destroy(this.gameObject);
 }
Пример #13
0
 /// <summary>
 /// Kun oliota käydään tuhoamaan
 /// </summary>
 protected void OnDestroying()
 {
     Destroying?.Invoke();
 }
Пример #14
0
 public void SurfaceDestroyed(ISurfaceHolder holder)
 {
     Destroying?.Invoke(this, EventArgs.Empty);
 }
Пример #15
0
 public void OnContextDestroy()
 {
     Destroying?.Invoke();
 }
Пример #16
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            Destroying?.Invoke(this, EventArgs.Empty);
        }
Пример #17
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     Destroying?.Invoke(this, EventArgs.Empty);
 }