Пример #1
0
        /// <summary>
        /// The default bindings for tank (classic) controls.
        /// </summary>
        /// <returns>Default bindings for tank controls.</returns>
        public static ControlActions CreateDefaultTank()
        {
            ControlActions actions = new ControlActions();

            actions.Left.AddDefaultBinding(Key.A);
            actions.Left.AddDefaultBinding(InputControlType.LeftStickLeft);

            actions.Right.AddDefaultBinding(Key.D);
            actions.Right.AddDefaultBinding(InputControlType.LeftStickRight);

            actions.Forward.AddDefaultBinding(Key.W);
            actions.Forward.AddDefaultBinding(InputControlType.LeftStickUp);

            actions.Backward.AddDefaultBinding(Key.S);
            actions.Backward.AddDefaultBinding(InputControlType.LeftStickDown);

            actions.LookUp.AddDefaultBinding(Key.E);
            actions.LookUp.AddDefaultBinding(InputControlType.Action4);

            actions.LookDown.AddDefaultBinding(Key.Q);
            actions.LookDown.AddDefaultBinding(InputControlType.Action3);

            actions.LookBehind.AddDefaultBinding(Key.Z);
            actions.LookBehind.AddDefaultBinding(InputControlType.Action2);

            actions.Run.AddDefaultBinding(Key.Space);
            actions.Run.AddDefaultBinding(InputControlType.Action1);

            return(actions);
        }
Пример #2
0
 /// <summary>
 /// Create a control scheme with these parameters.
 /// </summary>
 /// <param name="actions">The bindings to use.</param>
 /// <param name="name">The name of this control scheme.</param>
 /// <param name="fpsControls">Whether or not to use FPS controls.</param>
 /// <param name="mouseSensitivity">The mouse sensitivity.</param>
 public ControlScheme(ControlActions actions, string name, bool fpsControls, float mouseSensitivity = 1)
 {
     _controlActions  = actions;
     FpsControls      = fpsControls;
     MouseSensitivity = mouseSensitivity;
     Name             = name;
 }
Пример #3
0
        /// <summary>
        /// Initialize the control scheme manager. Should be called on game start.
        /// </summary>
        public static void Initialize()
        {
            Schemes = deserializeControlSchemes(PathToControlSchemes);

            // if no schemes are present create and serialise the default scheme
            if (Schemes.Count <= 0)
            {
                Debug.Log("No control schemes found - creating new ones!");
                Schemes.Add(new ControlScheme(ControlActions.CreateDefaultTank(), "Classic", false));
                Schemes.Add(new ControlScheme(ControlActions.CreateDefaultFps(), "Revamped", true, 5F));
                SerializeControlSchemes(Schemes);
            }
        }
        public void EnsureDefaultSchemes()
        {
            if (!File.Exists(PathUtil.Combine(_controlSchemesPath, "Classic.dat")))
            {
                Debug.Log("Unable to find 'Classic' control scheme - creating...");
                Schemes.Add(new ControlScheme(ControlActions.CreateDefaultTank(), "Classic", false));
            }

            if (!File.Exists(PathUtil.Combine(_controlSchemesPath, "Revamped.dat")))
            {
                Debug.Log("Unable to find 'Revamped' control scheme - creating...");
                Schemes.Add(new ControlScheme(ControlActions.CreateDefaultFps(), "Revamped", true, 15F));
            }

            SaveSchemes();

            // we now need to sort the list, as any schemes that might have already been there before the default ones
            // will now be before them in the list -- this is not preferable as loading them as normal will simply
            // load them in alphabetical order, so this is to emulate that
            Schemes.Sort((x, y) => String.Compare(x.Name, y.Name, StringComparison.Ordinal));
        }
Пример #5
0
        /// <summary>
        /// Create default bindings for FPS controls.
        /// </summary>
        /// <returns>Default bindings for FPS controls.</returns>
        public static ControlActions CreateDefaultFps()
        {
            ControlActions actions = new ControlActions();

            actions.Left.AddDefaultBinding(Key.A);
            actions.Left.AddDefaultBinding(InputControlType.LeftStickLeft);
            actions.Left.AddDefaultBinding(InputControlType.DPadLeft);

            actions.Right.AddDefaultBinding(Key.D);
            actions.Right.AddDefaultBinding(InputControlType.LeftStickRight);
            actions.Right.AddDefaultBinding(InputControlType.DPadRight);

            actions.Forward.AddDefaultBinding(Key.W);
            actions.Forward.AddDefaultBinding(InputControlType.LeftStickUp);
            actions.Forward.AddDefaultBinding(InputControlType.DPadUp);

            actions.Backward.AddDefaultBinding(Key.S);
            actions.Backward.AddDefaultBinding(InputControlType.LeftStickDown);
            actions.Backward.AddDefaultBinding(InputControlType.DPadDown);

            actions.LookUp.AddDefaultBinding(InputControlType.RightStickUp);

            actions.LookDown.AddDefaultBinding(InputControlType.RightStickDown);

            actions.LookLeft.AddDefaultBinding(InputControlType.RightStickLeft);

            actions.LookRight.AddDefaultBinding(InputControlType.RightStickRight);

            actions.LookBehind.AddDefaultBinding(Key.Z);
            actions.LookBehind.AddDefaultBinding(InputControlType.Action2);

            actions.Run.AddDefaultBinding(Key.Space);
            actions.Run.AddDefaultBinding(InputControlType.Action1);

            actions.Start.AddDefaultBinding(Key.Escape);
            actions.Start.AddDefaultBinding(InputControlType.Start);
            actions.Start.AddDefaultBinding(InputControlType.Plus);

            return(actions);
        }
Пример #6
0
        /// <summary>
        /// Create default bindings for FPS controls.
        /// </summary>
        /// <returns>Default bindings for FPS controls.</returns>
        public static ControlActions CreateDefaultFps()
        {
            ControlActions actions = new ControlActions();

            actions.Left.AddDefaultBinding(Key.A);
            actions.Left.AddDefaultBinding(InputControlType.LeftStickLeft);

            actions.Right.AddDefaultBinding(Key.D);
            actions.Right.AddDefaultBinding(InputControlType.LeftStickRight);

            actions.Forward.AddDefaultBinding(Key.W);
            actions.Forward.AddDefaultBinding(InputControlType.LeftStickUp);

            actions.Backward.AddDefaultBinding(Key.S);
            actions.Backward.AddDefaultBinding(InputControlType.LeftStickDown);

            actions.LookUp.AddDefaultBinding(Mouse.PositiveY);
            actions.LookUp.AddDefaultBinding(InputControlType.RightStickUp);

            actions.LookDown.AddDefaultBinding(Mouse.NegativeY);
            actions.LookDown.AddDefaultBinding(InputControlType.RightStickDown);

            actions.LookLeft.AddDefaultBinding(Mouse.NegativeX);
            actions.LookLeft.AddDefaultBinding(InputControlType.RightStickLeft);

            actions.LookRight.AddDefaultBinding(Mouse.PositiveX);
            actions.LookRight.AddDefaultBinding(InputControlType.RightStickRight);

            actions.LookBehind.AddDefaultBinding(Key.Z);
            actions.LookBehind.AddDefaultBinding(InputControlType.Action2);

            actions.Run.AddDefaultBinding(Key.Space);
            actions.Run.AddDefaultBinding(InputControlType.Action1);

            return(actions);
        }