Пример #1
0
        private static InputState GetRebindableKeyState(KeyFunctions name)
        {
            InputState state = InputState.NONE;

            if (RebindableKeys.TryGetValue(name, out RebindableKey key))
            {
                var states = Enumerable.Select(key.Keys, k => KeyState[k]);
                if (key.GamePadPlayerIndex != null)
                {
                    states = states.Concat(Enumerable.Select(key.Buttons, k => ControllerState[(int)key.GamePadPlayerIndex][k]));
                }
                state = states.Max();
            }
            return(state);
        }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (thisObject == null)
        {
            thisObject = GameObject.FindGameObjectWithTag("ThisOneIsTurnedOn");
        }

        if (kyf == null)
        {
            kyf = thisObject.GetComponent <KeyFunctions>();
        }

        if (kyf.Easy == true)
        {
            ReloadTime = 3;
        }
        else if (kyf.Medium == true)
        {
            ReloadTime = 2;
        }
        else if (kyf.Excruciatinglyhard == true)
        {
            ReloadTime = 1f;
        }
        else if (kyf.UFB == true)
        {
            ReloadTime = 0.9f;
        }

        if (xTimer > ReloadTime || text.text == "")
        {
            i         = Random.Range(0, InstructionArray.Length - 1);
            text.text = InstructionArray[i];
            for (int c = 0; c < InstructionBoolArray.Length; c++)
            {
                if (c != i)
                {
                    InstructionBoolArray[c] = false;
                }
                else
                {
                    InstructionBoolArray[c] = true;
                }
            }
            xTimer = 0;
            if (kyf.PressedButton == true)
            {
                kyf.PressedButton = false;
            }
            else
            {
                if (kyf.Easy == true)
                {
                    kyf.SHealth        -= 1;
                    kyf.ShipHealth.text = kyf.SHealth.ToString();
                    kyf.PressedButton   = false;
                }
                else if (kyf.Medium == true)
                {
                    kyf.SHealth        -= 3;
                    kyf.ShipHealth.text = kyf.SHealth.ToString();
                    kyf.PressedButton   = false;
                }
                else if (kyf.Excruciatinglyhard == true)
                {
                    kyf.SHealth        -= 6;
                    kyf.ShipHealth.text = kyf.SHealth.ToString();
                    kyf.PressedButton   = false;
                }
                else if (kyf.UFB == true)
                {
                    kyf.SHealth        -= 12;
                    kyf.ShipHealth.text = kyf.SHealth.ToString();
                    kyf.PressedButton   = false;
                }
            }
        }
        else
        {
            xTimer += Time.deltaTime;
        }
    }
Пример #3
0
 /// <summary>
 /// Returns if a rebindable key was just pressed this frame.
 /// </summary>
 /// <param name="functionName"></param>
 /// <returns></returns>
 public static bool JustPressedRebindableKey(KeyFunctions functionName)
 {
     return(GetRebindableKeyState(functionName) == InputState.PRESSED);
 }
Пример #4
0
 /// <summary>
 /// Simply checks if a rebindable key is down based on its function name.
 /// </summary>
 /// <param name="functionName"></param>
 /// <returns></returns>
 public static bool IsRebindableKeyPressed(KeyFunctions functionName)
 {
     return(GetRebindableKeyState(functionName) != InputState.NONE);
 }