예제 #1
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                hudWidth  = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.x);
                hudDepth  = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.z);
                hudHeight = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.y) - 1.5f;

                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }
            if (data != null)
            {
                // HUDType = GetGameplayCoreHUDTypeForEnvironmentSize(data.environmentInfo.environmentType);
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
예제 #2
0
        public override void CounterInit()
        {
            // Yeah this is required.
            // If the Score Counter is all alone on its own Canvas with nothing to accompany them,
            // I need to give 'em a friend or else they get shy and hide away in the void.
            _ = CanvasUtility.CreateTextFromSettings(Settings, null);

            ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>();
            TextMeshProUGUI   old           = ScoreUIText(ref scoreUIController);
            GameObject        baseGameScore = RelativeScoreGO(ref coreGameHUD);

            relativeScoreText       = baseGameScore.GetComponent <TextMeshProUGUI>();
            relativeScoreText.color = Color.white;
            GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD);

            rankText       = baseGameRank.GetComponent <TextMeshProUGUI>();
            rankText.color = Color.white;

            Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            old.rectTransform.SetParent(currentCanvas.transform, true);
            baseGameScore.transform.SetParent(old.transform, true);
            baseGameRank.transform.SetParent(old.transform, true);

            if (!mainConfig.ItalicText)
            {
                old.fontStyle = relativeScoreText.fontStyle = rankText.fontStyle = FontStyles.Normal;
                Vector3 localPosition = relativeScoreText.rectTransform.localPosition;
                relativeScoreText.rectTransform.localPosition = new Vector3(0, localPosition.y, localPosition.z);
                localPosition = rankText.rectTransform.localPosition;
                rankText.rectTransform.localPosition = new Vector3(0, localPosition.y, localPosition.z);
            }

            switch (Settings.Mode)
            {
            case ScoreMode.RankOnly:
                Object.Destroy(baseGameScore.gameObject);
                break;

            case ScoreMode.ScoreOnly:
                Object.Destroy(baseGameRank.gameObject);
                break;
            }

            RectTransform pointsTextTransform = old.rectTransform;

            HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);

            Vector2 anchoredPos = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale));

            pointsTextTransform.localPosition    = anchoredPos * currentSettings.PositionScale;
            pointsTextTransform.localPosition    = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0);
            pointsTextTransform.localEulerAngles = Vector3.zero;

            Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>());

            relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateText;

            UpdateText();
        }
        private void InitClassicMode()
        {
            // Yeah this is required.
            // If the Score Counter is all alone on its own Canvas with nothing to accompany them,
            // I need to give 'em a friend or else they get shy and hide away in the void.
            _ = CanvasUtility.CreateTextFromSettings(Settings, null);

            ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>();
            TextMeshProUGUI   old = ScoreUIText(ref scoreUIController);

            // Setup Score Text
            GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD);

            relativeScoreText       = baseGameScore.GetComponent <TextMeshProUGUI>();
            relativeScoreText.color = Color.white;

            // Setup Rank Text
            GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD);

            rankText       = baseGameRank.GetComponent <TextMeshProUGUI>();
            rankText.color = Color.white;

            // Set up parenting
            Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            old.rectTransform.SetParent(currentCanvas.transform, true);
            baseGameScore.transform.SetParent(old.transform, true);

            // Hide score if we're not using it.
            if (!Configuration.Instance.showScore)
            {
                UnityEngine.Object.Destroy(baseGameScore.gameObject);
            }

            // Adjust font sizes.
            // TODO: Pull this from config?
            relativeScoreText.fontSize = 10;
            rankText.fontSize          = 30;


            baseGameRank.transform.SetParent(old.transform, true);
            RectTransform pointsTextTransform = old.rectTransform;
            HUDCanvas     currentSettings     = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);
            Vector2       anchoredPos         = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale));

            pointsTextTransform.localPosition    = anchoredPos * currentSettings.PositionScale;
            pointsTextTransform.localPosition    = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0);
            pointsTextTransform.localEulerAngles = Vector3.zero;

            UnityEngine.Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>());

            InitPercentageRing();

            // Shift text into proper positions
            rankText.rectTransform.anchoredPosition          += rankScoreOffset;
            relativeScoreText.rectTransform.anchoredPosition += rankScoreOffset;

            //relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateClassicModeText;
            UpdateClassicModeText();
        }
예제 #4
0
        public override void CounterInit()
        {
            ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>();
            TextMeshProUGUI   old           = ScoreUIText(ref scoreUIController);
            GameObject        baseGameScore = RelativeScoreGO(ref coreGameHUD);

            relativeScoreText       = baseGameScore.GetComponent <TextMeshProUGUI>();
            relativeScoreText.color = Color.white;
            GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD);

            rankText       = baseGameRank.GetComponent <TextMeshProUGUI>();
            rankText.color = Color.white;

            Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            old.rectTransform.SetParent(currentCanvas.transform, true);
            baseGameScore.transform.SetParent(old.transform, true);
            baseGameRank.transform.SetParent(old.transform, true);

            switch (Settings.Mode)
            {
            case ScoreMode.RankOnly:
                Object.Destroy(baseGameScore.gameObject);
                break;

            case ScoreMode.ScoreOnly:
                Object.Destroy(baseGameRank.gameObject);
                break;
            }

            RectTransform pointsTextTransform = old.rectTransform;

            HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);
            float     positionScale   = currentSettings?.PositionScale ?? 10;

            Vector2 anchoredPos = (CanvasUtility.GetAnchoredPositionFromConfig(Settings, currentSettings.IsMainCanvas) + offset) * positionScale;

            Plugin.Logger.Warn(anchoredPos.ToString());

            pointsTextTransform.anchoredPosition = anchoredPos;
            // I dont know why Personal Best has even the SLIGHTEST of influence on the position of Score Counter... but it does?
            if (!personalBest.Enabled)
            {
                pointsTextTransform.anchoredPosition -= new Vector2(0, 25);
            }
            pointsTextTransform.localPosition    = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0);
            pointsTextTransform.localEulerAngles = Vector3.zero;

            Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>());

            relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateText;

            UpdateText();
        }
예제 #5
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                var comboPos = coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position;

                hudWidth  = Mathf.Abs(comboPos.x);
                hudHeight = comboPos.y;
                hudDepth  = comboPos.z;

                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
        public override void CounterInit()
        {
            Canvas canvas = coreGameHUDController.GetComponentInChildren <SongProgressUIController>(true).GetComponent <Canvas>();

            canvas.gameObject.SetActive(true);

            Canvas    currentCanvas   = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
            HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromCanvas(currentCanvas);
            float     positionScale   = currentSettings?.PositionScale ?? 10;
            Vector2   anchoredPos     = (CanvasUtility.GetAnchoredPositionFromConfig(Settings, currentSettings.IsMainCanvas) + offset) * positionScale;

            canvas.transform.SetParent(currentCanvas.transform, true);

            RectTransform canvasRect = canvas.transform as RectTransform;

            canvasRect.anchoredPosition = anchoredPos;
            canvasRect.localPosition    = new Vector3(canvasRect.localPosition.x, canvasRect.localPosition.y, 0);
            canvasRect.localEulerAngles = Vector3.zero;
        }