예제 #1
0
        public override InputWrapper[] Run()
        {
            Win32Point p;

            if (MacroManager.SavedPoints.TryGetValue(name, out p))
            {
                Inputs = new InputWrapper[]
                    {
                        new InputWrapper
                        {
                            Type = SendInputType.Mouse,
                            MKH = new MouseKeyboardHardwareUnion
                            {
                                Mouse = new MouseInputData
                                {
                                    X = p.X,
                                    Y = p.Y,
                                    Flags = MouseEventFlags.Move | MouseEventFlags.Absolute
                                }
                            }
                        }
                    };

                return base.Run();
            }

            return null;
        }
예제 #2
0
        public override bool Execute(CommandExecuteEventArgs args)
        {
            if (args.KeyBinding.KeyChord.HasAxis)
            {
                // make sure the keybinding and value change are going the
                // same "direction" (for the case where the axis is involved)
                if (!MathUtilities.SameSign(args.Data, _amount))
                {
                    return(false);
                }
            }

            SuperController sc         = SuperController.singleton;
            var             multiplier = _multiplier * Mathf.Abs(args.Data);

            if (InputWrapper.GetKey(KeyCode.LeftShift) || InputWrapper.GetKey(KeyCode.RightShift))
            {
                multiplier *= 5.0f;
            }

            var scale = sc.motionAnimationMaster.playbackSpeed + (_amount * multiplier);

            sc.motionAnimationMaster.playbackSpeed = Mathf.Clamp(scale, _min, _max);
            return(true);
        }
예제 #3
0
    public static void Main()
    {
        InputWrapper iw = new InputWrapper();

        // initialize and display array
        int[] primes = { 2, 3, 5, 7, 11, 13 };
        for (int i = 0; i < primes.Length; i++)
        {
            Console.Write("{0} ", primes[i]);
        }
        Console.WriteLine();
        // loop to read and search for targets
        Console.WriteLine("Enter numbers to search for, -1 when done");
        int target = iw.getInt("target number: ");

        while (target != -1)
        {
            int index = Search(primes, target);
            if (index == -1)
            {
                Console.WriteLine("{0} not found", target);
            }
            else
            {
                Console.WriteLine("{0} found at {1}", target, index);
            }
            target = iw.getInt("target number: ");
        }
    }
예제 #4
0
        public override bool Execute(CommandExecuteEventArgs args)
        {
            if (args.KeyBinding.KeyChord.HasAxis)
            {
                // make sure the keybinding and value change are going the
                // same "direction" (for the case where the axis is involved)
                if (!MathUtilities.SameSign(args.Data, _amount))
                {
                    return(false);
                }
            }

            SuperController sc         = SuperController.singleton;
            var             multiplier = _multiplier * Mathf.Abs(args.Data);

            if (InputWrapper.GetKey(KeyCode.LeftShift) || InputWrapper.GetKey(KeyCode.RightShift))
            {
                multiplier *= 5.0f;
            }

            var scale = sc.worldScale + (_amount * multiplier);

            SuperController.singleton.worldScale = Mathf.Clamp(scale, _worldScaleMin, _worldScaleMax);

            //// Modify player height with scale
            Vector3 dir = Vector3.down;

            dir *= multiplier * 0.0011f;
            sc.navigationRig.position += dir;
            return(true);
        }
예제 #5
0
        public override void Run()
        {
            if (PositionName == null)
            {
                return;
            }

            Win32Point p;

            if (MousePositionSave.SavedPoints.TryGetValue(PositionName, out p))
            {
                var inputs = new InputWrapper[]
                {
                    new InputWrapper
                    {
                        Type = SendInputType.Mouse,
                        MKH  = new MouseKeyboardHardwareUnion
                        {
                            Mouse = new MouseInputData
                            {
                                X     = p.X,
                                Y     = p.Y,
                                Flags = MouseEventFlags.Move | MouseEventFlags.Absolute
                            }
                        }
                    }
                };

                Interop.SendInput((uint)inputs.Length, inputs);
            }
        }
예제 #6
0
	/// <summary>
	/// Unity method.
	/// Awake this instance.
	/// </summary>
	void Awake()
	{
		if (instance == null) {
			instance = this;
			createdInstance = true;
		}
		else {
			Debug.LogWarning("Input Manager already exists. Destroying this instance: " + name);
			Destroy(this);
		}
		
		cachedInputWrapper = InputWrapper.Instance;
		
		cachedInputWrapper.OnTapBegan += OnTapBegan;
		cachedInputWrapper.OnTapEnded += OnTapEnded;
		cachedInputWrapper.OnSwipeLeftRight += OnSwipeLeftRight;
		cachedInputWrapper.OnSwipeRightLeft += OnSwipeRightLeft;
		
		if (inputCameras == null) {
			inputCameras = new List<Camera>();
		}
		
		if (modalStack == null) {
			modalStack = new List<ModalItem>();
		}
	}
