IEnumerator SpawnWaves()
    {
        waveNum = 0;

        while (true)
        {
            waveNum++;

            if (waveEvents.ContainsKey(waveNum))
            {
                waveEvents[waveNum].Invoke();
            }

            WaveSetting wave = SelectWave(waveNum);

            Debug.Log("Begin Wave " + waveNum + " (" + wave.Name + ")");

            OnRoundBegin?.Invoke(waveNum);
            waveInfoController.WaveNum = waveNum;

            //AlertText(wave.Name, Color.magenta);

            wave.WaveCallable?.Invoke();

            ScaledWave scaledWave = new ScaledWave(wave, Mathf.Pow(enemyScaleBase, waveNum - 1));

            while (scaledWave.HasEnemies)
            {
                List <GameObject> nextSet = scaledWave.GetNextSpawn();

                // single tick
                foreach (GameObject prefab in nextSet)
                {
                    // single spawn
                    GameObject newEnemy = Instantiate(prefab, Vector3.zero, Quaternion.identity);
                    enemiesSpawnedInWave.Enqueue(newEnemy);

                    yield return(new WaitForSeconds((timePerTick * Mathf.Pow(tickScaleBase, waveNum - 1)) / nextSet.Count));
                }

                yield return(new WaitForSeconds(timeBetweenTicks * Mathf.Pow(tickScaleBase, waveNum - 1)));
            }

            while (enemiesSpawnedInWave.Count > 0)
            {
                while (enemiesSpawnedInWave.Count > 0 && enemiesSpawnedInWave.Peek() == null)
                {
                    enemiesSpawnedInWave.Dequeue();
                }

                yield return(new WaitForSeconds(.5f));
            }

            OnRoundEnd?.Invoke(waveNum);

            waveInfoController.StartTimer(timeBetweenWaves);

            yield return(new WaitForSeconds(timeBetweenWaves));
        }
    }
    IEnumerator RoundCounter()
    {
        if (OnRoundCleanup != null)
        {
            OnRoundCleanup.Invoke();
        }

        NewPainting();
        NewTool();
        canvasAnimator.SetBool("Active", true);
        yield return(new WaitForSeconds(roundTime));

        if (OnRoundEnd != null)
        {
            OnRoundEnd.Invoke();
        }

        DiscardTool();

        originalCanvasAnimator.SetTrigger("Cycle");
        yield return(new WaitForSeconds(roundEndTime));

        canvasAnimator.SetBool("Active", false);

        if (nextPaintings.Count == 0)
        {
            EndGame();
        }
        else
        {
            yield return(new WaitForSeconds(betweenRoundTime));

            StartCoroutine(RoundCounter());
        }
    }
Example #3
0
        void RoundEnd()
        {
            OnRoundEnd?.Invoke();

            mCurMaxMove = 0;
            mAllMovableCheck.Clear();
            mCurSelectFrom = null;

            RecordCurrentGameToPref();
        }
Example #4
0
 public void EndRound()
 {
     OnRoundEnd?.Invoke(this);
     if (CurrentGamePlayerID == 1)
     {
         CurrentGamePlayerID = 2;
     }
     else
     {
         CurrentGamePlayerID = 1;
     }
     RoundStart();
 }
    private void Tile_OnPlayerAction(GameState lastGameState)
    {
        if (lastGameState == GameState.PLAYERX)
        {
            activeGameState = GameState.PLAYERO;
            OnGameStateChange?.Invoke(activeGameState);
        }
        else if (lastGameState == GameState.PLAYERO)
        {
            activeGameState = GameState.PLAYERX;
            OnGameStateChange?.Invoke(activeGameState);
        }
        //Check For WIN STATES
        if (CheckForWin(lastGameState) == Player.O)
        {
            activeGameState = GameState.WINO;
            OnGameStateChange?.Invoke(activeGameState);
            OnRoundEnd.Invoke(Player.O);
            StartCoroutine(SetUpNextRound(Player.O));
        }
        else if (CheckForWin(lastGameState) == Player.X)
        {
            activeGameState = GameState.WINX;
            OnGameStateChange?.Invoke(activeGameState);
            OnRoundEnd.Invoke(Player.X);
            StartCoroutine(SetUpNextRound(Player.X));
        } //Check for TIE
        else if (CheckForWin(lastGameState) == Player.None)
        {
            bool isTie = true;
            foreach (Tile tile in tiles)
            {
                if (tile.affiliation == Player.None)
                {
                    isTie = false;
                }
            }
            if (isTie)
            {
                OnRoundEnd.Invoke(Player.None);
                activeGameState = GameState.TIE;
                OnGameStateChange?.Invoke(activeGameState);
                StartCoroutine(SetUpNextRound(Player.None));
            }
        }

        if (lastGameState == GameState.PLAYERO || lastGameState == GameState.PLAYERX)
        {
            lastPlayerAction = (lastGameState == GameState.PLAYERO) ? GameState.PLAYERX : GameState.PLAYERO;
        }
    }
