private void Handle(GameCompleted e) { GameReadModel grm = this._context.Games.FirstOrDefault(game => game.Id == e.Id); grm.IsCompleted = true; this._context.SaveChanges(); }
public ActionResult Complete(int score) { ViewBag.ModuleID = ((UserGameSession)Session["userGameSession"]).gameModule.ModuleID; Score newScore = new Score(score, ((UserGameSession)Session["userGameSession"]).gameModule.ModuleID, ((UserGameSession)Session["userGameSession"]).GameSettings.Questions); string error = ""; SaveScore(newScore, error); GameCompleted resultScreen = new GameCompleted(); resultScreen.correctAnswers = newScore.CorrectAnswers; resultScreen.totalQuestions = newScore.TotalAnswers; if (error != "") { resultScreen.errorMessage = error; } using (Repos repo = new Repos()) { var dbScores = repo.GetTop10Scores(((UserGameSession)Session["userGameSession"]).gameModule.ModuleID); foreach (var dbs in dbScores) { resultScreen.Top10Scores.Add(dbs); } } return(View(resultScreen)); }
public void MakeGuess(string guess) { GuessMade e = new GuessMade(Guid.NewGuid().ToString(), this.Id, guess, this.Level); e.Handle(this); PublishEvent(e); if (CurrentRiddle.Solution.Trim().Equals(guess)) { bool completed = this.Level == MaxLevel; int nextLevel = completed ? this.Level : this.Level + 1; IEvent levelSucceeded = new LevelSucceeded(this.Id, this.Level, nextLevel, this.Score + 1 * Level, e.GuessId); levelSucceeded.Handle(this); PublishEvent(levelSucceeded); if (completed) { IEvent gameCompleted = new GameCompleted(this.Id); gameCompleted.Handle(this); PublishEvent(gameCompleted); } } else { int newScore = (this.Score - 1) < 0 ? 0 : this.Score - 1; IEvent levelFailed = new LevelFailed(this.Id, newScore, e.GuessId); levelFailed.Handle(this); PublishEvent(levelFailed); } }
public void Start() { GameStarted.Raise(this, new BigTwoEventArgs()); DealHands(); var activePlayerIndex = 0; PlayedCards activeCards = null; // while all players have at least one card the game continues while (players.All(p => p.CardCount > 0)) { IPlayer activePlayer = players[activePlayerIndex]; PlayerTurnStart.Raise(this, new BigTwoPlayerEventArgs(activePlayer)); // If the active cards belong to the active player, It means that // all other players have passed meaning this player has won the sequence. if (activeCards != null && activePlayer == activeCards.Player) { // clear the active card to start a new sequence. SequenceCompleted.Raise(this, new BigTwoPlayerEventArgs(activeCards.Player)); activeCards = null; } PlayedCards nextCards = activePlayer.PlayTurn(activeCards); PlayerPlayedTurn.Raise(this, new BigTwoPlayerHandEventArgs(activePlayer, nextCards)); // null is a passed turn if (nextCards != null) { // Ensure the cards the player is trying to play are valid nextCards.Validate(activeCards); activeCards = nextCards; // Remove the played cards from the players hand activePlayer.RemoveCards(nextCards); } // Advance to next player activePlayerIndex++; if (activePlayerIndex >= players.Count) { activePlayerIndex = 0; } PlayerTurnEnd.Raise(this, new BigTwoPlayerEventArgs(activePlayer)); } // Get the winner and notify everyone that the game is over! IPlayer winner = players.Single(p => p.CardCount == 0); GameCompleted.Raise(this, new BigTwoPlayerEventArgs(winner)); }
private void InvokeGameCompleted() { GameManager.Instance.ChangePauseState(this, false); if (currentResult != GameResult.None) { GameCompleted?.Invoke(LevelManager.Instance.SelectedChapter, LevelManager.Instance.CurrentLevel, LevelManager.Instance.SelectedLevel.GetCurrentStar().Number, CurrentScore, currentResult, LevelManager.Instance.DailyChallenge); } currentResult = GameResult.None; }
// Call this when the player completes the task public virtual void OnCompleted() { AddAudioSource(); if (GameCompleted != null) { if (onCompleteAudioClip != null) { audioSource.PlayOneShot(onCompleteAudioClip); } GameCompleted.Invoke(); } }
private void GameTick(object sender, EventArgs e) { if (!m_ComponentManager.HasWinner) { m_ComponentManager.Update(); Refresh(); } else { GameTimer.Stop(); GameCompleted?.Invoke(this); } }
void Start() { player = GameObject.FindWithTag("Player"); facingRight = true; soundManager = FindObjectOfType <SoundManager>(); levelTransition = FindObjectOfType <LevelTransition>(); levelCompleted = FindObjectOfType <LevelCompleted>(); gameCompleted = FindObjectOfType <GameCompleted>(); gameOver = FindObjectOfType <GameOver>(); playerDied = FindObjectOfType <PlayerDied>(); collectiblesManager = FindObjectOfType <CollectiblesManager>(); lifeManager = FindObjectOfType <LifeManager>(); saveData = FindObjectOfType <SaveData>(); rigidBody = GetComponent <Rigidbody2D>(); animator = GetComponent <Animator>(); }
void Reload(string serializedBoard) { if (string.IsNullOrWhiteSpace(serializedBoard)) { return; } var lines = serializedBoard.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (!lines.Any()) { return; } items.Clear(); foreach (var line in lines) { var values = line.Split(new string[] { ":" }, StringSplitOptions.None); var coordinateX = default(int); var coordinateY = default(int); if (int.TryParse(values[0], out coordinateX) && int.TryParse(values[1], out coordinateY)) { var shape = values[2]; items.Add(Tuple.Create(coordinateX, coordinateY, shape ?? string.Empty)); } } if (items.Count == 9) { GameCompleted?.Invoke(this, EventArgs.Empty); } else { Reloaded?.Invoke(this, EventArgs.Empty); } }
private void OnGameCompleted(EventArgs e) { GameCompleted?.Invoke(this, e); }
protected virtual void OnGameCompleted(Participant e) { GenerateRandomPuzzle(); GameCompleted?.Invoke(this, e); }
//document void Start() { explanationScreen = GameObject.Find("Explanation Screen").GetComponent <Canvas>(); rollScreen = GameObject.Find("Roll Screen").GetComponent <Canvas>(); messageScreen = GameObject.Find("Message Screen").GetComponent <Canvas>(); winScreen = GameObject.Find("Win Screen").GetComponent <Canvas>(); selectMoveScreen = GameObject.Find("Select Move Screen").GetComponent <Canvas>(); nextTurnButton = GameObject.Find("Next Turn Button").GetComponent <Button>(); defaultOKButton = GameObject.Find("Default OK Button").GetComponent <Button>(); specialOKButton = GameObject.Find("Special OK Button").GetComponent <Button>(); moveOrderScreen = GameObject.Find("Move Order Screen").GetComponent <Canvas>(); setupScreen = GameObject.Find("Setup Screen").GetComponent <Canvas>(); nameInputField = GameObject.Find("Name Input Field").GetComponent <InputField>(); colorDropdown = GameObject.Find("Color Dropdown").GetComponent <Dropdown>(); languageDropdown = GameObject.Find("Language Dropdown").GetComponent <Dropdown>(); playerCountScreen = GameObject.Find("Player Count Screen").GetComponent <Canvas>(); infoScreen = GameObject.Find("Info Screen").GetComponent <Canvas>(); doMoveButton = GameObject.Find("Move Button").GetComponent <Button>(); noMoveButton = GameObject.Find("No Move Button").GetComponent <Button>(); //infoTitleText = GameObject.Find("Info Title Text").GetComponent<Text>(); //infoText = GameObject.Find("Info Text").GetComponent<Text>(); mainScreen = GameObject.Find("Main Screen").GetComponent <Canvas>(); optionsScreen = GameObject.Find("Options Screen").GetComponent <Canvas>(); GameData.LoadLanguageGameObjectText(); GameData.InitilializeLanguages(); messageText = GameObject.Find("Message Text").GetComponent <Text>(); rollButtonText = GameObject.Find("Roll Button Text").GetComponent <Text>(); rollTitleText = GameObject.Find("Roll Title Text").GetComponent <Text>(); winMenuText = GameObject.Find("Win to Menu Text").GetComponent <Text>(); winTitleText = GameObject.Find("Win Text").GetComponent <Text>(); selectMoveTitleText = GameObject.Find("Select Move Title Text").GetComponent <Text>();; nextTurnOKButtonText = GameObject.Find("Next Turn Button Text").GetComponent <Text>();; moveOrderTitleText = GameObject.Find("Move Order Title Text").GetComponent <Text>();; moveOrderText = GameObject.Find("Move Order Text").GetComponent <Text>(); moveOrderOKButtonText = GameObject.Find("Move Order OK Text").GetComponent <Text>(); setupTitleText = GameObject.Find("Setup Title Text").GetComponent <Text>(); playerCountTitleText = GameObject.Find("Player Count Title Text").GetComponent <Text>(); mainTitleText = GameObject.Find("Main Title Text").GetComponent <Text>(); mainPlayButtonText = GameObject.Find("Main Play Text").GetComponent <Text>(); mainRuleButtonText = GameObject.Find("Main Rules Text").GetComponent <Text>(); mainOptionsButtonText = GameObject.Find("Main Options Text").GetComponent <Text>(); mainCreditsButtonText = GameObject.Find("Main Credits Text").GetComponent <Text>(); optionsTitleText = GameObject.Find("Options Title Text").GetComponent <Text>(); optionsOKButtonText = GameObject.Find("Options OK Button Text").GetComponent <Text>(); optionsMusicLabel = GameObject.Find("Option Music Label").GetComponent <Text>(); optionsLanguageLabel = GameObject.Find("Option Language Label").GetComponent <Text>(); explanationOKButtonText = GameObject.Find("Explanation OK Button Text").GetComponent <Text>(); setupNameText = GameObject.Find("Setup Name Text").GetComponent <Text>(); setupColorText = GameObject.Find("Setup Color Text").GetComponent <Text>(); explanationText = GameObject.Find("Explanation Text").GetComponent <Text>(); setupOKButton = GameObject.Find("Setup OK Button").GetComponent <Text>(); messageDefaultOKButton = GameObject.Find("Message Default OK Button Text").GetComponent <Text>(); messageSpecialOKButton = GameObject.Find("Message Special OK Button Text").GetComponent <Text>(); optionsMergeCollideLabel = GameObject.Find("Option Merge Collide Label").GetComponent <Text>(); messageCharacterSprite = GameObject.Find("Message Character Image").GetComponent <Image>(); spriteSource = GameObject.Find("Sprite Holder").GetComponent <SpriteHolder>(); GUITextComponents = new List <Text>() { rollButtonText, rollTitleText, winMenuText, winTitleText, selectMoveTitleText, nextTurnOKButtonText, moveOrderTitleText, moveOrderText, moveOrderOKButtonText, setupTitleText, playerCountTitleText, mainTitleText, mainPlayButtonText, mainRuleButtonText, mainOptionsButtonText, mainCreditsButtonText, optionsTitleText, optionsMusicLabel, optionsOKButtonText, optionsLanguageLabel, explanationOKButtonText, setupNameText, setupColorText, setupOKButton, messageSpecialOKButton, messageDefaultOKButton, optionsMergeCollideLabel }; //analytics analyticsGameStarted = setupScreen.GetComponent <GameStarted>(); analyticsApplicationExited = this.gameObject.GetComponent <ApplicationExited>(); analyticsGameCompleted = GameObject.Find("Win Screen").GetComponent <GameCompleted>(); analyticsInitialPathChosen = GameObject.Find("Message Screen").GetComponent <InitialPathChosen>(); }
protected virtual void OnGameCompleted(FieldState e) { GameCompleted?.Invoke(this, e); }
public void RegisterListenerGameCompleted(GameCompleted listener) => listOfListenerGameCompleted += listener;