public void ShipControl(InputKeys direction, float angle = -1)
    {
        if (direction == InputKeys.up)
        {
            Move(transform.forward, Axeleration);
        }

        if (direction == InputKeys.shoot)
        {
            Shoot();
        }

        if (angle != -1)
        {
            Rotation = angle;
        }
        else if (direction == InputKeys.left)
        {
            Rotation -= 1 * Time.deltaTime * AngleSpeed;
        }
        else if (direction == InputKeys.right)
        {
            Rotation += 1 * Time.deltaTime * AngleSpeed;
        }
    }
Example #2
0
 public void ActivateAbility4()
 {
     if (InputKeys.isDown(InputKeys.ABL4) && !abilitySlots[3].passive)
     {
         abilitySlots[3].Activate();
     }
 }
Example #3
0
        private void ComboTracker_OnComboReset(object sender, InputKeys obj)
        {
            SequenceCombo[] result = this.ComboTracker.SequenceCombos
                                     .FuzzySearch(this.DidYouMeanFuzzyness, obj);

            this.didYouMean = result;
        }
Example #4
0
 public override void Shoot()
 {
     if (audioTimer < -0.9f)
     {
         audioTimer = timerRate;
     }
     laserObj.SetActive(InputKeys.isDown(InputKeys.SHOOT) && equipped);
     if (InputKeys.isDown(InputKeys.SHOOT) && equipped)
     {
         //laserObj.SetActive(true); //should be able to migrate this here, but being cautious.
         audioTimer += Time.deltaTime;
         if (audioTimer >= timerRate) //prevents audio manager spamming
         {
             audioManager.PlayLoopedSound("Laserbeam");
             audioTimer -= timerRate;
         }
     }
     else  //should be unused now, but sleepy and 'aint broke' mentality.
     {
         if (audioTimer > 0.0f)
         {
             audioManager.StopSound("Laserbeam");
             audioTimer = 0.0f;
         }
     }
 }
Example #5
0
        /// <summary>
        /// if a key has been pressed up
        /// </summary>
        /// <param name="c">Target key</param>
        /// <returns>True or false</returns>
        public static bool GetKeyUp(InputKeys c)
        {
            bool isKeyPressed = INPUT_KEYS_UP.Contains(c);

            INPUT_KEYS_UP.Remove(c);
            return(isKeyPressed);
        }
Example #6
0
        /// <summary>
        /// gets if a key has been pressed down
        /// </summary>
        /// <param name="c">Target key</param>
        /// <returns>True or false</returns>
        public static bool GetKeyDown(InputKeys c)
        {
            bool isKeyPressed = INPUT_KEYS_DOWN.Contains(c);

            INPUT_KEYS_DOWN.Remove(c);
            return(isKeyPressed);
        }
Example #7
0
    void Fire()
    {
        if (InputKeys.isDown(InputKeys.SHOOT) && equipped)
        {
            hitbox.enabled = true;
            em.enabled     = true;
            audioTimer    += Time.deltaTime;
            if (audioTimer >= timerRate)  //will only send audio request every .25s.
            {
                audioTimer -= timerRate;
                audioManager.PlayLoopedSound("Flamethrower1");
                print("TOLD MANAGER TO PLAY SOUND");
            }
        }

        if (InputKeys.isPressed(InputKeys.SHOOT) && equipped)
        {
            hitbox.enabled = true;
            em.enabled     = true;
            if (!firing)
            {
                firing = true;
                //audioManager.PlaySound("Flamethrower1");
            }
        }
    }
Example #8
0
 public void DeactivateAbility4()
 {
     if (InputKeys.isUp(InputKeys.ABL4) && !abilitySlots[3].passive)
     {
         abilitySlots[3].Deactivate();
     }
 }
Example #9
0
 // Update is called once per frame
 void Update()
 {
     if (Global.bossMedley)
     {
         position = size;
     }
     if (InputKeys.isPressed(InputKeys.SHOOT))
     {
         position++;
         if (position < size)
         {
             UpdateText();
         }
     }
     else if (Input.GetKeyDown(KeyCode.Space))
     {
         {
             position = size;
             UpdateText();
         }
     }
     if (position >= size)
     {
         if (part % 2 == 0)
         {
             SetActiveText(chatTest.returnChatByPart(part + 1));
             stageManager.ChangeStage(gameObject, part / 2 + 1);
             gameObject.SetActive(false);
         }
         else
         {
             inventoryPanel.SetActive(true);
         }
     }
 }