예제 #7
0
    static void Main(string[] args)
    {
        //TODO: use command loop to show and find policies
        Policy[] policy = new Policy[3];
        policy[0] = new HomeOwnerLine
                        (33, "Duplex", "98001", 1, 300000, 2000000, "Kathy", "applied for",
                        "2016-5-6", "2017-5-6");
        policy[1] = new RentersLine
                        (45, "SingleFamily", "98000", 55, 2, 30000, 200000, "Rachel", "Bound", "2013-5-6", "2014-5-6");
        policy[2] = new MotorCycleLine
                        ("343525335vkj", "TwoWheel",
                        3, 20000, 20000, "Jay", "Bound", "2013-5-6", "2014-5-6");
        policy[0].ShowPolicy();            //works//
        Console.WriteLine(policy[0].Name); //works

        InputWrapper iw = new InputWrapper();
        string       cmd;

        Console.WriteLine("Enter the id to find the policy");
        cmd = iw.getString("> ");

        for (int i = 0; i < policy.Length; i++)
        {
            if (cmd.Equals(policy[i].Id.ToString()))
            {
                policy[i].ShowPolicy();
            }
        }
    }
예제 #8
0
파일: MouseDown.cs 프로젝트: HaKDMoDz/GNet
        public MouseDown(int button)
        {
            int data = 0;
            switch (button)
            {
                case 0:
                case 1:
                    Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.LeftDown, data) };
                    toString = "MouseDown(" + MouseEventFlags.LeftDown.ToString() + ")";
                    break;

                case 2:
                    Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.RightDown, data) };
                    toString = "MouseDown(" + MouseEventFlags.RightDown.ToString() + ")";
                    break;

                case 3:
                    Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.MiddleDown, data) };
                    toString = "MouseDown(" + MouseEventFlags.MiddleDown.ToString() + ")";
                    break;

                default:
                    data = button - 3;
                    Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.XDown, data) };
                    toString = "MouseDown(" + MouseEventFlags.XDown.ToString() + ", " + data + ")";
                    break;
            }
        }
예제 #9
0
        public MouseTap(int button)
        {
            int data = 0;

            switch (button)
            {
            case 0:
            case 1:
                Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.LeftDown, data), InputSimulator.MouseWrapper(MouseEventFlags.LeftUp, data) };

                toString = "MouseTap(LeftButton)";
                break;

            case 2:
                Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.RightDown, data), InputSimulator.MouseWrapper(MouseEventFlags.RightUp, data) };

                toString = "MouseTap(RightButton)";
                break;

            case 3:
                Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.MiddleDown, data), InputSimulator.MouseWrapper(MouseEventFlags.MiddleUp, data) };

                toString = "MouseTap(MiddleButton)";
                break;

            default:
                data   = button - 3;
                Inputs = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.XDown, data), InputSimulator.MouseWrapper(MouseEventFlags.XUp, data) };

                toString = "MouseTap(XButton, " + data + ")";
                break;
            }
        }
예제 #10
0
 public void Save(string name)
 {
     if (ContainsKey(name))
     {
         PlayerPrefs.SetString("controls_" + name + "_binds", InputWrapper.GetHardwareName(name));
     }
 }
예제 #11
0
        static void Main(string[] args)
        {
            InputWrapper iw = new InputWrapper();
            int          a  = iw.getInt("Please input the first coordiante x: ");
            int          b  = iw.getInt("Please input the first coordiante y: ");

            Console.WriteLine
                ("The corordinate({0}, {1}) lies in the {2} quandrant", a, b, FindSection(a, b));

            int c = iw.getInt("Please input the second coordiante x: ");
            int d = iw.getInt("Please input the second coordiante y: ");

            Console.WriteLine
                ("The corordinate({0}, {1}) lies in the {2} quandrant", c, d, FindSection(c, d));;

            int FindSection(int x, int y)
            {
                if (x > 0 && y > 0)
                {
                    return(1);
                }
                else if (x > 0 && y < 0)
                {
                    return(4);
                }
                else if (x < 0 && y > 0)
                {
                    return(2);
                }
                else
                {
                    return(3);
                }
            }
        }
예제 #12
0
        public override void Run()
        {
            if (PositionName == null)
                return;

            Win32Point p;

            if (MousePositionSave.SavedPoints.TryGetValue(PositionName, out p))
            {
                var inputs = new InputWrapper[]
                {
                    new InputWrapper
                    {
                        Type = SendInputType.Mouse,
                        MKH = new MouseKeyboardHardwareUnion
                        {
                            Mouse = new MouseInputData
                            {
                                X = p.X,
                                Y = p.Y,
                                Flags = MouseEventFlags.Move | MouseEventFlags.Absolute
                            }
                        }
                    }
                };

                Interop.SendInput((uint)inputs.Length, inputs);
            }
        }
예제 #13
0
 public virtual void DoInit()
 {
     mCameraCachedTransform = mapCamera.transform;
     subMapViewTemplate.gameObject.SetActive(false);
     mInputWrapper = new InputWrapper(OnClick, OnDrag, OnPinching);
     RefreshVisiableSubMapView();
 }
예제 #14
0
    public static void Main()
    {
        Bank         bank = new Bank();
        InputWrapper iw   = new InputWrapper();
        string       cmd;

        Console.WriteLine("Enter command, quit to exit");
        cmd = iw.getString("> ");
        while (!cmd.Equals("quit"))
        {
            if (cmd.Equals("open"))
            {
                AccountType type;
                string      stype = iw.getString("account type: ");
                switch (stype)
                {
                case "checking":
                    type = AccountType.Checking;
                    break;

                case "savings":
                    type = AccountType.Savings;
                    break;

                default:
                    type = AccountType.Invalid;
                    break;
                }
                if (type == AccountType.Invalid)
                {
                    Console.WriteLine("Valid account types are checking/savings");
                    continue;
                }
                decimal bal   = iw.getDecimal("starting balance: ");
                string  owner = iw.getString("owner: ");
                int     id    = bank.AddAccount(type, bal, owner);
                Console.WriteLine("Account opened, id = {0}", id);
            }
            else if (cmd.Equals("close"))
            {
                int id = iw.getInt("account id: ");
                bank.DeleteAccount(id);
            }
            else if (cmd.Equals("show"))
            {
                ShowArray(bank.GetAccounts());
            }
            else if (cmd.Equals("account"))
            {
                int     id  = iw.getInt("account id: ");
                Account acc = bank.FindAccount(id);
                Atm.ProcessAccount(acc);
            }
            else
            {
                help();
            }
            cmd = iw.getString("> ");
        }
    }
