private IEnumerator OnPickup(Chara c) { GetComponent <Collider2D>().enabled = false; icon_text.gameObject.SetActive(false); // User user = c; user.on_pickup += OnUserPickupNew; user.on_use_power += Respawn; // Name text string key_name = InputExt.GetControlName(c.PlayerID, Control.Action); name_text.text = power.ToString(); if (key_name != "") { name_text.text += " [" + key_name + "]"; } for (int i = 0; i < 5; ++i) { name_text.gameObject.SetActive(i % 2 == 0); yield return(new WaitForSeconds(0.1f)); } yield return(new WaitForSeconds(0.3f)); name_text.gameObject.SetActive(false); }
public void ShowTagScreen(Chara winner, int[] scores) { GameManager gm = GameManager.Instance; Chara chaser = gm.GetChaser(); Chara runner = gm.GetRunner(); gm.HideCourt(); tag_screen.gameObject.SetActive(true); tag_text.color = chaser.PlayerColor; // Score score_left.color = chaser.PlayerID == 0 ? chaser.PlayerColor : Color.white; score_right.color = chaser.PlayerID == 1 ? chaser.PlayerColor : Color.white; score_left.text = gm.GetScores()[0].ToString(); score_right.text = gm.GetScores()[1].ToString(); // Continue text tag_continue_text.color = winner.PlayerColor; string control = InputExt.GetControlName(winner.PlayerID, Control.Action); if (control != "") { tag_continue_text.text = "press " + control; } else { tag_continue_text.text = ""; } }
//---------------------------------------------------------------------- public void EmitterUpdate(bool alive) { if (!IsActive || _updatePush) { return; } #if DEBUG if (InputExt.OnePressed(Keys.R) && InputExt.Pressed(Keys.LeftShift) || _StartSizeChange) { SizeChange(GraphicsExt.GetDeviceWidth, GraphicsExt.GetDeviceHeight, ((float)GraphicsExt.GetDeviceWidth) / 1920f); _StartSizeChange = false; } #endif IsAllAlive = alive; if (alive) { AliveUpdate(); for (int i = 0; i < _Child.Count; i++) { _Child[i].EmitterUpdate(alive); } } else { IdleUpdate(); } }
public void CheckAndInvokeEvent() { if (InputExt.GetButton(buttonName, buttonType)) { callback.Invoke(); } }
private void OnInputStart(ControlScheme cs) { // Slot already with this cs for (int i = 0; i < 2; ++i) { if ((ControlScheme)InputExt.GetPlayerScheme(i) == cs) { InputExt.SetPlayerControlScheme(i, ControlScheme.AI); //SoundManager.PlayClickSound(); player_change_sound.Play(); UpdateControlsText(i); return; } } // Assign cs to empty slot for (int i = 0; i < 2; ++i) { if ((ControlScheme)InputExt.GetPlayerScheme(i) == ControlScheme.AI) { InputExt.SetPlayerControlScheme(i, cs); //SoundManager.PlayClickSound(); player_change_sound.Play(); UpdateControlsText(i); return; } } }
// PUBLIC ACCESSORS public bool ValidControlChoices() { ControlScheme cs0 = (ControlScheme)InputExt.GetPlayerScheme(0); ControlScheme cs1 = (ControlScheme)InputExt.GetPlayerScheme(1); return((cs0 != ControlScheme.None && cs1 != ControlScheme.None) && (cs0 != cs1 || cs0 == ControlScheme.AI)); }
private void Update() { // If input button is registered, emit if (InputExt.GetButton(emitButtonName, buttonType)) { mousePosition = mainCamera.ScreenToWorldPoint(Input.mousePosition); emitter.Emit(mousePosition - (Vector2)transform.position); } }
private void UpdateDirectionKeys() { if (KeyboardEventHandler == null) { return; } var keyUp = false; foreach (var direction in DirectionExt.Values) { var keys = directionKeys[direction]; if (InputExt.IsAnyKeyDown(keys)) { pressedKeys.Add(direction); } else if (InputExt.IsAnyKeyUp(keys)) { pressedKeys.Remove(direction); keyUp = true; } } if (pressedKeys.Count > 0) { var movement = pressedKeys.Last; PanArgs args; if (movement == previousMovement) { args = new PanArgs(HandyDetector.Gesture.Press, PanArgs.State.Hold, Vector2.zero, Vector2.zero, Vector2.zero); } else { var delta = movement.Reverse().ToVector2(); args = new PanArgs(HandyDetector.Gesture.Press, PanArgs.State.Move, Vector2.zero, Vector2.zero, delta * 10); } KeyboardEventHandler.OnGesturePan(args); previousMovement = pressedKeys.Last; } else if (keyUp) { var args = new PanArgs(HandyDetector.Gesture.Press, PanArgs.State.Up, Vector2.zero, Vector2.zero, Vector2.zero); KeyboardEventHandler.OnGesturePan(args); previousMovement = null; } }
private void UpdateControlsText(int player_id) { if ((ControlScheme)InputExt.GetPlayerScheme(player_id) == ControlScheme.AI) { controls_text[player_id].text = controls_text_initial; } else { controls_text[player_id].text = InputExt.GetPlayerScheme(player_id).ToString(); } }
public override void UpdateIntput(UnitBase unit, MovementBase Movement) { Movement.SetMovementVector(InputExt.KeyBoardAnalrog); if (InputExt.OnePressed(Keys.Space)) { if (unit.Status.Attackevt != null) { unit.Status.Attackevt(unit); } } }
private void MovementPanel() { if (PanelExt.PressedSprite(_itemui.ParantMenu.UICamera, TopRect) && _oldMousePoint != Vector2.Zero) { TopRect.Select = true; } if (TopRect.Select) { if (InputExt.Released(MouseButtons.Left)) { TopRect.Select = false; } AmoundPostion(_itemui.ParantMenu.UICamera.ScreenToWorldMouse() - _oldMousePoint); } _oldMousePoint = _itemui.ParantMenu.UICamera.ScreenToWorldMouse(); }
private IEnumerator OnTagRoutine(Chara winner) { HideCourt(); // Wait for end of turn change if happened on same frame as turn change while (State == MatchState.TurnChange) { yield return(null); } // State and score State = MatchState.Tagged; ++scores[winner.PlayerID]; yield return(new WaitForSeconds(1f)); // Show UI match_ui.ShowTagScreen(winner, scores); charas[0].ShowReplay(); charas[1].ShowReplay(); // Wait if ((ControlScheme)InputExt.GetPlayerScheme(winner.PlayerID) == ControlScheme.AI) { yield return(new WaitForSeconds(2.5f)); } else { while (!InputExt.GetKeyDown(winner.PlayerID, Control.Action)) { yield return(null); } } // Hide UI match_ui.HideTagScreen(); // Reset if (on_reset != null) { on_reset(); } // Next turn StartNextTurn(); }
private void Initialize() { if (player_color_ids.Length != 2) { player_color_ids = new int[2]; player_color_ids[0] = UnityEngine.Random.Range(0, color_options.Length); player_color_ids[1] = UnityEngine.Random.Range(0, color_options.Length); if (!ValidColorChoices()) { player_color_ids[0] = (player_color_ids[0] + 1) % color_options.Length; } } // Controls InputExt.RegisterPlayers(2, ControlScheme.None); for (int i = 0; i < 2; ++i) { if (i < initial_control_schemes.Length) { InputExt.SetPlayerControlScheme(i, initial_control_schemes[i]); } } InputExt.AddAxis(ControlScheme.WASD, Control.X, KeyCode.A, KeyCode.D); InputExt.AddAxis(ControlScheme.WASD, Control.Y, KeyCode.S, KeyCode.W); InputExt.AddKey(ControlScheme.WASD, Control.Action, KeyCode.LeftShift, "L.Shift"); InputExt.AddKey(ControlScheme.WASD, Control.Start, KeyCode.LeftShift); InputExt.AddAxis(ControlScheme.Arrows, Control.X, KeyCode.LeftArrow, KeyCode.RightArrow); InputExt.AddAxis(ControlScheme.Arrows, Control.Y, KeyCode.DownArrow, KeyCode.UpArrow); InputExt.AddKey(ControlScheme.Arrows, Control.Action, KeyCode.RightShift, "R.Shift"); InputExt.AddKey(ControlScheme.Arrows, Control.Start, KeyCode.RightShift); InputExt.AddAxis(ControlScheme.Gamepad1, Control.X, "GP1_Horizontal"); InputExt.AddAxis(ControlScheme.Gamepad1, Control.Y, "GP1_Vertical"); InputExt.AddKey(ControlScheme.Gamepad1, Control.Action, KeyCode.Joystick1Button0, "A"); InputExt.AddKey(ControlScheme.Gamepad1, Control.Action, () => Input.GetAxis("GP1_Triggers") != 0); InputExt.AddKey(ControlScheme.Gamepad1, Control.Start, KeyCode.Joystick1Button7); InputExt.AddAxis(ControlScheme.Gamepad2, Control.X, "GP2_Horizontal"); InputExt.AddAxis(ControlScheme.Gamepad2, Control.Y, "GP2_Vertical"); InputExt.AddKey(ControlScheme.Gamepad2, Control.Action, KeyCode.Joystick2Button0, "A"); InputExt.AddKey(ControlScheme.Gamepad2, Control.Action, () => Input.GetAxis("GP2_Triggers") != 0); InputExt.AddKey(ControlScheme.Gamepad2, Control.Start, KeyCode.Joystick2Button7); }
private IEnumerator UpdateHuman() { while (true) { while (Time.timeScale == 0) { yield return(null); } des_move_dir = new Vector2( InputExt.GetAxis(PlayerID, Control.X), InputExt.GetAxis(PlayerID, Control.Y)).normalized; if (InputExt.GetKeyDown(PlayerID, Control.Action)) { UsePower(); } yield return(null); } }
private void Start() { Mgr = GameObject.FindGameObjectWithTag("BattleManager").GetComponent <BattleManager>(); KeyText.text = InputExt.ToPrettyString(Key, Modifier); Ability = Mgr.Player.GetAbility(AbilityIndex); if (HasAbility) { SpellText.text = Ability.Name; SpellImage.enabled = true; SpellImage.sprite = Resources.Load <Sprite>(Ability.ImagePath); } else { SpellText.text = ""; SpellImage.enabled = false; } CDMask.fillAmount = 0; }
// PUBLIC MODIFIERS public void Initialize(int id, Color color) { this.PlayerID = id; this.PlayerColor = color; waypoints = CourtManager.court.waypoints; start_pos = CourtManager.court.spawn_positions[PlayerID].position; Setup(); if ((ControlScheme)InputExt.GetPlayerScheme(id) == ControlScheme.AI) { StartCoroutine(UpdateAI()); } else { StartCoroutine(UpdateHuman()); } GameManager.Instance.on_reset += Setup; }
protected override void Update() { base.Update(); if (IsInteractable()) { // Controls start foreach (ControlScheme cs in human_controls) { if (InputExt.GetKeyDownCS(cs, Control.Start)) { OnInputStart(cs); } } // Color switching for (int i = 0; i < 2; ++i) { SwitchColor(i, InputExt.GetAxisOnce(i, Control.X, true)); } } }
public void KeyPressDebugView() { if (InputExt.OnePressed(Keys.F1)) { EnableOrDisableFlag(DebugViewFlags.Shape); } if (InputExt.OnePressed(Keys.F2)) { EnableOrDisableFlag(DebugViewFlags.DebugPanel); EnableOrDisableFlag(DebugViewFlags.PerformanceGraph); } if (InputExt.OnePressed(Keys.F3)) { EnableOrDisableFlag(DebugViewFlags.Joint); } if (InputExt.OnePressed(Keys.F5)) { EnableOrDisableFlag(DebugViewFlags.ContactPoints); EnableOrDisableFlag(DebugViewFlags.ContactNormals); } if (InputExt.OnePressed(Keys.F5)) { EnableOrDisableFlag(DebugViewFlags.PolygonPoints); } if (InputExt.OnePressed(Keys.F6)) { EnableOrDisableFlag(DebugViewFlags.Controllers); } if (InputExt.OnePressed(Keys.F7)) { EnableOrDisableFlag(DebugViewFlags.CenterOfMass); } if (InputExt.OnePressed(Keys.F8)) { EnableOrDisableFlag(DebugViewFlags.AABB); } }
public void Update(float textSpeed) { //Debug.Log(displayedText); //Debug.Log(currentEntry); //if (currentEntry == null) { // Debug.Log("Impossibru!"); //} if (currentEntry != null && displayedText.Length != currentEntry.Content.Length) { string previous = displayedText; float chars = (Time.time - entryStartTime) * textSpeed; if (chars < currentEntry.Content.Length) { displayedText = currentEntry.Content.Substring(0, (int)chars); } else { displayedText = currentEntry.Content; return; } isTalking = (previous != displayedText); if (IsTalking) { if (!voiceOutput.isPlaying) { voiceOutput.clip = currentEntry.Author.VoiceSample; voiceOutput.pitch = UnityEngine.Random.Range(1.25f, 1.75f); voiceOutput.Play(); } } } fastforward = Input.GetMouseButtonDown(0) || InputExt.IsAnyKeyDown(KeyCode.Space, KeyCode.Return); }
public static void Update(GameTime gameTime, float elapsedTime) { TimeExt.Update(gameTime, elapsedTime); InputExt.UpdateStates(); }
public static bool SelectUiSprite(SimpleCamera camera, Sprite sprite) { return(InputExt.OnePressed(MouseButtons.Left) && sprite.Bounds.Contains(camera.ScreenToWorldMouse())); }
public bool Supply() { return(InputExt.GetButton(buttonName, type)); }
void Awake() { handledKeys = handledKeys == null? new KeyCode[0]: handledKeys.Distinct().ToArray(); keyTrigger = new InputTrigger <KeyCode, Key> (() => InputExt.KeysFromCodes(handledKeys), Key.Canceled); }