private void BuildItemImages()
        {
            if (itemImages != null && itemImages.Length > 0)
            {
                foreach (GameObject obj in itemImages)
                {
                    Destroy(obj);
                }
            }

            itemImages = new GameObject[validItems.Length, 4];

            for (int i = 0; i < itemImages.GetLength(0); i++)
            {
                itemImages[i, 0] = CanvasUtil.CreateImagePanel(gameObject,
                                                               RandomizerMod.GetSprite(items[validItems[i]].SpriteName),
                                                               new CanvasUtil.RectData(new Vector2(90, 90), Vector2.zero, new Vector2(0.525f, 0f),
                                                                                       new Vector2(0.525f, 0f)));
                itemImages[i, 1] = CanvasUtil.CreateImagePanel(gameObject, geoSprite,
                                                               new CanvasUtil.RectData(new Vector2(50, 50), Vector2.zero, new Vector2(0.57f, 0f),
                                                                                       new Vector2(0.57f, 0f)));

                int cost = (int)(items[validItems[i]].Cost * (items[validItems[i]].DungDiscount ? 0.75f : 1));
                itemImages[i, 2] = CanvasUtil.CreateTextPanel(gameObject, cost.ToString(), 34, TextAnchor.MiddleCenter,
                                                              new CanvasUtil.RectData(new Vector2(1920, 1080), Vector2.zero, new Vector2(0.61f, 0f),
                                                                                      new Vector2(0.61f, 0f)), Fonts.Get("Perpetua"));

                if (type == ShopType.Geo && cost > Ref.PD.geo ||
                    type == ShopType.Essence && cost > Ref.PD.dreamOrbs)
                {
                    itemImages[i, 3] = CanvasUtil.CreateImagePanel(gameObject, blackPixel,
                                                                   new CanvasUtil.RectData(new Vector2(300, 100), Vector2.zero, new Vector2(0.57f, 0f),
                                                                                           new Vector2(0.57f, 0f)));
                    itemImages[i, 3].GetComponent <Image>().preserveAspect = false;
                }
            }

            foreach (GameObject obj in itemImages)
            {
                obj.SetActive(false);
            }
        }
        public static GameObject Show(string spriteKey, string takeKey, string nameKey, string buttonKey,
                                      string descOneKey, string descTwoKey, GameObject fsmObj = null, string eventName = null)
        {
            // Create base canvas
            GameObject canvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));

            // Add popup component, set values
            BigItemPopup popup = canvas.AddComponent <BigItemPopup>();

            popup._imagePrompt = RandomizerMod.GetSprite(spriteKey);
            popup._takeText    = Language.Language.Get(takeKey, "Prompts").Replace("<br>", " ");
            popup._nameText    = Language.Language.Get(nameKey, "UI").Replace("<br>", " ");
            popup._buttonText  = Language.Language.Get(buttonKey, "Prompts").Replace("<br>", " ");
            popup._descOneText = Language.Language.Get(descOneKey, "Prompts").Replace("<br>", " ");
            popup._descTwoText = Language.Language.Get(descTwoKey, "Prompts").Replace("<br>", " ");
            popup._fsmObj      = fsmObj;
            popup._fsmEvent    = eventName;

            return(canvas);
        }
