Inheritance: MonoBehaviour
Esempio n. 1
0
 public Options()
 {
     Video = getDefaultVideoOptions();
     Audio = getDefaultAudioOptions();
     GamePlay = getDefaultGamePlayOptions();
     KeySettings = getDefaultKeyBindings();
 }
Esempio n. 2
0
        public VTankOptions()
        {
            videoOptions = getDefaultVideoOptions();
            audioOptions = getDefaultAudioOptions();
            gamePlayOptions = getDefaultGamePlayOptions();
            keyBindings = getDefaultKeyBindings();

            ServerAddress = "glacier2a.cis.vtc.edu";
            ServerPort = "4063";
            DefaultAccount = "";
            MapsFolder = "maps";
        }
Esempio n. 3
0
        public CPlayer()
        {
            m_cBaseWeapon = new CBaseWeapon(this);
            m_cSecondaryPlayer = null;
            m_dNumLives = 3;
            m_dScore = 0;
            m_dMovementSpeed = 200.0;
            m_dCombineSpeed = 150.0;
            m_cKeyboardBindings = new KeyBindings();
            m_cGamepadBindings = new ButtonBindings();
            m_bPrimaryPlayer = false;

            // Object Factory will take care of the following
            // - playerIndex

            EventManager.Instance.RegisterEvent(EVENT_ID.PLAYER_COMBINE, this);
        }
Esempio n. 4
0
 public LimbPunch(Dude body, LimbType limbType) : base()
 {
     this.limbType      = limbType;
     this.activationKey = KeyBindings.KeyBindingFromLimbType(limbType);
     this.body          = body;
 }
Esempio n. 5
0
 // Start is called before the first frame update
 void Start()
 {
     i    = 0;
     keys = FindObjectOfType <KeyBindings>();
 }
Esempio n. 6
0
        public string getKeyPressed()
        {
            Keys returnKey = KeysPressed.Count > 0 ? KeysPressed.Dequeue() : Keys.None;

            return(KeyBindings.SingleOrDefault(b => b.Value == returnKey).Key);
        }
