Exemplo n.º 1
0
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName)
            {
                return;
            }

            // Put a shiny in the same location as the original
            GameObject shiny = ObjectCache.ShinyItem;

            shiny.name = _newShinyName;

            shiny.transform.position = new Vector3(_x, _y, shiny.transform.position.z);
            shiny.SetActive(true);

            // Force the new shiny to fall straight downwards
            PlayMakerFSM fsm   = FSMUtility.LocateFSM(shiny, "Shiny Control");
            FsmState     fling = fsm.GetState("Fling?");

            fling.ClearTransitions();
            fling.AddTransition("FINISHED", "Fling R");
            FlingObject flingObj = fsm.GetState("Fling R").GetActionsOfType <FlingObject>()[0];

            flingObj.angleMin = flingObj.angleMax = 270;

            // For some reason not setting speed manually messes with the object position
            flingObj.speedMin = flingObj.speedMax = 0.1f;
        }
Exemplo n.º 2
0
        private IEnumerator configureHero()
        {
            while (HeroController.instance == null)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (sharpShadow != null && sharpShadow.CompareTag("Sharp Shadow"))
            {
                yield break;
            }


            foreach (var go in Resources.FindObjectsOfTypeAll <GameObject>())
            {
                if (go == null || !go.CompareTag("Sharp Shadow"))
                {
                    continue;
                }

                sharpShadow    = go;
                sharpShadowFSM = FSMUtility.LocateFSM(sharpShadow, "damages_enemy");
                log($"Found Sharp Shadow: {sharpShadow} - {sharpShadowFSM}.");
            }

            completedCoroutines = true;
            log("Completed needed coroutines. Your game is loaded.");
            //HeroController.instance.gameObject.AddComponent<SuperDashHandler>();
        }
        private void Start()
        {
            gameObject.transform.position = new Vector3(0f, 2.77f, -20f); // Dunno why, but it's in the FSM and seems to work. May work without but w/e.
            PlayMakerFSM.BroadcastEvent("CHARM MSG");
            FSMUtility.SendEventToGameObject(gameObject, "UP", true);

            StartCoroutine(WaitForTimeout());
        }