示例#3
0
        private void btn_load_rom_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                string filePath = openFileDialog1.FileName;


                _currentRom = new TmosRom();
                _currentRom.LoadRom(filePath);

                _randomizerMod = new RandomizerMod();
                _randomizerMod.LoadDataFromRom(_currentRom);

                _randomizerMod.Randomize();

                //Init display stuff
                Init();
            }
            //update initial settings display
        }
        private IEnumerator ShowShop()
        {
            GameObject background = CanvasUtil.CreateImagePanel(gameObject,
                                                                RandomizerMod.GetSprite("UI.Shop.Background"),
                                                                new CanvasUtil.RectData(new Vector2(810, 813), Vector2.zero, new Vector2(0.675f, 0.525f),
                                                                                        new Vector2(0.675f, 0.525f)));

            GameObject bottomFleur = CanvasUtil.CreateImagePanel(gameObject,
                                                                 RandomizerMod.GetSprite("Anim.Shop.BottomFleur.0"),
                                                                 new CanvasUtil.RectData(new Vector2(811, 241), Vector2.zero, new Vector2(0.675f, 0.3f),
                                                                                         new Vector2(0.675f, 0.3f)));

            StartCoroutine(AnimateImage(bottomFleur, bottomFrames, 12));
            StartCoroutine(TweenY(bottomFleur, 0.3f, 0.2f, 60, 15));

            GameObject topFleur = CanvasUtil.CreateImagePanel(gameObject,
                                                              RandomizerMod.GetSprite("Anim.Shop.TopFleur.0"),
                                                              new CanvasUtil.RectData(new Vector2(808, 198), Vector2.zero, new Vector2(0.675f, 0.6f),
                                                                                      new Vector2(0.675f, 0.6f)));

            StartCoroutine(AnimateImage(topFleur, topFrames, 12));
            StartCoroutine(TweenY(topFleur, 0.6f, 0.85f, 60, 15));

            yield return(StartCoroutine(CanvasUtil.FadeInCanvasGroup(background.AddComponent <CanvasGroup>())));

            CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.Shop.Selector"),
                                        new CanvasUtil.RectData(new Vector2(340, 113), Vector2.zero, new Vector2(0.57f, 0.5825f),
                                                                new Vector2(0.57f, 0.5825f)));
            CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.Shop.Shitpost"),
                                        new CanvasUtil.RectData(new Vector2(112, 112), Vector2.zero, new Vector2(0.6775f, 0.92f),
                                                                new Vector2(0.6775f, 0.92f)));

            ResetItems();

            StartCoroutine(ListenForInput());
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != SceneName)
            {
                return;
            }



            // Find the shop and save an item for use later
            GameObject    shopObj    = GameObject.Find(ObjectName);
            ShopMenuStock shop       = shopObj.GetComponent <ShopMenuStock>();
            GameObject    itemPrefab = Object.Instantiate(shop.stock[0]);

            itemPrefab.SetActive(false);

            // Remove all charm type items from the store
            List <GameObject> newStock = new List <GameObject>();

            foreach (ShopItemDef itemDef in _items)
            {
                // Create a new shop item for this item def
                GameObject newItemObj = Object.Instantiate(itemPrefab);
                newItemObj.SetActive(false);

                // Apply all the stored values
                ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>();
                stats.playerDataBoolName     = itemDef.PlayerDataBoolName;
                stats.nameConvo              = itemDef.NameConvo;
                stats.descConvo              = itemDef.DescConvo;
                stats.requiredPlayerDataBool = itemDef.RequiredPlayerDataBool;
                stats.removalPlayerDataBool  = itemDef.RemovalPlayerDataBool;
                stats.dungDiscount           = itemDef.DungDiscount;
                stats.notchCostBool          = itemDef.NotchCostBool;
                stats.cost = itemDef.Cost;

                // Need to set all these to make sure the item doesn't break in one of various ways
                stats.priceConvo     = string.Empty;
                stats.specialType    = 2;
                stats.charmsRequired = 0;
                stats.relic          = false;
                stats.relicNumber    = 0;
                stats.relicPDInt     = string.Empty;

                // Apply the sprite for the UI
                stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite =
                    RandomizerMod.GetSprite(itemDef.SpriteName);

                newStock.Add(newItemObj);
            }

            foreach (GameObject item in shop.stock)
            {// Update normal stock (specialType: 0 = lantern, elegant key, quill; 1 = mask, 2 = charm, 3 = vessel, 4-7 = relics, 8 = notch, 9 = map, 10 = simple key, 11 = egg, 12-14 = repair fragile, 15 = salubra blessing, 16 = map pin, 17 = map marker)
                if (RandomizerMod.Instance.Settings.RandomizeMaps)
                {
                    if (item.GetComponent <ShopItemStats>().specialType == 9 || item.GetComponent <ShopItemStats>().playerDataBoolName == "hasQuill")
                    {
                        continue;
                    }
                }

                string shopBool = item.GetComponent <ShopItemStats>().playerDataBoolName;
                if (!LogicManager.HasItemWithShopBool(shopBool))
                {     // LogicManager doesn't know about this shop item, which means it's never potentially randomized. Put it back!
                    if (!(shopBool.StartsWith("salubraNotch") && RandomizerMod.Instance.Settings.CharmNotch))
                    { // If Salubra QOL is off, we need to add these notches back into her shop.
                        newStock.Add(item);
                    }
                }
            }

            shop.stock = newStock.ToArray();

            // Update alt stock; Sly only
            if (shop.stockAlt != null)
            {
                // Save unchanged list for potential alt stock
                List <GameObject> altStock = new List <GameObject>();
                altStock.AddRange(newStock);

                foreach (GameObject item in shop.stockAlt)
                {
                    string shopBool = item.GetComponent <ShopItemStats>().playerDataBoolName;
                    if (!LogicManager.HasItemWithShopBool(shopBool) && !newStock.Contains(item))
                    {
                        altStock.Add(item);
                    }
                }

                shop.stockAlt = altStock.ToArray();
            }
        }
        private IEnumerator ShowPopup()
        {
            // Check for skipping popup
            Coroutine skipCoroutine = StartCoroutine(LookForShowInstantly());

            // Begin dimming the scene
            GameObject dimmer = CanvasUtil.CreateImagePanel(gameObject, BlackPixel,
                                                            new CanvasUtil.RectData(Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one));

            dimmer.GetComponent <Image>().preserveAspect = false;
            CanvasGroup dimmerCG = dimmer.AddComponent <CanvasGroup>();

            dimmerCG.blocksRaycasts = false;
            dimmerCG.interactable   = false;
            dimmerCG.alpha          = 0;

            StartCoroutine(FadeInCanvasGroup(dimmerCG));

            yield return(WaitForSeconds(0.1f));

            // Aim for 400 high prompt image
            float   scaler = _imagePrompt.texture.height / 400f;
            Vector2 size   = new Vector2(_imagePrompt.texture.width / scaler, _imagePrompt.texture.height / scaler);

            AudioSource.PlayClipAtPoint(ObjectCache.BigItemJingle, new Vector3(
                                            Camera.main.transform.position.x,
                                            Camera.main.transform.position.y,
                                            Camera.main.transform.position.z + 2
                                            ));

            // Begin fading in the top bits of the popup
            GameObject topImage = CanvasUtil.CreateImagePanel(gameObject, _imagePrompt,
                                                              new CanvasUtil.RectData(size, Vector2.zero, new Vector2(0.5f, 0.75f), new Vector2(0.5f, 0.8f)));
            GameObject topTextOne = CanvasUtil.CreateTextPanel(gameObject, _takeText, 34, TextAnchor.MiddleCenter,
                                                               new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.55f),
                                                                                       new Vector2(0.5f, 0.55f)), Fonts.Get("Perpetua"));
            GameObject topTextTwo = CanvasUtil.CreateTextPanel(gameObject, _nameText, 76, TextAnchor.MiddleCenter,
                                                               new CanvasUtil.RectData(new Vector2(1920, 300), Vector2.zero, new Vector2(0.5f, 0.49f),
                                                                                       new Vector2(0.5f, 0.49f)));

            CanvasGroup topImageCG   = topImage.AddComponent <CanvasGroup>();
            CanvasGroup topTextOneCG = topTextOne.AddComponent <CanvasGroup>();
            CanvasGroup topTextTwoCG = topTextTwo.AddComponent <CanvasGroup>();

            topImageCG.blocksRaycasts = false;
            topImageCG.interactable   = false;
            topImageCG.alpha          = 0;

            topTextOneCG.blocksRaycasts = false;
            topTextOneCG.interactable   = false;
            topTextOneCG.alpha          = 0;

            topTextTwoCG.blocksRaycasts = false;
            topTextTwoCG.interactable   = false;
            topTextTwoCG.alpha          = 0;

            StartCoroutine(FadeInCanvasGroup(topImageCG));
            StartCoroutine(FadeInCanvasGroup(topTextOneCG));
            yield return(StartCoroutine(FadeInCanvasGroup(topTextTwoCG)));

            // Animate the middle fleur
            GameObject fleur = CanvasUtil.CreateImagePanel(gameObject, Frames[0],
                                                           new CanvasUtil.RectData(new Vector2(Frames[0].texture.width / 1.6f, Frames[0].texture.height / 1.6f),
                                                                                   Vector2.zero, new Vector2(0.5f, 0.4125f), new Vector2(0.5f, 0.4125f)));

            yield return(StartCoroutine(AnimateFleur(fleur, 12)));

            yield return(WaitForSeconds(0.25f));

            // Fade in the remaining text
            GameObject botTextOne = CanvasUtil.CreateTextPanel(gameObject, _buttonText, 34, TextAnchor.MiddleCenter,
                                                               new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.335f),
                                                                                       new Vector2(0.5f, 0.335f)), Fonts.Get("Perpetua"));
            GameObject botTextTwo = CanvasUtil.CreateTextPanel(gameObject, _descOneText, 34, TextAnchor.MiddleCenter,
                                                               new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.26f),
                                                                                       new Vector2(0.5f, 0.26f)), Fonts.Get("Perpetua"));
            GameObject botTextThree = CanvasUtil.CreateTextPanel(gameObject, _descTwoText, 34, TextAnchor.MiddleCenter,
                                                                 new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.205f),
                                                                                         new Vector2(0.5f, 0.205f)), Fonts.Get("Perpetua"));

            CanvasGroup botTextOneCG   = botTextOne.AddComponent <CanvasGroup>();
            CanvasGroup botTextTwoCG   = botTextTwo.AddComponent <CanvasGroup>();
            CanvasGroup botTextThreeCG = botTextThree.AddComponent <CanvasGroup>();

            botTextOneCG.blocksRaycasts = false;
            botTextOneCG.interactable   = false;
            botTextOneCG.alpha          = 0;

            botTextTwoCG.blocksRaycasts = false;
            botTextTwoCG.interactable   = false;
            botTextTwoCG.alpha          = 0;

            botTextThreeCG.blocksRaycasts = false;
            botTextThreeCG.interactable   = false;
            botTextThreeCG.alpha          = 0;

            yield return(StartCoroutine(FadeInCanvasGroup(botTextOneCG)));

            StartCoroutine(FadeInCanvasGroup(botTextTwoCG));
            yield return(StartCoroutine(FadeInCanvasGroup(botTextThreeCG)));

            yield return(WaitForSeconds(1.5f));

            // Can I offer you an egg in this trying time?
            GameObject egg = CanvasUtil.CreateImagePanel(gameObject, RandomizerMod.GetSprite("UI.egg"),
                                                         new CanvasUtil.RectData(
                                                             new Vector2(RandomizerMod.GetSprite("UI.egg").texture.width / 1.65f,
                                                                         RandomizerMod.GetSprite("UI.egg").texture.height / 1.65f), Vector2.zero,
                                                             new Vector2(0.5f, 0.1075f), new Vector2(0.5f, 0.1075f)));
            CanvasGroup eggCG = egg.AddComponent <CanvasGroup>();

            eggCG.blocksRaycasts = false;
            eggCG.interactable   = false;
            eggCG.alpha          = 0;

            // Should wait for one fade in, don't want to poll input immediately
            yield return(FadeInCanvasGroup(eggCG));

            // Stop doing things instantly before polling input
            if (!_showInstantly)
            {
                StopCoroutine(skipCoroutine);
            }

            _showInstantly = false;

            // Save the coroutine to stop it later
            Coroutine coroutine = StartCoroutine(BlinkCanvasGroup(eggCG));

            // Wait for the user to cancel the menu
            while (true)
            {
                HeroActions actions = Ref.Input.inputActions;
                if (actions.jump.WasPressed || actions.attack.WasPressed || actions.menuCancel.WasPressed)
                {
                    break;
                }

                yield return(new WaitForEndOfFrame());
            }

            // Fade out the full popup
            yield return(FadeOutCanvasGroup(gameObject.GetComponent <CanvasGroup>()));

            // Small delay before hero control
            yield return(WaitForSeconds(0.75f));

            // Optionally send FSM event after finishing
            if (_fsmObj != null && _fsmEvent != null)
            {
                FSMUtility.SendEventToGameObject(_fsmObj, _fsmEvent);
            }

            // Stop the egg routine and destroy everything
            StopCoroutine(coroutine);
            Destroy(gameObject);
        }
