示例#1
0
    void Update()
    {
        if (Player.Current.State == Player.PlayerState.Shopping && GameState.Current.State == GameState.GlobalState.Playing)
        {
            if (Input.GetAxis(HORIZONTAL) < 0)
            {
                Player.Current.State = Player.PlayerState.Moving;
                Toggle(false);
            }

            if (Input.GetButtonUp(FIRE))
            {
                if (GameState.Current.Moneys < Costs[SelectedItem])
                {
                    // Do nothing
                    SoundBoard.PlayCantBuy();
                }
                else
                {
                    ApplyBonus();
                    SoundBoard.PlayBuy();
                    GameState.Current.Moneys -= Costs[SelectedItem];
                    Player.Current.State      = Player.PlayerState.Moving;
                    Toggle(false);
                }
            }

            if (Timer > 0)
            {
                Timer -= Time.deltaTime;
            }

            if (Timer <= 0 && Mathf.Abs(Input.GetAxis(VERTICAL)) > 0)
            {
                axisY = Input.GetAxis(VERTICAL);
                if (axisY > 0 && SelectedItem > 0)
                {
                    SelectedItem--;
                    Timer = MaxTimer;
                    SetCursor();
                }
                else if (axisY < 0 && SelectedItem < MenuOptions.Length - 1)
                {
                    SelectedItem++;
                    Timer = MaxTimer;
                    SetCursor();
                }
            }
        }
    }