Exemplo n.º 4
0
        private static void EnemyDescendants(Transform transform)
        {
            List <Transform> list = new List <Transform>();

            foreach (object obj in transform)
            {
                Transform transform2 = (Transform)obj;
                if ((transform2.gameObject.layer == 11 || transform2.gameObject.layer == 17) && !enemyPool.Any(ed => ed.gameObject == transform2.gameObject) && !Ignore(transform2.gameObject.name))
                {
                    PlayMakerFSM playMakerFSM = FSMUtility.LocateFSM(transform2.gameObject, "health_manager_enemy");
                    if (playMakerFSM == null)
                    {
                        playMakerFSM = FSMUtility.LocateFSM(GUIController.Instance.gameObject, "health_manager");
                    }
                    Component component = transform2.gameObject.GetComponent <tk2dSprite>();
                    if (playMakerFSM)
                    {
                        if (component == null)
                        {
                            component = null;
                        }
                        int value = playMakerFSM.FsmVariables.GetFsmInt("HP").Value;
                        enemyPool.Add(new EnemyData(value, playMakerFSM, component, parent, transform2.gameObject));
                    }
                }
                list.Add(transform2);
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].childCount > 0)
                {
                    foreach (object obj2 in list[i])
                    {
                        Transform transform3 = (Transform)obj2;
                        if ((transform3.gameObject.layer == 11 || transform3.gameObject.layer == 17) && !enemyPool.Any(ed => ed.gameObject == transform3.gameObject) && !Ignore(transform3.gameObject.name))
                        {
                            PlayMakerFSM playMakerFSM2 = FSMUtility.LocateFSM(transform3.gameObject, "health_manager_enemy");
                            if (playMakerFSM2 == null)
                            {
                                playMakerFSM2 = FSMUtility.LocateFSM(GUIController.Instance.gameObject, "health_manager");
                            }
                            Component component2 = transform3.gameObject.GetComponent <tk2dSprite>();
                            if (playMakerFSM2)
                            {
                                if (component2 == null)
                                {
                                    component2 = null;
                                }
                                int value2 = playMakerFSM2.FsmVariables.GetFsmInt("HP").Value;
                                enemyPool.Add(new EnemyData(value2, playMakerFSM2, component2, parent, transform3.gameObject));
                            }
                        }
                        list.Add(transform3);
                    }
                }
            }
        }
        private void Close()
        {
            if (_ableToClose)
            {
                _ableToClose = false;
                PlayMakerFSM.BroadcastEvent("CHARM MSG DOWN");
                FSMUtility.SendEventToGameObject(gameObject, "DOWN", true);

                Destroy(gameObject, 0.25f);
            }
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName)
            {
                return;
            }

            GameObject shiny = ObjectCache.ShinyItem;

            shiny.name = _newShinyName;

            if (_activeCheck.Invoke())
            {
                // Simply create the shiny to be active, as in CreateNewShiny

                shiny.transform.position = new Vector3(_x, _y, shiny.transform.position.z);

                shiny.SetActive(true);

                // Force the new shiny to fall straight downwards
                PlayMakerFSM fsm   = FSMUtility.LocateFSM(shiny, "Shiny Control");
                FsmState     fling = fsm.GetState("Fling?");
                fling.ClearTransitions();
                fling.AddTransition("FINISHED", "Fling R");
                FlingObject flingObj = fsm.GetState("Fling R").GetActionsOfType <FlingObject>()[0];
                flingObj.angleMin = flingObj.angleMax = 270;

                // For some reason not setting speed manually messes with the object position
                flingObj.speedMin = flingObj.speedMax = 0.1f;
            }
            else
            {
                // Inactive shiny needs a parent so we can find it later, so create a dummy object if necessary

                string parentName = string.IsNullOrEmpty(_parent) ? _newShinyName + " Parent" : _parent;

                if (GameObject.Find(parentName) is GameObject go)
                {
                    shiny.transform.SetParent(go.transform);
                    shiny.transform.localPosition = new Vector3(0, 0, shiny.transform.position.z);
                }
                else
                {
                    GameObject go2 = new GameObject()
                    {
                        name = parentName
                    };
                    go2.SetActive(true);
                    shiny.transform.SetParent(go2.transform);

                    shiny.SetActive(false);
                }
            }
        }
Exemplo n.º 7
0
        public static void FixBottleFSM(GameObject jar, string item, string location)
        {
            var fsm  = FSMUtility.LocateFSM(jar, "Bottle Control");
            var init = fsm.GetState("Init");

            init.RemoveActionsOfType <BoolTest>();
            init.AddFirstAction(new RandomizerExecuteLambda(() => fsm.SendEvent(RandomizerMod.Instance.Settings.CheckLocationFound(location) ? "ACTIVATE" : null)));
            // The bottle FSM already takes care of granting the grub and playing happy grub noises
            // We have to add the GiveItem action before incrementing the grub count so the RecentItems
            // correctly notes the grub index
            fsm.GetState("Shatter").AddFirstAction(new RandomizerExecuteLambda(() => GiveItem(GiveAction.None, item, location)));
        }
