//метод для обработчика события CreatingSticker public Stick СreatingStickerForHander(AnswerId answerId) { Stick stick = new Stick(answerId.id, User.id); User.sticks.Add(stick); return(stick); }
public DualShock(int i) { var suffix = (i == 0 ? "" : "2"); LStick = new Stick("LeftStickX"+suffix, "LeftStickY"+suffix); RStick = new Stick("RightStickX"+suffix, "RightStickY"+suffix); L1 = new Button("L1"+suffix); R1 = new Button("R1"+suffix); L2 = new Button("L2"+suffix); R2 = new Button("R2"+suffix); Start = new Button("Start"+suffix); Select = new Button("Select"+suffix); X = new Button("X"+suffix); O = new Button("O"+suffix); Triangle = new Button("Triangle"+suffix); Square = new Button("Square"+suffix); Up = new Button("Up"+suffix); Down = new Button("Down"+suffix); Left = new Button("Left"+suffix); Right = new Button("Right"+suffix); RStickBtn = new Button("RStickBtn"+suffix); LStickBtn = new Button("LStickBtn"+suffix); }
static void Main(string[] args) { var w1 = new Stick(); var s1 = new Skill(5, 1.5f); var f1 = new Warrior(); f1.Skill = s1; f1.Name = "DragonSlayer"; f1.Weapon = w1; var w2 = new Staff(); var s2 = new Skill(6, 2.0f); var f2 = new Mage(); f2.Skill = s2; f2.Name = "ILikeFire"; f2.Weapon = w2; var engine = new BattleEngine(); var winner = engine.Battle(f1, f2); var origColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"The Winner is ..... {winner.Name}"); Console.ForegroundColor = origColor; Console.ReadLine(); }
public HalfPadState(ControlSide side, PlayerIndex controllerIndex) { GamePadState gamePadState = GamePad.GetState(controllerIndex); if (side == ControlSide.left) { stick1 = new Stick(gamePadState.ThumbSticks.Left); stick2 = new Stick(gamePadState.DPad.Up, gamePadState.DPad.Down, gamePadState.DPad.Left, gamePadState.DPad.Right); Btn1 = gamePadState.Buttons.LeftShoulder; Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test Btn2AsTrigger = gamePadState.Triggers.Left; Btn3 = gamePadState.Buttons.LeftStick; BtnStart = gamePadState.Buttons.Back; } else //if (side == ControlSide.right) { stick1 = new Stick(gamePadState.ThumbSticks.Right); stick2 = new Stick(gamePadState.Buttons.Y, gamePadState.Buttons.A, gamePadState.Buttons.X, gamePadState.Buttons.B); Btn1 = gamePadState.Buttons.RightShoulder; Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test Btn2AsTrigger = gamePadState.Triggers.Right; Btn3 = gamePadState.Buttons.RightStick; BtnStart = gamePadState.Buttons.Start; } }
//сохранение стика (обновление) public static void SaveStick(Stick stick) { try { List <StickB> st = (from S in dataBase.Sticks where S.Id == stick.id select S).ToList(); foreach (var item in st) { item.Title = stick.title; item.Date = stick.date; item.Color = stick.color.ToString(); } dataBase.SubmitChanges(); if (stick.content.Count != 0) { SaveTextCheck(stick.content, stick.id); } if (stick.tags.Count != 0) { SaveTags(stick.tags, stick.id); } if (stick.idVisiters.Count != 0) { SaveFriends(stick.idVisiters, stick.id); } } catch { } }
public Stick_GE(PlayerID pID, Stick s, float uD, float lR) { thisPID = pID; stick = s; upDown = uD; leftRight = lR; }
public void Init(int id, InventoryManager iManager, Stick stickData) { index = id; manager = iManager; stick = stickData; stickArtImage.sprite = stick.stickArt; }
public override void Update() { if (targetedNode.enabled) { if (targetedNode.value == null) { Console.WriteLine("CAMERACONTROL: We've found it. We've finally found null."); } else { room.camera.pos = targetedNode.value.body.pos; return; } } KeyboardState state = KeyManager.newKeyboardState; KeyboardState oldstate = KeyManager.oldKeyboardState; bool up = state.IsKeyDown(Keys.Up); bool down = state.IsKeyDown(Keys.Down); bool left = state.IsKeyDown(Keys.Left); bool right = state.IsKeyDown(Keys.Right); Stick s = new Stick(up, down, left, right); room.camera.pos += s.v2 * velocity; }
// helper functions ///////////////////// public void MakeEdges() { _points = new List <Point>(); foreach (GameObject vert in _vertices) { Vector3 position = vert.transform.position; _points.Add(new Point(position.x, position.y)); } _sticks = new List <Stick>(); foreach (StickLister verletStick in _verletSticks) { if (verletStick.Pair.Count > 1) { GameObject firstVerlet = verletStick.Pair[0]; GameObject secondVerlet = verletStick.Pair[1]; Point firstPoint = _points[_vertices.IndexOf(firstVerlet)]; Point secondPoint = _points[_vertices.IndexOf(secondVerlet)]; Stick newStick = new Stick(firstPoint, secondPoint); newStick.IsConstraint = verletStick.isConstraint; _sticks.Add(newStick); } } }
/*public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse, ButtonState A_1, ButtonState X_2, ButtonState B_3, ButtonState Y_4, ButtonState Dpad_UpArrow, ButtonState Dpad_DownArrow, ButtonState Dpad_RightArrow, ButtonState Dpad_LeftArrow, ButtonState Select_TAB, ButtonState Start_ESC, ButtonState LeftBumper_Q, ButtonState RightBumper_E, ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1, float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0) { this.LeftStick_WASD = LeftStick_WASD; this.RightStick_Mouse = RightStick_Mouse; this.A_1 = A_1; this.X_2 = X_2; this.B_3 = B_3; this.Y_4 = Y_4; this.Dpad_UpArrow = Dpad_UpArrow; this.Dpad_DownArrow = Dpad_DownArrow; this.Dpad_RightArrow = Dpad_RightArrow; this.Dpad_LeftArrow = Dpad_LeftArrow; this.Select_TAB = Select_TAB; this.Start_ESC = Start_ESC; this.LeftBumper_Q = LeftBumper_Q; this.RightBumper_E = RightBumper_E; this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2; this.RightTrigger_Mouse1 = RightTrigger_Mouse1; this.LeftTriggerAnalog = LeftTriggerAnalog; this.RightTriggerAnalog = RightTriggerAnalog; }*/ //keyboard/mouse public InputState(Stick LeftStick_WASD, Stick RightStick_Mouse, ButtonState LeftTrigger_Mouse2, ButtonState RightTrigger_Mouse1, bool A_1, bool X_2, bool B_3, bool Y_4, bool Dpad_UpArrow, bool Dpad_DownArrow, bool Dpad_RightArrow, bool Dpad_LeftArrow, bool Select_TAB, bool Start_ESC, bool LeftBumper_Q, bool RightBumper_E, float LeftTriggerAnalog = 0, float RightTriggerAnalog = 0) { this.LeftStick_WASD = LeftStick_WASD; this.RightStick_Mouse = RightStick_Mouse; this.LeftTrigger_Mouse2 = LeftTrigger_Mouse2; this.RightTrigger_Mouse1 = RightTrigger_Mouse1; this.A_1 = A_1 ? ButtonState.Pressed : ButtonState.Released; this.X_2 = X_2 ? ButtonState.Pressed : ButtonState.Released; this.B_3 = B_3 ? ButtonState.Pressed : ButtonState.Released; this.Y_4 = Y_4 ? ButtonState.Pressed : ButtonState.Released; this.Dpad_UpArrow = Dpad_UpArrow ? ButtonState.Pressed : ButtonState.Released; this.Dpad_DownArrow = Dpad_DownArrow ? ButtonState.Pressed : ButtonState.Released; this.Dpad_RightArrow = Dpad_RightArrow ? ButtonState.Pressed : ButtonState.Released; this.Dpad_LeftArrow = Dpad_LeftArrow ? ButtonState.Pressed : ButtonState.Released; this.Select_TAB = Select_TAB ? ButtonState.Pressed : ButtonState.Released; this.Start_ESC = Start_ESC ? ButtonState.Pressed : ButtonState.Released; this.LeftBumper_Q = LeftBumper_Q ? ButtonState.Pressed : ButtonState.Released; this.RightBumper_E = RightBumper_E ? ButtonState.Pressed : ButtonState.Released; this.LeftTriggerAnalog = LeftTriggerAnalog; this.RightTriggerAnalog = RightTriggerAnalog; }
private void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = new Ray(transform.position, Vector3.forward); if (Physics.Raycast(ray, out RaycastHit hitInfo)) { if (hitInfo.collider.TryGetComponent(out Block block)) { _rigidbody.isKinematic = false; _rigidbody.velocity = Vector3.zero; } else if (hitInfo.collider.TryGetComponent(out Segment segment)) { _rigidbody.isKinematic = true; _rigidbody.velocity = Vector3.zero; } else if (hitInfo.collider.TryGetComponent(out Finish finish)) { _rigidbody.isKinematic = true; _rigidbody.velocity = Vector3.zero; FinishBlock?.Invoke(); } } } if (Input.GetMouseButton(0)) { if (_currentStick == null && _rigidbody.isKinematic == true) { _power = 0; _currentStick = CreateStick(); } _power += Time.deltaTime; _power = Mathf.Clamp(_power, 0f, 1f); if (_currentStick != null) { _currentStick.UpdateBlend(_power); } } if (Input.GetMouseButtonUp(0)) { transform.parent = null; if (_currentStick != null) { _rigidbody.isKinematic = false; _rigidbody.AddForce(Vector3.up * _jumpForce * _power, ForceMode.Impulse); Destroy(_currentStick.gameObject); } _currentStick = null; transform.rotation = Quaternion.identity;// new Quaternion(0, 0, 0, 0); transform.position = new Vector3(transform.position.x, transform.position.y, -4f); } }
public void SaveSticker(Stick stick, int index = -1) { if (index >= 0) { User.sticks[index] = stick; } Transfer.SendData(socket, new EditStick(stick)); }
public MobileInputs(GameObject body, float speed, GameObject model) { _myBody = body; _speed = speed; _myModel = model; stickAim = CanvasController.instance.aimStick; stick = CanvasController.instance.moveStick; }
protected void SetDirectionByStick(Stick stick) { character.baseParameter.moveParameter.direction = (int)stick; if (!IsLockDirection) { animation.SetPatternByStick(stick); } }
public void activateAI() { Stick = GameObject.FindGameObjectWithTag("Stick2"); stick = Stick.GetComponent <Stick>(); Debug.Log(Stick); Debug.Log(stick); activated = true; }
void CreateStickAndBall() { stickPrimary = new Stick(); ballPrimary = new Ball(); stickPrimary.Setup(GameMan.instance.GetItemMan().stickModel); ballPrimary.Setup(GameMan.instance.GetItemMan().ballModel); }
public void SetUp() { wizard = new Wizard("wizard"); magic = new Magic(); stick = new Stick(); armor = new Armor(); robes = new Robes(); }
public void TestMagicStickAttack() { MagicStick magicstick = new MagicStick(); Magic magic = new Magic(); Stick stick = new Stick(); int expected = (magic.AttackPower + stick.AttackPower * 3); Assert.AreEqual(expected, magicstick.AttackPower); }
///<summary> ///gets the stick information for specified controller index and returns an array of size 2 ///</summary> ///<example> ///<code> ///Stick[] sticks = getSticks(0); ///sticks[LS].x//gets the x component of the left stick ///</code> ///</example> public static Stick[] getSticks(int index) { Stick[] sticks = new Stick[2]; if (controllerConnected(index)) { getSticks(index, sticks); } return(sticks); }
public XBoxController(string device = "/dev/input/js0") { try { _fs = File.OpenRead(device); } catch (FileNotFoundException ex) { throw new ControllerNotConnectedExeption("Please connect the controller", ex); } Events = Observable.Create <JoystickEvent>(async(subject, token) => { try { while (true) { if (token.IsCancellationRequested) { subject.OnCompleted(); return; } var data = new byte[8]; var n = await _fs.ReadAsync(data, token); if (!token.IsCancellationRequested) { if (n != data.Length) { throw new IOException($"expected 8 bytes, got {n}"); } var value = BitConverter.ToInt16(data, 4); var timestamp = BitConverter.ToUInt32(data); if (data[6] == 1) { subject.OnNext(new ButtonEvent(timestamp, (Button)data[7], value != 0)); } else if (data[6] == 2) { subject.OnNext(new AxisEvent(timestamp, (Axis)data[7], value)); } } } } catch (Exception ex) { subject.OnError(ex); } }).Publish(); LeftStick = new Stick(Events, Axis.LeftStickX, Axis.LeftStickY); RightStick = new Stick(Events, Axis.RightStickX, Axis.RightStickY); Events.Connect(); }
private void Awake() { _controlls = new Input(); _controlls.InputPad.Jump.performed += Button => Jumps(); _controlls.InputPad.Run.performed += Stick => _stickAxis = Stick.ReadValue <Vector2>(); _controlls.InputPad.Run.canceled += Stick => _stickAxis = Vector2.zero; _controlls.InputPad.JetPack.performed += Trigger => Jet(); }
private void ActivateElements(Player player, int actionId) { // Get the Axis value of the Action from the Player float axisValue = player.GetAxis(actionId); if (axisValue == 0f) { return; // not active } // Get all the sources contributing to the Action IList <InputActionSourceData> sources = player.GetCurrentInputSources(actionId); // Check each source and activate the elements they map to for (int i = 0; i < sources.Count; i++) { InputActionSourceData source = sources[i]; // Try to get the GamepadTemplate from the Controller IGamepadTemplate gamepad = source.controller.GetTemplate <IGamepadTemplate>(); if (gamepad == null) { continue; // does not implement the Dual Analog Gamepad Template } // Get all element targets on the template by passing in the Action Element Map // This gives you the Template element targets that are mapped to the Controller element target. gamepad.GetElementTargets(source.actionElementMap, _tempTargetList); // Activate Template element targets for (int j = 0; j < _tempTargetList.Count; j++) { ControllerTemplateElementTarget target = _tempTargetList[j]; int templateElementId = target.element.id; ControllerUIElement uiElement = _uiElements[templateElementId]; if (target.elementType == ControllerTemplateElementType.Axis) { uiElement.Activate(axisValue); } else if (target.elementType == ControllerTemplateElementType.Button) { // If the target element is a Button, make sure the Button value of the Action is true before activating if (player.GetButton(actionId) || player.GetNegativeButton(actionId)) { uiElement.Activate(1f); } } // Move the stick for stick axes Stick stick = GetStick(templateElementId); if (stick != null) { stick.SetAxisPosition(templateElementId, axisValue * stickRadius); } } } }
//public void EditContentText(int indexSticker, int indexContent, string text) //{ // TextCheck content = User.sticks[indexSticker].content[indexContent]; // if (content.text != text) // { // content.text = text; // SaveSticker(User.sticks[indexSticker]); // } //} //public void EditContentIsChecked(int indexSticker, int indexContent, bool isChecked) //{ // TextCheck content = User.sticks[indexSticker].content[indexContent]; // if (content.isChecked != isChecked) // { // content.isChecked = isChecked; // SaveSticker(User.sticks[indexSticker]); // } //} public void EditTag(int indexSticker, int indexTag, string tag) { Stick stick = User.sticks[indexSticker]; if (stick.tags[indexTag] != tag) { stick.tags[indexTag] = tag; SaveSticker(stick); } }
public void EditTags(int indexSticker, List <string> tags) { Stick stick = User.sticks[indexSticker]; if (stick.tags.Except(tags).Count() != 0) { stick.tags = tags; SaveSticker(stick); } }
public void EditDate(int indexSticker, DateTime date) { Stick stick = User.sticks[indexSticker]; if (stick.date != date) { stick.date = date; SaveSticker(stick); } }
bool isActive; //Is the sword active? void Start() { //Get references to the sword and audio source components stick = GetComponent <Stick> (); stickAudio = GetComponent <AudioSource> (); //Set the initial volume and pitch stickAudio.volume = 0f; stickAudio.pitch = 0f; }
public void EditColor(int indexSticker, string color) { Stick stick = User.sticks[indexSticker]; if (stick.color != color) { stick.color = color; SaveSticker(stick); } }
/// <summary> /// See <see cref="IEtsInterface.GetHoleState(int)"/> /// </summary> public int GetHoleState(int holeIndex) { if (!query.dynamite) { Log.Warn("ETSI: Dynamite state accessed but not queried"); } Stick stick = state.dynamite.hole_states[holeIndex]; return(stick != null ? stick.id : -1); }
} //[X cordinations, Y cordinations] private float[] Get_Stick(Stick which) { float[] cord = { this.Rx, this.Ry }; if (which == Stick.L) { cord[0] = this.Lx; cord[1] = this.Ly; } return(cord); }
//public void AddFriend(int idFriend, int idStick) //{ // Transfer.SendData(socket, new AddFriend(User.id, idFriend, idStick)); //} public void EditTitle(int indexSticker, string title) { Stick stick = User.sticks[indexSticker]; if (stick.title != title) { stick.title = title; SaveSticker(stick); } }
//void Start() //{ // //Changes buffer size when the buffer percentage changes // InvokeRepeating("ChangeBufferSize", _gameManager.ChangeBufferPercentageTime, _gameManager.ChangeBufferPercentageTime); //} void FindComponents() { Values = this; //Finds Game Manager _gameManager = FindObjectOfType <GameManager>(); _stick = FindObjectOfType <Stick>(); //Finds renderer bounds StickmaxX = MyRenderer.bounds.max.x; StickminX = MyRenderer.bounds.min.x; }
private void Start() { CoinCollected?.Invoke(_coins); Ray ray = new Ray(transform.position, Vector3.forward); Physics.Raycast(ray, out RaycastHit hitInfo); _stick = Instantiate(_stickTemplate, GetSpawnPsition(hitInfo.point), _stickTemplate.transform.rotation); transform.parent = _stick.FixationPoint; _rigidbody = GetComponent <Rigidbody>(); }
public void PauseAIAndReturnToMiddle() { if (stick == null) { Stick = GameObject.FindGameObjectWithTag("Stick2"); stick = Stick.GetComponent <Stick>(); stick.ai = true; } stick.moveNeutral(); pause = true; }
static Vector2 GetRawStickValue(Stick stick) { if (!Enabled) { return(Vector3.zero); } Vector2 input; Controller activeController = Instance.activeController; if (stick is VirtualStick) { throw new System.ApplicationException("No external raw value for virtual sticks"); } else if (stick == Instance.leftStick) { input = new Vector2( Input.GetAxis("Horizontal"), Input.GetAxis("Vertical") ); if (activeController != null) { input = input.magnitude < activeController.LeftAxisMin ? Vector2.zero : input * activeController.LeftAxisScale; } return(input); } else if (stick == Instance.rightStick) { if (Instance.activeController != null) { string axisName = Instance.activeController.GetType().Name; input = new Vector2( Input.GetAxis(axisName + "RightX"), Input.GetAxis(axisName + "RightY") ); input = input.magnitude < activeController.RightAxisMin ? Vector2.zero : input * activeController.RightAxisScale; return(input); } else { return(new Vector2( Input.GetAxis("Mouse X"), -Input.GetAxis("Mouse Y") ) * (Utility.IsWindows ? WindowsMouseSensitivityScale : 1.0f)); } } return(Vector2.zero); }
public void SetPatternByStick(Stick st) { if(st == Stick.None)return; string newPattern=""; switch(st) { case Stick.Down:newPattern = Animations.DOWN;break; case Stick.Up:newPattern = Animations.UP;break; case Stick.Right:newPattern = Animations.RIGHT;break; case Stick.Left:newPattern = Animations.LEFT;break; case Stick.RightDown:newPattern = Animations.DOWNRIGHT;break; case Stick.RightUp:newPattern = Animations.UPRIGHT;break; case Stick.LeftUp:newPattern = Animations.UPLEFT;break; case Stick.LeftDOwn:newPattern = Animations.DOWNLEFT;break; } frontDirection = (int)st; if(parameter.pattern == newPattern)return; ChangePattern(newPattern); }
public void releaseStick(Stick stick) { holdStick(new StickState(stick, 0.0, 0.0)); }
public Vector2 GetStick(Stick stick) { return mStickStates[stick]; }
public override InputState GetState() { newKeyState = Keyboard.GetState(); newMouseState = Mouse.GetState(); Stick LeftStick_WASD = new Stick(newKeyState.IsKeyDown(Keys.W), newKeyState.IsKeyDown(Keys.S), newKeyState.IsKeyDown(Keys.A), newKeyState.IsKeyDown(Keys.D)); Stick RightStick_Mouse = new Stick(GetRightStick(mouseStickRadius)); newInputState = new InputState(LeftStick_WASD, RightStick_Mouse, newMouseState.RightButton, newMouseState.LeftButton, newKeyState.IsKeyDown(Keys.D1), newKeyState.IsKeyDown(Keys.D2), newKeyState.IsKeyDown(Keys.D3), newKeyState.IsKeyDown(Keys.D4), newKeyState.IsKeyDown(Keys.Up), newKeyState.IsKeyDown(Keys.Down), newKeyState.IsKeyDown(Keys.Right), newKeyState.IsKeyDown(Keys.Left), newKeyState.IsKeyDown(Keys.Tab), newKeyState.IsKeyDown(Keys.Escape), newKeyState.IsKeyDown(Keys.Q), newKeyState.IsKeyDown(Keys.E)); return newInputState; }
public static void Init(Graphics g,TextBox t,ShowOK CallBack) { NameInput = t; CallShowOK = CallBack; DrawMap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); gp = Graphics.FromImage(DrawMap); Sgp = g; rect = new Rectangle(Screen.PrimaryScreen.Bounds.Width/2-300, 0, 600, 400); startpoint = new Point(rect.X, rect.Y); DrawDelay.Interval = 10; DrawDelay.Tick += (new EventHandler((object sender, EventArgs e) => { DrawUI(); ((Timer)sender).Stop(); })); NameInput.Visible = false; NameInput.Location = new Point(startpoint.X + 130, 329); //NameInput.Parent.Focus(); //NameInput.KeyDown += new KeyEventHandler((object sender, KeyEventArgs e) => { // if (isEditName) // { // if (e.KeyCode == Keys.Enter) // { // ((Control.Button)SaveItem).SetName(NameInput.Text); // NameInput.Parent.Focus(); // NameInput.Visible = false; // isEditName = false; // DrawDelay.Start(); // } // } // else // { // ((TextBox)sender).Visible = false; // } //}); //--------按钮属性 ButtonInfo.Add(new Control.Button(startpoint.X + 10, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => { isEditKey = true; SelectButtonIndex = 0; if (ButtonUI.ScreenKeyboard) ButtonUI.ShowScreenKeyboard(); }))); ButtonInfo.Add(new Control.Button(startpoint.X + 120, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => { isEditName = true; NameInput.Visible = true; NameInput.Focus(); if (ButtonUI.ScreenKeyboard) ButtonUI.ShowScreenKeyboard(); }))); ButtonInfo.Add(new Control.Button(startpoint.X + 380, 310, 100, 80, "X方向缩放", 4, new Control.Button.ButtonCallBack((Control.Button b) => { if ((((Control.Button)SaveItem).mode & Control.Button.Button_IsRect) == 0) { if (ButtonXSize) { ButtonXSize = ButtonYSize = false; ButtonInfo[0].mode &= ~Control.Button.Button_IsUse; ButtonInfo[1].mode &= ~Control.Button.Button_IsUse; } else { ButtonXSize = ButtonYSize = true; ButtonInfo[0].mode |= Control.Button.Button_IsUse; ButtonInfo[1].mode |= Control.Button.Button_IsUse; } } else { if (ButtonXSize) { ButtonXSize = false; b.mode &= ~Control.Button.Button_IsUse; } else { ButtonXSize = true; b.mode |= Control.Button.Button_IsUse; } } DrawUI(); }))); ButtonInfo.Add(new Control.Button(startpoint.X + 490, 310, 100, 80, "Y方向缩放", 4, new Control.Button.ButtonCallBack((Control.Button b) => { if ((((Control.Button)SaveItem).mode & Control.Button.Button_IsRect)==0) { if (ButtonYSize) { ButtonXSize = ButtonYSize = false; ButtonInfo[0].mode &= ~Control.Button.Button_IsUse; ButtonInfo[1].mode &= ~Control.Button.Button_IsUse; } else { ButtonXSize = ButtonYSize = true; ButtonInfo[0].mode |= Control.Button.Button_IsUse; ButtonInfo[1].mode |= Control.Button.Button_IsUse; } } else { if (ButtonYSize) { ButtonYSize = false; b.mode &= ~Control.Button.Button_IsUse; } else { ButtonYSize = true; b.mode |= Control.Button.Button_IsUse; } } DrawUI(); }))); //--------- //------摇杆属性 StickInfo.Add(new Control.Button(startpoint.X + 10, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => { SelectButtonIndex = 0; isEditKey = true; if (ButtonUI.ScreenKeyboard) ButtonUI.ShowScreenKeyboard(); }))); StickInfo.Add(new Control.Button(startpoint.X + 160, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => { SelectButtonIndex = 1; isEditKey = true; if (ButtonUI.ScreenKeyboard) ButtonUI.ShowScreenKeyboard(); }))); StickInfo.Add(new Control.Button(startpoint.X + 310, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => { SelectButtonIndex = 2; isEditKey = true; if (ButtonUI.ScreenKeyboard) ButtonUI.ShowScreenKeyboard(); }))); StickInfo.Add(new Control.Button(startpoint.X + 490, 310, 100, 80, "", 4, new Control.Button.ButtonCallBack((Control.Button b) => { SelectButtonIndex = 3; isEditKey = true; if (ButtonUI.ScreenKeyboard) ButtonUI.ShowScreenKeyboard(); }))); //------- NewList.Add(new Control.Button(startpoint.X + 100 - 50, 200 - 50, 100, 100, "圆形按钮", 0, null, new Control.Button.ButtonCallBack((Control.Button b) => { Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - 50, 160); ControlBase item = new Control.Button(p.X,p.Y,100,100, "圆形按钮",(short)'A',0); item.g = gp; Touch.MobList.Add(item); SaveItem = item; DrawUI(); }))); NewList.Add(new Control.Button(startpoint.X + 300 - 50, 200 - 40, 100, 80, "方形按钮", 4, null, new Control.Button.ButtonCallBack((Control.Button b) => { Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - 50, 160); ControlBase item = new Control.Button(p.X, p.Y, 100, 80, "方形按钮", (short)'A', 4); item.g = gp; Touch.MobList.Add(item); SaveItem = item; DrawUI(); }))); NewList.Add(new Control.Stick(startpoint.X + 500 - 50, 200 - 50, 50, DefKeyList, 0, 110, 0.3F, 0.5F, new Stick.StickCallBack((Stick s) => { Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - 50, 160); ControlBase item = new Stick(p.X, p.Y, 50, DefKeyList); item.g = gp; Touch.MobList.Add(item); SaveItem = item; DrawUI(); }))); ContList.Add(new Control.Button(startpoint.X + 10, 0, 80, 50, "添加", 4, new Control.Button.ButtonCallBack((Control.Button b) => { isNewList = true; DrawNewList(); }))); ContList.Add(new Control.Button(startpoint.X + 110, 0, 80, 50, "删除", 4, new Control.Button.ButtonCallBack((Control.Button b) => { if (SaveItem != null) { Touch.MobList.Remove(SaveItem); SaveItem = null; DrawUI(); GC.Collect(); } }))); ContList.Add(new Control.Button(startpoint.X + 210, 0, 80, 50, "复制", 4, new Control.Button.ButtonCallBack((Control.Button b) => { if (SaveItem != null) { Point p = new Point(Screen.PrimaryScreen.Bounds.Width / 2-SaveItem.rect.Width/2,200-SaveItem.rect.Height/2); ControlBase item = SaveItem.clone(); item.setpos(p); Touch.MobList.Add(item); DrawUI(); } }))); ContList.Add(new Control.Button(startpoint.X + 310, 0, 80, 50, "放大", 4, new Control.Button.ButtonCallBack((Control.Button b) => { if (SaveItem != null) { if (SaveItem is Control.Button) { SaveItem.setsize(new Size((ButtonXSize) ? SaveItem.rect.Width + 10 : SaveItem.rect.Width, (ButtonYSize) ? SaveItem.rect.Height + 10 : SaveItem.rect.Height)); } else { SaveItem.setsize(new Size(SaveItem.rect.Width + 10, SaveItem.rect.Height + 10)); } SaveItem.setpos(SaveItem.rect.Location); DrawUI(); } }))); ContList.Add(new Control.Button(startpoint.X + 410, 0, 80, 50, "缩小", 4, new Control.Button.ButtonCallBack((Control.Button b) => { if (SaveItem != null) { if (SaveItem.rect.Width > 10 && SaveItem.rect.Height > 10) { if(SaveItem is Control.Button) SaveItem.setsize(new Size((ButtonXSize) ? SaveItem.rect.Width - 10 : SaveItem.rect.Width, (ButtonYSize) ? SaveItem.rect.Height - 10 : SaveItem.rect.Height)); else SaveItem.setsize(new Size(SaveItem.rect.Width - 10, SaveItem.rect.Height - 10)); SaveItem.setpos(SaveItem.rect.Location); DrawUI(); } } }))); ContList.Add(new Control.Button(startpoint.X + 510, 0, 80, 50, "关闭", 4,null, new Control.Button.ButtonCallBack((Control.Button b) => { Hide(); if (CallShowOK != null)CallShowOK(); }))); foreach (Control.Button b in ContList) b.g = gp; foreach (Control.ControlBase b in NewList) b.g = gp; foreach (Control.ControlBase b in ButtonInfo) b.g = gp; foreach (Control.ControlBase b in StickInfo) b.g = gp; }
protected void SetDirectionByStick(Stick stick) { character.baseParameter.moveParameter.direction = (int)stick; if (!IsLockDirection) animation.SetPatternByStick(stick); }
public bool IsPushStick(Stick stick) { return stick == stickPush; }
public bool IsDownStick(Stick stick) { return stick == stickDown; }
public void Update() { stickData = new Vector2(Input.GetAxisRaw(GetAxesFullName("StickX")), Input.GetAxisRaw(GetAxesFullName("StickY"))); Stick before = stickPush; stickPush = getPushStick; stickDown = before != stickPush ? stickPush : Stick.None; stickUp = stickPush == Stick.None ? before : Stick.None; }
public bool IsUpStick(Stick stick) { return stick == stickUp; }
public StickState(Stick stick, double x, double y) { Contract.Requires(-1.0 <= x && x <= 1.0); Contract.Requires(-1.0 <= y && y <= 1.0); this.stick = stick; this.x = x; this.y = y; }
public HalfPadState(FullPadMode mode, PlayerIndex controllerIndex) { GamePadState gamePadState = GamePad.GetState(controllerIndex, GamePadDeadZone.Circular); if (mode == FullPadMode.mirrorMode) { stick1 = new Stick(gamePadState.Buttons.Y, gamePadState.Buttons.A, gamePadState.Buttons.X, gamePadState.Buttons.B); if (stick1.isCentered()) { stick1 = new Stick(gamePadState.ThumbSticks.Left); } stick2 = new Stick(gamePadState.ThumbSticks.Right); if (stick2.isCentered()) { stick2 = new Stick(gamePadState.DPad.Up, gamePadState.DPad.Down, gamePadState.DPad.Left, gamePadState.DPad.Right); } Btn1 = gamePadState.Buttons.RightShoulder; if (Btn1 == ButtonState.Released) Btn1 = gamePadState.Buttons.LeftShoulder; Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test if (Btn2 == ButtonState.Released) Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; Btn2AsTrigger = Math.Max(gamePadState.Triggers.Right, gamePadState.Triggers.Left); Btn3 = gamePadState.Buttons.RightStick; if (Btn3 == ButtonState.Released) Btn3 = gamePadState.Buttons.LeftStick; BtnStart = gamePadState.Buttons.Start; if (BtnStart == ButtonState.Released) BtnStart = gamePadState.Buttons.Back; } else { stick1 = new Stick(gamePadState.ThumbSticks.Left); stick2 = new Stick(gamePadState.ThumbSticks.Right); if (stick2.isCentered()) { stick2 = new Stick(gamePadState.DPad.Up, gamePadState.DPad.Down, gamePadState.DPad.Left, gamePadState.DPad.Right); } Btn1 = gamePadState.Buttons.RightShoulder; if (Btn1 == ButtonState.Released) Btn1 = gamePadState.Buttons.LeftShoulder; if (Btn1 == ButtonState.Released) Btn1 = gamePadState.Buttons.A; Btn2 = (gamePadState.Triggers.Right < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; //TODO: test if (Btn2 == ButtonState.Released) Btn2 = (gamePadState.Triggers.Left < Controller.deadZone) ? ButtonState.Released : ButtonState.Pressed; if (Btn2 == ButtonState.Released) Btn2 = gamePadState.Buttons.B; if (Btn2 == ButtonState.Released) Btn2 = gamePadState.Buttons.Y; Btn2AsTrigger = Math.Max(gamePadState.Triggers.Right, gamePadState.Triggers.Left); if (gamePadState.Buttons.B == ButtonState.Pressed || gamePadState.Buttons.Y == ButtonState.Pressed) Btn2AsTrigger = 1.0f; Btn3 = gamePadState.Buttons.RightStick; if (Btn3 == ButtonState.Released) Btn3 = gamePadState.Buttons.LeftStick; if (Btn3 == ButtonState.Released) Btn3 = gamePadState.Buttons.X; BtnStart = gamePadState.Buttons.Start; if (BtnStart == ButtonState.Released) BtnStart = gamePadState.Buttons.Back; } }
//controller public InputState(ref GamePadState state, float triggerDeadZone) { this.LeftStick_WASD = new Stick(state.ThumbSticks.Left); this.LeftStick_WASD.v2.Y *= -1; //todo: fix directional buttonstates? this.RightStick_Mouse = new Stick(state.ThumbSticks.Right); this.RightStick_Mouse.v2.Y *= -1; this.LeftTrigger_Mouse2 = state.Triggers.Left > triggerDeadZone ? ButtonState.Pressed : ButtonState.Released; this.RightTrigger_Mouse1 = state.Triggers.Right > triggerDeadZone ? ButtonState.Pressed : ButtonState.Released; this.A_1 = state.Buttons.A; this.X_2 = state.Buttons.X; this.B_3 = state.Buttons.B; this.Y_4 = state.Buttons.Y; this.Dpad_UpArrow = state.DPad.Up; this.Dpad_DownArrow = state.DPad.Down; this.Dpad_RightArrow = state.DPad.Right; this.Dpad_LeftArrow = state.DPad.Left; this.Select_TAB = state.Buttons.Back; this.Start_ESC = state.Buttons.Start; this.LeftBumper_Q = state.Buttons.LeftShoulder; this.RightBumper_E = state.Buttons.RightShoulder; this.LeftTriggerAnalog = state.Triggers.Left; this.RightTriggerAnalog = state.Triggers.Right; }
static Vector2 GetRawStickValue (Stick stick) { if (!Enabled) { return Vector3.zero; } Vector2 input; Controller activeController = Instance.activeController; if (stick is VirtualStick) { throw new System.ApplicationException ("No external raw value for virtual sticks"); } else if (stick == Instance.leftStick) { input = new Vector2 ( Input.GetAxis ("Horizontal"), Input.GetAxis ("Vertical") ); if (activeController != null) { input = input.magnitude < activeController.LeftAxisMin ? Vector2.zero : input * activeController.LeftAxisScale; } return input; } else if (stick == Instance.rightStick) { if (Instance.activeController != null) { string axisName = Instance.activeController.GetType ().Name; input = new Vector2 ( Input.GetAxis (axisName + "RightX"), Input.GetAxis (axisName + "RightY") ); input = input.magnitude < activeController.RightAxisMin ? Vector2.zero : input * activeController.RightAxisScale; return input; } else { return new Vector2 ( Input.GetAxis ("Mouse X"), -Input.GetAxis ("Mouse Y") ) * (Utility.IsWindows ? WindowsMouseSensitivityScale : 1.0f); } } return Vector2.zero; }
void Start() { stick = stickGameObject.GetComponent<Stick>(); stickText = stickTextGameObject.GetComponent<Text>(); }