public static void ModifyGeoRock(PlayMakerFSM rockFsm, FlingType flingType, AbstractPlacement location, IEnumerable <AbstractItem> items)
        {
            GameObject rock = rockFsm.gameObject;

            FsmState init   = rockFsm.GetState("Initiate");
            FsmState hit    = rockFsm.GetState("Hit");
            FsmState payout = rockFsm.GetState("Destroy");
            FsmState broken = rockFsm.GetState("Broken");

            FsmStateAction checkAction = new RandomizerExecuteLambda(() => rockFsm.SendEvent(location.HasVisited() ? "BROKEN" : null));

            init.RemoveActionsOfType <IntCompare>();
            init.AddAction(checkAction);

            hit.ClearTransitions();
            hit.AddTransition("HIT", "Pause Frame");
            hit.AddTransition("FINISHED", "Pause Frame");
            hit.RemoveActionsOfType <FlingObjectsFromGlobalPool>();

            var payoutAction = payout.GetActionOfType <FlingObjectsFromGlobalPool>();

            payoutAction.spawnMin.Value = 0;
            payoutAction.spawnMax.Value = 0;

            GameObject itemParent = new GameObject("item");

            itemParent.transform.SetParent(rock.transform);
            itemParent.transform.position      = rock.transform.position;
            itemParent.transform.localPosition = Vector3.zero;
            itemParent.SetActive(true);

            FsmStateAction spawnShinies = new ActivateAllChildren {
                gameObject = new FsmGameObject {
                    Value = itemParent,
                }, activate = true
            };

            payout.AddAction(spawnShinies);
            broken.AddAction(spawnShinies);

            foreach (AbstractItem item in items)
            {
                if (item.GiveEarly(Container.GeoRock))
                {
                    FsmStateAction giveAction = new RandomizerExecuteLambda(() => item.Give(location, Container.GeoRock, flingType, rockFsm.gameObject.transform, message: MessageType.None));
                    payout.AddAction(giveAction);
                }
                else
                {
                    GameObject shiny = ShinyUtility.MakeNewShiny(location, item);
                    ShinyUtility.PutShinyInContainer(itemParent, shiny);
                }
            }
        }
        public static void ModifyBottleFsm(GameObject jar, FlingType flingType, AbstractPlacement location, IEnumerable <AbstractItem> items)
        {
            PlayMakerFSM fsm      = jar.LocateFSM("Bottle Control");
            FsmState     init     = fsm.GetState("Init");
            FsmState     shatter  = fsm.GetState("Shatter");
            FsmState     activate = fsm.GetState("Activate");

            init.RemoveActionsOfType <BoolTest>();
            shatter.RemoveActionsOfType <IncrementPlayerDataInt>();
            shatter.RemoveActionsOfType <SendMessage>();

            FsmStateAction checkAction = new RandomizerExecuteLambda(() => fsm.SendEvent(location.HasVisited() ? "ACTIVATE" : null));

            init.AddFirstAction(checkAction);

            GameObject itemParent = new GameObject("item");

            itemParent.transform.SetParent(jar.transform);
            itemParent.transform.position      = jar.transform.position;
            itemParent.transform.localPosition = Vector3.zero;
            itemParent.SetActive(true);

            FsmStateAction spawnShinies = new ActivateAllChildren {
                gameObject = new FsmGameObject {
                    Value = itemParent,
                }, activate = true
            };
            FsmStateAction removeParent = new RandomizerExecuteLambda(() => itemParent.transform.parent = null);

            shatter.AddAction(spawnShinies);
            activate.AddFirstAction(removeParent); // activate has a destroy all children action
            activate.AddFirstAction(spawnShinies);

            foreach (AbstractItem item in items)
            {
                if (item.GiveEarly(Container.GrubJar))
                {
                    FsmStateAction giveAction = new RandomizerExecuteLambda(() => item.Give(location, Container.GrubJar, flingType, jar.transform, MessageType.Corner));
                    shatter.AddAction(giveAction);
                }
                else
                {
                    GameObject shiny = ShinyUtility.MakeNewShiny(location, item);
                    ShinyUtility.PutShinyInContainer(itemParent, shiny);
                }
            }
        }
        public static void ModifyChest(PlayMakerFSM chestFsm, FlingType flingType, AbstractPlacement location, IEnumerable <AbstractItem> items)
        {
            FsmState init       = chestFsm.GetState("Init");
            FsmState spawnItems = chestFsm.GetState("Spawn Items");

            FsmStateAction checkAction = new RandomizerExecuteLambda(() => chestFsm.SendEvent(location.HasVisited() ? "ACTIVATE" : null));

            init.RemoveActionsOfType <BoolTest>();
            init.AddAction(checkAction);

            // Destroy any existing shinies in the chest
            GameObject itemParent = chestFsm.gameObject.transform.Find("Item").gameObject;

            foreach (Transform t in itemParent.transform)
            {
                UnityEngine.Object.Destroy(t.gameObject);
            }

            // Remove pre-existing geo from chest
            foreach (FlingObjectsFromGlobalPool fling in spawnItems.GetActionsOfType <FlingObjectsFromGlobalPool>())
            {
                fling.spawnMin = 0;
                fling.spawnMax = 0;
            }

            // Need to check SpawnFromPool action too because of Mantis Lords chest
            foreach (SpawnFromPool spawn in spawnItems.GetActionsOfType <SpawnFromPool>())
            {
                spawn.spawnMin = 0;
                spawn.spawnMax = 0;
            }

            foreach (AbstractItem item in items)
            {
                if (item.GiveEarly(Container.Chest))
                {
                    spawnItems.AddAction(new RandomizerExecuteLambda(() => item.Give(location, Container.Chest, flingType, chestFsm.gameObject.transform, MessageType.Corner)));
                }
                else
                {
                    GameObject shiny = ShinyUtility.MakeNewShiny(location, item);
                    ShinyUtility.PutShinyInContainer(itemParent, shiny);
                }
            }
        }
Ejemplo n.º 4
0
        public static GameObject GetNewContainer(AbstractPlacement placement, IEnumerable <AbstractItem> items, Container type)
        {
            switch (type)
            {
            default:
            case Container.Shiny:
                return(ShinyUtility.MakeNewMultiItemShiny(placement));

            case Container.Chest:
                return(ChestUtility.MakeNewChest(placement));

            case Container.GeoRock:
                return(GeoRockUtility.MakeNewGeoRock(placement, items, out _));

            case Container.GrubJar:
                return(GrubJarUtility.MakeNewGrubJar(placement));
            }
        }