Exemplo n.º 8
0
        public override void OnEnter()
        {
            GameManager gm = Ref.GM;

            if (gm == null)
            {
                Finish();
                return;
            }

            PlayerData pd = gm.playerData;

            if (pd == null)
            {
                Finish();
                return;
            }

            GameObject spawnPoint = GameObject.FindGameObjectWithTag("RespawnPoint");

            if (spawnPoint == null)
            {
                LogWarn(
                    "RandomizerSetHardSave action present in scene with no respawn points: " +
                    Ref.GM.GetSceneNameString());
                Finish();
                return;
            }

            PlayMakerFSM  bench  = FSMUtility.LocateFSM(spawnPoint, "Bench Control");
            RespawnMarker marker = spawnPoint.GetComponent <RespawnMarker>();

            if (bench != null)
            {
                pd.SetBenchRespawn(spawnPoint.name, gm.GetSceneNameString(), 1, true);
            }
            else if (marker != null)
            {
                pd.SetBenchRespawn(marker, gm.GetSceneNameString(), 2);
            }
            else
            {
                LogWarn(
                    "RandomizerSetHardSave could not identify type of RespawnPoint object in scene " +
                    Ref.GM.GetSceneNameString());
                Finish();
                return;
            }

            gm.SaveGame();
            Finish();
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName)
            {
                return;
            }

            Scene currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();

            string[]   objectHierarchy = _objectName.Split('\\');
            int        i   = 1;
            GameObject obj = currentScene.FindGameObject(objectHierarchy[0]);

            while (i < objectHierarchy.Length)
            {
                obj = obj.FindGameObjectInChildren(objectHierarchy[i++]);
            }

            if (obj == null)
            {
                return;
            }

            // Put a shiny in the same location as the original
            GameObject shiny = ObjectCache.ShinyItem;

            shiny.name = _newShinyName;
            if (obj.transform.parent != null)
            {
                shiny.transform.SetParent(obj.transform.parent);
            }

            shiny.transform.position      = obj.transform.position;
            shiny.transform.localPosition = obj.transform.localPosition;
            shiny.SetActive(obj.activeSelf);

            // Force the new shiny to fall straight downwards
            PlayMakerFSM fsm   = FSMUtility.LocateFSM(shiny, "Shiny Control");
            FsmState     fling = fsm.GetState("Fling?");

            fling.ClearTransitions();
            fling.AddTransition("FINISHED", "Fling R");
            FlingObject flingObj = fsm.GetState("Fling R").GetActionsOfType <FlingObject>()[0];

            flingObj.angleMin = flingObj.angleMax = 270;

            // For some reason not setting speed manually messes with the object position
            flingObj.speedMin = flingObj.speedMax = 0.1f;

            // Destroy the original
            Object.Destroy(obj);
        }
Exemplo n.º 10
0
        private static IEnumerator KillGeoText()
        {
            PlayMakerFSM ynFsm = FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control");

            while (ynFsm.ActiveStateName != "Ready for Input")
            {
                yield return(new WaitForEndOfFrame());
            }

            ynFsm.FsmVariables.GetFsmGameObject("Geo Text").Value.SetActive(false);
            ynFsm.FsmVariables.GetFsmInt("Toll Cost").Value = int.MaxValue;
            PlayMakerFSM.BroadcastEvent("NOT ENOUGH");
        }
Exemplo n.º 11
0
 private GameObject DashSoul(GameObject go, Fsm fsm)
 {
     if (go == sharpShadow)
     {
         PlayMakerFSM hm = FSMUtility.LocateFSM(fsm.GameObject, "health_manager") ?? FSMUtility.LocateFSM(fsm.GameObject, "health_manager_enemy");
         if (!Equals(hm, null))
         {
             LogDebug($"Hitting enemy {fsm.GameObject}");
             HeroController.instance.AddMPChargeSpa(11);
         }
     }
     return(go);
 }
Exemplo n.º 12
0
        private static void CloneClicked(string buttonName)
        {
            int       num = Convert.ToInt32(buttonName.Substring(5));
            EnemyData dat = enemyPool.FindAll(ed => ed.gameObject != null && ed.gameObject.activeSelf)[num - 1];

            GameObject   gameObject2   = UnityEngine.Object.Instantiate(dat.gameObject, dat.gameObject.transform.position, dat.gameObject.transform.rotation) as GameObject;
            Component    component     = gameObject2.GetComponent <tk2dSprite>();
            PlayMakerFSM playMakerFSM2 = FSMUtility.LocateFSM(gameObject2, dat.FSM.FsmName);
            int          value8        = playMakerFSM2.FsmVariables.GetFsmInt("HP").Value;

            enemyPool.Add(new EnemyData(value8, playMakerFSM2, component, parent, gameObject2));
            Console.AddLine("Cloning enemy as: " + gameObject2.name);
        }
