void FlickHandler(object sender, System.EventArgs e) { if (flickReady && flickCooldownTimer > FLICKCOOLDOWN && AnimationSetter.instance.state != MonsterState.Fall && AnimationSetter.instance.state != MonsterState.Dash) { FlickGesture gesture = sender as FlickGesture; TouchHit hitFlick; gesture.GetTargetHitResult(out hitFlick); Vector3 direction = hitFlick.Point - pressPoint; //print(direction.normalized.x + " , " + direction.normalized.y + " : " + direction.magnitude); if (direction.normalized.y < 0) { player.GetComponent <MonsterController>().SetDashPower(1); } else if (direction.magnitude > MAXDASHPOWER) { player.GetComponent <MonsterController>().SetDashPower(MAXDASHPOWER); } else { player.GetComponent <MonsterController>().SetDashPower(direction.magnitude); } //print(direction.magnitude); direction.Normalize(); //print(direction); player.GetComponent <MonsterController>().SetSwipeDirection(direction); AnimationSetter.instance.state = MonsterState.Dash; flickCooldownTimer = 0; } }
/// <summary> /// Handle flick events /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void flickHandler(object sender, EventArgs e) { // get the gesture that was sent to us, which will tell us // which object was flicked FlickGesture gesture = sender as FlickGesture; TouchHit hit; // get info about where the hit object was located when the gesture was // recognized - i.e., where on the object (in screen dimensions) did // the flick occur? if (gesture.GetTargetHitResult(out hit)) { Logger.Log("FLICK on " + gesture.gameObject.name + " at " + hit.Point); // fire event to logger to log this action if (this.logEvent != null) { // log the flick this.logEvent(this, new LogEvent(LogEvent.EventType.Action, gesture.gameObject.name, "flick", hit.Point)); } if (this.allowTouch) { // if flick/swipe was to the right, advance page if (gesture.ScreenFlickVector.x < 0) { ChangePage(Constants.NEXT); } // if to the left, go back a page else if (gesture.ScreenFlickVector.x > 0) { ChangePage(Constants.PREVIOUS); } } // trigger sound on flick as feedback? //if(this.allowTouch && !gesture.gameObject.tag.Contains(Constants.TAG_SIDEKICK)) //{ // Logger.Log("going to play a sound for " + gesture.gameObject.name); // PlaySoundAndPulse(gesture.gameObject); //} } else { // this probably won't ever happen, but in case it does, we'll log it Logger.LogWarning("!! could not register where FLICK was located!"); } }