static void Postfix(GameplayModifiers gameplayModifiers, GameplayModifierParamsSO ____fasterSong, GameplayModifierParamsSO ____slowerSong, ref List <GameplayModifierParamsSO> __result)
 {
     if (gameplayModifiers is CustomGameplayModifiers)
     {
         ChallengeModifiers challenge = ((CustomGameplayModifiers)gameplayModifiers).challengeModifiers;
         if (challenge.songSpeed == GameplayModifiers.SongSpeed.Normal && challenge.speedMul != 1)
         {
             GameplayModifierParamsSO speedParamsSo = ScriptableObject.CreateInstance <GameplayModifierParamsSO>();
             speedParamsSo.SetPrivateField("_modifierNameLocalizationKey", "Song Speed - " + (int)(challenge.speedMul * 100) + "%");
             if (challenge.speedMul < 1)
             {
                 speedParamsSo.SetPrivateField("_descriptionLocalizationKey", "Song will play slower.");
                 speedParamsSo.SetPrivateField("_icon", ____slowerSong.icon);
             }
             else
             {
                 speedParamsSo.SetPrivateField("_descriptionLocalizationKey", "Song will play faster.");
                 speedParamsSo.SetPrivateField("_icon", ____fasterSong.icon);
             }
             __result.Add(speedParamsSo);
         }
         if (gameplayModifiers.failOnSaberClash)
         {
             __result.Add(APITools.CreateModifierParam(Assets.FailOnClashIcon, "Fail On Saber Clash", "If your sabers touch, you fail."));
         }
     }
 }
        public static GameplayModifierParamsSO CreateModifierParam(Sprite icon, string title, string desc)
        {
            GameplayModifierParamsSO param = ScriptableObject.CreateInstance <GameplayModifierParamsSO>();

            param.SetPrivateField("_modifierNameLocalizationKey", title);
            param.SetPrivateField("_descriptionLocalizationKey", desc);
            param.SetPrivateField("_icon", icon);
            return(param);
        }
Ejemplo n.º 3
0
        public override void Instantiate()
        {
            if (initialized)
            {
                return;
            }

            //We have to find our own target
            //TODO: Clean up time complexity issue. This is called for each new option
            SoloFreePlayFlowCoordinator sfpfc = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
            GameplaySetupViewController gsvc  = sfpfc.GetField <GameplaySetupViewController>("_gameplaySetupViewController");
            RectTransform container           = (RectTransform)gsvc.transform.Find("GameplayModifiers").Find("RightColumn");

            gameObject                         = UnityEngine.Object.Instantiate(container.Find("NoFail").gameObject, container);
            gameObject.name                    = optionName;
            gameObject.layer                   = container.gameObject.layer;
            gameObject.transform.parent        = container;
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.rotation      = Quaternion.identity;
            gameObject.SetActive(false);

            var gmt = gameObject.GetComponent <GameplayModifierToggle>();

            if (gmt != null)
            {
                gmt.toggle.isOn = GetValue;
                gmt.toggle.onValueChanged.RemoveAllListeners();
                gmt.toggle.onValueChanged.AddListener((bool e) => { OnToggle?.Invoke(e); });

                GameplayModifierParamsSO _gameplayModifier = new GameplayModifierParamsSO();
                _gameplayModifier.SetPrivateField("_modifierName", optionName);
                _gameplayModifier.SetPrivateField("_hintText", hintText);
                _gameplayModifier.SetPrivateField("_multiplier", 0.0f);
                _gameplayModifier.SetPrivateField("_icon", optionIcon == null ? gmt.GetPrivateField <GameplayModifierParamsSO>("_gameplayModifier").icon : optionIcon);
                gmt.SetPrivateField("_gameplayModifier", _gameplayModifier);

                if (hintText != String.Empty)
                {
                    var hoverHint = gmt.GetPrivateField <HoverHint>("_hoverHint");
                    hoverHint.text    = hintText;
                    hoverHint.name    = optionName;
                    hoverHint.enabled = true;
                    var hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();
                    hoverHint.SetPrivateField("_hoverHintController", hoverHintController);
                }
            }



            initialized = true;
        }