Exemplo n.º 13
0
        public void GrimmballUpdater()
        {
            try
            {
                AddSoulGrimmball();

                customGrimmball = UnityEngine.Object.Instantiate(deadShootSpawner.gameObject.Value, grimmchild.transform.position, Quaternion.Euler(Vector3.up));
                customGrimmball.transform.position = grimmchild.transform.position;
                PlayMakerFSM     customGrimmballControl = FSMUtility.LocateFSM(customGrimmball, "Control");
                CircleCollider2D grimmballHitbox        = customGrimmball.GetComponent <CircleCollider2D>();


                //customGrimmball.d
                Rigidbody2D grimmPhysics = customGrimmball.GetComponent <Rigidbody2D>();
                grimmPhysics.isKinematic = true;

                grimmballHitbox.radius = 1.1f;

                SetScale realSize = customGrimmballControl.GetState("Init").GetActionsOfType <SetScale>()[0];
                realSize.x = ballSize;
                realSize.y = ballSize;


                customGrimmballControl.SetState("Init");



                GameObject   hitbox        = customGrimmball.FindGameObjectInChildren("Enemy Damager");
                PlayMakerFSM hitboxControl = FSMUtility.LocateFSM(hitbox, "Attack");
                FsmState     inv           = hitboxControl.GetState("Invincible?");

                hitboxControl.FsmVariables.FindFsmInt("Damage").Value = damage;


                if (ghostBalls)
                {
                    FsmState         initState   = customGrimmballControl.GetState("Init");
                    Collision2dEvent initCollide = initState.GetActionsOfType <Collision2dEvent>()[0];
                    initCollide.collideTag = "Enemy";
                }



                oldAttack.gameObject.OwnerOption = OwnerDefaultOption.SpecifyGameObject;
                oldAttack.gameObject.GameObject  = customGrimmball;
            }
            catch (Exception e)
            {
                Log("Unable to make the ball because of error: " + e);
            }
        }
Exemplo n.º 14
0
        protected static void SendEventToFSM(GameObject gameObject, string fsmName, string eventName)
        {
            if (gameObject == null)
            {
                return;
            }

            PlayMakerFSM fsm = FSMUtility.LocateFSM(gameObject, fsmName);

            if (fsm != null)
            {
                fsm.SendEvent(eventName);
            }
        }
Exemplo n.º 15
0
        public static void SelfDamage()
        {
            if (PlayerData.instance.health <= 0 || HeroController.instance.cState.dead || !GameManager.instance.IsGameplayScene() || GameManager.instance.IsGamePaused() || HeroController.instance.cState.recoiling || HeroController.instance.cState.invulnerable)
            {
                Console.AddLine("Unacceptable conditions for selfDamage(" + PlayerData.instance.health + "," + DebugMod.HC.cState.dead + "," + DebugMod.GM.IsGameplayScene() + "," + DebugMod.HC.cState.recoiling + "," + DebugMod.GM.IsGamePaused() + "," + DebugMod.HC.cState.invulnerable + ")." + " Pressed too many times at once?");
                return;
            }
            if (!DebugMod.settings.EnemiesPanelVisible)
            {
                Console.AddLine("Enable EnemyPanel for self-damage");
                return;
            }
            if (EnemiesPanel.enemyPool.Count < 1)
            {
                Console.AddLine("Unable to locate a single enemy in the scene.");
                return;
            }

            GameObject    enemyObj     = EnemiesPanel.enemyPool.ElementAt(new Random().Next(0, EnemiesPanel.enemyPool.Count)).gameObject;
            CollisionSide side         = HeroController.instance.cState.facingRight ? CollisionSide.right : CollisionSide.left;
            int           damageAmount = 1;
            int           hazardType   = (int)HazardType.NON_HAZARD;

            PlayMakerFSM fsm = FSMUtility.LocateFSM(enemyObj, "damages_hero");

            if (fsm != null)
            {
                damageAmount = FSMUtility.GetInt(fsm, "damageDealt");
                hazardType   = FSMUtility.GetInt(fsm, "hazardType");
            }

            object[] paramArray;

            if (EnemiesPanel.parameters.Length == 2)
            {
                paramArray = new object[] { enemyObj, side };
            }
            else if (EnemiesPanel.parameters.Length == 4)
            {
                paramArray = new object[] { enemyObj, side, damageAmount, hazardType };
            }
            else
            {
                Console.AddLine("Unexpected parameter count on HeroController.TakeDamage");
                return;
            }

            Console.AddLine("Attempting self damage");
            EnemiesPanel.takeDamage.Invoke(HeroController.instance, paramArray);
        }
