public override void OnStateEnter() { base.OnStateEnter(); if (_data == null) { Helpers.Utility.LogError("_data shouldn't be null in OnStateEnter of " + this.GetType().ToString()); } else { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters = _data as Dictionary <string, object>; if (parameters.ContainsKey(PRIVATE_CHALLENGE_TYPE)) { privateChallengeArgs = (Events.PrivateChallengeArgs)parameters[PRIVATE_CHALLENGE_TYPE]; } } eventListener = GetComponent <EventListenerForPrivateChallenge>(); if (!eventListener.enabled) { eventListener.enabled = true; } ConnectionController.Instance.M3OnConnectedToMaster += _onConnectedToMaster; ConnectionController.Instance.M3OnJoinedLobby += _onJoinedLobby; ConnectionController.Instance.M3OnJoinedRoom += _onJoinedRoom; ConnectionController.Instance.M3OnPhotonPlayerDisconnected += _onPlayerDisconnected; ConnectionController.Instance.M3OnPhotonJoinRoomFailed += _onPhotonRandomJoinFailed; ConnectionController.Instance.M3OnPhotonRandomJoinFailed += _onPhotonRandomJoinFailed; ConnectionController.Instance.M3OnDisconnectedFromPhoton += _onDisconnectedFromPhoton; //EventManager Hookup Events.EventManager.Instance.PrivateChallengeMessageHandler += _onPrivateChallengeMessage; Events.EventManager.Instance.PrivateChallengeBusyHandler += _onPrivateChallengeBusyHandler; Events.EventManager.Instance.PrivateChallengeIgnoreHandler += _onPrivateChallengeIgnoreHandler; Events.EventManager.Instance.PrivateChallengeYesHandler += _onPrivateChallengeYesHandler; Events.EventManager.Instance.PrivateChallengeNoHandler += _onPrivateChallengeNoHandler; Events.EventManager.Instance.PrivateChallengeStartBattleHandler += _onPrivateChallengeStartBattleHandler; if (ConnectionController.Instance.ConnectedAndOnline) { DoTryToJoinRoomWithUserId(privateChallengeArgs.OpponentUserId); } else { Helpers.Utility.LogError("Not Connected to PhotonServer" + this.GetType().ToString()); DoHideVersusScreen(); StateMachine.Instance.MakeTransition(typeof(StateInitialize)); } }
void _onPrivateChallengeMessage(object sender, Events.ChallengeArgs args) { Events.PrivateChallengeArgs privateChallengeArgs = new Events.PrivateChallengeArgs(args.OtherPlayer.M3UserId(), args.OtherPlayer.M3NickName(), args.OtherPlayer.M3Trophies().ToString(), args.OtherPlayer.M3GuildName(), args.OtherPlayer.M3FacebookId(), args.BattleType); if ((args.BattleType & BattleType.FacebookMaskForCheck) > 0) { StateMachine.Instance.MakeTransition(typeof(StateReceivedChallengeFacebook), privateChallengeArgs); } else if ((args.BattleType & BattleType.GuildMaskForCheck) > 0) { StateMachine.Instance.MakeTransition(typeof(StateReceivedChallengeGuild), privateChallengeArgs); } else { //mode not supported ConnectionController.Instance.KickPlayer(args.OtherPlayer); //kick Player } }
void _OnChallengeButtonPressed(object sender, Events.PrivateChallengeArgs privateChallenge) { //UnityEngine.GameObject button = sender as UnityEngine.GameObject; BattleType challengeType = privateChallenge.BattleType; if ((challengeType & BattleType.FriendlyMaskForCheck) > 0) { //This is a Friendly Battle if ((challengeType & BattleType.FacebookFriendly) > 0) { VersusScreen.Instance.StartAnimationForFriendlyChallenge(); StateMachine.Instance.MakeTransition(typeof(StateSendChallengeFacebook), new Dictionary <string, object>() { { StateSendChallengeBase.PRIVATE_CHALLENGE_TYPE, privateChallenge } } ); } else if ((challengeType & BattleType.GuildPrivateFriendly) > 0) { VersusScreen.Instance.StartAnimationForFriendlyChallenge(); StateMachine.Instance.MakeTransition(typeof(StateSendChallengeGuild), new Dictionary <string, object>() { { StateSendChallengeBase.PRIVATE_CHALLENGE_TYPE, privateChallenge } } ); } else if ((challengeType & BattleType.GuildFriendly) > 0) { Helpers.Utility.LogMessage("_OnChallengeButtonPressed: Guild Challenge is not supported yet."); } else { Helpers.Utility.LogMessage("_OnChallengeButtonPressed: This Challenge Type is not supported yet."); } } }
public override void OnStateExit() { privateChallengeArgs = null; ConnectionController.Instance.M3OnConnectedToMaster -= _onConnectedToMaster; ConnectionController.Instance.M3OnJoinedLobby -= _onJoinedLobby; ConnectionController.Instance.M3OnJoinedRoom -= _onJoinedRoom; ConnectionController.Instance.M3OnPhotonPlayerDisconnected -= _onPlayerDisconnected; ConnectionController.Instance.M3OnPhotonJoinRoomFailed -= _onPhotonRandomJoinFailed; ConnectionController.Instance.M3OnPhotonRandomJoinFailed -= _onPhotonRandomJoinFailed; ConnectionController.Instance.M3OnDisconnectedFromPhoton -= _onDisconnectedFromPhoton; //EventManager Hookup Events.EventManager.Instance.PrivateChallengeMessageHandler -= _onPrivateChallengeMessage; Events.EventManager.Instance.PrivateChallengeBusyHandler -= _onPrivateChallengeBusyHandler; Events.EventManager.Instance.PrivateChallengeIgnoreHandler -= _onPrivateChallengeIgnoreHandler; Events.EventManager.Instance.PrivateChallengeYesHandler -= _onPrivateChallengeYesHandler; Events.EventManager.Instance.PrivateChallengeNoHandler -= _onPrivateChallengeNoHandler; Events.EventManager.Instance.PrivateChallengeStartBattleHandler -= _onPrivateChallengeStartBattleHandler; base.OnStateExit(); }
public override void OnStateEnter() { base.OnStateEnter(); #if !UNITY_WEBGL if (M3Utils.Instance.IsFizzOpen) { FIZZ.FIZZUISDK.Instance.Close(); } #endif if (_data == null) { Helpers.Utility.LogError("_data shouldn't be null in OnStateEnter of " + this.GetType().ToString()); } else { privateChallengeArgs = (Events.PrivateChallengeArgs)_data; } eventListener = GetComponent <EventListenerForPrivateChallenge>(); if (!eventListener.enabled) { eventListener.enabled = true; } ConnectionController.Instance.M3OnConnectedToMaster += _onConnectedToMaster; ConnectionController.Instance.M3OnPhotonPlayerDisconnected += _onPlayerDisconnected; //EventManager Hookup Events.EventManager.Instance.PrivateChallengeBusyHandler += _onPrivateChallengeBusyHandler; Events.EventManager.Instance.PrivateChallengeIgnoreHandler += _onPrivateChallengeIgnoreHandler; Events.EventManager.Instance.PrivateChallengeYesHandler += _onPrivateChallengeYesHandler; Events.EventManager.Instance.PrivateChallengeNoHandler += _onPrivateChallengeNoHandler; Events.EventManager.Instance.PrivateChallengeStartBattleHandler += _onPrivateChallengeStartBattleHandler; DoCloseAndHideTheRoom(); //do not let other people to come to this room }