public override void Update() { if (Main.Instance.uIManager == null) { GameObject uiManagerGo = GameObject.Instantiate(ResourceManager.Instance.LoadAsset <UnityEngine.Object> ("UI/UiManager")) as GameObject; if (uiManagerGo == null) { QLogger.LogErrorAndThrowException("UiManager was not instantiated"); } Main.Instance.uIManager = uiManagerGo.GetComponent <UIManager>(); if (Main.Instance.uIManager == null) { QLogger.LogErrorAndThrowException("UiManager script was not instantiated"); } if (QLogger.CanLogInfo) { QLogger.LogInfo("UI manager was instantiated"); } ResourceManager.Instance.LoadLevel("Lobby", true, delegate() { Main.Instance.gameStateManager.SetGameState(GameStateManager.GameStates.Frontend, null); }, true ); } }
public void AddMapping(T state1, T state2) { if (GetKeyValueMap(state1, state2) != null) { QLogger.LogErrorAndThrowException("We already have a mapping between " + state1.ToString() + state2.ToString()); } stateMapping.Add(new MyKeyValuePair <T, T>(state1, state2)); }
public void RegisterState(T key, FSMState state) { if (!typeof(T).IsEnum) { QLogger.LogErrorAndThrowException("TEnum must be an enum."); } if (statesDictionary.ContainsKey(key)) { QLogger.LogErrorAndThrowException("Already contains key " + key.ToString()); } statesDictionary.Add(key, state); }
void SetNextState() { if (currentState.HasValue) { if (GetKeyValueMap(currentState.Value, nextState.Value) == null) { QLogger.LogErrorAndThrowException("There is no mapping between " + currentState.Value.ToString() + " and " + nextState.Value.ToString()); nextState = null; return; } } //set current to peviousState previousState = currentState; //exit previousState if (previousState.HasValue) { if (QLogger.CanLogInfo) { QLogger.LogInfo(string.Format("FSM:On Exit called for \"{0}\" state ", previousState.Value)); } statesDictionary[previousState.Value].OnExit(); } //set currentState to Next currentState = nextState; //enter current state if (currentState.HasValue) { if (QLogger.CanLogInfo) { QLogger.LogInfo(string.Format("FSM:On Enter called for \"{0}\" state ", currentState.Value)); } statesDictionary[currentState.Value].OnEnter(); statesDictionary[currentState.Value].OnContext(contextForNextState /* this can be null if there is no context */); } //set nextState to Null nextState = null; contextForNextState = null; }
public override void OnContext(System.Object context) { base.OnContext(context); collisionProcessor = new CollisionProcessor(); GameObject voxelCharacter = GameObject.Instantiate(ResourceManager.Instance.LoadAsset <UnityEngine.Object> ("Characters/VoxelGirl/MainCharacter")) as GameObject; if (voxelCharacter == null) { QLogger.LogErrorAndThrowException("VoxelGirl is not instantiated"); } // Main.Instance.uIManager = uiManagerGo.GetComponent<UIManager>(); // if ( Main.Instance.uIManager == null ) QLogger.LogErrorAndThrowException ( "UiManager script was not instantiated"); player = new iPlayer(); CharacterController controller = new CharacterController(); controller.Init(voxelCharacter, player); WeaponController weaponController = new WeaponController(); player.Init(controller, weaponController); CollisionListener playerCollisionListener = voxelCharacter.GetComponentInChildren <CollisionListener>(); Core.QLogger.Assert(playerCollisionListener != null); playerCollisionListener.Init(collisionProcessor.ProcessCollision, player); cameraScript = GameObject.Find("ThirdPersonCamera").GetComponent <ThirdPersonCamera>(); cameraScript.SetCharacterToFollow(voxelCharacter.transform); player.EquipWeapon(eInventoryItem.Pistol); Core.Updater.Instance.FixedUpdater += FixedUpdate; Core.Updater.Instance.LateUpdater += LateUpdate; }