예제 #1
0
    private void Update()
    {
        currentMana = chargeManager.CurrentCharges;

        prevState = state;
        state     = GamePad.GetState(playerIndex);

        RTButtonDown = state.Triggers.Right >= 0.9f && RTButtonUp;
        RTButtonUp   = state.Triggers.Right <= 0.9f;

        LTButtonDown = state.Triggers.Left >= 0.1f && LTButtonUp;
        LTButtonUp   = state.Triggers.Left <= 0.1f;


        //FIREBALL
        if (IsButtonDown(state.Buttons.X, prevState.Buttons.X) || RTButtonDown)
        {
            if (projectile.manaCost <= currentMana && projectile.CanActivate())
            {
                currentMana -= projectile.OnActivate(gameObject);
                chargeManager.CurrentCharges = currentMana;
                int listIndex = Random.Range(0, castFireballAudioNames.Count);
                AudioManager.instance.PlayWithRandomPitch(castFireballAudioNames[listIndex]);
            }
        }

        //Start Button
        if (IsButtonDown(state.Buttons.Start, prevState.Buttons.Start))
        {
            Debug.Log("You need to press both Start and Back to restart");
            if (IsButtonDown(state.Buttons.Start, prevState.Buttons.Start) && IsButtonDown(state.Buttons.Back, prevState.Buttons.Back))
            {
                GameManager.managerInstance.LoadScene(2);
            }
        }

        //REFLECT
        if (IsButtonDown(state.Buttons.A, prevState.Buttons.A) || LTButtonDown)
        {
            if (reflect.manaCost <= currentMana && reflect.CanActivate())
            {
                currentMana -= reflect.OnActivate(gameObject);
                chargeManager.CurrentCharges = currentMana;

                int listIndex = Random.Range(0, reflectAudioNames.Count);
                AudioManager.instance.PlayWithRandomPitch(reflectAudioNames[listIndex]);
            }
        }

        //DASH
        if (IsButtonDown(state.Buttons.B, prevState.Buttons.B) ||
            IsButtonDown(state.Buttons.LeftShoulder, prevState.Buttons.LeftShoulder) ||
            IsButtonDown(state.Buttons.RightShoulder, prevState.Buttons.RightShoulder))
        {
            if (dash.manaCost <= currentMana && dash.CanActivate())
            {
                currentMana -= dash.OnActivate(gameObject);
                chargeManager.CurrentCharges = currentMana;

                int listIndex = Random.Range(0, dashAudioNames.Count);
                AudioManager.instance.PlayWithRandomPitch(dashAudioNames[listIndex]);
            }
        }
    }