Exemple #1
0
        public override void Activate()
        {
            Performer.WaitingForAnimation = true;
            ExplosionStart = Game1.GameTime.TotalGameTime;
            HashSet <LogicalPosition> visited = new HashSet <LogicalPosition>();
            Queue <LogicalPosition>   pending = new Queue <LogicalPosition>();

            pending.Enqueue(Position);

            while (Caster.Mana > 0 && pending.Count > 0)
            {
                LogicalPosition current = pending.Dequeue();
                Grids[current].Mark = null;
                visited.Add(current);
                ExplosionPositions.Add(current);

                List <LogicalPosition> neighbors = GetNeighbors(current, visited);
                for (int i = neighbors.Count - 1; i >= 0; i--)
                {
                    int randomPick = Game1.Random.Next(neighbors.Count);
                    pending.Enqueue(neighbors[randomPick]);
                    neighbors.RemoveAt(randomPick);
                }

                Caster.Mana -= 1;
            }
        }
Exemple #2
0
        public void Update(GameTime gameTime)
        {
            if (ExplosionStart != TimeSpan.Zero)
            {
                double elapsedSeconds = (gameTime.TotalGameTime - ExplosionStart).TotalSeconds;

                if (elapsedSeconds <= 2.15)
                {
                    Performer.WaitingForAnimation = true;
                }
                else
                {
                    ExplosionPositions.Clear();
                    ExplosionStart = TimeSpan.Zero;
                    Performer.WaitingForAnimation = false;
                }
            }
            else
            {
                Performer.WaitingForAnimation = false;
            }
        }