protected void RaiseOnNewBoardPieceSelected(AbstractBoardPiece boardPiece, CustomInput.TouchInfo touchInfo) { if(OnNewBoardPieceSelected != null) { OnNewBoardPieceSelected(boardPiece, touchInfo); } }
/// <summary> /// Create a new instance of <see cref="KeyMapping"/> with 3 specified <see cref="CustomInput"/>. /// </summary> /// <param name="name">KeyMapping name.</param> /// <param name="primaryCustomInput">Primary input.</param> /// <param name="secondaryCustomInput">Secondary input.</param> /// <param name="thirdCustomInput">Third input.</param> public KeyMapping(string name = "", CustomInput primaryCustomInput = null, CustomInput secondaryCustomInput = null, CustomInput thirdCustomInput = null) { mName = name; primaryInput = primaryCustomInput; secondaryInput = secondaryCustomInput; thirdInput = thirdCustomInput; }
public void Enqueue (CustomInput currentInput) { if (currentInput.IsDown) { TouchManager.Instance.OnTouchStart (currentInput); } if (currentInput.IsUp) { TouchManager.Instance.OnTouchEnd (currentInput); } }
void Start() { if(instance!=null) { Destroy (gameObject, 0f); return; } instance = this; DontDestroyOnLoad(gameObject); keyDownListeners = new List<KeyListener>(); keyUpListeners = new List<KeyListener>(); keyHeldListeners = new List<KeyListener>(); }
private void Navigate(CustomInput.UserInput direction) { if ( EventSystem.current.currentSelectedGameObject == this.gameObject) { switch(direction) { case CustomInput.UserInput.Left: slider.value -= 1; break; case CustomInput.UserInput.Right: slider.value += 1; break; } if (sp) sp.SetVolume(slider.value); } }
private void setInput(CustomInput input) { switch (keyIndex) { case 0: keyMapping.primaryInput = input; break; case 1: keyMapping.secondaryInput = input; break; case 2: keyMapping.thirdInput = input; break; } updateText(); selectedButton = null; }
public static void Navigate(CustomInput.UserInput direction, GameObject defaultGameObject) { GameObject next = EventSystem.current.currentSelectedGameObject; if (next == null) { if(defaultGameObject != null) EventSystem.current.SetSelectedGameObject(defaultGameObject); return; } bool nextIsValid = false; while (!nextIsValid) { switch (direction) { case CustomInput.UserInput.Up: if (EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnUp() != null) next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnUp().gameObject; else next = null; break; case CustomInput.UserInput.Down: if (EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown() != null) next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown().gameObject; else next = null; break; case CustomInput.UserInput.Left: if (EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnLeft() != null) next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnLeft().gameObject; else next = null; break; case CustomInput.UserInput.Right: if (EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnRight() != null) next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnRight().gameObject; else next = null; break; } if (next != null) { EventSystem.current.SetSelectedGameObject(next); nextIsValid = next.GetComponent<Selectable>().interactable; } else nextIsValid = true; } }
private void Navigate(CustomInput.UserInput direction) { if ( EventSystem.current.currentSelectedGameObject == this.gameObject) { switch(direction) { case CustomInput.UserInput.Left: slider.value -= .01f; break; case CustomInput.UserInput.Right: slider.value += .01f; break; } } if (isSfx) GameManager.SFXVol = slider.value; else GameManager.MusicVol = slider.value; }
private void Navigate(CustomInput.UserInput direction) { GameObject next = EventSystem.current.currentSelectedGameObject; switch(direction) { case CustomInput.UserInput.Up: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnUp().gameObject; break; case CustomInput.UserInput.Down: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown().gameObject; break; case CustomInput.UserInput.Accept: var pointer = new PointerEventData(EventSystem.current); ExecuteEvents.Execute(EventSystem.current.currentSelectedGameObject, pointer, ExecuteEvents.submitHandler); return; } EventSystem.current.SetSelectedGameObject(next); }
private void Navigate(CustomInput.UserInput direction) { GameObject next = EventSystem.current.currentSelectedGameObject; switch(direction) { case CustomInput.UserInput.Up: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnUp().gameObject; break; case CustomInput.UserInput.Down: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown().gameObject; break; case CustomInput.UserInput.Left: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnLeft().gameObject; break; case CustomInput.UserInput.Right: next = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnRight().gameObject; break; } EventSystem.current.SetSelectedGameObject(next); }
public void OnNewBoardPieceSelected(AbstractBoardPiece boardPiece, CustomInput.TouchInfo touchInfo) { if(BoardShuffleController.Instance.IsBoardReshuffling) { return; } bool selectionSucces = false; selectedBoardPiece = boardPiece; tileToDestroy = boardPiece.Tile as Match3Tile; effectPosition = boardPiece.cachedTransform; //Decide wether this selection is icepick worthy or not if(boardPiece.Tile == null) { if(boardPiece is LayeredBoardPiece && (boardPiece as LayeredBoardPiece).NumLayers > 0 ) { selectionSucces = true; } } else if (!tileToDestroy.IsMoving && tileToDestroy.IsDestructible && !tileToDestroy.IsDestroying && !(tileToDestroy as NormalTile).IsFrozen()) { selectionSucces = true; } if(selectionSucces) { SoundManager.Instance.PlayOneShot("icepick_sfx"); touchController.StopInputController(); touchController.OnNewBoardPieceSelected -= OnNewBoardPieceSelected; StartItemEffects(); } }
public void OnDrag(CustomInput input) { if (this.Drag != null) this.Drag (this.gameObject, new CustomInputEventArgs (input)); }
public void OnTouchStart(CustomInput input) { if (this.TouchStart != null) this.TouchStart (this.gameObject, new CustomInputEventArgs (input)); }
/// <summary> /// Convert argument to <see cref="CustomInput"/>. /// </summary> /// <returns>Converted CustomInput.</returns> /// <param name="arg">Some kind of argument.</param> private static CustomInput ArgToInput(CustomInput arg) { return arg; }
public void Enqueue(CustomInput currentInput) { if (!(currentInput.IsDown || currentInput.IsDrag || currentInput.IsUp)) return; this.pastInputs.Add (currentInput); if (this.pastInputs.Count == 1) { //First Input currentInput.MovedDistance = Vector3.zero; currentInput.LevelingTime = 0; currentInput.LevelingOriginSpeedVector = Vector3.zero; } else { //currentInputからLevelingFrame数だけ古いフレームのInput CustomInput levelingOriginInput = this.pastInputs [0]; currentInput.MovedDistance = currentInput.ScreenPosition - levelingOriginInput.ScreenPosition; currentInput.LevelingTime = currentInput.Time - levelingOriginInput.Time;// this.LevelingFrameCount; currentInput.LevelingOriginSpeedVector = levelingOriginInput.SpeedVector; //フリック開始&継続判定 var lastInput = this.pastInputs [this.pastInputs.Count - 2]; if (lastInput.IsFlicking) { //継続判定 if (currentInput.SpeedVector.magnitude > this.DefeatSpeed) { currentInput.IsFlicking = true; } else { //フリック中止 this.FlickStartInput = null; currentInput.IsFlicking = false; this.FlickStartInput = null; } } else { //フリック開始判定 if (currentInput.AccelerationVector.magnitude > this.DetectAcceleration) { if (currentInput.SpeedVector.magnitude > 0.0001f) { if (!this.ContinuousDetect && this.IsDetected) { //指を離すまで再検知しない } else { currentInput.IsFlicking = true; this.FlickStartInput = currentInput; this.IsDetected = true; //フリック開始イベント TouchManager.Instance.OnFlickStart (new FlickEventArgs (levelingOriginInput, currentInput)); } } } } //フリック完了判定 if (currentInput.IsFlicking && currentInput.IsUp) { Vector3 flickDistance = currentInput.ScreenPosition - this.FlickStartInput.ScreenPosition; if (flickDistance.magnitude > this.MinFlickDistance) { //フリック成立 TouchManager.Instance.OnFlickComplete (new FlickEventArgs (this.pastInputs [this.pastInputs.Count - 2], currentInput)); //TouchManager.Instance.OnFlickComplete (new FlickEventArgs (this.FlickStartInput, currentInput)); currentInput.IsFlicking = false; this.FlickStartInput = null; } } //指が離れた if (currentInput.IsUp) { this.IsDetected = false; this.pastInputs.Clear(); } } while (this.pastInputs.Count > this.LevelingFrameCount) { this.pastInputs.RemoveAt (0); } }
/// <summary> Aims the gun. </summary> private void Aim() { float up, right; if (CustomInput.UsingPad) { up = CustomInput.Bool(CustomInput.UserInput.LookUp) ? CustomInput.Raw(CustomInput.UserInput.LookUp) : CustomInput.Raw(CustomInput.UserInput.LookDown); right = CustomInput.Bool(CustomInput.UserInput.LookRight) ? CustomInput.Raw(CustomInput.UserInput.LookRight) : CustomInput.Raw(CustomInput.UserInput.LookLeft); } else { Vector3 norm = (new Vector3(CustomInput.MouseX, CustomInput.MouseY, 0) - camera.WorldToScreenPoint(transform.position)).normalized; up = norm.y; right = norm.x; } if (right < 0) { FaceLeft(); } else { FaceRight(); } if (up == 0 && right == 0) { } else if (up == 0) { if (right < 0) { gun.transform.rotation = Quaternion.Euler(0, 0, 0); } else { gun.transform.rotation = Quaternion.Euler(0, 0, 0); } } else if (right == 0) { if (up < 0) { gun.transform.rotation = Quaternion.Euler(0, 0, 270); } else { gun.transform.rotation = Quaternion.Euler(0, 0, 90); } } else { if (right < 0) { gun.transform.rotation = Quaternion.Euler(0, 0, Mathf.Rad2Deg * Mathf.Atan(up / right)); } else { gun.transform.rotation = Quaternion.Euler(0, 0, Mathf.Rad2Deg * Mathf.Atan(up / right)); } } }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> public static KeyMapping SetKey(string name, KeyCode primary, CustomInput secondary) { return SetKey(name, ArgToInput(primary), ArgToInput(secondary)); }
public KeyMapping(string name, CustomInput primaryCustomInput = null, CustomInput secondaryCustomInput = null, CustomInput thirdCustomInput = null) { set(name, primaryCustomInput, secondaryCustomInput, thirdCustomInput); }
public void set(string name, CustomInput primaryCustomInput = null, CustomInput secondaryCustomInput = null, CustomInput thirdCustomInput = null) { mName = name; set(primaryCustomInput, secondaryCustomInput, thirdCustomInput); }
private void Update () { CustomInput currentInput = IsTouchPlatform ? InputOfTouch : InputOfMouse; foreach (var detector in this.Detectors) { detector.Enqueue (currentInput); } this.lastInput = currentInput; }
void InitializeInputNameKeys() { _MouseX = CustomInput.Name2Key("MouseX"); _MouseY = CustomInput.Name2Key("MouseY"); }
// Update is called once per frame void FixedUpdate() { if (time < 0.0f) { time += Time.deltaTime; } else if (playerControl) { time += Time.deltaTime; Rigidbody2D rb = GetComponent <Rigidbody2D>(); if (Input.GetButton("Accelerate")) { rb.AddForce(transform.right * speedForce); } if (Input.GetKey("left") || Input.GetKey("right")) { CustomInput.SetAxis("Horizontal", Input.GetAxis("Horizontal")); } else { CustomInput.SetAxis("Horizontal", 0); } rb.angularVelocity = (CustomInput.GetAxis("Horizontal") * torqueForce); rb.velocity = ForwardVelocity() + LeftVelocity() * driftFactor; if (hitWall && Parameters.wallDeath) { Destroy(me); } } else { // Update fitness time += Time.deltaTime; fitness += Vector3.Distance(lastposition, transform.position); lastposition = transform.position; // Check if collided with wall and if so update the fitness and destroy yourself if (hitWall || time > 70.0f || Parameters.killCommand) { isDone = true; } // Raycast double[] inputs = Raycast(); // Now do movement based on that double[] outputs = individual.computeOutput(inputs); Rigidbody2D rb = GetComponent <Rigidbody2D>(); if (outputs[0] > 0.5) { GetComponent <Rigidbody2D>().AddForce(transform.right * speedForce); } CustomInput.SetAxis("Horizontal", (float)outputs[1]); rb.angularVelocity = (CustomInput.GetAxis("Horizontal") * torqueForce); rb.velocity = ForwardVelocity() + LeftVelocity() * driftFactor; } if (Parameters.race && finished) { if (playerControl) { text.text = "Finished with time of " + time; } // Save highscore finished = false; if (name == null) { Parameters.listForHighScore.Add(new HighScoreData("Player", finalTime, Parameters.track)); } else { Parameters.listForHighScore.Add(new HighScoreData(name, finalTime, Parameters.track)); } } finalTime = time; }
private void Update() { // Get the input vector from keyboard or analog stick var directionVector = new Vector3(CustomInput.GetAxis(_HorizontalAxis), 0, CustomInput.GetAxis(_VerticalAxis)); // Debug.Log(directionVector); if (directionVector != Vector3.zero) { // Get the length of the directon vector and then normalize it // Dividing by the length is cheaper than normalizing when we already have the length anyway var directionLength = directionVector.magnitude; directionVector = directionVector / directionLength; // Make sure the length is no bigger than 1 directionLength = Mathf.Min(1, directionLength); // Make the input vector more sensitive towards the extremes and less sensitive in the middle // This makes it easier to control slow speeds when using analog sticks directionLength = directionLength * directionLength; // Multiply the normalized direction vector by the modified length directionVector = directionVector * directionLength; } // Apply the direction to the CharacterMotor motor.inputMoveDirection = transform.rotation * directionVector; motor.inputJump = CustomInput.GetButtonDown(_JumpButton); }
void InitializeInputNameKeys() { _HorizontalAxis = CustomInput.Name2Key("Horizontal"); _VerticalAxis = CustomInput.Name2Key("Vertical"); _JumpButton = CustomInput.Name2Key("Jump"); }
// Update is called once per frame void Update() { if (photonView.isMine) { if (Input.GetButtonDown("Run")) { if (!freeRunning) { freeRunning = true; } animator.SetBool("Walking", true); } if (Input.GetButtonUp("Run")) { if (freeRunning) { freeRunning = false; } animator.SetBool("Walking", false); } float strafeInput = 0; float forwardInput = 0; if (Input.touchCount == 0) { strafeInput = Input.GetAxis("Horizontal"); forwardInput = Input.GetAxis("Vertical"); } else { strafeInput = CustomInput.GetAxis("Horizontal"); forwardInput = CustomInput.GetAxis("Vertical"); if (Input.touchCount == 2) { freeRunning = true; } else if (freeRunning) { freeRunning = false; } } if (strafeInput != 0 || forwardInput != 0) { Vector3 dirToMove = Vector3.Normalize(camera.transform.forward * forwardInput + camera.transform.right * strafeInput); if (!freeRunning) //Fighting { transform.LookAt(new Vector3(GameObject.Find("Target").gameObject.transform.position.x, transform.position.y, GameObject.Find("Target").gameObject.transform.position.z)); float forwardWeight = Mathf.Sign(Vector3.Dot(dirToMove, transform.forward)) * Vector3.Project(dirToMove, transform.forward.normalized).magnitude; // Debug.Log("FORWARD WEIGHT: " + forwardWeight); float strafeWeight = Mathf.Sign(Vector3.Dot(dirToMove, transform.right)) * Vector3.Project(dirToMove, transform.right.normalized).magnitude; // Debug.Log("STRAFE WEIGHT: " + strafeWeight); rigidbody.MovePosition(transform.position + transform.forward * forwardWeight * forwardSpeed + transform.right * strafeWeight * strafeSpeed); } else //Running { Vector3 target = transform.position + dirToMove * 10; transform.LookAt(new Vector3(target.x, transform.position.y, target.z)); rigidbody.MovePosition(transform.position + transform.forward * runSpeed); } } } }
public void set(CustomInput primaryCustomInput = null, CustomInput secondaryCustomInput = null, CustomInput thirdCustomInput = null) { primaryInput = primaryCustomInput; secondaryInput = secondaryCustomInput; tertiaryInput = thirdCustomInput; }
/// <summary> /// Set the same <see cref="CustomInput"/> as in another instance. /// </summary> /// <param name="another">Another KeyMapping instance.</param> public void set(KeyMapping another) { mPrimaryInput = another.mPrimaryInput; mSecondaryInput = another.mSecondaryInput; mThirdInput = another.mThirdInput; }
void Start() { Debug.Log(inputs[currentInput]); CustomInput.setGamePadButton(CustomInput.UserInput.Accept, inputs[currentInput], playerNum); }
void Update() { if (state != State.waiting) { image.sprite = backgrounds[whichBackgroundForWhichPage[currentPage]]; text.text = currentText.ToString(); } if (state == State.waiting) { if (start) { GameState.Instance.State = Enums.GameState.Cutscene; state = State.displaying; pageChars = pageStrings[currentPage].ToCharArray(); canvas.SetActive(true); } } else if (state == State.displaying) { if (Util.CustomInput.BoolFreshPress(Util.CustomInput.UserInput.Pause)) { for (int i = Mathf.RoundToInt(currentLetter); i < pageChars.Length; i++) { currentText.Append(pageChars[i]); } state = State.paused; } else { if (currentLetter == 0) { currentText.Append(pageChars[(int)currentLetter]); } int a = (int)(currentLetter); float temp = textSpeed; if (Util.CustomInput.BoolHeld(Util.CustomInput.UserInput.Accept) || Util.CustomInput.BoolHeld(Util.CustomInput.UserInput.Attack)) { temp *= 2; } currentLetter += temp * Time.deltaTime; if (a < (int)currentLetter && currentLetter < pageChars.Length) { currentText.Append(pageChars[(int)currentLetter]); sound.PlaySong(0); } if (currentLetter >= pageChars.Length) { //currentText = new System.Text.StringBuilder(pageStrings[currentPage]); state = State.paused; } } } else { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept) || CustomInput.BoolFreshPress(CustomInput.UserInput.Attack) || CustomInput.BoolFreshPress(CustomInput.UserInput.Pause)) { currentLetter = 0; currentPage++; if (currentPage >= pages.Length) { text.text = ""; GameState.Instance.State = Enums.GameState.Playing; canvas.SetActive(false); Destroy(this.gameObject); } else { pageChars = pageStrings[currentPage].ToCharArray(); currentText = new System.Text.StringBuilder(); state = State.displaying; } } } }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> /// <param name="third">Third input.</param> public static KeyMapping SetKey(string name, MouseButton primary, MouseButton secondary, CustomInput third) { return SetKey(name, ArgToInput(primary), ArgToInput(secondary), ArgToInput(third)); }
void Update() { if (active && !finished && (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept) || CustomInput.BoolFreshPress(CustomInput.UserInput.Melee) || CustomInput.BoolFreshPress(CustomInput.UserInput.Shoot) || CustomInput.BoolFreshPress(CustomInput.UserInput.Screech) || CustomInput.BoolFreshPress(CustomInput.UserInput.Pause))) { if (!skipIcon.enabled) { skipIcon.enabled = true; skipTimer = skipTimerMax; } else { Skip(); } } if (skipTimer > 0) { skipTimer -= Time.deltaTime; if (skipTimer <= 0) { skipIcon.enabled = false; } } }
// Update is called once per frame void Update() { float lsh = Input.GetAxis("L_Stick_H"); float lsv = Input.GetAxis("L_Stick_V"); float dph = Input.GetAxis("D_Pad_H"); float dpv = Input.GetAxis("D_Pad_V"); if (lsh == 0 && lsv == 0 && dph == 0 && dpv == 0) { count_potepo = 1; } //UnityEngine.Debug.Log(currentScenes); if (currentScenes == 0) { if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown("joystick button 1") || Input.GetKeyDown("joystick button 0")) { audioSource.PlayOneShot(soundlist[1]); ShowSelect(); UnityEngine.Debug.Log("Return key was pressed."); } currentStage = 0; selectUpStage.GetComponent <Image>().sprite = spriteimages[(spriteimages.Length - 2)]; selectDownStage.GetComponent <Image>().sprite = spriteimages[2]; } else if (currentScenes == 1) { if (Input.GetKeyDown(KeyCode.UpArrow) || ((lsv > 0) && (lsv > lsh) && (count_potepo == 1)) || ((dpv > 0) && (dpv > dph) && (count_potepo == 1))) { count_potepo = 0; audioSource.PlayOneShot(soundlist[0]); if (currentStage == 0) { currentStage = spriteimages.Length / 2 - 1; } else { // 一周回るようにしたい currentStage--; } UnityEngine.Debug.Log("上矢印が押されました"); UnityEngine.Debug.Log(currentStage); selectStage.GetComponent <Image>().sprite = spriteimages[(currentStage + 1) * 2 - 1]; if (currentStage == 0) { selectUpStage.GetComponent <Image>().sprite = spriteimages[(spriteimages.Length - 2)]; } else { selectUpStage.GetComponent <Image>().sprite = spriteimages[(currentStage - 1) * 2]; } if (currentStage == spriteimages.Length / 2 - 1) { selectDownStage.GetComponent <Image>().sprite = spriteimages[0]; } else { selectDownStage.GetComponent <Image>().sprite = spriteimages[(currentStage + 1) * 2]; } } else if (Input.GetKeyDown(KeyCode.DownArrow) || ((lsv < 0) && (lsv < lsh) && (count_potepo == 1)) || ((dpv < 0) && (dpv < dph) && (count_potepo == 1))) { count_potepo = 0; audioSource.PlayOneShot(soundlist[0]); if (currentStage == spriteimages.Length / 2 - 1) { currentStage = 0; } else { // 一周回るようにしたい currentStage++; } UnityEngine.Debug.Log("下矢印が押されました"); UnityEngine.Debug.Log(currentStage); selectStage.GetComponent <Image>().sprite = spriteimages[(currentStage + 1) * 2 - 1]; if (currentStage == 0) { selectUpStage.GetComponent <Image>().sprite = spriteimages[(spriteimages.Length - 2)]; } else { selectUpStage.GetComponent <Image>().sprite = spriteimages[(currentStage - 1) * 2]; } if (currentStage == spriteimages.Length / 2 - 1) { selectDownStage.GetComponent <Image>().sprite = spriteimages[0]; } else { selectDownStage.GetComponent <Image>().sprite = spriteimages[(currentStage + 1) * 2]; } } else if (CustomInput.Interval_InputKeydown(KeyCode.Return, 3) || CustomInputJoyStick.Interval_InputKeydown("joystick button 1", 3) || CustomInputJoyStick.Interval_InputKeydown("joystick button 0", 3)) { audioSource.PlayOneShot(soundlist[1]); int[,] stagedata = stageinfo[currentStage]; UnityEngine.Debug.Log("return"); MainGameController.setStageData(stagedata); UnityEngine.Debug.Log(MainGameController.getStageData()); //SceneManager.LoadScene("tagaitest"); //SceneFadeManagerの中のフェードアウト開始関数を呼び出し fadeManager.fadeOutStart(0, 0, 0, 0, "tagaitest"); } } }
//The following methods control when and how you can transition between states private Enums.PlayerState Idle(bool hit, bool animDone, Enums.Direction direction, Enums.CardTypes type, bool handEmpty, int playerNumber) { if (hit) { return(Enums.PlayerState.Hit); } if (!handEmpty && CustomInput.BoolFreshPress(CustomInput.UserInput.UseCard, playerNumber)) { switch (type) { case Enums.CardTypes.SwordVert: return(Enums.PlayerState.VertiSwingHeavy); case Enums.CardTypes.SwordHori: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.WideSword: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.NaginataVert: return(Enums.PlayerState.VertiSwingHeavy); case Enums.CardTypes.NaginataHori: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.HammerVert: return(Enums.PlayerState.VertiSwingHeavy); case Enums.CardTypes.HammerHori: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.ThrowLight: return(Enums.PlayerState.ThrowLight); case Enums.CardTypes.ThrowMid: return(Enums.PlayerState.ThrowMid); case Enums.CardTypes.Shoot: return(Enums.PlayerState.Shoot); case Enums.CardTypes.ChiAttack: return(Enums.PlayerState.ChiAttack); case Enums.CardTypes.ChiStationary: return(Enums.PlayerState.ChiStationary); case Enums.CardTypes.Error: return(Enums.PlayerState.ChiAttack); case Enums.CardTypes.Fan: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Kanobo: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Tanto: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Wakizashi: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Tonfa: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.BoStaff: return(Enums.PlayerState.HoriSwingMid); } } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack, playerNumber)) { return(Enums.PlayerState.BasicAttack); } if (direction != Enums.Direction.None) { return(Enums.PlayerState.MoveBegining); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Taunt, playerNumber)) { float chance = UnityEngine.Random.Range(0f, 1f); if (chance < .225f) { return(Enums.PlayerState.TauntPointPoint); } else if (chance < .45f) { return(Enums.PlayerState.TauntThumbsDown); } else if (chance < .675f) { return(Enums.PlayerState.TauntWrasslemania); } else if (chance < .9f) { return(Enums.PlayerState.TauntYaMoves); } else { return(Enums.PlayerState.TauntGokuStretch); } } return(Enums.PlayerState.Idle); }
private void Update() { joyAxisWriter.Write(CustomInput.GetAxis(AxisName)); }
/// <summary> Gets input from mouse and controller to get offset vector. </summary> /// <returns> The offset vector. </returns> private Vector2 GetOffset() { Vector2 mouse = new Vector2((Managers.GameState.Instance.Inverted ? 1 : -1) * CustomInput.MouseYRaw, CustomInput.MouseXRaw); Vector2 controller = new Vector2( (Managers.GameState.Instance.Inverted ? 1 : -1) * (CustomInput.Bool(CustomInput.UserInput.LookUp) ? CustomInput.Raw(CustomInput.UserInput.LookUp) : CustomInput.Raw(CustomInput.UserInput.LookDown)), CustomInput.Bool(CustomInput.UserInput.LookRight) ? CustomInput.Raw(CustomInput.UserInput.LookRight) : CustomInput.Raw(CustomInput.UserInput.LookLeft)); return((mouse + controller) * Managers.GameState.Instance.Sensitivity); }
public void OnGUI() { if (!this.DebugMode) return; CustomInput input = this.lastInput; if (input == null) { input = new CustomInput (); } int i = 0; GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("ScreenPosition : X:{0} Y:{1}", input.ScreenPosition.x.ToString ("0"), input.ScreenPosition.y.ToString ("0"))); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("DeltaPosition : X:{0} Y:{1}", input.DeltaPosition.x.ToString ("0"), input.DeltaPosition.y.ToString ("0"))); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("DeltaTime : {0}sec", input.DeltaTime.ToString ("0.000"))); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("Time : {0}sec", input.Time.ToString ("0.000"))); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsDown : {0}", input.IsDown.ToString ())); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsUp : {0}", input.IsUp.ToString ())); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsDrag : {0}", input.IsDrag.ToString ())); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsFlicking : {0}", input.IsFlicking.ToString ())); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("TouchID : {0}", input.TouchId)); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("", "")); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("LevelingTime : {0}sec", input.LevelingTime.ToString ("0.000"))); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("MovedDistance : {0}", input.MovedDistance.magnitude)); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("Speed : {0} [X:{1},Y:{2}]", input.SpeedVector.magnitude, input.SpeedVector.x.ToString ("0"), input.SpeedVector.y.ToString ("0"))); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("LevelingOriginSpeed : {0} [X:{1},Y:{2}]", input.LevelingOriginSpeedVector.magnitude, input.LevelingOriginSpeedVector.x.ToString ("0"), input.LevelingOriginSpeedVector.y.ToString ("0"))); GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("Acceleration : {0} [X:{1},Y:{2}]", input.AccelerationVector.magnitude, input.AccelerationVector.x.ToString ("0"), input.AccelerationVector.y.ToString ("0"))); }
public void Enqueue(CustomInput currentInput) { if (!(currentInput.IsDown || currentInput.IsDrag || currentInput.IsUp)) { return; } this.pastInputs.Add(currentInput); if (this.pastInputs.Count == 1) { //First Input currentInput.MovedDistance = Vector3.zero; currentInput.LevelingTime = 0; currentInput.LevelingOriginSpeedVector = Vector3.zero; } else { //currentInputからLevelingFrame数だけ古いフレームのInput CustomInput levelingOriginInput = this.pastInputs [0]; currentInput.MovedDistance = currentInput.ScreenPosition - levelingOriginInput.ScreenPosition; currentInput.LevelingTime = currentInput.Time - levelingOriginInput.Time; // this.LevelingFrameCount; currentInput.LevelingOriginSpeedVector = levelingOriginInput.SpeedVector; //フリック開始&継続判定 var lastInput = this.pastInputs [this.pastInputs.Count - 2]; if (lastInput.IsFlicking) { //継続判定 if (currentInput.SpeedVector.magnitude > this.DefeatSpeed) { currentInput.IsFlicking = true; } else { //フリック中止 this.FlickStartInput = null; currentInput.IsFlicking = false; this.FlickStartInput = null; } } else { //フリック開始判定 if (currentInput.AccelerationVector.magnitude > this.DetectAcceleration) { if (currentInput.SpeedVector.magnitude > 0.0001f) { if (!this.ContinuousDetect && this.IsDetected) { //指を離すまで再検知しない } else { currentInput.IsFlicking = true; this.FlickStartInput = currentInput; this.IsDetected = true; //フリック開始イベント TouchManager.Instance.OnFlickStart(new FlickEventArgs(levelingOriginInput, currentInput)); } } } } //フリック完了判定 if (currentInput.IsFlicking && currentInput.IsUp) { Vector3 flickDistance = currentInput.ScreenPosition - this.FlickStartInput.ScreenPosition; if (flickDistance.magnitude > this.MinFlickDistance) { //フリック成立 TouchManager.Instance.OnFlickComplete(new FlickEventArgs(this.pastInputs [this.pastInputs.Count - 2], currentInput)); //TouchManager.Instance.OnFlickComplete (new FlickEventArgs (this.FlickStartInput, currentInput)); currentInput.IsFlicking = false; this.FlickStartInput = null; } } //指が離れた if (currentInput.IsUp) { this.IsDetected = false; } } while (this.pastInputs.Count > this.LevelingFrameCount) { this.pastInputs.RemoveAt(0); } }
void Update() { if (!start) { if (GameState.Instance.IsPaused && GameState.Instance.State != Enums.GameState.Cutscene) { return; } else if (!this.doOnce) { GameState.Instance.State = Enums.GameState.Cutscene; DungeonManager.GetHero().SetActive(false); for (int i = 0; i < this.actors.Length; i++) { if (this.actorEntrancePage[i] == 0) { this.actors[i].StartTranslate(true); } } this.doOnce = true; } } if (this.waitingToExit) { bool allDone = true; foreach (Effects.Translate actor in this.actors) { if (!actor.Finished) { allDone = false; } } if (allDone) { GameState.Instance.State = Enums.GameState.Playing; DungeonManager.GetHero().SetActive(true); DungeonManager.TransitionMaps(); } } if (this.state != State.waiting && !this.waitingToExit) { this.image.sprite = this.backgrounds[this.whichBackgroundForWhichPage[currentPage]]; this.text.text = this.currentText.ToString(); } if (this.state == State.waiting) { if (start) { this.state = State.displaying; this.pageChars = this.pageStrings[this.currentPage].ToCharArray(); this.canvas.SetActive(true); } else { bool allDone = true; foreach (Effects.Translate actor in this.actors) { if (!actor.Finished) { allDone = false; } } if (allDone) { start = true; } } } else if (this.state == State.displaying) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Pause)) { this.currentText = new System.Text.StringBuilder(this.pageStrings[this.currentPage]); this.state = State.paused; } else { if (this.currentLetter == 0) { this.currentText.Append(this.pageChars[(int)currentLetter]); } int a = (int)(currentLetter); float temp = this.textSpeed; if (CustomInput.BoolHeld(CustomInput.UserInput.Accept) || CustomInput.BoolHeld(CustomInput.UserInput.Attack)) { temp *= 2; } this.currentLetter += temp * Time.deltaTime; if (a < (int)this.currentLetter && this.currentLetter < this.pageChars.Length) { this.currentText.Append(this.pageChars[(int)this.currentLetter]); this.sound.PlaySong(0); } if (this.currentLetter >= this.pageChars.Length) { //currentText = new System.Text.StringBuilder(pageStrings[currentPage]); this.state = State.paused; } } } else { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept) || CustomInput.BoolFreshPress(CustomInput.UserInput.Attack) || CustomInput.BoolFreshPress(CustomInput.UserInput.Pause)) { this.currentLetter = 0; this.currentPage++; for (int i = 0; i < this.actors.Length; i++) { if (this.actorEntrancePage[i] == this.currentPage) { this.actors[i].StartTranslate(true); } } for (int i = 0; i < this.actors.Length; i++) { if (this.actorExitPage[i] == this.currentPage) { this.actors[i].transform.localScale = new Vector3( -this.actors[i].transform.localScale.x, this.actors[i].transform.localScale.y, this.actors[i].transform.localScale.z); this.actors[i].StartTranslate(false); } } if (this.currentPage >= this.pages.Length) { this.text.text = ""; this.canvas.SetActive(false); this.waitingToExit = true; this.start = false; this.state = State.waiting; } else { this.pageChars = this.pageStrings[this.currentPage].ToCharArray(); this.currentText = new System.Text.StringBuilder(); this.state = State.displaying; } } } }
protected void OnNewBoardPieceSelected(AbstractBoardPiece boardPiece, CustomInput.TouchInfo touchInfo) { // Debug.LogWarning("[OnNewBoardPieceSelect]"); if(BoardShuffleController.Instance.IsBoardReshuffling) { return; } if(startPosition == Vector3.zero) { startPosition = boardPiece.cachedTransform.position; } else { endPosition = boardPiece.cachedTransform.position; } }
void Update() { if (this.state != State.waiting) { this.image.sprite = this.backgrounds[this.whichBackgroundForWhichPage[currentPage]]; this.text.text = this.currentText.ToString(); } if (this.state == State.waiting) { if (start) { GameState.Instance.State = Enums.GameState.Cutscene; this.state = State.displaying; this.pageChars = this.pageStrings[this.currentPage].ToCharArray(); this.canvas.SetActive(true); } } else if (this.state == State.displaying) { if (CustomInput.BoolFreshPressDeleteOnRead(CustomInput.UserInput.Pause)) { this.currentText = new System.Text.StringBuilder(this.pageStrings[this.currentPage]); this.state = State.paused; } else { if (this.currentLetter == 0) { this.currentText.Append(this.pageChars[(int)currentLetter]); } int a = (int)(currentLetter); float temp = this.textSpeed; if (CustomInput.BoolHeld(CustomInput.UserInput.Accept) || CustomInput.BoolHeld(CustomInput.UserInput.Attack)) { temp *= 2; } this.currentLetter += temp * Time.deltaTime; if (a < (int)this.currentLetter && this.currentLetter < this.pageChars.Length) { this.currentText.Append(this.pageChars[(int)this.currentLetter]); this.sound.PlaySong(0); } if (this.currentLetter >= this.pageChars.Length) { //currentText = new System.Text.StringBuilder(pageStrings[currentPage]); this.state = State.paused; } } } else { if (CustomInput.BoolFreshPressDeleteOnRead(CustomInput.UserInput.Accept) || CustomInput.BoolFreshPressDeleteOnRead(CustomInput.UserInput.Attack) || CustomInput.BoolFreshPressDeleteOnRead(CustomInput.UserInput.Pause)) { this.currentLetter = 0; this.currentPage++; if (this.currentPage >= this.pages.Length) { this.text.text = ""; GameState.Instance.State = Enums.GameState.Playing; this.canvas.SetActive(false); Destroy(this.gameObject); } else { this.pageChars = this.pageStrings[this.currentPage].ToCharArray(); this.currentText = new System.Text.StringBuilder(); this.state = State.displaying; } } } }
void Update() { ControlBinderStateMachine.State prevState = currState; if (running) { bool accept = CustomInput.AcceptFreshPressDeleteOnRead; currState = machine.update(accept); if (prevState != currState) { foreach (GameObject g in cursors) { g.SetActive(false); } int cursor = (int)currState - 1; if (cursor >= 0 && cursor < 16) { cursors[cursor].SetActive(true); } else if (currState == ControlBinderStateMachine.State.Prep) { Kernel.disalble(); } else if (prevState == ControlBinderStateMachine.State.Holding) { Kernel.enalble(); } } if (accept) { if (currState == ControlBinderStateMachine.State.Default) { CustomInput.DefaultPad(); Attack.text = CustomInput.GamePadAttack; Block.text = CustomInput.GamePadBlock; Jump.text = CustomInput.GamePadJump; CycleLeft.text = CustomInput.GamePadCycleLeft; CycleRight.text = CustomInput.GamePadCycleRight; Left.text = CustomInput.GamePadLeft; Right.text = CustomInput.GamePadRight; ChangeColor.text = CustomInput.GamePadChangeColor; Up.text = CustomInput.GamePadUp; Down.text = CustomInput.GamePadDown; Super.text = CustomInput.GamePadSuper; Accept.text = CustomInput.GamePadAccept; Cancel.text = CustomInput.GamePadCancel; Pause.text = CustomInput.GamePadPause; } if (currState == ControlBinderStateMachine.State.Exit) { Kernel.controlsExit(); } } if (currState != ControlBinderStateMachine.State.GettingKey) { if (CustomInput.CancelFreshPressDeleteOnRead) { Kernel.controlsExit(); } } } }
void Awake () { gameObject.name = (GetComponent<NetworkView>().isMine ? "Local" : "Remote") + "_Player"; a.SetLayerWeight(1, 1); a.SetLayerWeight(2, 1); if(GetComponent<NetworkView>().isMine){ cInput = Utils.LoadInput(); foreach (GameObject go in FindObjectsOfType(typeof (GameObject))) go.SendMessage("OnPlayerSpawn", gameObject, SendMessageOptions.DontRequireReceiver); moveDirection_current = transform.TransformDirection(Vector3.forward); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.UNARMED, weapons.slots[(int)weapons.currentSlot].ID); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.HANDGUN, weapons.slots[(int)weapons.currentSlot].ID); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.SUBMACHINEGUN, weapons.slots[(int)weapons.currentSlot].ID); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.SHOTGUN, weapons.slots[(int)weapons.currentSlot].ID); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.SHOTGUN, weapons.slots[(int)weapons.currentSlot].ID); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.RIFLE, weapons.slots[(int)weapons.currentSlot].ID); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.RIFLE, weapons.slots[(int)weapons.currentSlot].ID); GetComponent<NetworkView>().RPC("AddOrReplaceWeapon", RPCMode.AllBuffered, (int)WeaponSystemSetupNetwork.Weapon_Slots.HEAVY, weapons.slots[(int)weapons.currentSlot].ID); weapons.currentSlot = TryToSelectSlot(WeaponSystemSetupNetwork.Weapon_Slots.HANDGUN); c.xInicial = c.camera_PositionOffset_normal.x; c.xInicialAiming = c.camera_PositionOffset_aiming.x; c.zInicial = c.camera_PositionOffset_normal.z; } }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> public static KeyMapping setKey(string name, CustomInput primary, MouseButton secondary) { return setKey(name, argToInput(primary), argToInput(secondary)); }
void Update() { if (Managers.GameManager.State == Enums.GameStates.Battle) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Up, Type)) { direction = Enums.Direction.Up; nextNode = currentNode.Up; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Down, Type)) { direction = Enums.Direction.Down; nextNode = currentNode.Down; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Left, Type)) { direction = Enums.Direction.Left; nextNode = currentNode.Left; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Right, Type)) { direction = Enums.Direction.Right; nextNode = currentNode.Right; } } else { direction = Enums.Direction.None; } //get next state currState = machine.update(hit, animDone, direction, hand.GetCurrentType(), hand.Empty(), playerNumber); //state clean up if (prevState != currState) { doOnce = false; animDone = false; attack = false; basicAttack = false; move = false; hit = false; if (weapon) { Destroy(weapon); } anim.SetInteger("state", (int)currState); } if (invunTimer > 0) { if (renderTimer > renderTime) { render = !render; renderTimer = 0; //GetComponent<Renderer>().enabled = render; } hit = false; renderTimer += Time.deltaTime; invunTimer -= Time.deltaTime; } else { //GetComponent<Renderer>().enabled = true; invun = false; } //run state doState[(int)currState](); if (move) { move = false; currentNode.clearOccupied(); currentNode = nextNode; currentNode.Owner = (this); transform.position = currentNode.transform.position; } if (useCard) { if (!hand.Empty()) { Enums.CardTypes type = hand.GetCurrentType(); if (type == Enums.CardTypes.SwordHori || type == Enums.CardTypes.SwordVert) { //weapon = Instantiate(Katana); //weapon.transform.parent = } else if (type == Enums.CardTypes.NaginataHori || type == Enums.CardTypes.NaginataVert) { } useCard = false; hand.UseCurrent(this); CardUIEvent(); } } if (basicAttack) { basicAttack = false; Weapons.Projectiles.Bullet b = Instantiate(bullet).GetComponent <Weapons.Projectiles.Bullet>(); b.transform.position = barrel.position; b.Direction = Direction; } if (damage > 0 && takeDamage) { takeDamage = false; TakeDamage(damage); damage = 0; } prevState = currState; } }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> /// <param name="third">Third input.</param> public static KeyMapping setKey(string name, MouseAxis primary, CustomInput secondary, MouseAxis third) { return setKey(name, argToInput(primary), argToInput(secondary), argToInput(third)); }
public CustomInputEventArgs (CustomInput input) { this.Input = input; }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> public static KeyMapping SetKey(string name, CustomInput primary, MouseAxis secondary) { return SetKey(name, ArgToInput(primary), ArgToInput(secondary)); }
void OnSensitivityChange(float value) { inputBinding.Sensitivity = value; CustomInput.SaveCustomControls(); }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> /// <param name="third">Third input.</param> public static KeyMapping SetKey(string name, MouseAxis primary, CustomInput secondary, KeyCode third) { return SetKey(name, ArgToInput(primary), ArgToInput(secondary), ArgToInput(third)); }
void OnInvertChanged(bool value) { inputBinding.InvertWhenReadAsAxis = value; CustomInput.SaveCustomControls(); }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> /// <param name="third">Third input.</param> public static KeyMapping SetKey(string name, CustomInput primary=null, CustomInput secondary=null, CustomInput third=null) { KeyMapping outKey = null; if (sKeysMap.TryGetValue(name, out outKey)) { outKey.primaryInput = primary; outKey.secondaryInput = secondary; outKey.thirdInput = third; } else { outKey = new KeyMapping(name, primary, secondary, third); sKeysList.Add(outKey); sKeysMap.Add(name, outKey); } return outKey; }
void OnStopScan() { CustomInput.SaveCustomControls(); RefreshText(); UIUtils.RestoreUIInputControl(); }
protected void CheckBoardTouch(Vector3 position, CustomInput.TouchInfo touchInfo) { boardCoord = ConvertToBoardCoord(position); if(boardCoord.row < 0 || boardCoord.row >= Match3BoardRenderer.Instance.Board.NumRows || boardCoord.col < 0 || boardCoord.col >= Match3BoardRenderer.Instance.Board.NumColumns) { return; } CustomInput.TouchInfo modifiedTouchInfo = new CustomInput.TouchInfo(touchInfo); modifiedTouchInfo.position = position; if(prevBoardCoord != boardCoord) { boardPiece = Match3BoardRenderer.Instance.Board[boardCoord.row, boardCoord.col]; RaiseOnNewBoardPieceSelected(boardPiece, modifiedTouchInfo); prevBoardCoord = boardCoord; } }
//Source: https://github.com/Gris87/InputControl /// <summary> /// Convert argument to <see cref="CustomInput"/>. /// </summary> /// <returns>Converted CustomInput.</returns> /// <param name="arg">Some kind of argument.</param> private static CustomInput argToInput(CustomInput arg) { return(arg); }
// Use this for initialization void Start() { input = GameObject.FindObjectOfType <CustomInput>(); }
//================================================================================================= ///The SetKey() and SetAxis() Functions called here are specific to our Controls.cs initialization. ///Additional functions (aside from Synthesis) can be found in <see cref="InputControl"/> ///Adapted from: https://github.com/Gris87/InputControl //================================================================================================= #region setKey() and SetAxis() Functions /// <summary> /// Creates new <see cref="KeyMapping"/> with specified name, primary KeyCode, and secondary CustomInput. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> public KeyMapping setKey(string name, KeyCode primary, CustomInput secondary) { return(SetKey(name, argToInput(primary), argToInput(secondary))); }
/// <summary> /// Create new <see cref="KeyMapping"/> with specified name and inputs. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> /// <param name="third">Third input.</param> public static KeyMapping setKey(string name, MouseButton primary, KeyCode secondary, CustomInput third) { return setKey(name, argToInput(primary), argToInput(secondary), argToInput(third)); }
/* * 0: Throttle * 1: Roll * 2: Pitch * 3: Yaw * 4: Tilt * 5: FoV * 6: Exit * 7: Submit * 8: Reset * 9: Flip */ void Update() { input.cancelButton = "empty"; input.submitButton = "empty"; input.horizontalAxis = "empty"; input.verticalAxis = "empty"; if (StaticDataAccess.config == null) { return; } if (StaticDataAccess.config.input == null) { return; } string cancelStr = "empty"; string submitStr = "empty"; string horizontalStr = "empty"; string verticalStr = "empty"; CustomInput inp = (CustomInput)StaticDataAccess.config.input; CustomInputAxis cancel = inp.axis.Length > 6 ? inp.axis[6] : null; CustomInputAxis submit = inp.axis.Length > 7 ? inp.axis[7] : null; CustomInputAxis horizontal = inp.axis.Length > 1 ? inp.axis[1] : null; CustomInputAxis vertical = inp.axis.Length > 2 ? inp.axis[2] : null; if (cancel != null) { if (cancel is ButtonInputAxis) { cancelStr = ((ButtonInputAxis)cancel).btnHigh; } if (cancel is SimpleInputAxis) { cancelStr = ((SimpleInputAxis)cancel).axisName; } } if (submit != null) { if (submit is ButtonInputAxis) { submitStr = ((ButtonInputAxis)submit).btnHigh; } if (submit is SimpleInputAxis) { submitStr = ((SimpleInputAxis)submit).axisName; } } if (horizontal != null) { if (horizontal is SimpleInputAxis) { horizontalStr = ((SimpleInputAxis)horizontal).axisName; } if (vertical is SimpleInputAxis) { verticalStr = ((SimpleInputAxis)vertical).axisName; } } input.cancelButton = cancelStr; input.submitButton = submitStr; input.horizontalAxis = horizontalStr; input.verticalAxis = verticalStr; }