예제 #15
0
        /// <summary>
        /// Are all of the keys being held down?
        /// </summary>
        /// <returns></returns>
        public bool IsBeingPressed()
        {
            var isButtonsPressed = _keyPressDefinitions.Any((definition) => definition.All(InputWrapper.GetKey));
            var isAxisPressed    = (_axisDefinition == null) ? true : InputWrapper.GetAxis(_axisDefinition) != 0;

            return(isButtonsPressed && isAxisPressed);
        }
예제 #16
0
            /// <summary>
            /// Update gamepad data
            /// </summary>
            /// <returns>TRUE - if state changed (button pressed, gamepad dis|connected, etc)</returns>
            public bool Update()
            {
                bool isChanged = false;

                buttons      = state.Gamepad.wButtons;
                packetNumber = state.PacketNumber;
                int result = InputWrapper.XInputGetState(userIndex, ref state);

                if (isConnected != (result == 0))
                {
                    isChanged   = true;
                    isConnected = (result == 0);
                    if (ConnectionChanged != null)
                    {
                        OnConnectionChanged();
                    }
                }

                if (isConnected)
                {
                    UpdateBattery();
                }

                if (state.PacketNumber != packetNumber)
                {
                    isChanged = true;
                    if (StateChanged != null)
                    {
                        OnStateChanged();
                    }
                }

                // KeyDown is a long event
                if ((Buttons != 0) && (KeyDown != null))
                {
                    OnKeyDown();
                }

                // Force feedback
                DateTime now = DateTime.UtcNow;

                if ((ffbL_IsActive && (now >= ffbL_StopTime)) &&
                    (ffbR_IsActive && (now >= ffbR_StopTime)))
                {
                    FFB_Stop();
                }
                else
                {
                    if (ffbL_IsActive && (now >= ffbL_StopTime))
                    {
                        FFB_StopLeft();
                    }
                    if (ffbR_IsActive && (now >= ffbR_StopTime))
                    {
                        FFB_StopRight();
                    }
                }

                return(isChanged);
            } // UpdateState()
예제 #17
0
        public override bool Execute(CommandExecuteEventArgs args)
        {
            if (args.KeyBinding.KeyChord.HasAxis)
            {
                // make sure the keybinding and value change are going the
                // same "direction" (for the case where the axis is involved)
                if (!MathUtilities.SameSign(args.Data, _unitsPerSecond))
                {
                    return(false);
                }

                if (_direction == Vector3.forward)
                {
                    // invert the direction for forward/back if using an axis
                    _direction = Vector3.back;
                }
            }

            if (_windowCamera != null)
            {
                var multiplier = 1.0f;
                if (InputWrapper.GetKey(KeyCode.LeftShift) || InputWrapper.GetKey(KeyCode.RightShift) || args.KeyBinding.KeyChord.HasAxis)
                {
                    multiplier *= 3.0f;
                }
                _windowCamera.transform.Translate(_direction * Time.deltaTime * _unitsPerSecond * multiplier * Mathf.Abs(args.Data));
            }
            return(true);
        }
예제 #18
0
    void Update()
    {
        if (playerInputEnabled)
        {
            inputPrev = input;
            input.y   = InputWrapper.GetVerticalAxis();
            input.x   = InputWrapper.GetHorizontalAxis();

            if (chargingSlash)
            {
                ChargeSlash();
            }

            if (savedSlashCharge > 0)
            {
                ApplySlashDistance();
            }
            else
            {
                Move();
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    BeginSlash();
                }
                if (Input.GetKeyUp(KeyCode.Space) && chargingSlash)
                {
                    ReleaseSlash();
                }
            }
        }
    }
예제 #19
0
        public void Update()
        {
            Vector2 movement;
            // Gets information about input axis
            float inputX = InputWrapper.GetAxisRaw("Horizontal");
            float inputY = InputWrapper.GetAxisRaw("Vertical");

            // Prepare the movement for each direction
            movement = new Vector2(inputX, inputY);

            // Makes the movement relative to time
            movement *= Time.deltaTime;

            //get dodge input from player
            bool dodge = InputWrapper.GetButtonDown("Dodge");

            if (dodge)
            {
                player.StartDodge();
            }

            player.Walk(movement.normalized);

            //get targeting input from player
            bool target = InputWrapper.GetButtonDown("Target");

            if (target)
            {
                if (!player.inCombat)
                {
                    player.Interact();
                }
                else
                {
                    player.ToggleTarget();
                }
            }

            //get attack input from player
            bool atk = InputWrapper.GetButtonDown("Attack");

            if (atk)
            {
                player.Attack();
            }

            bool toggleItem = InputWrapper.GetButtonDown("Toggle item");

            if (toggleItem)
            {
                ToggleItem();
            }

            bool useItem = InputWrapper.GetButtonDown("Use item");

            if (useItem)
            {
                UseItem();
            }
        }