Example #10
0
        private void OnInputProviderKeyDown(object sender, InputKeys keys)
        {
            if (keys == InputKeys.None || !IsActive)
            {
                return;
            }

            if (keys != InputKeys.Escape)
            {
                if (keys.HasFlag(InputKeys.Keyboard))
                {
                    _targetInputModel.Keyboard.Value = keys;
                }
                else if (keys.HasFlag(InputKeys.Controller))
                {
                    _targetInputModel.Controller.Value = keys;
                }
                else
                {
                    return;
                }
            }

            StopInputRecording();
        }
Example #11
0
 public static void MapStick(InputKeys key, ThumbStick stick, float direction, float hysteresis)
 {
     _stickMap.Add(new ThumbStickMap()
     {
         Key = key, ThumbStick = stick, Hysteresis = hysteresis, Direction = direction
     });
 }
    public void Options_ControlApplyPressed()
    {
        InputKeys keys = new InputKeys {
            left     = lButton.GetComponent <ControlButton>().keyCode,
            leftAlt  = lAltButton.GetComponent <ControlButton>().keyCode,
            right    = rButton.GetComponent <ControlButton>().keyCode,
            rightAlt = rAltButton.GetComponent <ControlButton>().keyCode,
            up       = uButton.GetComponent <ControlButton>().keyCode,
            upAlt    = uAltButton.GetComponent <ControlButton>().keyCode,
            down     = dButton.GetComponent <ControlButton>().keyCode,
            downAlt  = dAltButton.GetComponent <ControlButton>().keyCode,
            jump     = jumpButton.GetComponent <ControlButton>().keyCode,
            jumpAlt  = jumpAltButton.GetComponent <ControlButton>().keyCode,
            fire1    = fire1Button.GetComponent <ControlButton>().keyCode,
            fire1Alt = fire1AltButton.GetComponent <ControlButton>().keyCode,
            fire2    = fire2Button.GetComponent <ControlButton>().keyCode,
            fire2Alt = fire2AltButton.GetComponent <ControlButton>().keyCode,
            joystick = joystickToggle.isOn
        };

        InputManager.SetKeys(keys);

        gm.SaveControlsToConfig(keys);

        foreach (Button b in controlButtons)
        {
            b.GetComponent <Image>().color = Color.white;
        }
    }
        private void UpdateKeyBindings()
        {
            for (int i = 0; i < m_keyboardControls.Count; i++)
            {
                var input = (InputKeys)m_controlKeys[i];

                if ((int)input != -1)
                {
                    var button = InputManager.GetMappedButton(input);
                    if (button == 0)
                    {
                        m_gamepadControls[i].Text = "";
                    }
                    else
                    {
                        m_gamepadControls[i].Text = "[Button:" + button + "]";
                    }

                    var key = InputManager.GetMappedKey(input);
                    if (key == 0)
                    {
                        m_keyboardControls[i].Text = "";
                    }
                    else
                    {
                        var       baseStr = "[Key:" + key + "]";
                        InputKeys altKey  = 0;

                        switch (input)
                        {
                        case InputKeys.PlayerJump1: altKey = InputKeys.PlayerJump2; break;

                        case InputKeys.PlayerUp1: altKey = InputKeys.PlayerUp2; break;

                        case InputKeys.PlayerDown1: altKey = InputKeys.PlayerDown2; break;

                        case InputKeys.PlayerLeft1: altKey = InputKeys.PlayerLeft2; break;

                        case InputKeys.PlayerRight1: altKey = InputKeys.PlayerRight2; break;
                        }

                        if (altKey != 0)
                        {
                            baseStr += ", [Key:" + InputManager.GetMappedKey(altKey) + "]";
                        }

                        m_keyboardControls[i].Text = baseStr;
                    }
                }
                else
                {
                    m_keyboardControls[i].Text = "";
                    m_gamepadControls[i].Text  = "";
                }
            }

            InputManager.MapKey(InputManager.GetMappedKey(InputKeys.PlayerAttack), InputKeys.MenuConfirm2);
            InputManager.MapKey(InputManager.GetMappedKey(InputKeys.PlayerJump1), InputKeys.MenuCancel2);
        }
Example #14
0
 public bool getKey(InputKeys input)
 {
     if (keyValues == null)
     {
         init();
     }
     return(keyValues[(int)input]);
 }
Example #15
0
        public static Keys GetMappedKey(InputKeys key)
        {
            return(_keyMap[(int)key]);

            //foreach (var k in _keyMap)
            //    if (k.Value == key)
            //        return k.Key;
            //return 0;
        }
        public KeyboardInputButtonController(InputKeys id) : base(PlayerControllerIndex.Keyboard, id)
        {
            _keys = keyBindings[id];

            Dictionary <int, Keys[]> d = new Dictionary <int, Keys[]>()
            {
                { 1, new Keys[] { Keys.W, Keys.Up } },
            };
        }
