public void ClearButton() { m_State = BUTTONSTATE.OFF; m_SpriteRender.sprite = m_SkinData.m_ButtonClear; if (m_GameManger.m_GameState == GAMESTATE.PLAYING) { m_Board.Action(m_TileValue, transform.localPosition); } }
//this function is called when a touch screen button is pressed public void OnTouchScreenInputEvent(string action, BUTTONSTATE buttonState) { onInputEvent(action, buttonState); //defend exception if (action == "Defend") { defendKeyDown = (buttonState == BUTTONSTATE.PRESS); } }
void OnInputEvent(string action, BUTTONSTATE buttonState) { if (buttonState != BUTTONSTATE.PRESS) { return; } //only apply the following actions if this UI gameobject is currently selected if (EventSystem.current.currentSelectedGameObject != gameObject) { return; } //move navigation up if (action == "Up") { Selectable elementUp = EventSystem.current.currentSelectedGameObject.GetComponent <Selectable>().FindSelectableOnUp(); if (elementUp != null) { StartCoroutine(selectUIItem(elementUp.gameObject)); } } //move navigation down if (action == "Down") { Selectable elementDown = EventSystem.current.currentSelectedGameObject.GetComponent <Selectable>().FindSelectableOnDown(); if (elementDown != null) { StartCoroutine(selectUIItem(elementDown.gameObject)); } } //move navigation left if (action == "Left") { Selectable elementLeft = EventSystem.current.currentSelectedGameObject.GetComponent <Selectable>().FindSelectableOnLeft(); if (elementLeft != null) { StartCoroutine(selectUIItem(elementLeft.gameObject)); } } //move navigation right if (action == "Right") { Selectable elementRight = EventSystem.current.currentSelectedGameObject.GetComponent <Selectable>().FindSelectableOnRight(); if (elementRight != null) { StartCoroutine(selectUIItem(elementRight.gameObject)); } } }
void OnInputEvent(string action, BUTTONSTATE buttonState) { if (buttonState != BUTTONSTATE.PRESS) { return; //only respond to button press states } Sprite icon = Resources.Load <Sprite>("Icons/Icon" + action); if (icon != null) { AddIcon(action.ToString(), icon); } }
void OnInputEvent(string action, BUTTONSTATE buttonState) { //move left if (action == "Left" && buttonState == BUTTONSTATE.PRESS) { OnLeftButtonDown(); } //move right if (action == "Right" && buttonState == BUTTONSTATE.PRESS) { OnRightButtonDown(); } }
//input actions void OnInputEvent(string action, BUTTONSTATE buttonState) { //ignore input when we are dead or when this state is not active if (!MovementStates.Contains(playerState.currentState) || isDead) { return; } //start a jump if (action == "Jump" && buttonState == BUTTONSTATE.PRESS && IsGrounded() && playerState.currentState != UNITSTATE.JUMPING) { JumpNextFixedUpdate = true; } //start running when a run button is pressed (e.g. Joypad controls) if (action == "Run") { playerState.SetState(UNITSTATE.RUN); } }
//input event private void OnInputEvent(string action, BUTTONSTATE buttonState) { if (buttonState != BUTTONSTATE.PRESS) { return; } //restart the current level if (GlobalGameSettings.LevelData.Count == 0 || lastLevelReached()) { LoadLevel(SceneManager.GetActiveScene().name, GlobalGameSettings.currentLevelId); } else { //load the next level if (GlobalGameSettings.LevelData.Count > 0) { LoadLevel(GetNextSceneName(), GlobalGameSettings.currentLevelId + 1); } } }
void Update() { if (m_oneClick && m_State == BUTTONSTATE.ON) { if (!m_gameTimer.getIsPlaying()) { m_gameTimer.startTimer(); } m_SpriteRender.sprite = m_SkinData.m_ButtonPressed; ClearButton(); StopCoroutine(CheckForLongPress()); m_oneClick = false; m_timerhold = 0; } if (m_HoldClick) { if (!m_gameTimer.getIsPlaying()) { m_gameTimer.startTimer(); } if (m_State == BUTTONSTATE.ON) { m_State = BUTTONSTATE.FLAGGED; } else if (m_State == BUTTONSTATE.FLAGGED) { m_State = BUTTONSTATE.QUESTIONED; } else if (m_State == BUTTONSTATE.QUESTIONED) { m_State = BUTTONSTATE.ON; } if (m_State == BUTTONSTATE.FLAGGED) { if (!m_SkinData.m_IsAnimated) { m_SpriteRender.sprite = m_SkinData.m_Flagged; } } else if (m_State == BUTTONSTATE.QUESTIONED) { if (!m_SkinData.m_IsAnimated) { m_SpriteRender.sprite = m_SkinData.m_Question; } } else if (m_State == BUTTONSTATE.ON) { if (!m_SkinData.m_IsAnimated) { m_SpriteRender.sprite = m_SkinData.m_ButtonUp; } } StopCoroutine(CheckForLongPress()); m_HoldClick = false; } }
//combat input event private void OnInputEvent(string action, BUTTONSTATE buttonState) { if (AttackStates.Contains(playerState.currentState) && !isDead) { //running punch if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && playerState.currentState == UNITSTATE.RUN && isGrounded) { animator.SetAnimatorBool("Run", false); if (RunningPunch.animTrigger.Length > 0) { doAttack(RunningPunch, UNITSTATE.ATTACK, "Punch"); } return; } //running kick if (action == "Kick" && buttonState == BUTTONSTATE.PRESS && playerState.currentState == UNITSTATE.RUN && isGrounded) { animator.SetAnimatorBool("Run", false); if (RunningKick.animTrigger.Length > 0) { doAttack(RunningKick, UNITSTATE.ATTACK, "Kick"); } return; } //pick up an item if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && itemInRange != null && isGrounded && currentWeapon == null) { interactWithItem(); return; } //use an weapon if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && isGrounded && currentWeapon != null) { useCurrentWeapon(); return; } //ground punch if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && (playerState.currentState != UNITSTATE.PUNCH && NearbyEnemyDown()) && isGrounded) { if (GroundPunchData.animTrigger.Length > 0) { doAttack(GroundPunchData, UNITSTATE.GROUNDPUNCH, "Punch"); } return; } //ground kick if (action == "Kick" && buttonState == BUTTONSTATE.PRESS && (playerState.currentState != UNITSTATE.KICK && NearbyEnemyDown()) && isGrounded) { if (GroundKickData.animTrigger.Length > 0) { doAttack(GroundKickData, UNITSTATE.GROUNDKICK, "Kick"); } return; } //reset combo when switching to another combo chain (user setting) if (resetComboChainOnChangeCombo && (action != lastAttackInput)) { attackNum = -1; } //default punch if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && playerState.currentState != UNITSTATE.PUNCH && playerState.currentState != UNITSTATE.KICK && isGrounded) { //continue to the next attack if the time is inside the combo window bool insideComboWindow = (lastAttack != null && (Time.time < (lastAttackTime + lastAttack.duration + lastAttack.comboResetTime))); if (insideComboWindow && !continuePunchCombo && (attackNum < PunchCombo.Length - 1)) { attackNum += 1; } else { attackNum = 0; } if (PunchCombo[attackNum] != null && PunchCombo[attackNum].animTrigger.Length > 0) { doAttack(PunchCombo[attackNum], UNITSTATE.PUNCH, "Punch"); } return; } //advance the punch combo if "punch" was pressed during a punch attack if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && (playerState.currentState == UNITSTATE.PUNCH) && !continuePunchCombo && isGrounded) { if (attackNum < PunchCombo.Length - 1) { continuePunchCombo = true; continueKickCombo = false; return; } } //jump punch if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && !isGrounded) { if (JumpKickData.animTrigger.Length > 0) { doAttack(JumpKickData, UNITSTATE.JUMPKICK, "Kick"); StartCoroutine(JumpKickInProgress()); } return; } //jump kick if (action == "Kick" && buttonState == BUTTONSTATE.PRESS && !isGrounded) { if (JumpKickData.animTrigger.Length > 0) { doAttack(JumpKickData, UNITSTATE.JUMPKICK, "Kick"); StartCoroutine(JumpKickInProgress()); } return; } //default kick if (action == "Kick" && buttonState == BUTTONSTATE.PRESS && playerState.currentState != UNITSTATE.KICK && playerState.currentState != UNITSTATE.PUNCH && isGrounded) { //continue to the next attack if the time is inside the combo window bool insideComboWindow = (lastAttack != null && (Time.time < (lastAttackTime + lastAttack.duration + lastAttack.comboResetTime))); if (insideComboWindow && !continueKickCombo && (attackNum < KickCombo.Length - 1)) { attackNum += 1; } else { attackNum = 0; } doAttack(KickCombo[attackNum], UNITSTATE.KICK, "Kick"); return; } //advance the kick combo if "kick" was pressed during a kick attack if (action == "Kick" && buttonState == BUTTONSTATE.PRESS && (playerState.currentState == UNITSTATE.KICK) && !continueKickCombo && isGrounded) { if (attackNum < KickCombo.Length - 1) { continueKickCombo = true; continuePunchCombo = false; return; } } } }