Exemplo n.º 16
0
        // Taken and modified from https://github.com/5FiftySix6/HollowKnight.Lost-Lord/blob/master/LostLord/Kin.cs
        private void ReceiveHit(On.InfectedEnemyEffects.orig_RecieveHitEffect orig, InfectedEnemyEffects self, float attack_direction)
        {
            if (self.GetAttr <bool>("didFireThisFrame"))
            {
                return;
            }

            if (self.GetAttr <SpriteFlash>("spriteFlash") != null)
            {
                self.GetAttr <SpriteFlash>("spriteFlash").flashFocusHeal();
            }

            FSMUtility.SendEventToGameObject(gameObject, "DAMAGE FLASH", true);
            self.GetAttr <AudioEvent>("impactAudio").SpawnAndPlayOneShot(self.GetAttr <AudioSource>("audioSourcePrefab"), self.transform.position);
            self.SetAttr("didFireThisFrame", true);
        }
Exemplo n.º 17
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            if (monitorFSMStates)
            {
                return;
            }

            bool isPlayer = false;

            foreach (Transform t in collision.gameObject.GetComponentsInParent <Transform>())
            {
                if (t.gameObject == HeroController.instance.gameObject)
                {
                    isPlayer = true;
                    break;
                }
            }

            if (!isPlayer)
            {
                Dev.Log("Something not the player entered us!");
                return;
            }

            Dev.Log("Player entered our wake area! ");

            if (!string.IsNullOrEmpty(fsmName))
            {
                PlayMakerFSM fsm = FSMUtility.LocateFSM(owner, fsmName);

                if (fsm != null && wakeEvents != null)
                {
                    foreach (string s in wakeEvents)
                    {
                        Dev.Log("Sending event! " + s);
                        fsm.SendEvent(s);
                    }
                }
                else
                {
                    Dev.Log("Could not find FSM!");
                }
            }

            //remove this after waking up the enemy
            Destroy(gameObject);
        }
Exemplo n.º 18
0
        public static GameObject ShowAdditive(BigItemDef[] items, GameObject fsmObj = null, string eventName = null)
        {
            int count = items.Count(item => RandomizerMod.Instance.Settings.GetBool(false, item.Name));

            if (count < items.Length)
            {
                return(Show(items[count], fsmObj, eventName));
            }

            // In case of failure to give item, prevent soft lock
            if (fsmObj != null && eventName != null)
            {
                FSMUtility.SendEventToGameObject(fsmObj, eventName);
            }

            return(null);
        }
        public static void SetGeo(GameObject rock, string item, string location, int geo)
        {
            var fsm  = FSMUtility.LocateFSM(rock, "Geo Rock");
            var init = fsm.GetState("Initiate");

            init.RemoveActionsOfType <IntCompare>();
            init.AddAction(new RandomizerExecuteLambda(() => {
                fsm.SendEvent(RandomizerMod.Instance.Settings.CheckLocationFound(location) ? "BROKEN" : null);
            }));
            var hit = fsm.GetState("Hit");

            hit.ClearTransitions();
            hit.AddTransition("HIT", "Pause Frame");
            hit.AddTransition("FINISHED", "Pause Frame");
            hit.RemoveActionsOfType <FlingObjectsFromGlobalPool>();
            var payout       = fsm.GetState("Destroy");
            var payoutAction = payout.GetActionOfType <FlingObjectsFromGlobalPool>();

            // If we're flinging 420 geo from a rock that isn't the 420 rock, the game doesn't like loading 420 items at once.
            if (geo == 420)
            {
                geo /= 5;
                payout.AddFirstAction(new RandomizerExecuteLambda(() => {
                    GameObject mediumPrefab = ObjectCache.MediumGeo;
                    Object.Destroy(mediumPrefab.Spawn());
                    mediumPrefab.SetActive(true);
                    payoutAction.gameObject.Value = mediumPrefab;
                }));
                payout.AddAction(new RandomizerExecuteLambda(() => payoutAction.gameObject.Value.SetActive(false)));
            }

            payoutAction.spawnMin.Value = geo;
            payoutAction.spawnMax.Value = geo;
            // Keep geo from flying into unreachable spots
            switch (location)
            {
            case "Thorns_of_Agony":
            case "Spore_Shroom":
            case "Hallownest_Seal-Fog_Canyon_East":
                payoutAction.angleMin.Value = 90;
                payoutAction.angleMax.Value = 90;
                break;
            }
            payout.AddAction(new RandomizerExecuteLambda(() => GiveItem(GiveAction.None, item, location)));
        }
