/*Only the server recieves this event.*/ public override void OnEvent(SelectSpellcaster evnt) { BoltConsole.Write("SERVER: Recieved a new character selection event"); if (evnt.RaisedBy != null) { //BoltConsole.Write("Sent by: " + evnt.RaisedBy.ToString()); //Get the connection as a string and update the dictionary using that as the key. string con = evnt.RaisedBy.ToString(); if (connection_spellcaster.ContainsKey(con)) { connection_spellcaster[evnt.RaisedBy.ToString()] = evnt.spellcasterID; } else { connection_spellcaster.Add(con, evnt.spellcasterID); } } // Let the gamestate know about the new selected spellcaster and the previous selected one (if any). gameStateEntity.GetComponent <NetworkGameState>() .onSpellcasterSelected(evnt.spellcasterID, evnt.previousID); //Show the start button to the host if all player's have selected their spellcaster if (gameStateEntity.GetComponent <NetworkGameState>().allPlayersSelected()) { startGameButton.SetActive(true); } }
/** * Events, any script can call these. * Initiates and sends a message across the network, either to the server or everyone. */ public void notifySelectSpellcaster(int spellcasterID, int previous) { localPlayerSpellcasterID = spellcasterID; var selected = SelectSpellcaster.Create(Bolt.GlobalTargets.OnlyServer); selected.spellcasterID = spellcasterID; selected.previousID = previous; selected.Send(); }