예제 #20
0
        public MouseUp(int button)
        {
            int data = 0;

            switch (button)
            {
            case 0:
            case 1:
                Inputs   = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.LeftUp, data) };
                toString = "MouseUp(" + MouseEventFlags.LeftUp.ToString() + ")";
                break;

            case 2:
                Inputs   = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.RightUp, data) };
                toString = "MouseUp(" + MouseEventFlags.RightUp.ToString() + ")";
                break;

            case 3:
                Inputs   = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.MiddleUp, data) };
                toString = "MouseUp(" + MouseEventFlags.MiddleUp.ToString() + ")";
                break;

            default:
                data     = button - 3;
                Inputs   = new InputWrapper[] { InputSimulator.MouseWrapper(MouseEventFlags.XUp, data) };
                toString = "MouseUp(" + MouseEventFlags.XUp.ToString() + ", " + data + ")";
                break;
            }
        }
예제 #21
0
        public static Composite ChooseCharacterAndPressPlay(CharacterPositionDelegate characterPositionDelegate)
        {
            return(new DecoratorContinue(x => GameController.Game.IsSelectCharacterState == true,

                                         new Action(delegate(object context)
            {
                for (int i = 0; i < 6; i++)
                {
                    InputWrapper.KeyPress(Keys.Up);
                    Thread.Sleep(40);
                }
                for (int i = 1; i < characterPositionDelegate(context); i++)
                {
                    InputWrapper.KeyPress(Keys.Down);
                    Thread.Sleep(40);
                }

                Mouse.SetCursorPosAndLeftOrRightClick(playButtonRect2560x1600, 250);
                ControlTimer.Restart();
                while (ControlTimer.ElapsedMilliseconds < 6000 && GameController.Game.IsSelectCharacterState)
                {
                    Thread.Sleep(50);
                }
                if (GameController.Game.IsSelectCharacterState == false)
                {
                    return RunStatus.Success;
                }
                return RunStatus.Failure;
            })
                                         ));
        }
예제 #22
0
    // Attempts to detect input on any axis or button.
    // Returns true if input was captured. False otherwise.
    // Only creates the binding if captured input wasn't escape key/back button.
    public static bool CaptureInput(string inputFor, bool mouseMovement = true)
    {
        string axis = GetPressedAxis(mouseMovement);

        if (axis != null)
        {
            bool positive = (axis[axis.Length - 1] == '+');
            bindings[inputFor].Add(new ControlBinding(axis.Substring(0, axis.Length - 1), positive));
            bindings.Save(inputFor);
            return(true);
        }
        else
        {
            KeyCode kcode = InputWrapper.GetPressedKey();
            if (kcode != KeyCode.None)
            {
                if (kcode != KeyCode.Escape)
                {
                    bindings[inputFor].Add(new ControlBinding(kcode));
                    bindings.Save(inputFor);
                }
                return(true);
            }
        }
        return(false);
    }
예제 #23
0
    public static void Main(string[] args)
    {
        InputWrapper iw = new InputWrapper();

        Console.WriteLine("Enter command, 'quit' to exit.");
        string cmd = iw.getString("> ");

        while (!cmd.Equals("quit"))
        {
            if (cmd.Equals("Length"))
            {
                Console.WriteLine(cmd);
                break;
            }
            else if (cmd.Equals("new"))
            {
                Console.WriteLine(cmd);
                break;
            }
            else if (cmd.Equals("show"))
            {
                Console.WriteLine(cmd);
                break;
            }
            else
            {
                cmd = iw.getString(">> ");
            }
        }
    }
예제 #24
0
        public Window()
        {
            InitializeComponent();

            InfoVersion.Text = Core.Version;

            ConsoleOutput.Font = new System.Drawing.Font(Core.Fonts.Families[0], 10f);

            Package[] installedPackages = Workshop.GetInstalled();

            installedPackages.ToList().ForEach(x =>
            {
                Dictionary <string, string> packageInfo = x.GetInfo();

                PackageInfo p      = new PackageInfo();
                p.NameLabel.Text   = packageInfo["Name"];
                p.AuthorLabel.Text = packageInfo["Authors"];
                p.DescLabel.Text   = packageInfo["Description"];
                p.Package          = x;

                p.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;

                InstalledPackagesList.Controls.Add(p);

                p.RunButton.Click += (o, e) =>
                {
                    x.Run(true);
                };
            });

            var hoverColor = new ColorContainer(0, 0, 0);
            var cursorPos  = new PointContainer(0, 0);

            var timer = new System.Timers.Timer();

            timer.Interval = 1000;
            timer.Elapsed += (s, a) =>
            {
                if (this == null)
                {
                    return;
                }

                cursorPos  = InputWrapper.GetCursorPos();
                hoverColor = ScreenWrapper.GetPixels(cursorPos.X, cursorPos.Y, 1, 1)[0][0];

                Invoke(new Action(() =>
                {
                    if (IsDisposed)
                    {
                        return;
                    }

                    ColorDisplay.Text     = $"R: {hoverColor.R} G: {hoverColor.G} B: {hoverColor.B}";
                    CursorPosDisplay.Text = $"X: {cursorPos.X} Y: {cursorPos.Y}";
                }));
            };
            timer.Start();
        }