示例#7
0
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName ||
                fsm.gameObject.name != _objectName)
            {
                return;
            }


            FsmState pdBool      = fsm.GetState("PD Bool?");
            FsmState charm       = fsm.GetState("Charm?");
            FsmState trinkFlash  = fsm.GetState("Trink Flash");
            FsmState giveTrinket = fsm.GetState("Store Key"); // This path works well for our changes

            // Remove actions that stop shiny from spawning
            pdBool.RemoveActionsOfType <PlayerDataBoolTest>();
            pdBool.RemoveActionsOfType <StringCompare>();

            // Add our own check to stop the shiny from being grabbed twice
            pdBool.AddAction(
                new RandomizerExecuteLambda(() => fsm.SendEvent(
                                                RandomizerMod.Instance.Settings.CheckLocationFound(_location) ? "COLLECTED" : null
                                                )));

            // Force the FSM to follow the path for the correct trinket
            charm.ClearTransitions();
            charm.AddTransition("FINISHED", "Trink Flash");
            trinkFlash.ClearTransitions();
            fsm.GetState("Trinket Type").ClearTransitions();
            trinkFlash.AddTransition("FINISHED", "Store Key");

            giveTrinket.RemoveActionsOfType <SetPlayerDataBool>();
            giveTrinket.AddAction(new RandomizerExecuteLambda(() => GiveItem(_action, _item, _location)));

            // Makes sure the correct icon and text appear
            giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = _nameKey;
            giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite(_spriteName);
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != SceneName)
            {
                return;
            }

            // Find the shop and save an item for use later
            GameObject    shopObj    = GameObject.Find(ObjectName);
            ShopMenuStock shop       = shopObj.GetComponent <ShopMenuStock>();
            GameObject    itemPrefab = Object.Instantiate(shop.stock[0]);

            itemPrefab.SetActive(false);

            // Remove all charm type items from the store
            List <GameObject> newStock = new List <GameObject>();

            foreach (ShopItemDef itemDef in _items)
            {
                // Create a new shop item for this item def
                GameObject newItemObj = Object.Instantiate(itemPrefab);
                newItemObj.SetActive(false);

                // Apply all the stored values
                ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>();
                stats.playerDataBoolName     = itemDef.PlayerDataBoolName;
                stats.nameConvo              = itemDef.NameConvo;
                stats.descConvo              = itemDef.DescConvo;
                stats.requiredPlayerDataBool = itemDef.RequiredPlayerDataBool;
                stats.removalPlayerDataBool  = itemDef.RemovalPlayerDataBool;
                stats.dungDiscount           = itemDef.DungDiscount;
                stats.notchCostBool          = itemDef.NotchCostBool;
                stats.cost = itemDef.Cost;

                // Need to set all these to make sure the item doesn't break in one of various ways
                stats.priceConvo     = string.Empty;
                stats.specialType    = 2;
                stats.charmsRequired = 0;
                stats.relic          = false;
                stats.relicNumber    = 0;
                stats.relicPDInt     = string.Empty;

                // Apply the sprite for the UI
                stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite =
                    RandomizerMod.GetSprite(itemDef.SpriteName);

                newStock.Add(newItemObj);
            }

            // Save unchanged list for potential alt stock
            List <GameObject> altStock = new List <GameObject>();

            altStock.AddRange(newStock);

            // Update normal stock
            foreach (GameObject item in shop.stock)
            {
                // It would be cleaner to destroy the unused objects, but that breaks the shop on subsequent loads
                // TC must be reusing the shop items rather than destroying them on load
                if (item.GetComponent <ShopItemStats>().specialType != 2)
                {
                    newStock.Add(item);
                }
            }

            shop.stock = newStock.ToArray();

            // Update alt stock
            if (shop.stockAlt != null)
            {
                foreach (GameObject item in shop.stockAlt)
                {
                    if (item.GetComponent <ShopItemStats>().specialType != 2)
                    {
                        altStock.Add(item);
                    }
                }

                shop.stockAlt = altStock.ToArray();
            }
        }