Exemplo n.º 20
0
        public static void EnemyUpdate(float boxSize)
        {
            if (autoUpdate)
            {
                boxSize = 50f;
            }

            if (DebugMod.settings.EnemiesPanelVisible && HeroController.instance != null && !HeroController.instance.cState.transitioning && DebugMod.GM.IsGameplayScene())
            {
                int          count     = enemyPool.Count;
                int          layerMask = 133120;
                Collider2D[] array     = Physics2D.OverlapBoxAll(DebugMod.RefKnight.transform.position, new Vector2(boxSize, boxSize), 1f, layerMask);
                if (array != null)
                {
                    for (int i = 0; i < array.Length; i++)
                    {
                        PlayMakerFSM playMakerFSM = FSMUtility.LocateFSM(array[i].gameObject, "health_manager_enemy");
                        if (playMakerFSM == null)
                        {
                            FSMUtility.LocateFSM(array[i].gameObject, "health_manager");
                        }
                        if (playMakerFSM && !enemyPool.Any(ed => ed.gameObject == array[i].gameObject) && !Ignore(array[i].gameObject.name))
                        {
                            Component component = array[i].gameObject.GetComponent <tk2dSprite>();
                            if (component == null)
                            {
                                component = null;
                            }
                            int value = playMakerFSM.FsmVariables.GetFsmInt("HP").Value;
                            enemyPool.Add(new EnemyData(value, playMakerFSM, component, parent, array[i].gameObject));
                        }
                    }
                    if (enemyPool.Count > count)
                    {
                        Console.AddLine("EnemyList updated: +" + (enemyPool.Count - count));
                        return;
                    }
                }
            }
            else if (autoUpdate && (!DebugMod.settings.EnemiesPanelVisible || !GameManager.instance.IsGameplayScene() || HeroController.instance == null))
            {
                autoUpdate = false;
                Console.AddLine("Cancelling enemy auto-scan due to weird conditions");
            }
        }
Exemplo n.º 21
0
        private IEnumerator getHeroFSMs()
        {
            while (GameManager.instance == null || HeroController.instance == null)
            {
                yield return(null);
            }

            voidKnight = GameObject.Find("Knight");
            redwing_game_objects.voidKnight = voidKnight;


            voidKnightSpellControl = FSMUtility.LocateFSM(voidKnight, "ProxyFSM");
            voidKnightNailArts     = FSMUtility.LocateFSM(voidKnight, "Nail Arts");

            setupFlamePillar();
            setupNailArtFireballs();
            createFlameShield();
        }
Exemplo n.º 22
0
        public static bool InInventory()
        {
            GameObject inventoryTop = GameObject.FindGameObjectWithTag("Inventory Top");

            if (inventoryTop == null)
            {
                return(false);
            }

            PlayMakerFSM playMakerFsm = FSMUtility.LocateFSM(inventoryTop, "Inventory Control");

            if (playMakerFsm == null)
            {
                return(false);
            }

            return(playMakerFsm.FsmVariables.FindFsmBool("Open").Value);
        }
Exemplo n.º 23
0
        public static GameObject ShowAdditive(BigItemDef[] items, GameObject fsmObj = null, string eventName = null)
        {
            for (int i = 0; i < items.Length; i++)
            {
                if (!Ref.PD.GetBool(items[i].BoolName))
                {
                    return(Show(items[i], fsmObj, eventName));
                }
            }

            // In case of failure to give item, prevent soft lock
            if (fsmObj != null && eventName != null)
            {
                FSMUtility.SendEventToGameObject(fsmObj, eventName);
            }

            return(null);
        }
