コード例 #1
0
        public static void ModifyShiny(PlayMakerFSM shinyFsm, FlingType flingType, AbstractPlacement location, AbstractItem item)
        {
            FsmState pdBool     = shinyFsm.GetState("PD Bool?");
            FsmState charm      = shinyFsm.GetState("Charm?");
            FsmState trinkFlash = shinyFsm.GetState("Trink Flash");

            FsmStateAction checkAction = new RandomizerExecuteLambda(() => shinyFsm.SendEvent(item.IsObtained() ? "COLLECTED" : null));
            FsmStateAction giveAction  = new RandomizerExecuteLambda(() => item.Give(location, Container.Shiny, flingType, shinyFsm.gameObject.transform, message: MessageType.Any, callback: (_) => shinyFsm.SendEvent("GAVE ITEM")));

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

            // Change pd bool test to our new bool
            pdBool.RemoveActionsOfType <PlayerDataBoolTest>();
            pdBool.AddAction(checkAction);

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

            trinkFlash.ClearTransitions();
            trinkFlash.Actions = new FsmStateAction[]
            {
                trinkFlash.Actions[0], // Audio
                trinkFlash.Actions[1], // Audio
                trinkFlash.Actions[2], // visual effect
                trinkFlash.Actions[3], // hide shiny
                trinkFlash.Actions[4], // pickup animation
                // [5] -- spawn message
                // [6] -- store message text
                // [7] -- store message icon
                giveAction, // give item and await callback
            };
            trinkFlash.AddTransition("GAVE ITEM", "Hero Up");
        }