示例#9
0
        public override void Process(string scene, UnityEngine.Object changeObj)
        {
            if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName ||
                fsm.gameObject.name != _objectName)
            {
                return;
            }


            FsmState pdBool      = fsm.GetState("PD Bool?");
            FsmState charm       = fsm.GetState("Charm?");
            FsmState trinkFlash  = fsm.GetState("Trink Flash");
            FsmState giveTrinket = fsm.GetState("Store Key"); // This path works well for our changes

            // Remove actions that stop shiny from spawning
            pdBool.RemoveActionsOfType <PlayerDataBoolTest>();
            pdBool.RemoveActionsOfType <StringCompare>();

            // Add our own check to stop the shiny from being grabbed twice
            pdBool.AddAction(new RandomizerBoolTest(_boolName, null, "COLLECTED", true));

            // Force the FSM to follow the path for the correct trinket
            charm.ClearTransitions();
            charm.AddTransition("FINISHED", "Trink Flash");
            trinkFlash.ClearTransitions();
            fsm.GetState("Trinket Type").ClearTransitions();
            trinkFlash.AddTransition("FINISHED", "Store Key");

            giveTrinket.AddFirstAction(new RandomizerExecuteLambda(() => RandomizerMod.Instance.Settings.UpdateObtainedProgressionByBoolName(_boolName)));
            giveTrinket.AddAction(new RandomizerExecuteLambda(() => RandoLogger.LogItemToTrackerByBoolName(_boolName, _location)));
            giveTrinket.AddAction(new RandomizerExecuteLambda(() => RandoLogger.UpdateHelperLog()));
            giveTrinket.GetActionsOfType <SetPlayerDataBool>().First().boolName = _boolName;

            // Makes sure the correct icon and text appear
            switch (_trinketNum)
            {
            case 1:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET1";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.WanderersJournal");
                break;

            case 2:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET2";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.HallownestSeal");
                break;

            case 3:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET3";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.KingsIdol");
                break;

            case 4:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET4";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.ArcaneEgg");
                break;

            case 6:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRAM_PASS";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.TramPass");
                break;

            case 8:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_STOREKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.ShopkeepersKey");
                break;

            case 9:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_CITYKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.CityKey");
                break;

            case 10:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_LOVEKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.LoveKey");
                break;

            case 11:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_RANCIDEGG";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.RancidEgg");
                break;

            case 12:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_SIMPLEKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.SimpleKey");
                break;

            case 13:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_CHARM_NOTCH";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.CharmNotch");
                break;

            case 14:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_PALE_ORE";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.PaleOre");
                break;

            case 20:     //lantern
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_LANTERN";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.Lantern");
                break;

            case 21:     //elegant key
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_WHITEKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.ElegantKey");
                break;

            case 22:     //mask shards
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_MASK_SHARD";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.MaskShard");
                break;

            case 23:     //vessel fragments
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_VESSEL_FRAGMENT";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.VesselFragment");
                break;

            case 24:     //whispering root
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_ESSENCE";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite("ShopIcons.Essence");
                break;
            }
        }
        public override void Process(string scene, Object changeObj)
        {
            if (!(scene == _sceneName && changeObj is PlayMakerFSM fsm))
            {
                return;
            }
            var grimmkinLevel = 1;

            switch (scene)
            {
            case "Tutorial_01":
            case "RestingGrounds_06":
            case "Deepnest_East_03":
                grimmkinLevel = 2;
                break;

            case "Fungus2_30":
            case "Abyss_02":
            case "Hive_03":
                grimmkinLevel = 3;
                break;
            }
            if (fsm.FsmName == "Control")
            {
                // Make the grimmkin think we have the appropriate
                // Grimmchild level, so that it behaves the same
                // regardless of how much Grimmchild has been
                // upgraded.
                switch (fsm.gameObject.name)
                {
                case "Flamebearer Small(Clone)":
                case "Flamebearer Med(Clone)":
                case "Flamebearer Large(Clone)":
                    FixGrimmkinFSM(fsm, grimmkinLevel);
                    break;
                }
                return;
            }
            if (!(fsm.FsmName == _fsmName && fsm.gameObject.name == _objectName))
            {
                return;
            }

            FsmState get = fsm.GetState("Get");

            get.RemoveActionsOfType <IncrementPlayerDataInt>();
            get.RemoveActionsOfType <SendMessage>();
            get.AddFirstAction(new RandomizerExecuteLambda(() => {
                var def = LogicManager.GetItemDef(RandomizerMod.Instance.Settings.GetEffectiveItem(_item));
                // Make sure the correct icon and text appear.
                // Modifying the FSM from within itself is a bit of a kludge, but it's
                // simpler than replacing the existing item popup altogether.
                get.GetActionsOfType <GetLanguageString>().First().convName     = def.nameKey;
                get.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite(def.shopSpriteKey);
            }));
            get.AddAction(new RandomizerExecuteLambda(() => GiveItem(_action, _item, _location)));


            if (_objectName == "Brumm Torch NPC")
            {
                var checkActive = fsm.GetState("Check Active");
                checkActive.Actions    = new FsmStateAction[1];
                checkActive.Actions[0] = new RandomizerExecuteLambda(() => fsm.SendEvent(IsBrummActive() ? "FINISHED" : "INACTIVE"));
                var convo1 = fsm.GetState("Convo 1");
                convo1.RemoveActionsOfType <IntCompare>();
            }
            else
            {
                var init = fsm.GetState("State");
                init.RemoveActionsOfType <IntCompare>();
                init.RemoveActionsOfType <IntSwitch>();
                init.AddAction(new RandomizerExecuteLambda(() => fsm.SendEvent(Ref.PD.GetInt("grimmChildLevel") >= grimmkinLevel ? "LEVEL " + grimmkinLevel : "KILLED")));
            }
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != SceneName)
            {
                return;
            }



            // Find the shop and save an item for use later
            GameObject    shopObj    = GameObject.Find(ObjectName);
            ShopMenuStock shop       = shopObj.GetComponent <ShopMenuStock>();
            GameObject    itemPrefab = Object.Instantiate(shop.stock[0]);

            itemPrefab.SetActive(false);

            // Remove all charm type items from the store
            List <GameObject> newStock = new List <GameObject>();

            foreach (ShopItemDef itemDef in _items)
            {
                // Create a new shop item for this item def
                GameObject newItemObj = Object.Instantiate(itemPrefab);
                newItemObj.SetActive(false);

                // Apply all the stored values
                ShopItemStats stats = newItemObj.GetComponent <ShopItemStats>();
                stats.playerDataBoolName     = itemDef.PlayerDataBoolName;
                stats.nameConvo              = itemDef.NameConvo;
                stats.descConvo              = itemDef.DescConvo;
                stats.requiredPlayerDataBool = itemDef.RequiredPlayerDataBool;
                stats.removalPlayerDataBool  = itemDef.RemovalPlayerDataBool;
                stats.dungDiscount           = itemDef.DungDiscount;
                stats.notchCostBool          = itemDef.NotchCostBool;
                stats.cost = itemDef.Cost;

                // Need to set all these to make sure the item doesn't break in one of various ways
                stats.priceConvo     = string.Empty;
                stats.specialType    = 2;
                stats.charmsRequired = 0;
                stats.relic          = false;
                stats.relicNumber    = 0;
                stats.relicPDInt     = string.Empty;

                // Apply the sprite for the UI
                stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite =
                    RandomizerMod.GetSprite(itemDef.SpriteName);

                newStock.Add(newItemObj);
            }

            // Save unchanged list for potential alt stock
            List <GameObject> altStock = new List <GameObject>();

            altStock.AddRange(newStock);

            // Update normal stock
            //specialType: 0 = lantern, elegant key, quill; 1 = mask, 2 = charm, 3 = vessel, 4-7 = relics, 8 = notch, 9 = map, 10 = simple key, 11 = egg, 12-14 = repair fragile, 15 = salubra blessing, 16 = map pin, 17 = map marker
            foreach (GameObject item in shop.stock)
            {
                // It would be cleaner to destroy the unused objects, but that breaks the shop on subsequent loads
                // TC must be reusing the shop items rather than destroying them on load
                List <int> randomizedTypes = new List <int>()
                {
                    0, 1, 2, 3, 8, 10, 11
                };
                if (!randomizedTypes.Contains(item.GetComponent <ShopItemStats>().specialType))
                {
                    newStock.Add(item);
                }
                else if (item.GetComponent <ShopItemStats>().nameConvo == "INV_NAME_LANTERN" && !RandomizerMod.Instance.Settings.RandomizeKeys && !RandomizerMod.Instance.Settings.SpicySkips)
                {
                    // Easiest way to handle lantern on easy mode. Lantern is given automatically on new game load
                }
                else if (item.GetComponent <ShopItemStats>().specialType == 2 && !RandomizerMod.Instance.Settings.RandomizeCharms)
                {
                    newStock.Add(item);
                }
                else if ((item.GetComponent <ShopItemStats>().specialType == 0 || item.GetComponent <ShopItemStats>().specialType == 10) && !RandomizerMod.Instance.Settings.RandomizeKeys)
                {
                    newStock.Add(item);
                }
                else if (item.GetComponent <ShopItemStats>().nameConvo == "INV_NAME_QUILL" && RandomizerMod.Instance.Settings.RandomizeKeys)
                {
                    newStock.Add(item); //Special case: only nonrandomized item of special type 0
                }
                else if (item.GetComponent <ShopItemStats>().specialType == 1 && !RandomizerMod.Instance.Settings.RandomizeMaskShards)
                {
                    newStock.Add(item);
                }
                else if (item.GetComponent <ShopItemStats>().specialType == 3 && !RandomizerMod.Instance.Settings.RandomizeVesselFragments)
                {
                    newStock.Add(item);
                }
                else if (item.GetComponent <ShopItemStats>().specialType == 8 && !RandomizerMod.Instance.Settings.RandomizeCharmNotches)
                {
                    newStock.Add(item);
                }
                else if (item.GetComponent <ShopItemStats>().specialType == 11 && !RandomizerMod.Instance.Settings.RandomizeRancidEggs)
                {
                    newStock.Add(item);
                }
            }

            shop.stock = newStock.ToArray();

            // Update alt stock
            if (shop.stockAlt != null)
            {
                foreach (GameObject item in shop.stockAlt)
                {
                    // note we just have to handle the vanilla item types sly sells here
                    List <int> randomizedTypes = new List <int>()
                    {
                        0, 1, 2, 3, 8, 10, 11
                    };
                    if (!randomizedTypes.Contains(item.GetComponent <ShopItemStats>().specialType))
                    {
                        altStock.Add(item);
                    }
                    else if (item.GetComponent <ShopItemStats>().nameConvo == "INV_NAME_LANTERN" && !RandomizerMod.Instance.Settings.RandomizeKeys && !RandomizerMod.Instance.Settings.SpicySkips)
                    {
                        // Easiest way to handle lantern on easy mode. Lantern is given automatically on new game load
                    }
                    else if (item.GetComponent <ShopItemStats>().specialType == 2 && !RandomizerMod.Instance.Settings.RandomizeCharms)
                    {
                        altStock.Add(item);
                    }
                    else if ((item.GetComponent <ShopItemStats>().specialType == 0 || item.GetComponent <ShopItemStats>().specialType == 10) && !RandomizerMod.Instance.Settings.RandomizeKeys)
                    {
                        altStock.Add(item);
                    }
                    else if (item.GetComponent <ShopItemStats>().specialType == 1 && !RandomizerMod.Instance.Settings.RandomizeMaskShards)
                    {
                        altStock.Add(item);
                    }
                    else if (item.GetComponent <ShopItemStats>().specialType == 3 && !RandomizerMod.Instance.Settings.RandomizeVesselFragments)
                    {
                        altStock.Add(item);
                    }
                    else if (item.GetComponent <ShopItemStats>().specialType == 11 && !RandomizerMod.Instance.Settings.RandomizeRancidEggs)
                    {
                        altStock.Add(item);
                    }
                }

                shop.stockAlt = altStock.ToArray();
            }
        }
