// PRAGMA MARK - Public Interface public void SetupWithContext(RhythmSequence sequence) { this._sequence = sequence; this._sequence.OnSequenceFinished.AddListener(this.HandleSequenceFinished); this._sequence.OnKeyframeHit.AddListener(this.HandleKeyframeHit); this._sequence.OnKeyframesChanged.AddListener(this.HandleSequenceKeyframesChanged); }
// PRAGMA MARK - Public Interface public override void Apply(Battle battle, List <Actor> teammates, List <Actor> enemies, Actor actor, Actor target) { RhythmSequence sequence = RhythmSequenceManager.Instance.StartSequence(this.moveKeyframes, actor.transform.position); sequence.OnSequenceFinished.AddListener(this.HandleSequenceFinished); this._actor = actor; this._target = target; this._enemies = enemies; }
private void HandleSequenceFinished(RhythmSequence sequence, RhythmSequenceResult result) { this._result = result; this.DoAfterDelay(this._attackStartDelay, () => { sequence.OnSequenceFinished.RemoveListener(this.HandleSequenceFinished); this._actor.FlashyAnimateTo(this._target.AttackedPosition, this._rushTrigger, this._additionalScaling); this.DoAfterDelay(0.2f, () => { this._actor.transform.position = new Vector3(this._actor.transform.position.x, this._actor.transform.position.y, this._actor.transform.position.z - 6.0f); }); this._actor.OnFinishedFlashyAnimating.AddListener(this.Attack); }); }
private void HandleSequenceFinished(RhythmSequence sequence, RhythmSequenceResult result) { Vector3 storedPosition = this.transform.position; if (result.keyframeCount == 3 || result.keyframeCount == 4) { this.DoAfterDelay(0.2f, () => { string prefabName = ""; if (result.keyframeCount == result.perfectHitCount) { prefabName = "UltimateFloatingTextSFX"; CameraController.Main <CameraController>().Shake(GameConstants.Instance.kAttackShakeMagnitude * 1.0f, GameConstants.Instance.kAttackShakeDuration * 2.0f); } else if (result.keyframeCount == result.missCount) { prefabName = "SubparFloatingTextSFX"; CameraController.Main <CameraController>().Shake(GameConstants.Instance.kAttackShakeMagnitude * 0.7f, GameConstants.Instance.kAttackShakeDuration * 2.0f); } else { prefabName = "PrettyGoodFloatingTextSFX"; CameraController.Main <CameraController>().Shake(GameConstants.Instance.kAttackShakeMagnitude * 0.3f, GameConstants.Instance.kAttackShakeDuration * 2.0f); } SoundManager.Instance.PlaySoundFile(4); GameObject floatingTextSFXObject = Toolbox.GetInstance <ObjectPoolManager>().Instantiate(prefabName); floatingTextSFXObject.transform.SetParent(CanvasUtil.MainCanvas.transform, worldPositionStays: false); RectTransform rectTransform = (RectTransform)floatingTextSFXObject.transform; Vector2 anchoredPosition = rectTransform.anchoredPosition; if (storedPosition.x > 0.0f) { anchoredPosition = anchoredPosition.SetX(-anchoredPosition.x); } // rectTransform.anchoredPosition = anchoredPosition + (Vector2)Camera.main.WorldToScreenPoint(storedPosition); FloatingTextSFX floatingTextSFX = floatingTextSFXObject.GetComponent <FloatingTextSFX>(); floatingTextSFX.SetText(""); }); } foreach (KeyValuePair <RhythmSequenceKeyframe, RhythmSequenceKeyframeVisualizer> pair in this._visualizerMap) { pair.Value.FadeAway(); } this._container.SetActive(false); }