Inheritance: TrinketBehaviour
コード例 #1
0
    //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";
                }
            }
        }
    }
コード例 #2
0
        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;
        }
コード例 #3
0
    /// <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();
    }
コード例 #4
0
    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;
        }
    }
コード例 #5
0
    /// <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));
            }
        }
    }
コード例 #6
0
    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();
        }
    }
コード例 #7
0
    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>());
        }
    }
コード例 #8
0
 public StateMachine(GameStateBase owner)
 {
     m_owner         = owner;
     m_currentState  = null;
     m_previousState = null;
     m_globalState   = null;
 }
コード例 #9
0
 private void OnGameStateChanged(GameStateBase gameState)
 {
     if (gameState is PlayState)
     {
         gameObject.SetActive(true);
         transform.localPosition = _startGamePosition;
     }
 }
コード例 #10
0
    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();
    }
コード例 #11
0
    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);
        });
    }
コード例 #12
0
    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> ();
    }
コード例 #13
0
    public void Enter(GameStateBase owner)
    {
        GameObject prefab = Resources.Load("MainUICanvas") as GameObject;
        GameObject go     = GameObject.Instantiate(prefab);

        uiCtr = go.GetComponent <MainUI> ();
        uiCtr.HideAll();
    }
コード例 #14
0
 public void Exit(GameStateBase owner)
 {
     if (null != uiCtr)
     {
         GameObject.Destroy(uiCtr.gameObject);
         uiCtr = null;
     }
 }
コード例 #15
0
 public void Exit(GameStateBase owner)
 {
     if (null != go)
     {
         GameObject.Destroy(go);
         go = null;
     }
 }
コード例 #16
0
 private void OnGameStateChanged(GameStateBase gameState)
 {
     if (gameState is PlayState)
     {
         _playableDirector.Stop();
         _playableDirector.Play();
     }
 }
コード例 #17
0
 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);
     });
 }
コード例 #18
0
 public void runState(GameStateID stateID)
 {
     if (null != _currentState)
     {
         _currentState.leave();
     }
     _currentState = _states[stateID];
     _currentState.enter();
 }
コード例 #19
0
ファイル: GameManager.cs プロジェクト: xjl2018/TempProject
 public void ChangeGameState(GameStateEnum state)
 {
     if (currentGameState != null)
     {
         currentGameState.Exit();
     }
     currentGameState = GetGameState(state);
     currentGameState.Enter();
 }
コード例 #20
0
 public void Exit(GameStateBase owner)
 {
     if (null != go)
     {
         GameObject.Destroy(go);
         go = null;
     }
     Debug.Log("exit GameStateMenu");
 }
コード例 #21
0
    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);
        });
    }
コード例 #22
0
    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));
    }
コード例 #23
0
    public void SetStateImmediately(State nextState)
    {
        State prevState = CurrentState;

        if (m_currentState != null)
        {
            m_currentState.End(nextState);
        }
        m_currentState = CreateState(nextState);
        m_currentState.Begin(prevState);
    }
コード例 #24
0
 private void OnGameStateChanged(GameStateBase gameState)
 {
     if (gameState is PlayState)
     {
         EnableWaves();
     }
     else
     {
         DisableWaves();
     }
 }
コード例 #25
0
ファイル: MusicManager.cs プロジェクト: aulia14/rail-hunter
 private void OnGameStateChanged(GameStateBase gameState)
 {
     if (gameState is MenuState)
     {
         ChangePlaylist(_menuPlaylist);
     }
     if (gameState is PlayState)
     {
         ChangePlaylist(_gameplayPlaylist);
     }
 }
コード例 #26
0
    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> ();
        });
    }
コード例 #27
0
    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);
        }
    }
コード例 #28
0
    /// <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();
        }
    }
コード例 #29
0
    public void actionButtonClick()
    {
        GameStateBase currentState = gameController.GetCurrentState();

        if (currentState.GetComponent <WorkBench> () != null)
        {
            CallWorkbenchToTable();
        }
        else
        {
            gameObject.GetComponentInParent <InventoryContent>().removeItemUI(gameObject.GetComponent <ItemStackableBehavior>());
        }
    }
コード例 #30
0
        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();
        }
コード例 #31
0
    // 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;
        }
    }