예제 #25
0
    public static void Main(String[] args)
    {
        string[] names = new string[10];
        int      count = 0;

        names[count++] = "John";
        names[count++] = "Jane";
        names[count++] = "Todd";

        string cmd = " ";

        while (cmd != "quit")
        {
            InputWrapper iw = new InputWrapper();
            Console.WriteLine("Enter command, quit to exit.");
            cmd = iw.getString("> ");
            Console.WriteLine("the command {0} was entered", cmd);

            switch (cmd)
            {
            case "add":
                string name = iw.getString("names: ");
                names[count++] = name;
                Console.WriteLine(name);
                break;

            case "forward":
                for (int i = 0; i < names.Length; i++)
                {
                    Console.WriteLine(names[i]);
                }
                break;

            case "backward":
                Array.Reverse(names);
                Console.WriteLine("Backward");
                PrintIndexAndValues(names);
                break;

            //    case "find":
            //        int j = 0;
            //        string target = iw.getString("Search: ");
            //        while (target != names[j])
            //        {
            //            break;
            //        }
            //        Console.WriteLine(names[j]);
            //        break;
            case "remove":
                Console.WriteLine("Remove");
                break;

            default:
                Console.WriteLine("Available commands include: forward, backward, add, find, remove");
                break;
            }
            cmd = iw.getString("> ");
        }
    }
예제 #26
0
 // Update is called once per frame
 void Update()
 {
     if (InputWrapper.GetPrimary(keys) > 0 && previous <= 0.001f)
     {
         playAudioClip(Clip, volume);
     }
     previous = InputWrapper.GetPrimary(keys);
 }
 void Start()
 {
     _input                     = new InputWrapper();
     _dragGesture               = new InputKit.DragGesture(_input);
     _dragGesture.DragHandler   = OnDrag;
     _pinchGesture              = new InputKit.PinchGesture(_input);
     _pinchGesture.PinchHandler = OnPinch;
 }
예제 #28
0
 public void PlayerMovesOnPressingD()
 {
     player.PublicStart();
     player.rigidBody.startSpying();
     InputWrapper.SetKey(KeyCode.D);
     player.DoPlayerMovement();
     Assert.IsTrue(player.rigidBody.movePositionCalled);
 }