Esempio n. 7
0
        public static Options ReadOptions()
        {
            bool          doCommit = false;
            Options       options  = new Options();
            KeysConverter kc       = new KeysConverter();

            VideoOptions    defaultVideo = getDefaultVideoOptions();
            AudioOptions    defaultAudio = getDefaultAudioOptions();
            GamePlayOptions defaultGame  = getDefaultGamePlayOptions();
            KeyBindings     defaultKeys  = getDefaultKeyBindings();

            string filename = GetConfigFilePath();

            if (!File.Exists(filename))
            {
                doCommit = true;
            }
            Xmlconfig config = new Xmlconfig(filename, true);

            try
            {
                if (config.Settings.Name == "configuration")
                {
                    // Old configuration file. Port to new configuration type.
                    config.NewXml("xml");
                    doCommit = true;
                    ConvertFromLegacyConfig(config, filename);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Warning: Your old configuration settings have been lost due to an unforeseen error.",
                                "Old configuration settings lost!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            options.ServerAddress                = Get(config, "ServerAddress", "glacier2a.cis.vtc.edu");
            options.ServerPort                   = int.Parse(Get(config, "ServerPort", "4063"));
            options.DefaultAccount               = Get(config, "DefaultAccount");
            options.MapsFolder                   = Get(config, "MapsFolder", "maps");
            options.Video.Resolution             = Get(config, "options/video/Resolution", defaultVideo.Resolution);
            options.Video.Windowed               = bool.Parse(Get(config, "options/video/Windowed", defaultVideo.Windowed.ToString()));
            options.Video.TextureQuality         = Get(config, "options/video/TextureQuality", defaultVideo.TextureQuality);
            options.Video.AntiAliasing           = Get(config, "options/video/AntiAliasing", defaultVideo.AntiAliasing);
            options.Video.ShadingEnabled         = bool.Parse(Get(config, "options/video/ShadingEnabled", defaultVideo.ShadingEnabled.ToString()));
            options.Audio.ambientSound.Volume    = int.Parse(Get(config, "options/audio/ambientSound/Volume", defaultAudio.ambientSound.Volume.ToString()));
            options.Audio.ambientSound.Muted     = bool.Parse(Get(config, "options/audio/ambientSound/Muted", defaultAudio.ambientSound.Muted.ToString()));
            options.Audio.backgroundSound.Volume = int.Parse(Get(config, "options/audio/backgroundSound/Volume", defaultAudio.backgroundSound.Volume.ToString()));
            options.Audio.backgroundSound.Muted  = bool.Parse(Get(config, "options/audio/backgroundSound/Muted", defaultAudio.backgroundSound.Muted.ToString()));
            options.GamePlay.ShowNames           = bool.Parse(Get(config, "options/gameplay/ShowNames", defaultGame.ShowNames.ToString()));
            options.GamePlay.ProfanityFilter     = bool.Parse(Get(config, "options/gameplay/ProfanityFilter", defaultGame.ProfanityFilter.ToString()));
            options.GamePlay.InterfacePlugin     = Get(config, "options/gameplay/InterfacePlugin", defaultGame.InterfacePlugin);
            options.KeySettings.Forward          = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Forward", defaultKeys.Forward.ToString()));
            options.KeySettings.Backward         = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Backward", defaultKeys.Backward.ToString()));
            options.KeySettings.RotateLeft       = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/RotateLeft", defaultKeys.RotateLeft.ToString()));
            options.KeySettings.RotateRight      = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/RotateRight", defaultKeys.RotateRight.ToString()));
            //options.KeySettings.FirePrimary = (Keys)kc.ConvertFromString(Get(config, "options/keysettings/FirePrimary", ""));
            //options.KeySettings.FireSecondary = (Keys)kc.ConvertFromString(Get(config, "options/keysettings/FireSecondary", ""));
            options.KeySettings.Menu    = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Menu", defaultKeys.Menu.ToString()));
            options.KeySettings.Minimap = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Minimap", defaultKeys.Minimap.ToString()));
            options.KeySettings.Score   = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Score", defaultKeys.Score.ToString()));
            options.KeySettings.Camera  = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Camera", defaultKeys.Camera.ToString()));
            options.KeySettings.Pointer = Get(config, "options/keybindings/Pointer", defaultKeys.Pointer);

            if (doCommit)
            {
                WriteOptions(options);
            }

            return(options);
        }
Esempio n. 8
0
    private float playerXAxisValue = 0f;     // Value to store current thumbstick tilt


//-----Unity Functions--------------------------------------------------------------------------------------------------------

    void Awake()
    {
        playerData   = GetComponent <PlayerData>();
        keyBind      = GetComponent <KeyBindings>();
        playerSounds = GetComponent <PlayerSounds>();
    }
Esempio n. 9
0
        private bool handleNewPressed(InputState state, InputKey newKey, bool repeat, Vector2?scrollDelta = null, bool isPrecise = false)
        {
            var scrollAmount       = getScrollAmount(newKey, scrollDelta);
            var pressedCombination = KeyCombination.FromInputState(state, scrollDelta);

            bool handled      = false;
            var  bindings     = (repeat ? KeyBindings : KeyBindings?.Except(pressedBindings)) ?? Enumerable.Empty <IKeyBinding>();
            var  newlyPressed = bindings.Where(m =>
                                               m.KeyCombination.Keys.Contains(newKey) && // only handle bindings matching current key (not required for correct logic)
                                               m.KeyCombination.IsPressed(pressedCombination, matchingMode));

            if (KeyCombination.IsModifierKey(newKey))
            {
                // if the current key pressed was a modifier, only handle modifier-only bindings.
                // lambda expression is used so that the delegate is cached (see: https://github.com/dotnet/roslyn/issues/5835)
                newlyPressed = newlyPressed.Where(b => b.KeyCombination.Keys.All(key => KeyCombination.IsModifierKey(key)));
            }

            // we want to always handle bindings with more keys before bindings with less.
            newlyPressed = newlyPressed.OrderByDescending(b => b.KeyCombination.Keys.Length).ToList();

            if (!repeat)
            {
                pressedBindings.AddRange(newlyPressed);
            }

            // exact matching may result in no pressed (new or old) bindings, in which case we want to trigger releases for existing actions
            if (simultaneousMode == SimultaneousBindingMode.None && (matchingMode == KeyCombinationMatchingMode.Exact || matchingMode == KeyCombinationMatchingMode.Modifiers))
            {
                // only want to release pressed actions if no existing bindings would still remain pressed
                if (pressedBindings.Count > 0 && !pressedBindings.Any(m => m.KeyCombination.IsPressed(pressedCombination, matchingMode)))
                {
                    releasePressedActions();
                }
            }

            foreach (var newBinding in newlyPressed)
            {
                // we handled a new binding and there is an existing one. if we don't want concurrency, let's propagate a released event.
                if (simultaneousMode == SimultaneousBindingMode.None)
                {
                    releasePressedActions();
                }

                List <Drawable> inputQueue = getInputQueue(newBinding, true);
                Drawable        handledBy  = PropagatePressed(inputQueue, newBinding.GetAction <T>(), scrollAmount, isPrecise);

                if (handledBy != null)
                {
                    // only drawables up to the one that handled the press should handle the release, so remove all subsequent drawables from the queue (for future use).
                    var count = inputQueue.IndexOf(handledBy) + 1;
                    inputQueue.RemoveRange(count, inputQueue.Count - count);

                    handled = true;
                }

                // we only want to handle the first valid binding (the one with the most keys) in non-simultaneous mode.
                if (simultaneousMode == SimultaneousBindingMode.None && handled)
                {
                    break;
                }
            }

            return(handled);
        }
Esempio n. 10
0
        private PlayerState HandleMovementInputs()
        {
            if (MovementState.IsOnSlope)
            {
                if (TryClimb())
                {
                    MovementState.WasOnSlope = true;
                    MovementState.IsGrounded = true;
                    _wasGrounded             = true;
                    MovementState.IsOnSlope  = false;
                    _wasSliding = false;
                    Anim.SetBool(PlayerAnimBool.Sliding, false);
                    return(SetMotorToClimbState());
                }
                else
                {
                    return(PlayerState.Sliding);
                }
            }
            else
            {
                if (_wasSliding)
                {
                    _normalizedHorizontalSpeed = 0;
                }
                _wasSliding = false;
                Anim.SetBool(PlayerAnimBool.Sliding, false);
            }

            if (_isJumping)
            {
                return(PlayerState.Jumping);
            }
            else if (MovementState.IsGrounded)
            {
                if (_wasGrounded == false)
                {
                    _wasGrounded = true;
                    return(PlayerState.WaitingForInput);
                }
                else if (Interaction.IsInteracting)
                {
                    return(PlayerState.Interacting);
                }
                else if (ChannelingHandler.IsChanneling && ChannelingHandler.ChannelingSet == false)
                {
                    if (KeyBindings.GetKey(Controls.Light))
                    {
                        ChannelingHandler.Channel();
                    }
                    return(PlayerState.Static);
                }
                else if (IsClimbing())
                {
                    return(PlayerState.Climbing);
                }
                else if (TryClimb())
                {
                    return(SetMotorToClimbState());
                }
                else if (TryInteract())
                {
                    Interaction.IsInteracting = true;
                    return(PlayerState.Interacting);
                }
                else if (TryChannel())
                {
                    return(PlayerState.Static);
                }
                else
                {
                    return(PlayerState.WaitingForInput);
                }
            }
            else
            {
                _wasGrounded = false;

                if (Anim.GetBool(PlayerAnimBool.Falling) == false)
                {
                    Anim.PlayAnimation(Animations.Falling);
                }
                Anim.SetBool(PlayerAnimBool.Falling, true);
                Anim.SetBool(PlayerAnimBool.Moving, false);
                Anim.SetBool(PlayerAnimBool.Upright, false);
                _normalizedHorizontalSpeed = 0;
                return(PlayerState.Falling);
            }
        }
Esempio n. 11
0
 public void Start()
 {
     KeyBindings.LoadFromDisk();
     SceneManager.LoadScene("MainMenu");
 }
Esempio n. 12
0
        public static KeyBind EditKeyBind(string identifier, bool showHint = true, bool allowModifierOnly = false, params GUILayoutOption[] options)
        {
            if (Event.current.type == EventType.Layout)
            {
                KeyBindings.OnGUI();
            }
            var keyBind        = KeyBindings.GetBinding(identifier);
            var isEditing      = identifier == selectedIdentifier;
            var isEditingOther = selectedIdentifier != null && identifier != selectedIdentifier && oldValue != null;
            var label          = keyBind.IsEmpty ? (isEditing ? "Cancel" : "Bind") : keyBind.ToString().orange().bold();

            showHint = showHint && isEditing;
            var conflicts = keyBind.Conflicts();

            using (VerticalScope(options)) {
                Space(3.point());
                if (GL.Button(label, hotkeyStyle, AutoWidth()))
                {
                    if (isEditing || isEditingOther)
                    {
                        KeyBindings.SetBinding(selectedIdentifier, oldValue);
                        if (isEditing)
                        {
                            selectedIdentifier = null;
                            oldValue           = null;
                            return(KeyBindings.GetBinding(identifier));
                        }
                    }
                    selectedIdentifier = identifier;
                    oldValue           = keyBind;
                    keyBind            = new KeyBind(identifier);
                    KeyBindings.SetBinding(identifier, keyBind);
                }
                if (conflicts.Count() > 0)
                {
                    Label("conflicts".orange().bold() + "\n" + string.Join("\n", conflicts));
                }
                if (showHint)
                {
                    var hint = "";
                    if (keyBind.IsEmpty)
                    {
                        hint = oldValue == null ? "set key binding".green() : "press key".green();
                    }
                    Label(hint);
                }
            }
            if (isEditing && keyBind.IsEmpty && Event.current != null)
            {
                var isCtrlDown  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
                var isAltDown   = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt);
                var isCmdDown   = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt);
                var isShiftDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
                var keyCode     = Event.current.keyCode;
                //Logger.Log($"    {keyCode.ToString()} ctrl:{isCtrlDown} alt:{isAltDown} cmd: {isCmdDown} shift: {isShiftDown}");
                if (keyCode == KeyCode.Escape || keyCode == KeyCode.Backspace)
                {
                    selectedIdentifier = null;
                    oldValue           = null;
                    //Logger.Log("   unbound");
                    return(KeyBindings.GetBinding(identifier));
                }
                if (Event.current.isKey && !keyCode.IsModifier())
                {
                    keyBind = new KeyBind(identifier, keyCode, isCtrlDown, isAltDown, isCmdDown, isShiftDown);
                    Mod.Trace($"    currentEvent isKey - bind: {keyBind}");
                    KeyBindings.SetBinding(identifier, keyBind);
                    selectedIdentifier = null;
                    oldValue           = null;
                    Input.ResetInputAxes();
                    return(keyBind);
                }

                // Allow raw modifier keys as keybinds
                if (Event.current.isKey && keyCode.IsModifier() && allowModifierOnly)
                {
                    keyBind = new KeyBind(identifier, keyCode, false, false, false, false);
                    Mod.Trace($"    currentEvent isKey - bind: {keyBind}");
                    KeyBindings.SetBinding(identifier, keyBind);
                    selectedIdentifier = null;
                    oldValue           = null;
                    Input.ResetInputAxes();
                    return(keyBind);
                }

                foreach (var mouseButton in allowedMouseButtons)
                {
                    if (Input.GetKey(mouseButton))
                    {
                        keyBind = new KeyBind(identifier, mouseButton, isCtrlDown, isAltDown, isCmdDown, isShiftDown);
                        KeyBindings.SetBinding(identifier, keyBind);
                        selectedIdentifier = null;
                        oldValue           = null;
                        Input.ResetInputAxes();
                        return(keyBind);
                    }
                }
            }
            return(keyBind);
        }
 private Task AddAsync(string command)
 {
     return(KeyBindings.First(k => k.Command == command).ShowAddKeyBindingDialogAsync());
 }