Example #17
0
 private void Shoot()
 {
     if (InputKeys.isDown(InputKeys.SHOOT))
     {
         foreach (WeaponModule wep in weaponModules)
         {
             wep.Shoot();
         }
     }
 }
Example #18
0
 void Unfire()
 {
     if (InputKeys.isUp(InputKeys.SHOOT))
     {
         audioManager.StopSound("DarkWeapon");
         em.enabled     = false;
         hitbox.enabled = false;
         firing         = false;
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (FunctionType != null ? FunctionType.GetHashCode() : 0);
         result = (result * 397) ^ (FunctionNameKey != null ? FunctionNameKey.GetHashCode() : 0);
         result = (result * 397) ^ (InputKeys != null ? InputKeys.GetHashCode() : 0);
         result = (result * 397) ^ (OutputKeys != null ? OutputKeys.GetHashCode() : 0);
         return(result);
     }
 }
Example #20
0
 private void SwapWeapon(Collider2D col)
 {
     if (InputKeys.isPressed(InputKeys.WEP1))
     {
         SwapWeapon(0, col);
     }
     if (InputKeys.isPressed(InputKeys.WEP2))
     {
         SwapWeapon(1, col);
     }
 }
 public void SaveControlsToConfig(Configuration cfg, InputKeys keys)
 {
     cfg["Controls"]["Left"].IntValueArray    = new int[] { (int)keys.left, (int)keys.leftAlt };
     cfg["Controls"]["Right"].IntValueArray   = new int[] { (int)keys.right, (int)keys.rightAlt };
     cfg["Controls"]["Up"].IntValueArray      = new int[] { (int)keys.up, (int)keys.upAlt };
     cfg["Controls"]["Down"].IntValueArray    = new int[] { (int)keys.down, (int)keys.downAlt };
     cfg["Controls"]["Jump"].IntValueArray    = new int[] { (int)keys.jump, (int)keys.jumpAlt };
     cfg["Controls"]["Fire1"].IntValueArray   = new int[] { (int)keys.fire1, (int)keys.fire1Alt };
     cfg["Controls"]["Fire2"].IntValueArray   = new int[] { (int)keys.fire2, (int)keys.fire2Alt };
     cfg["Controls"]["UseJoystick"].BoolValue = keys.joystick;
 }
Example #22
0
        /// <summary>
        /// Set the keys on this setting.
        /// </summary>
        public bool Set(InputKeys keys)
        {
            if (this.IsReadOnly)
            {
                return(false);
            }

            this.property.SetValue(this.Layout, keys);
            this.Keys = keys;

            return(true);
        }
Example #23
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (equipped && !InputKeys.isDown(InputKeys.SHOOT))
     {
         inst = Instantiate(info) as GameObject;
         inst.transform.parent     = transform.parent.parent.parent;
         inst.transform.localScale = new Vector2(1, 1);
         inst.transform.position   = new Vector2(transform.position.x + 50, transform.position.y - 75);
         inst.GetComponent <AbilityInfoPanelHover> ().HoverSet(nameUI, extraUI);
     }
     Debug.Log("Mouse Enter");
 }
Example #24
0
 //
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
    public void OptionsTab_ControlsPressed()
    {
        OptionsTabActivate(false, true, false);
        foreach (Button b in controlButtons)   // Have to do this manually, unfortunately
        {
            b.GetComponent <ControlButton>().SetUp();
        }
        SharpConfig.Configuration config = gm.GetConfiguration();
        InputKeys keys = gm.ConfigurationToInputKeys(config);

        SetUIKeys(keys);
    }
    void Awake()
    {
        // Singleton stuff, needs to carry across multiple scenes
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;
        DontDestroyOnLoad(gameObject);

        //canvas = GameObject.Find("Canvas").GetComponent<Canvas>();

        if (gameInProgress)
        {
            Camera.main.fieldOfView = cameraFov;
        }
        else
        {
            // At main menu / first boot, do the song and dance

            SceneManager.sceneLoaded += OnSceneLoad;
            canvas = GameObject.Find("Canvas").GetComponent <Canvas>();
            if (blackFade == null)
            {
                blackFade = Instantiate(screenFaderPrefab).GetComponent <ScreenFader>();
                blackFade.transform.SetParent(canvas.transform);
                blackFade.transform.localPosition = Vector3.zero;
                blackFade.GetComponent <RectTransform>().sizeDelta = new Vector2(canvas.GetComponent <CanvasScaler>().referenceResolution.x, canvas.GetComponent <CanvasScaler>().referenceResolution.y); // Double what it needs but that's ok
                blackFade.transform.SetSiblingIndex(0);
            }
            // Read config file -- if none exists, make one
            try {
                config = Configuration.LoadFromFile(SETTINGS_FILENAME);
                // Set settings
                GameSettings s = ConfigurationToGameSettings(config);
                ApplyOptionsSettings(s);
                ApplyPlayerSettings(s);
                // Set controls
                InputKeys k = ConfigurationToInputKeys(config);
                InputManager.SetKeys(k);
            } catch (FileNotFoundException) {
                Debug.Log("No config file '" + SETTINGS_FILENAME + "' found. Making one with defaults!");
                config = MakeDefaultConfig(true);
                config.SaveToFile(SETTINGS_FILENAME);
            }

            Camera.main.fieldOfView = cameraFov;

            canvas.GetComponent <MenuUIManager>().PlayIntro();
        }
    }