示例#12
0
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName ||
                fsm.gameObject.name != _objectName)
            {
                return;
            }

            FsmState pdBool      = fsm.GetState("PD Bool?");
            FsmState charm       = fsm.GetState("Charm?");
            FsmState bigItem     = fsm.GetState("Big Item?");
            FsmState bigGetFlash = fsm.GetState("Big Get Flash");
            FsmState trinkFlash  = fsm.GetState("Trink Flash");
            FsmState giveTrinket = fsm.GetState("Store Key");

            // Remove actions that stop shiny from spawning
            pdBool.RemoveActionsOfType <StringCompare>();

            // Change pd bool test to our new bool
            pdBool.RemoveActionsOfType <PlayerDataBoolTest>();
            pdBool.AddAction(
                new RandomizerExecuteLambda(() => fsm.SendEvent(
                                                RandomizerMod.Instance.Settings.CheckLocationFound(_location) ? "COLLECTED" : null
                                                )));


            // Charm must be preserved as the entry point for AddYNDialogueToShiny
            charm.ClearTransitions();
            charm.AddTransition("FINISHED", "Big Item?");

            // Check if each additive item has already been obtained. Give 100 geo instead of popup if so.
            bigItem.ClearTransitions();
            bigItem.AddFirstAction(new RandomizerExecuteLambda(() => bigItem.AddTransition("FINISHED", BigItemPopup.AdditiveMaxedOut(_itemDefs) ? "Trink Flash" : "Big Get Flash"))); // if we have duplicates, the last item is not a big popup

            // give 300 geo for last duplicate
            trinkFlash.ClearTransitions();
            trinkFlash.AddTransition("FINISHED", "Store Key");
            fsm.GetState("Trinket Type").ClearTransitions();
            trinkFlash.AddTransition("FINISHED", "Store Key");
            giveTrinket.RemoveActionsOfType <SetPlayerDataBool>();
            giveTrinket.AddAction(new RandomizerExecuteLambda(() => GiveItem(GiveItemActions.GiveAction.AddGeo, _item, _location, 300)));
            giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = _itemDefs.Last().NameKey;
            giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = RandomizerMod.GetSprite(Randomization.LogicManager.GetItemDef(_itemDefs.Last().Name).shopSpriteKey);

            // Normal path for big items. Set bool and show the popup after the flash
            bigGetFlash.AddAction(new RandomizerCallStaticMethod(
                                      typeof(BigItemPopup),
                                      nameof(BigItemPopup.ShowAdditive),
                                      _itemDefs,
                                      fsm.gameObject,
                                      "GET ITEM MSG END"));

            // Don't actually need to set the skill here, that happens in BigItemPopup
            // Maybe change that at some point, it's not where it should happen
            bigGetFlash.AddAction(new RandomizerExecuteLambda(() => GiveItem(_action, _item, _location)));

            // Exit the fsm after the popup
            bigGetFlash.ClearTransitions();
            bigGetFlash.AddTransition("GET ITEM MSG END", "Hero Up");
            bigGetFlash.AddTransition("HERO DAMAGED", "Finish");
        }