Esempio n. 14
0
 public static void OnLoad()
 {
     KeyBindings.RegisterAction(MassLootBox, () => LootHelper.OpenMassLoot());
 }
Esempio n. 15
0
        private bool handleNewPressed(InputState state, InputKey newKey, bool repeat, Vector2?scrollDelta = null, bool isPrecise = false)
        {
            float scrollAmount = 0;

            if (newKey == InputKey.MouseWheelUp)
            {
                scrollAmount = scrollDelta?.Y ?? 0;
            }
            else if (newKey == InputKey.MouseWheelDown)
            {
                scrollAmount = -(scrollDelta?.Y ?? 0);
            }
            var pressedCombination = KeyCombination.FromInputState(state, scrollDelta);

            bool handled      = false;
            var  bindings     = (repeat ? KeyBindings : KeyBindings?.Except(pressedBindings)) ?? Enumerable.Empty <KeyBinding>();
            var  newlyPressed = bindings.Where(m =>
                                               m.KeyCombination.Keys.Contains(newKey) && // only handle bindings matching current key (not required for correct logic)
                                               m.KeyCombination.IsPressed(pressedCombination, matchingMode));

            if (KeyCombination.IsModifierKey(newKey))
            {
                // if the current key pressed was a modifier, only handle modifier-only bindings.
                newlyPressed = newlyPressed.Where(b => b.KeyCombination.Keys.All(KeyCombination.IsModifierKey));
            }

            // we want to always handle bindings with more keys before bindings with less.
            newlyPressed = newlyPressed.OrderByDescending(b => b.KeyCombination.Keys.Length).ToList();

            if (!repeat)
            {
                pressedBindings.AddRange(newlyPressed);
            }

            // exact matching may result in no pressed (new or old) bindings, in which case we want to trigger releases for existing actions
            if (simultaneousMode == SimultaneousBindingMode.None && (matchingMode == KeyCombinationMatchingMode.Exact || matchingMode == KeyCombinationMatchingMode.Modifiers))
            {
                // only want to release pressed actions if no existing bindings would still remain pressed
                if (pressedBindings.Count > 0 && !pressedBindings.Any(m => m.KeyCombination.IsPressed(pressedCombination, matchingMode)))
                {
                    releasePressedActions();
                }
            }

            foreach (var newBinding in newlyPressed)
            {
                // we handled a new binding and there is an existing one. if we don't want concurrency, let's propagate a released event.
                if (simultaneousMode == SimultaneousBindingMode.None)
                {
                    releasePressedActions();
                }

                handled |= PropagatePressed(getInputQueue(newBinding, true), newBinding.GetAction <T>(), scrollAmount, isPrecise);

                // we only want to handle the first valid binding (the one with the most keys) in non-simultaneous mode.
                if (simultaneousMode == SimultaneousBindingMode.None && handled)
                {
                    break;
                }
            }

            return(handled);
        }
