示例#1
0
 public void GameStateChange(Util.GameState state)
 {
     if (state != Util.GameState.gaming)
     {
         setCubesTouchable(false);
     }
     else
     {
         setCubesTouchable(true);
     }
 }
示例#2
0
        void Start()
        {
            if (spawnPoints.Length == 0)
            {
                return;
            }
            int        point = Random.Range(0, spawnPoints.Length);
            GameObject temp  = Instantiate(Coin);

            temp.transform.position = spawnPoints[point].position;
            temp.transform.parent   = this.gameObject.transform;
            Util.GameState g = FindObjectOfType <Util.GameState>();
            if (g != null)
            {
                g.currentObtainableCoins++;
            }
        }
示例#3
0
 void Start()
 {
     gamestate = FindObjectOfType <Util.GameState>();
 }
 /// <summary>
 /// 设置游戏状态接口
 /// </summary>
 /// <param name="state"></param>
 public void SetGameState(Util.GameState state)
 {
     this.gamestate = state;
     GameStateChange(gamestate);
 }
 /// <summary>
 /// 游戏状态改变需要调用的函数,通知所有监听对象
 /// </summary>
 /// <param name="state"></param>
 private void GameStateChange(Util.GameState state)
 {
     gameStateChangeListeners.ForEach(delegate(GameStateChangeListener l) { l.GameStateChange(state); });
 }
示例#6
0
        void Update()
        {
            if (menu.enabled)
            {
                if (set)
                {
                    Util.GameState.state = Util.GameState.State.Gameover;
                    FindObjectOfType <Player.PlayerController>().transform.parent = null;
                    set = false;
                }

                if (!doOnce)
                {
                    int   oldLevel  = 0;
                    float oldTime   = 999f;
                    int   oldCoins  = 0;
                    int   oldCoinsT = 999;
                    if (PlayerPrefs.HasKey(hash + "Level"))
                    {
                        oldLevel  = PlayerPrefs.GetInt(hash + "Level");
                        oldTime   = PlayerPrefs.GetFloat(hash + "Time");
                        oldCoins  = PlayerPrefs.GetInt(hash + "Coins");
                        oldCoinsT = PlayerPrefs.GetInt(hash + "CoinsT");
                    }
                    Util.GameState state = FindObjectOfType <Util.GameState>();
                    timeTotal          = state.time;
                    numOfLevels        = state.numOfLevels;
                    coinNum            = state.totalCoins + state.currentCoins;
                    coinTNum           = state.totalObtainableCoins + state.currentObtainableCoins;
                    total.text         = timeTotal.ToString("N2") + " sec";
                    levelsCleared.text = numOfLevels + "";
                    coins.text         = coinNum + " / " + coinTNum;
                    if (numOfLevels > oldLevel || (numOfLevels == oldLevel && ((coinNum / coinTNum) > (oldCoins / oldCoinsT) || timeTotal < oldTime)))
                    {
                        newHigh.SetActive(true);
                        oldHigh.SetActive(false);
                        PlayerPrefs.SetInt(hash + "Level", numOfLevels);
                        PlayerPrefs.SetFloat(hash + "Time", timeTotal);
                        PlayerPrefs.SetInt(hash + "Level", numOfLevels);
                        PlayerPrefs.SetInt(hash + "Level", numOfLevels);
                    }
                    else
                    {
                        newHigh.SetActive(false);
                        oldHigh.SetActive(true);
                        totalHigh.text         = oldTime.ToString("N2") + " sec";
                        levelsClearedHigh.text = oldLevel + "";
                        coinsHigh.text         = oldCoins + " / " + oldCoinsT;
                    }
                    doOnce = true;
                }

                if (EventSystem.current.currentSelectedGameObject == null)
                {
                    EventSystem.current.SetSelectedGameObject(selected);
                }

                currentSelected = EventSystem.current.currentSelectedGameObject;

                if (Util.CustomInput.BoolFreshPressDeleteOnRead(Util.CustomInput.UserInput.Left))
                {
                    Navigator.Navigate(Util.CustomInput.UserInput.Left, currentSelected);
                }
                if (Util.CustomInput.BoolFreshPressDeleteOnRead(Util.CustomInput.UserInput.Right))
                {
                    Navigator.Navigate(Util.CustomInput.UserInput.Right, currentSelected);
                }
                if (Util.CustomInput.BoolFreshPressDeleteOnRead(Util.CustomInput.UserInput.Accept))
                {
                    Navigator.CallSubmit();
                }
            }
        }
示例#7
0
 void Start()
 {
     gamestate = FindObjectOfType<Util.GameState>();
 }