Exemplo n.º 24
0
 public static void RefreshEnemyList()
 {
     if (DebugMod.settings.EnemiesPanelVisible)
     {
         GameObject[] rootGameObjects = UnityEngine.SceneManagement.SceneManager.GetSceneByName(DebugMod.GetSceneName()).GetRootGameObjects();
         if (rootGameObjects != null)
         {
             foreach (GameObject gameObject in rootGameObjects)
             {
                 if ((gameObject.layer == 11 || gameObject.layer == 17 || gameObject.tag == "Boss") && !Ignore(gameObject.name))
                 {
                     PlayMakerFSM playMakerFSM = FSMUtility.LocateFSM(gameObject, "health_manager_enemy");
                     Component    component    = gameObject.GetComponent <tk2dSprite>();
                     if (playMakerFSM == null)
                     {
                         playMakerFSM = FSMUtility.LocateFSM(gameObject, "health_manager");
                     }
                     int num3 = gameObject.name.IndexOf("grass", StringComparison.OrdinalIgnoreCase);
                     int num2 = gameObject.name.IndexOf("hopper", StringComparison.OrdinalIgnoreCase);
                     if (num3 >= 0 && num2 >= 0)
                     {
                         component = gameObject.transform.FindChild("Sprite").gameObject.gameObject.GetComponent <tk2dSprite>();
                     }
                     if (playMakerFSM != null)
                     {
                         if (component == null)
                         {
                             component = null;
                         }
                         int value = playMakerFSM.FsmVariables.GetFsmInt("HP").Value;
                         enemyPool.Add(new EnemyData(value, playMakerFSM, component, parent, gameObject));
                     }
                 }
                 EnemyDescendants(gameObject.transform);
             }
         }
         if (enemyPool.Count > 0)
         {
             Console.AddLine("Enemy data filled, entries added: " + enemyPool.Count);
         }
         EnemyUpdate(200f);
     }
 }
Exemplo n.º 25
0
        private static void OpenYNDialogue(GameObject shiny, string text, Func <bool> canBuy)
        {
            FSMUtility.LocateFSM(GameObject.Find("DialogueManager"), "Box Open YN").SendEvent("BOX UP YN");
            FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control").FsmVariables
            .GetFsmGameObject("Requester").Value = shiny;

            Lang.Add("UI", "RANDOMIZER_YN_DIALOGUE", text);
            if (!canBuy())
            {
                KillGeoText().RunCoroutine();
            }

            FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control").FsmVariables
            .GetFsmInt("Toll Cost").Value = 0;
            FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control").FsmVariables
            .GetFsmGameObject("Geo Text").Value.SetActive(true);

            GameObject.Find("Text YN").GetComponent <DialogueBox>().StartConversation("RANDOMIZER_YN_DIALOGUE", "UI");
        }
        // No idea
        private static void FalseKnightNoises(On.EnemyHitEffectsArmoured.orig_RecieveHitEffect orig,
                                              EnemyHitEffectsArmoured self, float dir)
        {
            orig(self, dir);

            if (_rndNum != 17 || self.gameObject.name != "False Knight New")
            {
                return;
            }

            AudioPlayerOneShot hitPlayer = FSMUtility.LocateFSM(self.gameObject, "FalseyControl").GetState("Hit")
                                           .GetActionsOfType <AudioPlayerOneShot>()[0];
            AudioClip clip = hitPlayer.audioClips[Rnd.Next(hitPlayer.audioClips.Length)];

            AudioClip temp = self.enemyDamage.Clip;

            self.enemyDamage.Clip = clip;
            self.enemyDamage.SpawnAndPlayOneShot(self.audioPlayerPrefab, self.transform.position);
            self.enemyDamage.Clip = temp;
        }
        private static void OpenYNDialogue(GameObject shiny, string itemName, int cost, int type)
        {
            FSMUtility.LocateFSM(GameObject.Find("DialogueManager"), "Box Open YN").SendEvent("BOX UP YN");
            FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control").FsmVariables
            .GetFsmGameObject("Requester").Value = shiny;

            if (type == TYPE_ESSENCE)
            {
                LanguageStringManager.SetString("UI", "RANDOMIZER_YN_DIALOGUE",
                                                cost + " Essence: " + LanguageStringManager.GetLanguageString(itemName, "UI"));

                if (Ref.PD.dreamOrbs < cost)
                {
                    FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control")
                    .StartCoroutine(KillGeoText());
                }

                cost = 0;
            }
            else if (type == TYPE_GRUB)
            {
                LanguageStringManager.SetString("UI", "RANDOMIZER_YN_DIALOGUE", cost + " Grubs: " + LanguageStringManager.GetLanguageString(itemName, "UI"));

                if (PlayerData.instance.grubsCollected < cost)
                {
                    FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control").StartCoroutine(KillGeoText());
                }

                cost = 0;
            }
            else
            {
                LanguageStringManager.SetString("UI", "RANDOMIZER_YN_DIALOGUE",
                                                LanguageStringManager.GetLanguageString(itemName, "UI"));
            }

            FSMUtility.LocateFSM(GameObject.Find("Text YN"), "Dialogue Page Control").FsmVariables
            .GetFsmInt("Toll Cost").Value = cost;

            GameObject.Find("Text YN").GetComponent <DialogueBox>().StartConversation("RANDOMIZER_YN_DIALOGUE", "UI");
        }
