//void Update () {} public void refreshState() { GameStateBase currentState = gameController.GetCurrentState(); if (currentState is InGameState) { disableButton(); } else { if (currentState.gameObject.GetComponent <WorkBench>() != null) { enableButton(); //actionText.text="Utilizar"; } else if (currentState is GetInterface) { GetInterface interfaceTest = currentState as GetInterface; if (interfaceTest.isGlassware() && gameObject.GetComponent <AnyObjectInstantiation>().itemType == ItemType.Glassware) { enableButton(); //actionText.text="Remover"; } if (!interfaceTest.isGlassware() && (gameObject.GetComponent <AnyObjectInstantiation>().itemType == ItemType.Liquids || gameObject.GetComponent <AnyObjectInstantiation>().itemType == ItemType.Solids)) { enableButton(); //actionText.text="Remover"; } } } }
public override void ShowMove(GameStateBase response) { if (IsShow == Visibility.Hidden) { IsShow = Visibility.Visible; } var state = (TexasHoldEmGameState)response; PlayerStack = state.PlayerStack; PlayerBet = state.PlayerRoundBetTotal; PlayerHand = new ObservableCollection <Card>(state.PlayerHand); OpponentStack = state.OpponentStack; OpponentBet = state.OpponentRoundBetTotal; OpponentHand = new ObservableCollection <Card>(state.OpponentHand); BoardCards = new ObservableCollection <Card>(state.BoardCards); IsDealer = state.IsDealer; CurrentDealNumber = state.DealNumber; DealCount = state.DealCount; PotAfterPreviousRound = state.PotAfterPreviousRound; PlayerDealResult = state.PlayerDealResult; OpponentDealResult = state.OpponentDealResult; }
/// <summary> /// 将临时入栈的state出栈, 并设置成当前状态 /// </summary> public void PopStackState() { GameStateBase oldState = currentState; if (oldState != null) { oldState.PrepareExit(); } currentState = stateStack.Pop(); currentState.PreparePopStack(); if (oldState != null) { var oldStateType = oldState.StateType; oldState.Exit(); // 记录上次的状态 stateChangingContex.RecordLastState(oldStateType); } currentState.PopStack(); if (oldState != null) { oldState.DoneExit(); oldState.Dispose(); GameObject.Destroy(oldState); } currentState.DonePopStack(); }
void Update() { // State machine shenanigans if (!m_initialised) { return; } if (m_currentGameState != null) { m_currentGameState.UpdateState(); } if (m_nextGameStateIndex != Enums.GameStateNames.GS_00_NULL) { if (m_currentGameState != null) { m_currentGameState.ExitState(m_nextGameStateIndex); } m_currentGameState = m_gameStateDictionary[m_nextGameStateIndex]; m_currentGameState.EnterState(m_currentGameStateIndex); m_currentGameStateIndex = m_nextGameStateIndex; m_nextGameStateIndex = Enums.GameStateNames.GS_00_NULL; } }
/// <summary> /// Determinates what to do when action button is clicked /// </summary> public void actionButtonClick() { bool remove = true; if (selectedItem != null) { ItemInventoryBase item = new ItemInventoryBase(); item = selectedItem; GameStateBase currentState = gameController.GetCurrentState(); if (currentState.GetComponent <WorkBench> () != null) { remove = SendObjectToWorkbench(item); } if (currentState.GetComponent <LIAState> () != null) { remove = currentState.GetComponent <LIAState>().ReceiveProduct(item, GameObject.Find(item.index)); } if (remove) { removeItem(GameObject.Find(selectedItem.gameObject.name)); } } }
private void SwitchState() { if (this.kGameStateType != kNextGameStateType) { kGameState.CleanUp(); GameStateBase nextGameState = null; switch (kNextGameStateType) { case GameStateType.MainMenu: { nextGameState = new MainMenuGameState(); break; } case GameStateType.Simulation: { nextGameState = new SimulationGameState(); break; } case GameStateType.Quit: { nextGameState = new QuitGameState(); break; } } this.kGameStateType = kNextGameStateType; this.kGameState = nextGameState; nextGameState.Startup(); } }
void Start() { player = FindObjectOfType(typeof(CharacterController)) as CharacterController; if (lockPlayerStart) { Vector3 positionPlayer = new Vector3(PlayerPrefs.GetFloat("PlayerPosX"), 1, PlayerPrefs.GetFloat("PlayerPosZ")); player.transform.position = positionPlayer; } currentGameState = gameStates[0]; for (int i = 0; i < gameStates.Count; i++) { gameStates[i].SetGameController(this, i); } if (GameController.instance == null) { GameController.instance = this; } // GameObject[] invItem = GameObject.FindGameObjectsWithTag("InventoryItem"); for (int i = 0; i < invItem.Length; i++) { inventoryItems.Add(invItem [i].GetComponent <InventoryItem>()); } }
public StateMachine(GameStateBase owner) { m_owner = owner; m_currentState = null; m_previousState = null; m_globalState = null; }
private void OnGameStateChanged(GameStateBase gameState) { if (gameState is PlayState) { gameObject.SetActive(true); transform.localPosition = _startGamePosition; } }
public void Enter(GameStateBase owner) { GameObject prefab = Resources.Load("UI/LevelCanvas") as GameObject; GameObject player = GameObject.Instantiate(prefab); m_uiCtr = player.GetComponent <GameLevelUI> (); m_uiCtr.Init(); }
public void Enter(GameStateBase owner) { // GameObject prefab = Resources.Load ("OutDoorScene")as GameObject; // go = GameObject.Instantiate (prefab); ResourcesManager.Instance.Load("OutDoorScene", (Object asset) => { go = GameObject.Instantiate((GameObject)asset); }); }
public void Enter(GameStateBase owner) { //m_owner = (GameHome)owner; GameObject prefab = Resources.Load("UI/HomeCanvas") as GameObject; GameObject player = GameObject.Instantiate(prefab); m_uiCtr = player.GetComponent <GameHomeUI> (); }
public void Enter(GameStateBase owner) { GameObject prefab = Resources.Load("MainUICanvas") as GameObject; GameObject go = GameObject.Instantiate(prefab); uiCtr = go.GetComponent <MainUI> (); uiCtr.HideAll(); }
public void Exit(GameStateBase owner) { if (null != uiCtr) { GameObject.Destroy(uiCtr.gameObject); uiCtr = null; } }
public void Exit(GameStateBase owner) { if (null != go) { GameObject.Destroy(go); go = null; } }
private void OnGameStateChanged(GameStateBase gameState) { if (gameState is PlayState) { _playableDirector.Stop(); _playableDirector.Play(); } }
public void Enter(GameStateBase owner) { CursorManager.SetCursor(CursorManager.CursorState.DEFAULT); //GameObject prefab = Resources.Load ("HallScene")as GameObject; ResourcesManager.Instance.Load("HallScene", (Object asset) => { go = GameObject.Instantiate((GameObject)asset); }); }
public void runState(GameStateID stateID) { if (null != _currentState) { _currentState.leave(); } _currentState = _states[stateID]; _currentState.enter(); }
public void ChangeGameState(GameStateEnum state) { if (currentGameState != null) { currentGameState.Exit(); } currentGameState = GetGameState(state); currentGameState.Enter(); }
public void Exit(GameStateBase owner) { if (null != go) { GameObject.Destroy(go); go = null; } Debug.Log("exit GameStateMenu"); }
public void Enter(GameStateBase owner) { m_owner = (GameMenu)owner; CursorManager.SetCursor(CursorManager.CursorState.DEFAULT); // GameObject prefab = Resources.Load ("MenuCanvas")as GameObject; // go = GameObject.Instantiate (prefab); ResourcesManager.Instance.Load("MenuCanvas", (Object asset) => { go = GameObject.Instantiate((GameObject)asset); }); }
public GameStateMgr(GameBattle battle) { _currentState = null; _states = new Dictionary <GameStateID, GameStateBase>(); _states.Add(GameStateID.GAMELOAD, new GameStateGameload(battle)); _states.Add(GameStateID.LOBBY, new GameStateLobby(battle)); _states.Add(GameStateID.LEVELLOAD, new GameStateLevelload(battle)); _states.Add(GameStateID.BATTLE, new GameStateBattle(battle)); }
public void SetStateImmediately(State nextState) { State prevState = CurrentState; if (m_currentState != null) { m_currentState.End(nextState); } m_currentState = CreateState(nextState); m_currentState.Begin(prevState); }
private void OnGameStateChanged(GameStateBase gameState) { if (gameState is PlayState) { EnableWaves(); } else { DisableWaves(); } }
private void OnGameStateChanged(GameStateBase gameState) { if (gameState is MenuState) { ChangePlaylist(_menuPlaylist); } if (gameState is PlayState) { ChangePlaylist(_gameplayPlaylist); } }
public void Enter(GameStateBase owner) { CursorManager.SetCursor(CursorManager.CursorState.DEFAULT); // GameObject prefab = Resources.Load ("BathRoomScene")as GameObject; // GameObject go = GameObject.Instantiate (prefab); // uiCtr = go.GetComponent<BathRoomUI> (); ResourcesManager.Instance.Load("BathRoomScene", (Object asset) => { GameObject go = GameObject.Instantiate((GameObject)asset); uiCtr = go.GetComponent <BathRoomUI> (); }); }
IEnumerator Start() { var obj = Instantiate(m_transitionPrefab); m_transition = obj.GetComponent <Transition>(); DontDestroyOnLoad(m_transition); while (true) { if (m_currentState != null) { m_currentState.Update(); } if (m_queuedState != State.None) { var prevState = CurrentState; var nextState = m_queuedState; EventManager.Instance.SendEvent(new EventChangeGameState(prevState, nextState)); // Fade out previous state //yield return m_transition.StartCoroutine(m_transition.In()); float start = Time.time; // Switch state if (m_currentState != null) { m_currentState.End(nextState); } m_currentState = CreateState(nextState); m_currentState.Begin(prevState); // Take the hit of some expensive Start frames // for (int i = 0; i < 5; ++i) // yield return null; //float minimumSplashVisibleDuration = (nextState == State.Game || prevState == State.Game) ? 1.0f : 0.0f; //while (Time.time < start + minimumSplashVisibleDuration) // yield return null; // Fade in next state // yield return m_transition.StartCoroutine(m_transition.Out()); m_queuedState = State.None; } // Wait one frame until next "Update" yield return(null); } }
/// <summary> /// 设置当前状态 /// </summary> /// <param name="newState"></param> public void SetState(SceneType newState) { if (m_Dic.ContainsKey(newState)) { if (m_CurrentSceneState != null) { m_CurrentSceneState.OnExit(); } m_CurrentSceneState = m_Dic[newState]; m_CurrentSceneState.OnEnter(); } }
public void actionButtonClick() { GameStateBase currentState = gameController.GetCurrentState(); if (currentState.GetComponent <WorkBench> () != null) { CallWorkbenchToTable(); } else { gameObject.GetComponentInParent <InventoryContent>().removeItemUI(gameObject.GetComponent <ItemStackableBehavior>()); } }
public void IsWinLine_WithFourStonesWithTheSameSizeButNothingElseInCommon_ReturnsTrue() { var winLine = new[] { new Stone(Size.High, Surface.Flat, Color.Black, Shape.Round), new Stone(Size.High, Surface.Hole, Color.Black, Shape.Round), new Stone(Size.High, Surface.Flat, Color.White, Shape.Round), new Stone(Size.High, Surface.Flat, Color.Black, Shape.Square), }; var result = GameStateBase.IsWinLine(winLine); result.Should().BeTrue(); }
// Update is called once per frame void Update() { // State machine shenanigans if (!m_initialised) return; if (m_currentGameState != null) m_currentGameState.UpdateState(); if (m_nextGameStateIndex != Enums.GameStateNames.GS_00_NULL) { if (m_currentGameState != null) m_currentGameState.ExitState(m_nextGameStateIndex); m_currentGameState = m_gameStateDictionary[m_nextGameStateIndex]; m_currentGameState.EnterState(m_currentGameStateIndex); m_currentGameStateIndex = m_nextGameStateIndex; m_nextGameStateIndex = Enums.GameStateNames.GS_00_NULL; } }