Пример #1
0
        /// <summary>
        /// Unsubscribing from the events when the instance is destroyed.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            if (disposedValue)
            {
                return;
            }

            if (disposing)
            {
                if (OnUpdateMap != null)
                {
                    foreach (Action <int[, ]> act in OnUpdateMap.GetInvocationList())
                    {
                        OnUpdateMap -= act;
                    }
                }

                if (OnUpdateScore != null)
                {
                    foreach (Action <int, int> act in OnUpdateScore.GetInvocationList())
                    {
                        OnUpdateScore -= act;
                    }
                }
            }

            disposedValue = true;
        }
Пример #2
0
        /// <summary>
        /// Filling the map with random units and clearing matches.
        /// </summary>
        private void InitMap()
        {
            var random = new Random();

            for (int x = 0; x < XMax; x++)
            {
                for (int y = 0; y < YMax; y++)
                {
                    Map[x, y] = random.Next(0, KindsCount);
                }
            }

            ClearMapForAllMatches();

            OnUpdateMap?.Invoke(Map);
        }