Example #27
0
 // Update is called once per frame
 protected override void Update()
 {
     base.Update();
     if (!InputKeys.isDown(InputKeys.SHOOT))
     {
         if (audioTimer > 0.0f)
         {
             audioManager.StopSound("Laserbeam");
             audioTimer = -1.0f;
         }
         laserObj.SetActive(false);
     }
 }
    public void Options_ControlsRevertPressed()
    {
        InputKeys defaults = InputManager.GetDefaultKeys();

        SetUIKeys(defaults);

        // Set the text here, rather than doubling the mess above
        foreach (Button b in controlButtons)
        {
            b.GetComponent <ControlButton>().text.text = b.GetComponent <ControlButton>().keyCode.ToString();
            b.GetComponent <Image>().color             = Color.white;
        }
    }
Example #29
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (equipped && !InputKeys.isDown(InputKeys.SHOOT))
     {
         inst = Instantiate(info) as GameObject;
         inst.transform.parent     = transform.parent.parent.parent;
         inst.transform.localScale = new Vector2(1, 1);
         inst.transform.position   = new Vector2(transform.position.x + 50, transform.position.y - 75);
         inst.GetComponent <InfoPanelScriptHover> ().HoverSet(nameUI, (int)damageUI, (int)firerateUI, GetComponent <WeaponDraggable>());
     }
     AudioManager.instance.PlaySound("HoverBeep");
     Debug.Log("Mouse Enter");
 }
Example #30
0
        public static Buttons GetMappedButton(InputKeys key)
        {
            return(_buttonMap[(int)key]);

            //int index = -1;
            //int length = _buttonMap.Length;
            //while (++index < length)
            //{
            //    if (key == _buttonMap[index])
            //        return (Buttons)(1 << index);
            //}

            //return 0;
        }
Example #31
0
 public static extern uint SendInput(uint nInputs, InputKeys[] inputs, int cbSize);
Example #32
0
        public static Buttons GetMappedButton(InputKeys key)
        {
            return _buttonMap[(int)key];

            //int index = -1;
            //int length = _buttonMap.Length;
            //while (++index < length)
            //{
            //    if (key == _buttonMap[index])
            //        return (Buttons)(1 << index);
            //}

            //return 0;
        }
Example #33
0
        public static Keys GetMappedKey(InputKeys key)
        {
            return _keyMap[(int)key];

            //foreach (var k in _keyMap)
            //    if (k.Value == key)
            //        return k.Key;
            //return 0;
        }
Example #34
0
 public static bool IsNewlyPressed(InputKeys key)
 {
     return ((1 << (int)key) & (int)_newInputFlags) != 0;
 }
Example #35
0
 public static bool IsPressed(InputKeys key)
 {
     return ((1 << (int)key) & (int)_currentInputFlags) != 0;
 }
Example #36
0
        public static void MapKey(Keys key, InputKeys input)
        {
            int i = (int)input;
            var oldKey = _keyMap[i];

            if (oldKey == key)
                return;

            _keyMap[i] = key;

            HashSet<InputFlags> lookup;

            var flag = (InputFlags)i.ToBitFlag();
            InputFlags oldMap = 0;

            if (oldKey != 0 && _keyFlagMap.TryGetValue(oldKey, out lookup))
                lookup.Remove(flag);

            if (key != 0)
            {
                if (!_keyFlagMap.TryGetValue(key, out lookup))
                    _keyFlagMap[key] = lookup = new HashSet<InputFlags>();

                //Find existing player-mapped key, so it can be swapped
                if (oldKey != 0 && (_systemKeys & flag) == 0)
                    oldMap = lookup.FirstOrDefault(x => (_systemKeys & x) == 0);

                lookup.Add(flag);
            }

            //Swap player key maps
            if (oldMap != 0)
                MapKey(oldKey, (InputKeys)((int)oldMap).FromBitFlag());
        }
Example #37
0
 public static void MapStick(InputKeys key, ThumbStick stick, float direction, float hysteresis)
 {
     _stickMap.Add(new ThumbStickMap() { Key = key, ThumbStick = stick, Hysteresis = hysteresis, Direction = direction });
 }