Пример #1
0
        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);
        }
Пример #2
0
        private void HandleKeyframeHit(RhythmSequenceKeyframe keyframe, RhythmSequenceKeyframeRating rating)
        {
            string prefabName = "";

            switch (rating)
            {
            case RhythmSequenceKeyframeRating.PERFECT:
                prefabName = "PerfectFloatingTextSFX";
                CameraController.Main <CameraController>().Shake(GameConstants.Instance.kAttackShakeMagnitude * 0.6f, GameConstants.Instance.kAttackShakeDuration * 2.0f);
                SoundManager.Instance.PlaySoundFile(2);
                break;

            case RhythmSequenceKeyframeRating.GOOD:
                prefabName = "GoodFloatingTextSFX";
                CameraController.Main <CameraController>().Shake(GameConstants.Instance.kAttackShakeMagnitude * 0.4f, GameConstants.Instance.kAttackShakeDuration * 1.5f);
                SoundManager.Instance.PlaySoundFile(0);
                break;

            case RhythmSequenceKeyframeRating.MISS:
            default:
                prefabName = "MissFloatingTextSFX";
                CameraController.Main <CameraController>().Shake(GameConstants.Instance.kAttackShakeMagnitude * 0.2f, GameConstants.Instance.kAttackShakeDuration);
                SoundManager.Instance.PlaySoundFile(1);
                break;
            }

            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 (this.transform.position.x > 0.0f)
            {
                anchoredPosition = anchoredPosition.SetX(-anchoredPosition.x);
            }

            rectTransform.anchoredPosition = anchoredPosition + (Vector2)Camera.main.WorldToScreenPoint(this.transform.position);

            FloatingTextSFX floatingTextSFX = floatingTextSFXObject.GetComponent <FloatingTextSFX>();

            floatingTextSFX.SetText(rating.ToString());

            this._visualizerMap[keyframe].FadeAway();
            this._visualizerMap.Remove(keyframe);
        }
        protected virtual void DoDamage()
        {
            float computedAttackMultiplier = this._attackMultiplier + (this._perfectMultiplier * this._result.perfectHitCount) + (this._goodMultiplier * this._result.goodHitCount) + (this._missMultiplier * this._result.missCount);

            int damage = (int)(this._actor.attackPower * computedAttackMultiplier);

            this._target.health -= damage;
            this._target.AnimatorDamage();

            if (this._target.health <= 0)
            {
                this._target.Die();
            }

            GameObject floatingTextSFXObject = Toolbox.GetInstance <ObjectPoolManager>().Instantiate("DamageFloatingTextSFX");

            floatingTextSFXObject.transform.SetParent(CanvasUtil.MainCanvas.transform, worldPositionStays: false);
            ((RectTransform)floatingTextSFXObject.transform).anchoredPosition = (Vector3)((RectTransform)floatingTextSFXObject.transform).anchoredPosition + Camera.main.WorldToScreenPoint(this._target.transform.position);

            FloatingTextSFX floatingTextSFX = floatingTextSFXObject.GetComponent <FloatingTextSFX>();

            floatingTextSFX.SetText(string.Format("-{0}", damage));
        }