// Show the win screen. private void showWinScreen(GameOverMessage message) { if ((this._gameOverText == null) || !message.win || this._winner) { return; } string animal = ""; switch (message.animal) { case 0: animal = "BUNNY"; break; case 1: animal = "FOXY"; break; case 2: animal = "BIRDY"; break; case 3: animal = "MOOZY"; break; default: Debug.Log("ERROR! Unknown model: " + message.animal); break; } this._winner = true; this._gameOverText.text = string.Format("WINNER WINNER {0} DINNER!\n\tPlacement: #1\t\tKills: {2}\n", animal, message.placement, message.kills); this._gameOverText.color = new Color(this._gameOverText.color.r, this._gameOverText.color.g, this._gameOverText.color.b, 1.0f); }
private void HandleMessage(byte[] data) { MessageType type = Message.GetMessageType(data); string DataAsText = Encoding.UTF8.GetString(data); Debug.Log($"received from server : {DataAsText}"); switch (type) { case MessageType.move: graphics.AskMove(); Debug.Log("asked a move"); break; case MessageType.gameOver: GameOverMessage gameOverMessage = new GameOverMessage(data); graphics.DisplayGameOver(gameOverMessage); break; case MessageType.grid: var grid = new Morpion3Dimension.Model.Grid(data); graphics.DisplayNewGrid(grid); break; default: Debug.Log(Encoding.UTF8.GetString(data)); break; } }
// Show the death screen. private void showDeathScreen(GameOverMessage message) { if ((this._gameOverText == null) || (this._spectateImage == null) || (this._spectateText == null) || message.win || this._winner || GameInfo.gamemode == "Deathmatch") { return; } if (message.killer == "KILLER_ID_FALL") { this._gameOverText.text = string.Format("YOU FELL TO YOUR DEATH!\n\tPlacement: #{0}\t\tKills: {1}\n", message.placement, message.kills); } else if (message.killer == "KILLER_ID_WALL") { this._gameOverText.text = string.Format("YOU WERE BURNED TO DEATH!\n\tPlacement: #{0}\t\tKills: {1}\n", message.placement, message.kills); } else if (message.killer == "KILLER_ID_WATER") { this._gameOverText.text = string.Format("YOU DROWNED!\n\tPlacement: #{0}\t\tKills: {1}\n", message.placement, message.kills); } else if (message.killer != "") { this._gameOverText.text = string.Format("YOU WERE KILLED BY {0}!\n\tPlacement: #{1}\t\tKills: {2}\n", message.killer, message.placement, message.kills); } else { this._gameOverText.text = string.Format("UNKNOWN CAUSE OF DEATH!\n\tPlacement: #{0}\t\tKills: {1}\n", message.placement, message.kills); } this._gameOverText.color = new Color(this._gameOverText.color.r, this._gameOverText.color.g, this._gameOverText.color.b, 1.0f); this._spectateImage.color = new Color(this._spectateImage.color.r, this._spectateImage.color.g, this._spectateImage.color.b, 1.0f); this._spectateText.color = new Color(this._spectateText.color.r, this._spectateText.color.g, this._spectateText.color.b, 1.0f); this.spectate(); }
private void handleMessage(byte[] data) { MessageType type = Message.GetMessageType(data); switch (type) { case MessageType.move: var move = inte.AskMove(); SendMove(move); break; case MessageType.gameOver: var mes = new GameOverMessage(data); inte.DisplayGameOver(mes); break; case MessageType.grid: var grid = new Grid(data); inte.DisplayNewGrid(grid); break; default: break; } }
public void SendGameOver(GameOverMessage message) { // Disable async receive StopDataReceiveLoop(); while (!_receivingDataEnd) { Thread.Sleep(0); } byte[] gameoverData = Util.SerializeUpdate(message); _socket.Send(gameoverData); IClientUpdate response = null; while (!(response is ClientStatusUpdate && (response as ClientStatusUpdate).Update == ClientUpdate.GameOverOk)) { byte[] buffer = new byte[512]; try { _socket.Receive(buffer); } catch (SocketException e) { break; } response = GetUpdate(buffer, 0, buffer.Length); } Console.WriteLine("Game over received OK"); }
private void OnGameOver(GameOverMessage obj) { foreach (var emitter in emitters) { emitter.ClearParticles(); emitter.emit = false; } }
void QueueGameOver(ScreenSide side, int points) { //Object.Instantiate(Resources.Load("GameOverMessage")); GameOverMessage instance = Instantiate(Resources.Load("GameOverMessage", typeof(GameOverMessage))) as GameOverMessage; instance.SetWinner(side); AudioManager.Play(AudioClipName.GameOver); }
/// <summary> /// Ends the game and displays the winner message /// </summary> /// <param name="winner">winning side</param> public void EndGame(ScreenSide winner) { // instantiate prefab and set score GameObject gameOverMessage = Instantiate(Resources.Load("GameOverMessage")) as GameObject; GameOverMessage gameOverMessageScript = gameOverMessage.GetComponent <GameOverMessage>(); gameOverMessageScript.SetWinner(winner); }
private void ShowWinnerAndCleanup(GameOverMessage message) { QueueAction(() => { ScenePanel.IsVisible = false; Dialog.ShowMessage("And the winner is: ".ToConsoleString() + message.WinnerDisplayName.ToGreen()).Then(Cleanup); }); }
void Gameover(ScreenSide side) { GameObject instance = Instantiate(Resources.Load("gameovermenu")) as GameObject; GameOverMessage game = instance.GetComponent <GameOverMessage>(); game.SetWinner(side); AudioManager.Play(AudioClipName.GameOver); }
public void TestGameOver() { var gameOv = new GameOverMessage(WinType.win, new Position[] { new Position(0, 0, 0), new Position(0, 0, 0), new Position(0, 0, 0) }); byte[] bytes = Encoding.UTF8.GetBytes(gameOv.MessageToString()); var gameOv2 = new GameOverMessage(WinType.win, new Position[] { new Position(0, 0, 0), new Position(0, 0, 0), new Position(0, 0, 0) }); Assert.AreEqual(gameOv.MessageToString(), gameOv2.MessageToString()); }
private void OnGameOver(GameOverMessage message) { Entity player = this.EntityWorld.TryFindEntityByName(EntityNames.Player); if (player) { CPlayerInfo playerInfo = player.Get<CPlayerInfo>(); HighscoreHelper.SubmitScore(playerInfo.Score); } }
/// <summary> /// Ends the game /// </summary> void EndGame() { // instantiate prefab and set score GameObject gameOverMessage = Instantiate(Resources.Load("GameOverMessage")) as GameObject; GameOverMessage gameOverMessageScript = gameOverMessage.GetComponent <GameOverMessage>(); GameObject hud = GameObject.FindGameObjectWithTag("HUD"); HUD hudScript = hud.GetComponent <HUD>(); gameOverMessageScript.SetScore(hudScript.Score); }
// Update the player ranking. private void updateGameOver(GameOverMessage message) { if (this.isServer) { this.RpcUpdateGameOver(message); } else if (this.isClient) { this.CmdUpdateGameOver(message); } }
public void ProcessGameOverMessage(GameOverMessage m) { if (_Client == null) { return; } if (_GameOverMessageDelegate != null) { _GameOverMessageDelegate(); } }
public void OnGameOverEvent(GameOverMessage message) { Position[] winningSequence = message.winningSequence; foreach (Position p in winningSequence) { if ((x, y, z) == (p.x, p.y, p.z)) { Debug.Log("make cube spin bc game over"); this.animateWinSequence = true; } } }
public void SendGameOver(WinType winType, Position[] winningSequence) { var gameOver = new GameOverMessage(winType, winningSequence); var data = Encoding.UTF8.GetBytes(gameOver.MessageToString()); try { stream.Write(data, 0, data.Length); } catch (System.IO.IOException e) { } }
public override void Process() { if (World.Instance.ControlledCar.HealthPoints == 0 && !IsGameOver) { this.IsGameOver = true; var result = GameOverMessage.Show(null); result.ContinueWith(x => { this.IsGameOver = false; World.Instance.ControlledCar.Reset(); }); } }
// Ctor. public GameManager(string[] settings, DrawBoard drawBoardDelegate, DrawFigure drawFigureDelegate, GameOverMessage gameOverMessageDelegate, UpdateTimeLimit updateTimeLimitDelegate, DrawBFLimits DrawBFLimitsDelegate) { // Set variables boardSize = int.Parse(settings[0]); stripeLengthToWin = int.Parse(settings[1]); player1Type = (PlayerType)(int.Parse(settings[2])); player2Type = (PlayerType)(int.Parse(settings[3])); deDrawBoard = drawBoardDelegate; deDrawFigure = drawFigureDelegate; deGameOver = gameOverMessageDelegate; deUpdateTimeLimit = updateTimeLimitDelegate; deDrawBFLimits = DrawBFLimitsDelegate; timeLimit = new TimeSpan(0, 0, int.Parse(settings[4])); }
IEnumerator waitThenReload() { yield return(new WaitForSeconds(waitTime)); GameObject obj = new GameObject("GameOverMessage"); obj.tag = "GameOverMessage"; DontDestroyOnLoad(obj); GameOverMessage message = obj.AddComponent <GameOverMessage>(); message.completedCaves = this.completedCaves; Application.LoadLevel("GameOverScene"); }
public virtual void GameOver(bool forceOver) { var msg = GameOverMessage.Allocate(); msg.HallRoomId = this.HallRoomId; if (!forceOver) { try { foreach (var player in _dictPlayers.Values) { var gameOverPlayer = GameOverPlayer.Allocate(); SetGameOverPlayerValue(gameOverPlayer, player); //_gameStatisticData.SetStatisticData(gameOverPlayer, playerInfo, _contexts.session.commonSession.FreeArgs); msg.Players.Add(gameOverPlayer); } if (_dictGoPlayers.Count > 0) { foreach (var gameOverPlayer in _dictGoPlayers.Values) { msg.Players.Add(gameOverPlayer); } } msg.TotalPlayer = _dictPlayers.Count + _dictGoPlayers.Count; } catch (Exception e) { _logger.ErrorFormat("GameOver ... Error:{0}", e.StackTrace); } } else { Dispose(); } IFreeRule rule = _contexts.session.commonSession.FreeArgs.Rule; msg.BattleStartTime = rule.StartTime + rule.GameStartTime; msg.BattleEndTime = rule.StartTime + rule.GameEndTime; var evt = RoomEvent.AllocEvent <GameOverEvent>(); evt.HallRoomId = HallRoomId; evt.Message = msg; _dispatcher.AddEvent(evt); }
// // GUI methods, updates and displays information on the screen. // // The game has ended, show the win or death screen respectively. private void showGameOverScreen(GameOverMessage message) { if (!this.isLocalPlayer) { return; } if (message.win) { this.showWinScreen(message); } else { this.showDeathScreen(message); } }
public void DisplayGameOver(GameOverMessage gameOverMessage) { if (gameOverMessage.winType == WinType.win) { if (WinEvent != null) { WinEvent(gameOverMessage); } } if (gameOverMessage.winType == WinType.lose) { if (WinEvent != null) { WinEvent(gameOverMessage); } } }
public AbstractMessage Parse(string input) { Regex regex = new Regex(pattern); if (regex.IsMatch(input)) { var message = new GameOverMessage(); var match = regex.Match(input); message.GameMode = match.Groups["gameMode"].Value; message.Map = match.Groups["map"].Value; message.Score = match.Groups["score"].Value; int.TryParse(match.Groups["duration"].Value, out int duration); message.Duration = duration; return(message); } return(null); }
public virtual void GameOver(bool forceOver) { var msg = GameOverMessage.Allocate(); msg.HallRoomId = this.HallRoomId; if (!forceOver) { try { foreach (var player in _dictPlayers.Values) { var gameOverPlayer = GameOverPlayer.Allocate(); SetGameOverPlayerValue(gameOverPlayer, player); //_gameStatisticData.SetStatisticData(gameOverPlayer, playerInfo, _contexts.session.commonSession.FreeArgs); msg.Players.Add(gameOverPlayer); _logger.InfoFormat("游戏结束时战报玩家ID {0} 排名 {1}", gameOverPlayer.Id, gameOverPlayer.Statistics[1]); } if (_dictGoPlayers.Count > 0) { foreach (var gameOverPlayer in _dictGoPlayers.Values) { msg.Players.Add(gameOverPlayer); } } _logger.InfoFormat("游戏结束时战报玩家数 {0}", msg.Players.Count); } catch (Exception e) { _logger.ErrorFormat("GameOver ... Error:{0}", e.StackTrace); } } Dispose(); var evt = RoomEvent.AllocEvent <GameOverEvent>(); evt.HallRoomId = HallRoomId; evt.Message = msg; _dispatcher.AddEvent(evt); }
public override void DoAction(IEventArgs args) { var msg = GameOverMessage.Allocate(); msg.HallRoomId = args.GameContext.session.commonSession.RoomInfo.HallRoomId; FreeGameRule rule = (FreeGameRule)args.Rule; foreach (PlayerEntity player in args.GameContext.player.GetInitializedPlayerEntities()) { SimpleParable sp = new SimpleParable(); SimpleParaList paras = new SimpleParaList(); sp.SetList(paras); var gameOverPlayer = GameOverPlayer.Allocate(); paras.AddFields(new ObjectFields(gameOverPlayer)); gameOverPlayer.Id = player.playerInfo.PlayerId; args.Act(action, new TempUnit[] { new TempUnit("basic", sp) }); } }
// Tell the player the end game stats. private void sendGameOverMessage(int id, int killerID = -1, bool win = true) { GameOverMessage message = new GameOverMessage(); switch ((KillerID)killerID) { case KillerID.KILLER_ID_FALL: message.killer = "KILLER_ID_FALL"; break; case KillerID.KILLER_ID_WALL: message.killer = "KILLER_ID_WALL"; break; case KillerID.KILLER_ID_WATER: message.killer = "KILLER_ID_WATER"; break; default: message.killer = (killerID >= 0 ? this._players[killerID].name : ""); break; } message.name = this._players[id].name; message.animal = this._players[id].animal; message.placement = this._players[id].placement; message.kills = this._players[id].kills; message.win = this._players[id].win; NetworkServer.SendToClient(id, (short)NetworkMessageType.MSG_GAME_OVER, message); }
// Use this for initialization void Start() { GameObject obj = GameObject.FindGameObjectWithTag("GameOverMessage"); if (obj != null) { GameOverMessage message = obj.GetComponent <GameOverMessage>(); score.text = message.completedCaves.ToString(); string ranking = ""; for (int i = 0; i < rankingScores.Length; i++) { if (rankingScores[i] <= message.completedCaves) { ranking = rankings[i]; } } rankingText.text = ranking; Destroy(obj); } }
public void GameOverMessage() { var message = new GameOverMessage(NetworkId.Generate()); Assert.NotNull(SerializeAndBack(message)); }
protected Message getMessage() { byte[] b; int avail; try { //while we're here, look for data in the buffer avail = _sock.Available; if (avail > 0) { buffer.ReadFromSocket(_sock, avail); this.BytesReceived += avail; } //first see if we can actually decode something if (buffer.CanDecode()) { b = buffer.Decode(); } else { return(null); } } catch (Exception ex) { PhazeXLog.LogError(ex, GameLibraryVersion.VersionString, 104); _connected = false; return(null); } Message m = null; if (b.Length == 0) { return(m); } else if (b[0] == (byte)pxMessages.Heartbeat) { m = new HeartBeatMessage(b); } else if (b[0] == (byte)pxMessages.ChangeName) { m = new ChangeNameMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.ChangeNameReject) { m = new ChangeNameRejectMessage(b); } else if (b[0] == (byte)pxMessages.Chat) { m = new ChatMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.CompletedPhaze) { m = new CompletedPhazeMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.CurrentPhaze) { m = new CurrentPhazeMessage(b, this.GameRules); } else if (b[0] == (byte)pxMessages.DiscardSkip) { m = new DiscardSkipMessage(b, this.GetPlayerIDs(), this.GameRules); } else if (b[0] == (byte)pxMessages.DialogMessage) { m = new DialogMessage(b); } else if (b[0] == (byte)pxMessages.ErrorMessage) { m = new ErrorMessage(b); } else if (b[0] == (byte)pxMessages.GameOver) { m = new GameOverMessage(b); } else if (b[0] == (byte)pxMessages.GameRules) { m = new GameRulesMessage(b); } else if (b[0] == (byte)pxMessages.GameStarting) { m = new GameStartingMessage(b); } else if (b[0] == (byte)pxMessages.Goodbye) { m = new GoodbyeMessage(b); } else if (b[0] == (byte)pxMessages.GotCards) { m = new GotCardsMessage(b, this.GameRules); } else if (b[0] == (byte)pxMessages.GotDeckCard) { m = new GotDeckCardMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.GotDiscard) { m = new GotDiscardMessage(b, this.GetPlayerIDs(), this.GameRules); } else if (b[0] == (byte)pxMessages.Hand) { m = new HandMessage(b, this.GameRules); } else if (b[0] == (byte)pxMessages.Login) { m = new LoginMessage(b); } else if (b[0] == (byte)pxMessages.LoginAcknowledgment) { m = new LoginAckMessage(b); } else if (b[0] == (byte)pxMessages.LogOff) { m = new LogOffMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.NewHand) { m = new NewHandMessage(b); } else if (b[0] == (byte)pxMessages.PlayedCardOnTable) { m = new PlayedCardOnTableMessage(b, this.GetPlayerIDs(), this.GameRules); } else if (b[0] == (byte)pxMessages.Ready) { m = new ReadyMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.Scoreboard) { m = new ScoreboardMessage(b, this.GetPlayerIDs(), this.GameRules); } else if (b[0] == (byte)pxMessages.SkipNotification) { m = new SkipNotificationMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.StartGameTimer) { m = new StartGameTimerMessage(b); } else if (b[0] == (byte)pxMessages.Status) { m = new StatusMessage(b, this.GetPlayerIDs(), this.GameRules); } else if (b[0] == (byte)pxMessages.SystemMessage) { m = new SystemMessage(b); } else if (b[0] == (byte)pxMessages.Table) { m = new TableMessage(b, this.GameRules); } else if (b[0] == (byte)pxMessages.TurnEnd) { m = new TurnEndMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.TurnStart) { m = new TurnStartMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.UpdateDiscard) { m = new UpdateDiscardMessage(b, this.GetPlayerIDs(), this.GameRules); } else if (b[0] == (byte)pxMessages.WentOut) { m = new WentOutMessage(b, this.GetPlayerIDs()); } else if (b[0] == (byte)pxMessages.Won) { m = new WonMessage(b, this.GetPlayerIDs()); } else { m = new UnknownMessage(b); } return(m); }
private void OnGameOver(GameOverMessage obj) { _rigidBody.isKinematic = true; enabled = false; }
public void Toast(GameOverMessage message) { content.text = message.Winner == Player.None ? "Draw!" : string.Format("{0} wins!", message.Winner); animator.SetTrigger("doToast"); }
private void OnGameOver(GameOverMessage obj) { enabled = false; }
private void OnGameOver(GameOverMessage obj) { GameOver(); }
private void OnGameOverMessage(GameOverMessage gameOverMessage) { GameOverScreen.Instance.Set(gameOverMessage.statsTransmission); }
private void OnGameOver(GameOverMessage obj) { replayQueue.Add(currentQueue); currentQueue = null; }
private void OnGameOver(GameOverMessage obj) { gameOverText.enabled = true; instructionText.enabled = true; enabled = true; }
protected virtual void OnGameOver(GameOverMessage obj) { enabled = false; }
private void OnGameOver(GameOverMessage obj) { _gameOver = true; }
private void OnGameOver(GameOverMessage message) { _statsManager.Save(); }
private void OnGameOver(GameOverMessage message) { this.GameOver.InvokeIfNotNull(); }
private void OnGameOver(GameOverMessage obj) { _gameObject.SetActive(false); }