Example #1
0
    /// <summary>
    /// Clear the list
    /// </summary>
    public void Clear()
    {
        lock (syncRoot)
            list.Clear();

        OnCleared?.Invoke(state);
    }
Example #2
0
            private void Source_CollectionChanged(object aSender, NotifyCollectionChangedEventArgs aArgs)
            {
                switch (aArgs.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    //CheckOneOrNone(aArgs.NewItems);
                    OnItemAdded?.Invoke(Source, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]);
                    break;

                case NotifyCollectionChangedAction.Move:
                    //CheckOneOrNone(aArgs.NewItems);
                    OnItemMoved?.Invoke(Source, aArgs.OldStartingIndex, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]);
                    break;

                case NotifyCollectionChangedAction.Remove:
                    //CheckOneOrNone(aArgs.OldItems);
                    OnItemRemoved?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0]);
                    break;

                case NotifyCollectionChangedAction.Replace:
                    //CheckOneOrNone(aArgs.NewItems);
                    OnItemReplaced?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0], (T)aArgs.NewItems[0]);
                    break;

                case NotifyCollectionChangedAction.Reset:
                    OnCleared?.Invoke(Source);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
Example #3
0
        public void Clear()
        {
            FirstOperand  = 0;
            SecondOperand = 0;
            Operation     = CalculatorOperation.Unknown;
            Result        = 0;

            OnCleared.Invoke(this, new EventArgs());
        }
Example #4
0
        /// <summary>
        /// Clears this game state for re-use
        /// </summary>
        public void Clear()
        {
            myParameters.Clear();

            if (OnCleared != null)
            {
                OnCleared.Invoke(this, EventArgs.Empty);
            }
        }
Example #5
0
        /// <summary>
        /// Clear the list
        /// </summary>
        public void Clear()
        {
            if (removableList)
            {
                foreach (IDestructible v in list)
                {
                    if (v != null)
                    {
                        v.OnDestroy -= ItemDestroyed;
                    }
                }
            }

            lock (syncRoot)
                list.Clear();

            OnCleared?.Invoke(state);
        }
    public IEnumerator actionTaken(bool delay, Action then)
    {
        _elapsedTurns += 1;
        EnqueueEvent(new GameEvent(GameEvent.EventType.TURN_ELAPSED));

        var turnWaitDuration = delay ? 0.25f : 0;

        // wait 0.2f seconds
        yield return(new WaitForSeconds(turnWaitDuration));

        ClearEventQueue();

        Entities.FindAll(e => e.Dead).ForEach(e => {
            e.GoDie();

            Rune rune = e.RuneList[0];
            if (rune != null)
            {
                AnimUtils.ShowFloatingText("Rune Shard Recovered!", new Vector3(e.Coordinates.x, e.Coordinates.y, 0));
                if (UnityEngine.Random.value > 0.5f)
                {
                    Player.AddRuneShard(rune.action);
                }
                else
                {
                    Player.AddRuneShard(rune.trigger);
                }
            }

            this.EnqueueEvent(new GameEvent(GameEvent.EventType.ENEMY_DEAD));
        });

        Entities.RemoveAll(e => e.Dead);

        bool enemiesMoved = false;

        foreach (var e in Enemies)
        {
            e.TakeTurn();
            // if (e.isVisible) {
            enemiesMoved = true;
            //   yield return new WaitForSeconds(turnWaitDuration);
            // }
        }

        ClearEventQueue();

        // We want to prevent movement scumming, so if the player hasn't been hit in 75 turns, spawn some enemies
        if (++Player.TurnsSinceHitByEnemy >= 200)
        {
            var positions = EnumerateCircle(Player.Coordinates, 3)
                            .Where(pos => canOccupy(pos))
                            .ToList()
                            .Shuffle()
                            .Take(2);

            foreach (var pos in positions)
            {
                Enemy enemy = new Enemy0(pos);
                AddEntity(enemy);
                OnEntityAdded(enemy);
            }

            Player.TurnsSinceHitByEnemy = 0;
        }

        if (enemiesMoved)
        {
            yield return(new WaitForSeconds(turnWaitDuration));
        }

        /// Move onto the next floor!
        if (Tiles[Player.Coordinates.x, Player.Coordinates.y] is Downstairs)
        {
            Player.score += 10;
            OnCleared?.Invoke();
        }

        then();
    }