Esempio n. 16
0
 public void SaveKeyBindings(KeyBindings keyBindings)
 {
     _roamingSettings.WriteValueAsJson(nameof(KeyBindings), keyBindings);
     KeyBindingsChanged?.Invoke(this, keyBindings);
 }
Esempio n. 17
0
 private void Awake()
 {
     instance        = this;
     worldController = WorldController.GetWorldController;
     keyBindings     = KeyBindings.GetKeyBindings;
 }
Esempio n. 18
0
        public static void Init()
        {
            if (initialized) {
                return;
            }
            initialized = true;

            keyBindings = new KeyBindings<BoundKey>();

            keyBindings.AddBinding(BoundKey.KEY_TOGGLE_WINDOW,
                new KeyBind("toggle KerbCam window", true, KeyCode.F8));

            // Playback controls.
            keyBindings.AddBinding(BoundKey.KEY_PATH_TOGGLE_RUNNING,
                new KeyBind("play/stop selected path", false, KeyCode.Insert));
            keyBindings.AddBinding(BoundKey.KEY_PATH_TOGGLE_PAUSE,
                new KeyBind("pause selected path", false, KeyCode.Home));

            // Manual camera control keys.
            keyBindings.AddBinding(BoundKey.KEY_TRN_UP, new KeyBind("translate up"));
            keyBindings.AddBinding(BoundKey.KEY_TRN_FORWARD, new KeyBind("translate forward"));
            keyBindings.AddBinding(BoundKey.KEY_TRN_LEFT, new KeyBind("translate left"));
            keyBindings.AddBinding(BoundKey.KEY_TRN_RIGHT, new KeyBind("translate right"));
            keyBindings.AddBinding(BoundKey.KEY_TRN_DOWN, new KeyBind("translate down"));
            keyBindings.AddBinding(BoundKey.KEY_TRN_BACKWARD, new KeyBind("translate backward"));
            keyBindings.AddBinding(BoundKey.KEY_ROT_ROLL_LEFT, new KeyBind("roll left"));
            keyBindings.AddBinding(BoundKey.KEY_ROT_UP, new KeyBind("pan up"));
            keyBindings.AddBinding(BoundKey.KEY_ROT_ROLL_RIGHT, new KeyBind("roll right"));
            keyBindings.AddBinding(BoundKey.KEY_ROT_LEFT, new KeyBind("pan left"));
            keyBindings.AddBinding(BoundKey.KEY_ROT_RIGHT, new KeyBind("pan right"));
            keyBindings.AddBinding(BoundKey.KEY_ROT_DOWN, new KeyBind("pan down"));

            keyBindings.AddBinding(BoundKey.KEY_DEBUG,
                new KeyBind("log debug data (developer mode only)"));

            paths = new List<SimpleCamPath>();
            camControlObj = new GameObject("KerbCam.CameraController");
            UnityEngine.Object.DontDestroyOnLoad(camControlObj);
            camControl = camControlObj.AddComponent<CameraController>();
            manCamControl = ManualCameraControl.Create();
            mainWindow = new MainWindow();
        }
 public KeyCode GetKeyCode(KeyBindings keyBinding)
 {
     return(keys[(int)keyBinding]);
 }