void ProcessGameEvent(GameEvent gameEvent) { switch (gameEvent.type) { case GameEventType.LevelPause: PauseGame(); break; case GameEventType.ResumeLevel: ResumeGame(); break; //GameDialogue object display dialogue text by dialog id. case GameEventType.ShowGameDialogue: this.gameDialogueObject.OnGameEvent(gameEvent); break; case GameEventType.WhiteInScenarioCamera: case GameEventType.WhiteOutScenarioCamera: case GameEventType.TimeScaleOn: case GameEventType.TimeScaleOff: case GameEventType.ScenarioCameraOff: case GameEventType.ScenarioCameraOn: case GameEventType.PlayerCameraOn: case GameEventType.PlayerCameraOff: case GameEventType.PlayerCameraAudioListenerOff: case GameEventType.PlayerCameraAudioListenerOn: case GameEventType.ScenarioCameraAudioListenerOn: case GameEventType.ScenarioCameraAudioListenerOff: case GameEventType.StartDocking: case GameEventType.StartDockingOnRuntimeTarget: case GameEventType.PlayerCameraSlowMotionOnFixedPoint: case GameEventType.PlayerCameraSlowMotionOnTransform: case GameEventType.PlayerCameraSlowMotionOnPredefinedViewPointAndLookOnFixedPoint: case GameEventType.PlayerCameraSlowMotionOnPredefinedViewPointAndLookOnTransform: case GameEventType.ShiftToPlayerMode: case GameEventType.ShiftToScenarioMode: this.scenarioControlObject.OnGameEvent(gameEvent); break; case GameEventType.ApplyTopdownCameraParameter: case GameEventType.ResetTopdownCameraParameter: playerRuntimeCameraConfig.OnGameEvent(gameEvent); break; case GameEventType.PlayerSetToActive: player.SetActive(true); break; case GameEventType.PlayerSetToInactive: player.SetActive(false); break; case GameEventType.PlayerControlOn: case GameEventType.PlayerControlOff: case GameEventType.WhiteInPlayerCamera: case GameEventType.WhiteOutPlayerCamera: player.transform.root.BroadcastMessage("OnGameEvent", gameEvent, SendMessageOptions.DontRequireReceiver); break; case GameEventType.NPCPutToGround: Util.PutToGround(gameEvent.receiver.transform, this.GroundLayer, 0.1f); break; case GameEventType.NPCPlayAnimation: gameEvent.receiver.animation.Rewind(gameEvent.StringParameter); gameEvent.receiver.animation.Play(gameEvent.StringParameter); break; case GameEventType.NPCPlayQueueAnimation: foreach (string ani in gameEvent.StringParameter.Split(new char[] { ';' })) { gameEvent.receiver.animation.CrossFadeQueued(ani); } break; case GameEventType.NPCFaceToPlayer: gameEvent.receiver.transform.LookAt(new Vector3(player.transform.position.x, gameEvent.receiver.transform.position.y, player.transform.position.z)); break; case GameEventType.NPCStopPlayingAnimation: gameEvent.receiver.animation.Stop(gameEvent.StringParameter); break; case GameEventType.NPCStartAI: case GameEventType.NPCStartDefaultAI: gameEvent.receiver.SendMessage("OnGameEvent", gameEvent); break; case GameEventType.DeactivateGameObject: Util.DeactivateRecurrsive(gameEvent.receiver); // gameEvent.receiver.SetActive(false); break; case GameEventType.DestroyGameObject: Destroy(gameEvent.receiver, gameEvent.FloatParameter); break; case GameEventType.ActivateGameObject: Util.ActivateRecurrsive(gameEvent.receiver); // gameEvent.receiver.SetActive(true); break; case GameEventType.ActivateGameObjectIgnoreChildren: gameEvent.receiver.SetActive(true); break; case GameEventType.DeactivateGameObjectIgnoreChildren: gameEvent.receiver.SetActive(false); break; case GameEventType.SpecifiedSpawn: gameEvent.receiver.SendMessage("OnGameEvent", gameEvent); break; case GameEventType.InvokeMethod: //in case the receiver is destroyed in runtime. if (gameEvent.receiver == null) { break; } else { if (gameEvent.parameterType == ParameterType.None) { gameEvent.receiver.SendMessage(gameEvent.CustomMessage); } else if (gameEvent.parameterType == ParameterType.Int) { gameEvent.receiver.SendMessage(gameEvent.CustomMessage, gameEvent.IntParameter); } else if (gameEvent.parameterType == ParameterType.Float) { gameEvent.receiver.SendMessage(gameEvent.CustomMessage, gameEvent.FloatParameter); } else if (gameEvent.parameterType == ParameterType.String) { gameEvent.receiver.SendMessage(gameEvent.CustomMessage, gameEvent.StringParameter); } else if (gameEvent.parameterType == ParameterType.Bool) { gameEvent.receiver.SendMessage(gameEvent.CustomMessage, gameEvent.BoolParameter); } break; } case GameEventType.SetLanguage: SystemLanguage systemlanguage = (SystemLanguage)System.Enum.Parse(typeof(SystemLanguage), gameEvent.StringParameter); if (Persistence.GetPlayerLanguage() != systemlanguage) { Persistence.SetPlayerLanguage(systemlanguage); Debug.Log("Change language:" + systemlanguage); } break; case GameEventType.SetQuality: Persistence.SetPlayerQualityLevel(gameEvent.IntParameter); break; case GameEventType.LoadLevel: LoadLevel(gameEvent); break; case GameEventType.LoadNextLevel: LoadNextLevel(); break; case GameEventType.ContinueLastCheckPoint: ContinueLastCheckpoint(); break; case GameEventType.ReloadLevelWithCheckpoint: //Reload the current level with checkpoint ReloadCurrentLevel(true); break; case GameEventType.ReloadLevel: //Reload the current level ReloadCurrentLevel(false); break; case GameEventType.Mute: Persistence.Mute(); break; case GameEventType.UnMute: Persistence.Unmute(); break; case GameEventType.ForceToPhysicsCharacter: gameEvent.receiver.SendMessage("OnGameEvent", gameEvent); break; case GameEventType.PlayBackgroundMusic: case GameEventType.StopBackgroundMusic: backGroundMusicPlayer.OnGameEvent(gameEvent); break; case GameEventType.SaveCheckPoint: checkPointManager.CheckPointReach(gameEvent.StringParameter); break; case GameEventType.AttachObjectToSpecifiedParent: gameEvent.receiver.transform.parent = gameEvent.GameObjectParameter.transform; break; case GameEventType.DetachObjectFromParent: gameEvent.receiver.transform.parent = null; break; case GameEventType.SetPlayerControlDirectionPivot: this.ControlDirectionPivot = gameEvent.GameObjectParameter.transform; break; case GameEventType.AlignObjectToSpecifiedParent: gameEvent.receiver.transform.position = gameEvent.GameObjectParameter.transform.position; gameEvent.receiver.transform.rotation = gameEvent.GameObjectParameter.transform.rotation; break; case GameEventType.ActivateAllScriptsInObject: Util.ActivateMonoRecurrsive(gameEvent.receiver); break; case GameEventType.ActivateScriptByName: Util.ActivateMonobehaviorByName(gameEvent.receiver, gameEvent.StringParameter); break; } }