public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUILayout.Separator(); eventCode = (SpewEventCode)EditorGUILayout.EnumPopup("Event code", eventCode); for (int i = 0; i < commands.Length; ++i) { EditorGUILayout.BeginHorizontal(); commands[i] = EditorGUILayout.TextField("Player " + (i + 1), commands[i]); if (GUILayout.Button("Go")) { main.DebugEvent(eventCode, commands[i], i + 1); commands[i] = string.Empty; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Quick Start")) { main.QuickStart(); eventCode = SpewEventCode.SubmitClue; } }
public void DebugEvent(SpewEventCode eventCode, string content, int senderId) { if (eventCode == SpewEventCode.JoinRoom) { OnPhotonPlayerConnected(new PhotonPlayer(false, senderId, string.IsNullOrEmpty(content) ? "Player " + senderId : content)); } else { OnEvent((byte)eventCode, content, senderId); } }
public static void RaiseEvent(SpewEventCode eventCode, string content, int receiverId = -1) { var options = RaiseEventOptions.Default; if (receiverId != -1) { options.TargetActors = new int[] { receiverId }; } else { options.TargetActors = null; } Debug.Log("Raise event " + eventCode.ToString() + ": " + content); //Debug.Log("Raise event targetActors: " + (options.TargetActors == null? "NULL" : "Has stuff")); if (!PhotonNetwork.RaiseEvent((byte)eventCode, content, true, options)) { Debug.LogError("Event could not be sent"); } }
public void ReceiveEvent(SpewEventCode eventCode, string content, PlayerInfo player) { switch (m_state) { case State.Login: if (eventCode == SpewEventCode.StartGame) { StartGame(); } break; case State.Clues: if (eventCode == SpewEventCode.SubmitClue) { SubmitClue(player, content); } break; case State.Guess: if (eventCode == SpewEventCode.SubmitGuess) { SubmitGuess(content); } break; case State.Tally: if (eventCode == SpewEventCode.BooPlayer) { if (!playerScores.Any(p => p.boo.activeInHierarchy)) { int index = int.Parse(content); m_clues[index].booCount++; int count = m_clues.Count; if ((count == 3 && m_clues[index].booCount == 2) || (count != 3 && m_clues[index].booCount >= count / 2)) { foreach (var score in playerScores) { if (score.ID == m_clues[index].player.Id && !score.boo.activeInHierarchy) { score.boo.SetActive(true); m_clues[index].player.TotalScore -= m_clues[index].player.RoundScore; score.RefreshScore(); AudioManager.Instance.Play("Boo"); break; } } } } } break; case State.Final: if (eventCode == SpewEventCode.RestartGame) { StopTimer(); loginState.SetActive(true); finalState.SetActive(false); foreach (var p in m_playerList) { p.ResetScore(); } StartGame(); } else if (eventCode == SpewEventCode.NewPlayers) { StopTimer(); SetState(State.Intro); m_playerList.Clear(); } break; } }