Exemplo n.º 1
0
        public void CR_Change_Room_temple(Scene scene)
        {
            if (scene.name != "Room_temple")
            {
                return;
            }

            Log("CR_Change_Room_temple()");
            //yield return null;

            #region Hornet NPC FSM

            GameObject   hornetNpcGo     = scene.FindRoot("Hornet Black Egg NPC");
            PlayMakerFSM hornetNpcFsm    = hornetNpcGo.LocateMyFSM("Conversation Control");
            FsmVariables hornetNpcFsmVar = hornetNpcFsm.FsmVariables;

            hornetNpcFsm.CopyState("Greet", "Give Item");
            hornetNpcFsm.RemoveAction("Give Item", 0);

            hornetNpcFsm.GetAction <CallMethodProper>("Give Item", 0).parameters = new FsmVar[]
            {
                new FsmVar(typeof(string))
                {
                    stringValue = "CUSTOM_HORNET_PRE_FINAL_BATTLE"
                },
                new FsmVar(typeof(string))
                {
                    stringValue = "Hornet"
                }
            };

            var pdbtAction = new PlayerDataBoolTest();
            pdbtAction.gameObject = hornetNpcFsm.GetAction <PlayerDataBoolTest>("Choice", 1).gameObject;
            pdbtAction.boolName   = "SFGrenadeTestOfTeamworkHornetCompanion";
            pdbtAction.isFalse    = FsmEvent.GetFsmEvent("ABSENT");

            hornetNpcFsm.InsertAction("Choice", pdbtAction, 1);

            hornetNpcFsm.AddTransition("Choice", "ABSENT", "Give Item");

            #endregion

            #region Shiny FSM

            GameObject shinyParent = GameObject.Instantiate(PrefabHolder.shinyPrefab);
            shinyParent.name = "Necklace";
            shinyParent.SetActive(false);
            shinyParent.transform.GetChild(0).gameObject.SetActive(true);
            shinyParent.transform.position = new Vector3(29.0f, 4.3f, 0.0f);

            hornetNpcFsm.CopyState("Box Up", "Give Item Spawn");

            hornetNpcFsm.ChangeTransition("Give Item Spawn", FsmEvent.Finished.Name, "Talk Finish");
            hornetNpcFsm.GetState("Give Item").Transitions.First(x => x.ToState == "Talk Finish").ToState = "Give Item Spawn";

            hornetNpcFsm.RemoveAction("Give Item Spawn", 5);
            hornetNpcFsm.RemoveAction("Give Item Spawn", 4);
            hornetNpcFsm.RemoveAction("Give Item Spawn", 3);
            hornetNpcFsm.RemoveAction("Give Item Spawn", 2);
            hornetNpcFsm.RemoveAction("Give Item Spawn", 1);
            hornetNpcFsm.RemoveAction("Give Item Spawn", 0);

            var agoAction = new ActivateGameObject();
            agoAction.gameObject             = new FsmOwnerDefault();
            agoAction.gameObject.OwnerOption = OwnerDefaultOption.SpecifyGameObject;
            agoAction.gameObject.GameObject  = shinyParent;
            agoAction.activate    = true;
            agoAction.recursive   = false;
            agoAction.resetOnExit = false;
            agoAction.everyFrame  = false;
            hornetNpcFsm.AddAction("Give Item Spawn", agoAction);
            hornetNpcFsm.AddAction("Give Item Spawn", new NextFrameEvent()
            {
                sendEvent = FsmEvent.Finished
            });

            PlayMakerFSM shinyFsm     = shinyParent.transform.GetChild(0).gameObject.LocateMyFSM("Shiny Control");
            FsmVariables shinyFsmVars = shinyFsm.FsmVariables;
            shinyFsmVars.FindFsmInt("Charm ID").Value         = 0;
            shinyFsmVars.FindFsmInt("Type").Value             = 0;
            shinyFsmVars.FindFsmBool("Activated").Value       = false;
            shinyFsmVars.FindFsmBool("Charm").Value           = false;
            shinyFsmVars.FindFsmBool("Dash Cloak").Value      = false;
            shinyFsmVars.FindFsmBool("Exit Dream").Value      = false;
            shinyFsmVars.FindFsmBool("Fling L").Value         = false;
            shinyFsmVars.FindFsmBool("Fling On Start").Value  = true;
            shinyFsmVars.FindFsmBool("Journal").Value         = false;
            shinyFsmVars.FindFsmBool("King's Brand").Value    = false;
            shinyFsmVars.FindFsmBool("Mantis Claw").Value     = false;
            shinyFsmVars.FindFsmBool("Pure Seed").Value       = false;
            shinyFsmVars.FindFsmBool("Quake").Value           = false;
            shinyFsmVars.FindFsmBool("Show Charm Tute").Value = false;
            shinyFsmVars.FindFsmBool("Slug Fling").Value      = false;
            shinyFsmVars.FindFsmBool("Super Dash").Value      = false;
            shinyFsmVars.FindFsmString("Item Name").Value     = Consts.LanguageStrings.HornetInvNameKey;
            shinyFsmVars.FindFsmString("PD Bool Name").Value  = "SFGrenadeTestOfTeamworkHornetCompanion";

            IntSwitch isAction     = shinyFsm.GetAction <IntSwitch>("Trinket Type", 0);
            var       tmpCompareTo = new List <FsmInt>(isAction.compareTo);
            tmpCompareTo.Add(tmpCompareTo.Count + 1);
            isAction.compareTo = tmpCompareTo.ToArray();
            shinyFsmVars.FindFsmInt("Trinket Num").Value = tmpCompareTo.Count;
            var tmpSendEvent = new List <FsmEvent>(isAction.sendEvent);
            tmpSendEvent.Add(FsmEvent.FindEvent("PURE SEED"));
            isAction.sendEvent = tmpSendEvent.ToArray();

            shinyFsm.CopyState("Love Key", "Necklace");

            shinyFsm.GetAction <SetPlayerDataBool>("Necklace", 0).boolName     = "SFGrenadeTestOfTeamworkHornetCompanion";
            shinyFsm.GetAction <SetSpriteRendererSprite>("Necklace", 1).sprite = TestOfTeamwork.Instance.SpriteDict.Get(TextureStrings.InvHornetKey);
            shinyFsm.GetAction <GetLanguageString>("Necklace", 2).convName     = Consts.LanguageStrings.HornetInvNameKey;

            shinyFsm.AddTransition("Trinket Type", "PURE SEED", "Necklace");

            #endregion

            Log("~CR_Change_Room_temple()");
        }