Exemplo n.º 28
0
        public void GetReferences()
        {
            if (sharpShadow == null || sharpShadow.tag != "Sharp Shadow")
            {
                foreach (GameObject gameObject in Resources.FindObjectsOfTypeAll <GameObject>())
                {
                    if (gameObject != null && gameObject.tag == "Sharp Shadow")
                    {
                        sharpShadow    = gameObject;
                        sharpShadowFSM = FSMUtility.LocateFSM(sharpShadow, "damages_enemy");
                        LogDebug($@"Found Sharp Shadow: {sharpShadow} - {sharpShadowFSM}.");
                    }
                }
            }

            if (superDash == null)
            {
                superDash = HeroController.instance.superDash;
                HeroController.instance.gameObject.AddComponent <SuperDashHandler>();
            }
        }
Exemplo n.º 29
0
        // Spawns in grimmchild after loading scene.
        public static IEnumerator spawnGrimmchild()
        {
            yield return(new WaitForFinishedEnteringScene());

            yield return(new WaitForSeconds(5f));

            if (!PlayerData.instance.GetBoolInternal("equippedCharm_40"))
            {
                yield break;
            }
            log("Spawning grimmchild in grimm arena.");
            PlayMakerFSM gcControl = FSMUtility.LocateFSM(infinite_tent.grimmchild, "Control");

            infinite_tent.grimmchild.SetActive(true);
            FsmState starting = gcControl.getState("Pause");

            starting.removeActionsOfType <BoolTest>();
            starting.clearTransitions();
            starting.addTransition("FINISHED", "Spawn");
            starting.addTransition("AWOKEN", "Spawn");
        }
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName ||
                fsm.gameObject.name != _objectName)
            {
                return;
            }

            FsmState spawnItems = fsm.GetState("Spawn Items");

            // Remove 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;
            }

            // Instantiate a new shiny and set the chest as its parent
            GameObject item  = fsm.gameObject.transform.Find("Item").gameObject;
            GameObject shiny = ObjectCache.ShinyItem;

            shiny.SetActive(false);
            shiny.transform.SetParent(item.transform);
            shiny.transform.position = item.transform.position;
            shiny.name = _newShinyName;

            // Force the new shiny to fling out of the chest
            PlayMakerFSM shinyControl = FSMUtility.LocateFSM(shiny, "Shiny Control");
            FsmState     shinyFling   = shinyControl.GetState("Fling?");

            shinyFling.ClearTransitions();
            shinyFling.AddTransition("FINISHED", "Fling R");
        }