//Create a function to fire event public void RaiseEvent(GameboardEventArgs e) { if (GameboardEvent != null) { GameboardEvent(this, e); } }
//Create a function to raise/fire gameboard event public void RaiseEvent(GameboardEventArgs e) { //Only execute if there are event listener listing to events if (GameEventHandler != null) { GameEventHandler(this, e); } }
//Override the On Click Mine Event Handler, Do not call the base.OnCollectObject(); public override void OnCollectObject(object sender, GameboardEventArgs e) { //Check event type if (e.GameboardEvent != GAME_EVENT.COLLECT_OBJECT) { return; } //Show all the mine board.ShowAllMine(); //Fire gameover event board.RaiseEvent(new GameboardEventArgs(GAME_EVENT.GAMEOVER)); }
//On CollectObject/ ClickMine Event Handler, only multiplayer game mode use it public virtual void OnCollectObject(Object sender, GameboardEventArgs e) { //Check event type if (e.GameboardEvent != GAME_EVENT.COLLECT_OBJECT) { return; } //Add score to the current player gameBoard.Players[gameBoard.Turn].Score++; //Update the score label gameBoard.TopBannerHUD.UpdateScore(gameBoard.Turn, gameBoard.Players[gameBoard.Turn].Score); //Flag the mine SetTileImage("F"); //If player has found more than half of the mines, gameover if (gameBoard.Players[gameBoard.Turn].Score > gameBoard.Mine / 2) { gameBoard.RaiseEvent(new GameboardEventArgs(GAME_EVENT.GAMEOVER)); } }