Example #6
0
        private void NextQuestion()
        {
            if (questionCounter >= questions.Count)
            {
                OnRoundEnd?.Invoke();
                return;
            }

            Question q = questions[questionCounter];

            currentQuestion = q;

            MediaAnswer answer = new MediaAnswer();

            if (q.AnswerVideoPath != null)
            {
                answer.AnswerVideoPath = q.AnswerVideoPath;
                answer.Kind            = AnswerKind.WithVideo;
            }
            else if (q.AnswerImagePath != null)
            {
                answer.AnswerImagePath = q.AnswerImagePath;
                answer.Kind            = AnswerKind.WithImage;
            }
            else
            {
                answer.Kind = AnswerKind.Simple;
            }

            if (q.VideoPath != null)
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.WithVideo, null, q.VideoPath, answer));
            }
            else if (q.ImagePath != null)
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.WithImage, null, q.ImagePath, answer));
            }
            else if (q.Answers != null)
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.WithAnswers, q.Answers, null, answer));
            }
            else
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.Simple, null, null, answer));
            }

            questionCounter++;
            isQuestionAnswered = true;
            isWrongAnswer      = false;
            isWrongPlayer      = false;
        }
Example #7
0
    /// <summary>
    /// Proceeds to the next thing in the turn order if
    /// there is one.
    /// </summary>
    private void Next()
    {
        turnEndRequested  = false;
        turnEndInProgress = true;

        // Notify that the current actor's turn is ending
        if (turnOrder.Current != null)
        {
            turnOrder.Current.OnTurnEnd();
            OnTurnEnd?.Invoke(turnOrder.Current);
        }

        // If the round hasn't started notify that a new one
        // is starting
        if (!roundStarted)
        {
            RoundCount++;
            OnRoundStart?.Invoke();
            roundStarted = true;
        }

        // Go to next thing in the turn order
        bool anyMore = turnOrder.MoveNext();

        // If there's nothing left in the order then the round has ended
        if (!anyMore)
        {
            roundStarted = false;
            turnOrder.Reset();
            OnRoundEnd?.Invoke();
        }

        // Otherwise, let the new thing know its turn is
        // starting
        else
        {
            // Notify the turn based thing FIRST - then other listeners.
            turnOrder.Current.OnTurnStart();
            OnTurnStart?.Invoke(turnOrder.Current);
        }

        turnEndInProgress = false;

        if (turnEndRequested)
        {
            Next();
        }
    }
Example #8
0
    private IEnumerator GameRoundRoutine()
    {
        gameStateText.text = $"Start Round {_roundCounter}";
        yield return(new WaitForSeconds(0.3f));

        gameStateText.text    = "";
        gameStateText.enabled = false;
        blocker.enabled       = false;
        _timeCounter          = roundDuration;
        _gameStartStamp       = Time.time;
        OnRoundStart?.Invoke(_roundCounter);
        for (_timeCounter = roundDuration; _timeCounter >= 0; --_timeCounter)
        {
            timeText.text = _timeCounter.ToString();
            yield return(_waitForTimerTick);
        }
        OnRoundEnd?.Invoke(_roundCounter);
    }
Example #9
0
 internal void RoundEndEvent()
 {
     OnRoundEnd?.Invoke(game);
 }
Example #10
0
 private static void EndRound(Player winner)
 {
     OnRoundEnd?.Invoke(winner);
     Eitrum.Engine.Core.Timer.Once(6f, Restart, ref endGameRestartRoutine);
 }
Example #11
0
        public static void InvokeRoundEnd()
        {
            OnRoundEnd roundEndEvent = RoundEndEvent;

            roundEndEvent?.Invoke();
        }
Example #12
0
 internal void RoundEnd(RoundLogic logic)
 {
     OnRoundEnd?.Invoke(this, new RoundEventArgs(logic));
 }