Exemplo n.º 2
0
        /// <summary>
        /// adds a invintory panel
        /// </summary>
        /// <param name="go">the gameobject used for the panel</param>
        /// <returns>the panel index, used in (language) PANE_# and (bool) hasPane#</returns>
        public static int AddInventoryPanel(GameObject go)
        {
            if (!initiated)
            {
                Init();
            }

            FsmEvent      panelEvent = new FsmEvent("Panel " + Panels);
            FsmGameObject fsmPanel   = new FsmGameObject()
            {
                Name = Panels + " Pane", Value = go
            };

            GameManager.instance.inventoryFSM.FsmVariables.GameObjectVariables =
                GameManager.instance.inventoryFSM.FsmVariables.GameObjectVariables.Append(fsmPanel).ToArray();

            IntSwitch loopThrough = GameManager.instance.inventoryFSM.GetAction <IntSwitch>("Loop Through", 3);

            FsmEvent[] newevents = loopThrough.sendEvent.Append(panelEvent).ToArray();
            FsmInt[]   newpanels = loopThrough.compareTo.Append(Panels).ToArray();
            newpanels[5] = Panels + 1;

            loopThrough.compareTo = newpanels;
            loopThrough.sendEvent = newevents;

            IntSwitch checkLPane = GameManager.instance.inventoryFSM.GetAction <IntSwitch>("Check L Pane", 1);

            checkLPane.compareTo = newpanels;
            checkLPane.sendEvent = newevents;

            IntSwitch checkRPane = GameManager.instance.inventoryFSM.GetAction <IntSwitch>("Check R Pane", 1);

            checkRPane.compareTo = newpanels;
            checkRPane.sendEvent = newevents;

            GameManager.instance.inventoryFSM.GetAction <IntSwitch>("Check Current Pane", 11).compareTo =
                GameManager.instance.inventoryFSM.GetAction <IntSwitch>("Check Current Pane", 11).compareTo.Append(Panels).ToArray();
            GameManager.instance.inventoryFSM.GetAction <IntSwitch>("Check Current Pane", 11).sendEvent =
                GameManager.instance.inventoryFSM.GetAction <IntSwitch>("Check Current Pane", 11).sendEvent.Append(panelEvent).ToArray();

            GameManager.instance.inventoryFSM.GetAction <SetIntValue>("Under", 0).intValue   = Panels + 1;
            GameManager.instance.inventoryFSM.GetAction <SetIntValue>("Under 2", 0).intValue = Panels + 1;
            GameManager.instance.inventoryFSM.GetAction <SetIntValue>("Under 3", 0).intValue = Panels + 1;

            FsmState test  = GameManager.instance.inventoryFSM.CopyState("Next Charms", "Next Panel " + Panels);
            FsmState testR = GameManager.instance.inventoryFSM.CopyState("Next Charms 2", "Next Panel " + Panels + " 2");
            FsmState testL = GameManager.instance.inventoryFSM.CopyState("Next Charms 3", "Next Panel " + Panels + " 3");
            FsmState open  = GameManager.instance.inventoryFSM.CopyState("Open charms", "Open Panel " + Panels);

            test.GetAction <PlayerDataBoolTest>(0).boolName = "hasPane" + Panels;
            test.GetAction <SetGameObject>(2).gameObject    = fsmPanel;
            test.GetAction <GetLanguageString>(3).convName  = "PANE_" + Panels;

            testR.GetAction <PlayerDataBoolTest>(0).boolName = "hasPane" + Panels;
            testR.GetAction <GetLanguageString>(1).convName  = "PANE_" + Panels;

            testL.GetAction <PlayerDataBoolTest>(0).boolName = "hasPane" + Panels;
            testL.GetAction <GetLanguageString>(1).convName  = "PANE_" + Panels;

            open.GetAction <GetLanguageString>(0).convName = "PANE_" + Panels;
            open.GetAction <SetGameObject>(2).gameObject   = fsmPanel;
            open.GetAction <SetIntValue>(3).intValue       = Panels;
            open.GetAction <SetIntValue>(4).intValue       = Panels;

            GameManager.instance.inventoryFSM.AddTransition("Loop Through", panelEvent, test.Name);
            GameManager.instance.inventoryFSM.AddTransition("Check R Pane", panelEvent, testR.Name);
            GameManager.instance.inventoryFSM.AddTransition("Check L Pane", panelEvent, testL.Name);
            GameManager.instance.inventoryFSM.AddTransition("Check Current Pane", panelEvent, open.Name);

            Panels++;
            return(Panels - 1);
        }