Пример #1
0
        public async void StartCountDown(bool firstMelee)
        {
            var currentCount  = Interlocked.Increment(ref this.count);
            var countingState = CountingState.Activate;

            while (this.count == currentCount)
            {
                switch (countingState)
                {
                case CountingState.Activate:
                    if (firstMelee)
                    {
                        announcer.AnnounceAsync("Activating first melee.", 10, 150, true);
                        countingState = CountingState.Four;
                    }
                    else
                    {
                        announcer.AnnounceAsync("Activating normal melee.", 10, 150, true);
                        countingState = CountingState.Five;
                    }

                    await Task.Delay(1000);

                    break;

                case CountingState.Seven:
                    announcer.AnnounceAsync("Seven", -5, 200);
                    countingState = CountingState.Six;
                    await Task.Delay(1000);

                    break;

                case CountingState.Six:
                    announcer.AnnounceAsync("Six", -5, 200);
                    countingState = CountingState.Five;
                    await Task.Delay(1000);

                    break;

                case CountingState.Five:
                    announcer.AnnounceAsync("Five", -5, 200);
                    countingState = CountingState.Four;
                    await Task.Delay(1000);

                    break;

                case CountingState.Four:
                    announcer.AnnounceAsync("Four", -5, 200);
                    countingState = CountingState.Three;
                    await Task.Delay(1000);

                    break;

                case CountingState.Three:
                    announcer.AnnounceAsync("Three", -5, 200);
                    countingState = CountingState.Two;
                    await Task.Delay(1000);

                    break;

                case CountingState.Two:
                    announcer.AnnounceAsync("Two", -5, 200);
                    countingState = CountingState.One;
                    await Task.Delay(1000);

                    break;

                case CountingState.One:
                    announcer.AnnounceAsync("One", -5, 200);
                    countingState = CountingState.Attack;
                    await Task.Delay(1000);

                    break;

                case CountingState.Attack:
                    announcer.AnnounceAsync("Attack", 10, 200);
                    countingState = CountingState.Defense;
                    await Task.Delay(1000);

                    break;

                case CountingState.Defense:
                    announcer.AnnounceAsync("Defense", 10, 200);
                    countingState = CountingState.Six;
                    await Task.Delay(1000);

                    break;

                case CountingState.None:
                default:
                    break;
                }
            }
        }