void onTargetLaunch(YoumuSlashBeatMap.TargetBeat target) { if (!gameObject.activeInHierarchy || target.HitDirection != direction) { return; } var beat = target.LaunchBeat; CancelInvoke(); if (otherSideNumber.getStage() > 0 && beat - otherSideNumber.LastTriggeredBeat <= 1.01f) //If other side is not on stage 0, disable that and set this to next stage { setStage(otherSideNumber.getStage() + 1); otherSideNumber.setStage(0); otherSideNumber.CancelInvoke(); } else if (beat - LastTriggeredBeat <= 1.01f) { setStage(stage + 1); //Trigger next stage by default, max is handled naturally } else { setStage(1); } lastTriggeredBeat = lastIncrementedBeat = beat; invokeNextIncrement(); }
void onAttack(YoumuSlashBeatMap.TargetBeat target) { if (target != null) { setTrigger("Hit" + (target.HitDirection == YoumuSlashBeatMap.TargetBeat.Direction.Right ? "Right" : "Left")); } }
void onTargetLaunch(YoumuSlashBeatMap.TargetBeat target) { if (!gameObject.activeInHierarchy) { return; } if (target.HitDirection != direction) { return; } if (otherSideNumber.getStage() > 0) //If other side is not on stage 0, disable that and set this to next stage { setStage(otherSideNumber.getStage() + 1); otherSideNumber.setStage(0); } else //Otherwise we increment it ourselves { setStage(stage + 1); //Trigger next stage by default, max is handled naturally } if (target.LaunchBeat % 1f > 0f) { handleOffbeat(); //Set up off-beat increment loop if not on whole number beat } }
void Update() { if (beatTriggerResetTimer > 0) { beatTriggerResetTimer--; if (beatTriggerResetTimer <= 0) { rigAnimator.ResetTrigger("Beat"); } } if (slashCooldownTimer > 0f) { slashCooldownTimer = Mathf.MoveTowards(slashCooldownTimer, 0f, Time.deltaTime); if (!attackWasSuccess && slashCooldownTimer <= 0f) { returnToIdle(); } } handleInput(); var currentNextTarget = getFirstActiveTarget(); if (nextTarget != currentNextTarget) { if (nextTarget != null && !nextTarget.slashed) { triggerMiss(); if (failQueued) { fail(); } else if (canReactToMissedNote()) { playNoteMissReaction(); } else { noteMissReactionQueued = true; } } nextTarget = currentNextTarget; checkForGameplayEnd(); } else if (canReactToMissedNote()) { if (failQueued) { fail(); } else if (noteMissReactionQueued) { playNoteMissReaction(); } noteMissReactionQueued = false; } }
void onTargetLaunched(YoumuSlashBeatMap.TargetBeat target) { if (target.HitEffect.ToString().EndsWith("Burst")) { animator.SetInteger("BurstLevel", getBurstValue(target.HitEffect)); setTrigger("Burst"); } }
private void Start() { YoumuSlashTimingController.onBeat += onBeat; YoumuSlashTargetSpawner.OnTargetLaunch += onTargetLaunched; nextTarget = getFirstActiveTarget(); finalGameplayBeat = timingData.BeatMap.TargetBeats.Last().HitBeat; timeScale = Time.timeScale; }
void spawnTarget(YoumuSlashBeatMap.TargetBeat target) { if (target.LaunchBeat % 1f == 0f && timingData.LastProcessedBeat < (int)target.LaunchBeat) //If whole number, force TimingController to call OnBeat, to make sure beat is called before launch { YoumuSlashTimingController.onBeat(timingData.LastProcessedBeat + 1); } var newTargetInstance = Instantiate(target.TypeData.Prefab, transform.position, Quaternion.identity).GetComponent <YoumuSlashTarget>(); newTargetInstance.initiate(target); }
public void initiate(YoumuSlashBeatMap.TargetBeat mapInstance) { this.mapInstance = mapInstance; mapInstance.launchInstance = this; importTargetTypeTraits(mapInstance); isRight = mapInstance.HitDirection == YoumuSlashBeatMap.TargetBeat.Direction.Right; if (isRight) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } BroadcastMessage("onLaunch", MapInstance, SendMessageOptions.DontRequireReceiver); }
public void initiate(YoumuSlashBeatMap.TargetBeat mapInstance) { this.mapInstance = mapInstance; mapInstance.launchInstance = this; isRight = mapInstance.HitDirection == YoumuSlashBeatMap.TargetBeat.Direction.Right; if (isRight) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } sfxSource = GetComponent <AudioSource>(); sfxSource.panStereo = launchPan * (isRight ? 1f : -1f); sfxSource.pitch = (isRight ? rightPitch : leftPitch) * Time.timeScale; sfxSource.PlayOneShot(launchClip); }
void checkForGameplayEnd(YoumuSlashBeatMap.TargetBeat attackedBeat = null) { if (attackedBeat != null && attackedBeat.HitBeat >= finalGameplayBeat) { gameplayComplete = true; } else if (timingData.CurrentBeat >= finalGameplayBeat + hitTimeFudge.y) { gameplayComplete = true; } if (gameplayComplete) { AllowInput = false; onGameplayEnd(); } }
void onTargetLaunched(YoumuSlashBeatMap.TargetBeat target) { if (autoSlash) { Invoke("performAutoSlash", (target.HitBeat - timingData.CurrentBeat) * timingData.BeatDuration); } if ((!firstTargetStareMode || timingData.BeatMap.getFirstActiveTarget(timingData.CurrentBeat, hitTimeFudge.y) == target) && !attacking && getFirstHittableTarget(YoumuSlashBeatMap.TargetBeat.Direction.Any) == null) { rigAnimator.SetBool("LookBack", isFacingRight() != (target.HitDirection == YoumuSlashBeatMap.TargetBeat.Direction.Right)); } if (target.HitEffect.ToString().EndsWith("Burst")) { rigAnimator.ResetTrigger("UnSquint"); rigAnimator.SetTrigger("Squint"); rigAnimator.SetBool("ForceTense", true); Invoke("unSquint", timingData.BeatDuration * 4f); } }
void handleIdleAnimation(int beat) { nextTarget = timingData.BeatMap.getFirstActiveTarget((float)beat, hitTimeFudge.y); if (beat == nextIdleBeat) { if (nextTarget != null && beat >= (int)nextTarget.HitBeat) { nextIdleBeat++; return; } else { MicrogameController.instance.playSFX(debugSound); rigAnimator.SetTrigger("Idle"); rigAnimator.ResetTrigger("Attack"); rigAnimator.SetTrigger("Beat"); } } else if (beat > nextIdleBeat) { rigAnimator.SetTrigger("Beat"); } if (nextTarget != null && beat + 1 >= (int)nextTarget.HitBeat && !attacking) { bool flipIdle = nextTarget.HitDirection == YoumuSlashBeatMap.TargetBeat.Direction.Right; if (isRigFacingRight()) { flipIdle = !flipIdle; } setIdleFlipped(flipIdle); nextIdleBeat = beat + 2; } rigAnimator.SetBool("Prep", false); }
void importTargetTypeTraits(YoumuSlashBeatMap.TargetBeat target) { body.RigAnimator.runtimeAnimatorController = target.TypeData.Animator; body.BaseImage.sprite = target.TypeData.Image; launchSoundEffect = target.TypeData.LaunchSoundEffect; }
void onLaunch(YoumuSlashBeatMap.TargetBeat mapInstance) { target = mapInstance; }
private void Start() { YoumuSlashTimingController.onBeat += onBeat; YoumuSlashTargetSpawner.OnTargetLaunch += onTargetLaunched; nextTarget = getFirstActiveTarget(); }
void spawnTarget(YoumuSlashBeatMap.TargetBeat target) { var newTargetInstance = Instantiate(target.Prefab, transform.position, Quaternion.identity).GetComponent <YoumuSlashTarget>(); newTargetInstance.initiate(target); }