예제 #1
0
        public void OnTriggerEnter2D(Collider2D otherCollider)
        {
            if (points.Length <= 0 || speed == 0 || _moving || running)
            {
                return;
            }
            if (otherCollider.gameObject.name == "Knight")
            {
                //HeroController.instance.StartCoroutine(coroutine = MoveKnight());

                #region IEnumerator Start

                _moving = true;
                running = true;
                //Log("Moving the Knight");

                checkPointIndex = 0;
                heroController  = HeroController.instance;
                heroRb2d        = heroController.GetComponent <Rigidbody2D>();

                // Cancel stuff
                // Spells
                if (heroController.spellControl.ActiveStateName.Contains("Quake"))
                {
                    PlayMakerFSM.BroadcastEvent("QUAKE FALL END");
                    heroController.spellControl.SetState("Quake Finish");
                }
                Transform spellsTransform = heroController.transform.Find("Spells");
                for (int child = 0; child < spellsTransform.childCount; child++)
                {
                    spellsTransform.GetChild(child).gameObject.SetActive(false);
                }
                // Nail Arts
                heroController.EndCyclone();
                var nailArtFsm = heroController.gameObject.LocateMyFSM("Nail Arts");
                nailArtFsm.SendEvent("END");
                nailArtFsm.SendEvent("FINISHED");
                try { heroController.transform.Find("Great Slash").gameObject.SetActive(false); }
                catch (Exception)
                { }

                try { heroController.transform.Find("Cyclone Slash").gameObject.SetActive(false); }
                catch (Exception)
                { }

                try { heroController.transform.Find("Dash Slash").gameObject.SetActive(false); }
                catch (Exception)
                { }

                // Other stuff
                heroController.CancelSuperDash();
                typeof(HeroController).GetMethod("CancelJump", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelDoubleJump", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelDash", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelWallsliding", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelBackDash", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelDownAttack", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelAttack", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelBounce", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelRecoilHorizontal", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("CancelDamageRecoil", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                heroResetAttacksFunction?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("ResetAttacksDash", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                typeof(HeroController).GetMethod("ResetLook", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(heroController, null);
                // Animation
                var hac = heroController.GetAttr <HeroController, HeroAnimationController>("animCtrl");
                typeof(HeroAnimationController).GetMethod("Play", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(hac, new object[] { "Airborne" });

                // Now we can do stuff
                heroController.IgnoreInputWithoutReset();
                heroController.ResetHardLandingTimer();
                heroController.hero_state = ActorStates.airborne;
                heroController.hero_state = ActorStates.no_input;
                heroController.AffectedByGravity(false);

                heroGoPos = gameObject.transform.position;

                currentSecondsDelayBeforeInputAccepting = 0;

                #endregion
            }
        }