Ejemplo n.º 4
0
        public override void Instantiate()
        {
            gameObject       = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll <GameplayModifierToggle>().Where(g => g.transform.Find("BG"))?.Last().gameObject, Container);
            gameObject.name  = optionName;
            gameObject.layer = Container.gameObject.layer;
            gameObject.transform.SetParent(Container);
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.rotation      = Quaternion.identity;
            gameObject.SetActive(false);

            // Add a separator for this menu option
            AddSeparator(Container);

            // Remove the multiplier text if the toggle has no multiplier
            if (multiplier == 0)
            {
                gameObject.AddComponent <ToggleNameOverride>();
            }

            var currentToggle = gameObject.GetComponent <GameplayModifierToggle>();

            if (currentToggle != null)
            {
                currentToggle.toggle.isOn = GetValue;
                currentToggle.toggle.onValueChanged.RemoveAllListeners();
                currentToggle.toggle.onValueChanged.AddListener((bool e) => OnToggle?.Invoke(e));
                currentToggle.name = optionName;

                GameplayModifierParamsSO _gameplayModifier = ScriptableObject.CreateInstance <GameplayModifierParamsSO>();
                _gameplayModifier.SetPrivateField("_modifierName", optionName);
                _gameplayModifier.SetPrivateField("_hintText", hintText);
                _gameplayModifier.SetPrivateField("_multiplier", multiplier);
                _gameplayModifier.SetPrivateField("_icon", optionIcon == null ? UIUtilities.BlankSprite : optionIcon);
                currentToggle.SetPrivateField("_gameplayModifier", _gameplayModifier);

                if (hintText != String.Empty)
                {
                    HoverHint hoverHint = currentToggle.GetPrivateField <HoverHint>("_hoverHint");
                    hoverHint.text = hintText;
                    hoverHint.name = optionName;
                    HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();
                    hoverHint.SetPrivateField("_hoverHintController", hoverHintController);
                }
            }
            initialized = true;
        }
        public override void Instantiate()
        {
            //We have to find our own target
            //TODO: Clean up time complexity issue. This is called for each new option
            SoloFreePlayFlowCoordinator sfpfc = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
            GameplaySetupViewController gsvc  = sfpfc.GetField <GameplaySetupViewController>("_gameplaySetupViewController");
            RectTransform container           = (RectTransform)gsvc.transform.Find(pageName).Find(panelName);

            gameObject       = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll <GameplayModifierToggle>().Where(g => g.transform.Find("BG"))?.Last().gameObject, container);
            gameObject.name  = optionName;
            gameObject.layer = container.gameObject.layer;
            gameObject.transform.SetParent(container);
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.rotation      = Quaternion.identity;
            gameObject.SetActive(false);

            foreach (Transform t in container)
            {
                if (t.name.StartsWith("Separator"))
                {
                    separator      = UnityEngine.Object.Instantiate(t.gameObject, container);
                    separator.name = "ExtraSeparator";
                    separator.SetActive(false);
                    break;
                }
            }

            string ConflictText  = "\r\n\r\n<size=60%><color=#ff0000ff><b>Conflicts </b></color>";
            var    currentToggle = gameObject.GetComponent <GameplayModifierToggle>();

            if (currentToggle != null)
            {
                currentToggle.toggle.isOn = GetValue;
                currentToggle.toggle.onValueChanged.RemoveAllListeners();
                currentToggle.toggle.onValueChanged.AddListener((bool e) => OnToggle?.Invoke(e));
                currentToggle.name = optionName.Replace(" ", "");

                GameplayModifierToggle[] gameplayModifierToggles = Resources.FindObjectsOfTypeAll <GameplayModifierToggle>();

                if (conflicts.Count > 0)
                {
                    hintText += ConflictText;
                    foreach (string conflict in conflicts)
                    {
                        var conflictingModifier = gameplayModifierToggles.Where(t => t?.gameplayModifier?.modifierName == conflict).FirstOrDefault();
                        if (conflictingModifier)
                        {
                            if (!hintText.Contains(ConflictText))
                            {
                                hintText += ConflictText;
                            }

                            hintText += Char.ConvertFromUtf32((char)0xE069) + conflict + Char.ConvertFromUtf32((char)0xE069);
                        }
                    }
                }

                GameplayModifierParamsSO _gameplayModifier = new GameplayModifierParamsSO();
                _gameplayModifier.SetPrivateField("_modifierName", optionName);
                _gameplayModifier.SetPrivateField("_hintText", hintText);
                _gameplayModifier.SetPrivateField("_multiplier", multiplier);
                _gameplayModifier.SetPrivateField("_icon", optionIcon == null ? UIUtilities.BlankSprite : optionIcon);
                currentToggle.SetPrivateField("_gameplayModifier", _gameplayModifier);

                string currentDisplayName = Char.ConvertFromUtf32((char)0xE069) + optionName + Char.ConvertFromUtf32((char)0xE069);
                foreach (string conflictingModifierName in conflicts)
                {
                    GameplayModifierToggle conflictToggle = gameplayModifierToggles.Where(t => t?.gameplayModifier?.modifierName == conflictingModifierName).FirstOrDefault();
                    if (conflictToggle)
                    {
                        if (!conflictToggle.gameplayModifier.hintText.Contains(ConflictText))
                        {
                            conflictToggle.gameplayModifier.SetPrivateField("_hintText", conflictToggle.gameplayModifier.hintText + ConflictText);
                        }

                        if (!conflictToggle.gameplayModifier.hintText.Contains(currentDisplayName))
                        {
                            conflictToggle.gameplayModifier.SetPrivateField("_hintText", conflictToggle.gameplayModifier.hintText + currentDisplayName);
                        }

                        conflictToggle.toggle.onValueChanged.AddListener((e) => { if (e)
                                                                                  {
                                                                                      currentToggle.toggle.isOn = false;
                                                                                  }
                                                                         });
                        currentToggle.toggle.onValueChanged.AddListener((e) => { if (e)
                                                                                 {
                                                                                     conflictToggle.toggle.isOn = false;
                                                                                 }
                                                                        });
                    }
                }

                if (hintText != String.Empty)
                {
                    HoverHint hoverHint = currentToggle.GetPrivateField <HoverHint>("_hoverHint");
                    hoverHint.text = hintText;
                    hoverHint.name = optionName;
                    HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();
                    hoverHint.SetPrivateField("_hoverHintController", hoverHintController);
                }
            }
            initialized = true;
        }