예제 #29
0
    static void Main(string[] args)
    {
        InputWrapper iw   = new InputWrapper();
        string       name = " ";
        string       spouse;
        ArrayList    MyMarriedFriends = new ArrayList();

        while (true)
        {
            Console.WriteLine("Enter friend's name, quit to exit");
            name = iw.getString("> ");
            if (name.Equals("quit"))
            {
                break;
            }
            Console.WriteLine("Enter friend's spouse's name");
            spouse = iw.getString("> ");
            Friend node = new Friend(name, spouse);
            MyMarriedFriends.Add(node);
        }
        foreach (object o in MyMarriedFriends)
        {
            // todo: what errors need to be handled here?
            try
            {
                if (name != null)
                {
                    Friend f = (Friend)o;
                    Console.WriteLine(f.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                //Console.WriteLine("Please input valid names");
            }
        }
        MyMarriedFriends.Sort(); // default sort
        Console.WriteLine("\nSorted");
        foreach (object o in MyMarriedFriends)
        {
            // todo: what errors need to be handled here?
            try
            {
                if (MyMarriedFriends[0] is IComparable)
                {
                    Friend f = (Friend)o;
                    Console.WriteLine(f.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        Console.Write("Enter <cr> to end program");
        Console.ReadLine();
    }
예제 #30
0
        static public Composite SellItems(bool sellUnidCrItems = false)
        {
            return(new Decorator(x => DoSelling(),

                                 new Sequence(
                                     new Action(delegate
            {
                InputWrapper.ResetMouseButtons();
                // InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                return RunStatus.Success;
            }),
                                     FindVendor(),
                                     MoveToAndOpenVendor(),
                                     OpenVendorSellScreen(),

                                     new Action(delegate
            {
                var inventory = WillBot.gameController.Game.IngameState.IngameUi.InventoryPanel[InventoryIndex.PlayerInventory];
                var invItems = inventory.VisibleInventoryItems;
                var itemsToSell = WillBot.Me.sellit.GetItemsToSell(invItems, sellUnidCrItems);
                if (itemsToSell.Count == 0)
                {
                    WillBot.Me.HasSoldItemsThisTownCycle = true;
                    InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                    Thread.Sleep(200);
                    if (WillBot.gameController.IngameState.IngameUi.VendorPanel.IsVisible)
                    {
                        InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                    }

                    return RunStatus.Success;
                }
                int latency = (int)WillBot.gameController.IngameState.CurLatency;
                Input.KeyDown(System.Windows.Forms.Keys.LControlKey);
                foreach (var item in itemsToSell)
                {
                    Mouse.SetCursorPosAndLeftOrRightClick(item.Rect, latency, randomClick: true);
                    Thread.Sleep(200);
                }

                Input.KeyUp(System.Windows.Forms.Keys.LControlKey);

                var acceptButton = WillBot.gameController.IngameState.IngameUi.VendorAcceptButton;
                //var acceptButton = WillBot.gameController.IngameState.IngameUi.SellWindow.GetChildAtIndex(3).GetChildAtIndex(5);
                Mouse.SetCursorPosAndLeftOrRightClick(acceptButton.GetClientRectCache, latency, randomClick: true);

                Thread.Sleep(900);
                if (WillBot.gameController.IngameState.IngameUi.VendorPanel.IsVisible)
                {
                    InputWrapper.KeyPress(System.Windows.Forms.Keys.Escape);
                }
                WillBot.Me.HasSoldItemsThisTownCycle = true;
                WillBot.Me.IsPlayerInventoryFull = false;
                return RunStatus.Success;
            })

                                     )));
        }
예제 #31
0
    public static void Main()
    {
        // Initialize accounts and show starting state
        accounts = new ArrayList();
        Console.WriteLine("accounts.Count = {0}", accounts.Count);
        Console.WriteLine("accounts.Capacity = {0}", accounts.Capacity);
        AddAccount(100, "Bob", 1);
        AddAccount(200, "Mary", 2);
        AddAccount(300, "Charlie", 3);
        ShowAccounts(accounts);
        Console.WriteLine("accounts.Count = {0}", accounts.Count);
        Console.WriteLine("accounts.Capacity = {0}", accounts.Capacity);
        // Command processing loop
        InputWrapper iw = new InputWrapper();
        string       cmd;

        Console.WriteLine("Enter command, quit to exit");
        cmd = iw.getString("> ");
        while (!cmd.Equals("quit"))
        {
            try
            {
                if (cmd.Equals("show"))
                {
                    ShowAccounts(accounts);
                }
                else if (cmd.Equals("enum"))
                {
                    ShowEnum(accounts);
                }
                else if (cmd.Equals("remove"))
                {
                    int id = iw.getInt("id: ");
                    RemoveAccount(id);
                }
                else if (cmd.Equals("add"))
                {
                    decimal balance = iw.getDecimal("balance: ");
                    string  owner   = iw.getString("owner: ");
                    int     id      = iw.getInt("id: ");
                    AddAccount(balance, owner, id);
                }
                else
                {
                    help();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                    Console.WriteLine(e.InnerException.Message);
                }
            }
            cmd = iw.getString("> ");
        }
    }
예제 #32
0
    /// <summary>
    /// In the Update event, the script checks if the cooldown timer has reached its
    /// end. If not, the cooldown timer is incremented by Time.deltaTime.
    /// Otherwise, the script checks for player input. If a crew button is selected,
    /// then the function StatUpdate is called to update the stat in relation to the
    /// number of crew members available. If any change does occur, the modification
    /// goes to the StatSystem.
    /// </summary>

    // Update is called once per frame
    void Update()
    {
        if (isLocalPlayer)
        {
            if (cooldownTimer < COOLDOWN_LIMIT)
            {
                cooldownTimer           += Time.deltaTime;
                cooldownImage.fillAmount = cooldownTimer / COOLDOWN_LIMIT;
            }

            else
            {
                if (InputWrapper.GetButtonDown(attackButton))
                {
                    statChange = StatUpdate(ref attackStage);

                    if (statChange != 0)
                    {
                        statSystem.AlterAttack(STAGE_MULTIPLIER * statChange);
                        cooldownTimer = 0;
                    }
                }

                else if (InputWrapper.GetButtonDown(defenseButton))
                {
                    statChange = StatUpdate(ref defenseStage);

                    if (statChange != 0)
                    {
                        statSystem.AlterDefense(STAGE_MULTIPLIER * statChange);
                        cooldownTimer = 0;
                    }
                }

                else if (InputWrapper.GetButtonDown(speedButton))
                {
                    statChange = StatUpdate(ref speedStage);

                    if (statChange != 0)
                    {
                        statSystem.AlterSpeed(STAGE_MULTIPLIER * statChange);
                        cooldownTimer = 0;
                    }
                }

                else if (InputWrapper.GetButtonDown(resetButton))
                {
                    ResetStages();
                }

                //if some action was performed, play the sound
                if (cooldownTimer == 0)
                {
                    transform.Find("ShipSounds").Find("CrewManagement").GetComponent <AudioSource>().Play();
                }
            }
        }
    }
 void Update()
 {
     if (InputWrapper.GetEscape(keys) > 0 && previous <= 0.001f)
     {
         changePauseScreenActive(!PauseScreen.activeSelf);
         updateText();
     }
     previous = InputWrapper.GetEscape(keys);
 }
예제 #34
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     horizontalAxis = 0;
     verticalAxis   = 0;
 }
        public void ActivateController(InputWrapper wrapper, int controllerIndex, IController.ButtonPressedCallback pressedCallback, IController.ButtonReleasedCallback releasedCallback)
        {
            foreach (var config in controllers)
            {
                if (config.wrapper == wrapper && config.controllerIndex == controllerIndex)
                {
                    return;
                }
            }

            ControllerConfiguration controller = new ControllerConfiguration();

            controller.wrapper = wrapper;
            controller.controllerIndex = controllerIndex;

            if (Utility.CheckXInputSupport() && wrapper == InputWrapper.XInput)
            {
            #if !LINUX
                controller.iface = new XInputController(controller.controllerIndex);
            #endif
            }
            else if (Utility.CheckSDLSupport() && wrapper == InputWrapper.SDL)
            {
                controller.iface = new SDLController(controller.controllerIndex);
            }
            else  if (wrapper == InputWrapper.KeyboardMouse)
            {
                controller.iface = new KeyboardMouseController();
            }
            else
            {
                // invalid configuration, bail out..
                return;
            }

            controller.SetTreatHatsAsButtons(controller.treatHatsAsButtons);
            controller.iface.analogEvaluationCurve = CurveFactory.Instantiate(controller.analogInputCurve);
            controller.iface.buttonPressedCallback = new IController.ButtonPressedCallback(pressedCallback);
            controller.iface.buttonReleasedCallback = new IController.ButtonReleasedCallback(releasedCallback);

            controller.presets = DefaultControllerPresets.GetDefaultPresets(controller.iface);
            controller.currentPreset = 0;

            controllers.Add(controller);

            ScreenMessages.PostScreenMessage("CONTROLLER: " + controller.iface.GetControllerName(), 1.0f, ScreenMessageStyle.UPPER_CENTER);
        }
예제 #36
0
	/// <summary>
	/// Unity method.
	/// Start this instance.
	/// </summary>
	public override void Start()
	{
		base.Start();
		
		GenericSettings.Instance.OnAutoplayChanged += OnSettingChanged;
		GenericSettings.Instance.OnArrowsChanged += OnSettingChanged;
		
		if (children.Count == 0) {
			cachedRenderWrapper = RenderWrapper.Instance;
			cachedRender = cachedRenderWrapper.GetRenderComponent(gameObject);
			
			cachedInputWrapper = InputWrapper.Instance;
			cachedInputReceiver = cachedInputWrapper.GetInputComponent(gameObject);
		}
		
		UpdatedState();
	}
예제 #37
0
        public MouseMoveTo(int x, int y)
        {
            Inputs = new InputWrapper[]
                {
                    new InputWrapper
                    {
                        Type = SendInputType.Mouse,
                        MKH = new MouseKeyboardHardwareUnion
                        {
                            Mouse = new MouseInputData
                            {
                                X = x,
                                Y = y,
                                Flags = MouseEventFlags.Move | MouseEventFlags.Absolute
                            }
                        }
                    }
                };

            toString = "MouseMoveTo(" + x + ", " + y + ")";
        }
예제 #38
0
파일: KeyUp.cs 프로젝트: HaKDMoDz/GNet
 public KeyUp(char key)
 {
     Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(key, true) };
     toString = "KeyUp(" + key + ")";
 }
예제 #39
0
        public uint KeyTap(ScanCode scanCode, bool extended = false)
        {
            var inputData = new InputWrapper[]
            { 
                KeyWrapper(scanCode, false, extended),
                KeyWrapper(scanCode, true, extended)
            };

            return Interop.SendInput(2, inputData);
        }
예제 #40
0
        public static uint MouseMoveBy(int x, int y)
        {
            var inputData = new InputWrapper[]
            {
                new InputWrapper
                {
                    Type = SendInputType.Mouse,
                    MKH = new MouseKeyboardHardwareUnion
                    {
                        Mouse = new MouseInputData
                        {
                            X = x,
                            Y = y,
                            Flags = MouseEventFlags.Move
                        }
                    }
                }
            };

            return Interop.SendInput(1, inputData);
        }
예제 #41
0
        public void ReleaseKey(IList<ScanCode> scanCodes)
        {
            var inputData = new InputWrapper[scanCodes.Count];
            for (int i = 0; i < inputData.Length; i++)
            {
                Device.KeyRepeater.KeyUp(scanCodes[i]);
                inputData[i] = InputSimulator.KeyWrapper(scanCodes[i], true, ((int)scanCodes[i] & 0x100) == 0x100);
            }

            Interop.SendInput((uint)inputData.Length, inputData);
        }
예제 #42
0
        public void PressKey(IList<ScanCode> scanCodes)
        {
            var inputData = new InputWrapper[scanCodes.Count];
            for (int i = 0; i < inputData.Length; i++)
                inputData[i] = InputSimulator.KeyWrapper(scanCodes[i], false, ((int)scanCodes[i] & 0x100) == 0x100);

            Interop.SendInput((uint)inputData.Length, inputData);

            Device.KeyRepeater.KeyDown(scanCodes[scanCodes.Count - 1]);
        }
예제 #43
0
        public static uint MouseTap(MouseTapFlags flags, int xButton = 0)
        {
            var inputData = new InputWrapper[]
            {
                MouseWrapper((MouseEventFlags)flags, xButton),
                MouseWrapper((MouseEventFlags)((int)flags << 1), xButton)
            };

            return Interop.SendInput(2, inputData);
        }
        public ControllerConfiguration GetConfigurationByControllerType(InputWrapper wrapper, int controllerIndex)
        {
            foreach (ControllerConfiguration config in controllers)
            {
                if (config.wrapper == wrapper && config.controllerIndex == controllerIndex)
                {
                    return config;
                }
            }

            return null;
        }
예제 #45
0
 public InputState Try()
 {
     state = state.Try();
     return state.input;
 }
예제 #46
0
        public uint KeyTap(char c, bool extended = false)
        {
            var inputData = new InputWrapper[]
            { 
                KeyWrapper(c, false, extended),
                KeyWrapper(c, true, extended)
            };

            return Interop.SendInput(2, inputData);
        }
예제 #47
0
파일: Interop.cs 프로젝트: HaKDMoDz/GNet
 public static extern uint SendInput(uint numberInputs, InputWrapper[] inputs, int sizeOfStructure);
예제 #48
0
        public static void KeyTap(ScanCode scanCode)
        {
            var inputData = new InputWrapper[]
            {
                new InputWrapper()
                {
                    Type = SendInputType.Keyboard,
                    MKH = new MouseKeyboardHardwareUnion()
                    {
                        Keyboard = new KeyboardInputData()
                        {
                            Scan = scanCode,
                            Flags = KeyboardFlags.ScanCode,
                            Time = 0,
                            ExtraInfo = IntPtr.Zero
                        }
                    }
                },
                new InputWrapper()
                {
                    Type = SendInputType.Keyboard,
                    MKH = new MouseKeyboardHardwareUnion()
                    {
                        Keyboard = new KeyboardInputData()
                        {
                            Scan = scanCode,
                            Flags = KeyboardFlags.KeyUp | KeyboardFlags.ScanCode,
                            Time = 0,
                            ExtraInfo = IntPtr.Zero
                        }
                    }
                }
            };

            var v = SendInput(2, inputData, Marshal.SizeOf(typeof(InputWrapper)));
        }
예제 #49
0
        public static uint DoKeyUp(char c, bool extended)
        {
            var inputData = new InputWrapper[]
            {
                KeyWrapper(c, true, extended)
            };

            return Interop.SendInput(1, inputData);
        }
예제 #50
0
        public static uint MouseUp(MouseUpFlags flags, int xButton = 0)
        {
            var inputData = new InputWrapper[]
            {
                MouseWrapper((MouseEventFlags)flags, xButton)
            };

            return Interop.SendInput(1, inputData);
        }
예제 #51
0
파일: KeyUp.cs 프로젝트: HaKDMoDz/GNet
 public KeyUp(ScanCode scanCode)
 {
     Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(scanCode, true) };
     toString = "KeyUp(" + scanCode.ToString() + ")";
 }
예제 #52
0
 public void Complete()
 {
     state = InputState.None;
 }
        public void DeactivateController(InputWrapper wrapper, int controllerIndex)
        {
            for (int i = 0; i < controllers.Count; i++)
            {
                var config = controllers[i];

                if (config.wrapper == wrapper && config.controllerIndex == controllerIndex)
                {
                    controllers[i].iface = null;
                    controllers.RemoveAt(i);
                    return;
                }
            }
        }
예제 #54
0
 private void Awake()
 {
     _instance = this;
 }
예제 #55
0
        public static uint MouseMoveToPixel(int x, int y)
        {
            var size = ScreenSize;

            var inputData = new InputWrapper[]
            {
                new InputWrapper
                {
                    Type = SendInputType.Mouse,
                    MKH = new MouseKeyboardHardwareUnion
                    {
                        Mouse = new MouseInputData
                        {
                            X = x * 65536 / size.X + 1,
                            Y = y * 65536 / size.Y + 1,
                            Flags = MouseEventFlags.Move | MouseEventFlags.Absolute
                        }
                    }
                }
            };

            return Interop.SendInput(1, inputData);
        }
예제 #56
0
        /// <summary>
        /// Simulate a mouse wheel event
        /// </summary>
        /// <param name="amount">The amount of wheel movement (120 == one click)</param>
        /// <returns>1 if successful, 0 if Interop.SendInput failed</returns>
        public static uint MouseWheel(int amount)
        {
            var inputData = new InputWrapper[]
            {
                MouseWrapper(MouseEventFlags.Wheel, amount)
            };

            return Interop.SendInput(1, inputData);
        }
예제 #57
0
        static void DoKeyUp(ScanCode scanCode, bool extended)
        {
            var inputData = new InputWrapper[]
                {
                    new InputWrapper()
                    {
                        Type = SendInputType.Keyboard,
                        MKH = new MouseKeyboardHardwareUnion()
                        {
                            Keyboard = new KeyboardInputData()
                            {
                                Scan = scanCode,
                                Flags = KeyboardFlags.KeyUp | KeyboardFlags.ScanCode | (extended ? KeyboardFlags.ExtendedKey : 0)
                                //Time = 0,
                                //ExtraInfo = IntPtr.Zero
                            }
                        }
                    }
                };

            var v = SendInput(1, inputData, Marshal.SizeOf(typeof(InputWrapper)));
        }
예제 #58
0
        public static uint MouseMoveTo(int x, int y, bool virtualDesk = false)
        {
            var inputData = new InputWrapper[]
            {
                new InputWrapper
                {
                    Type = SendInputType.Mouse,
                    MKH = new MouseKeyboardHardwareUnion
                    {
                        Mouse = new MouseInputData
                        {
                            X = x,
                            Y = y,
                            Flags = MouseEventFlags.Move | MouseEventFlags.Absolute | (virtualDesk ? MouseEventFlags.VirtualDesktop : 0)
                        }
                    }
                }
            };

            return Interop.SendInput(1, inputData);
        }
예제 #59
0
        protected virtual void KeyRepeat(ScanCode repeatingKey)
        {
            var inputData = new InputWrapper[1]
            {
                InputSimulator.KeyWrapper(repeatingKey, false, ((int)repeatingKey & 0x100) == 0x100)
            };

            Interop.SendInput((uint)inputData.Length, inputData);
        }
예제 #60
0
        public static uint DoKeyDown(ScanCode scanCode, bool extended)
        {
            var inputData = new InputWrapper[]
            {
                KeyWrapper(scanCode, false, extended)
            };

            return Interop.SendInput(1, inputData);
        }