Exemplo n.º 1
0
        private void Awake()
        {
            _anim     = GetComponent <tk2dSpriteAnimator>();
            _audio    = GetComponent <AudioSource>();
            _collider = GetComponent <BoxCollider2D>();
            _hm       = GetComponent <HealthManager>();
            _nb       = GetComponent <NonBouncer>();
            _rb       = GetComponent <Rigidbody2D>();

            _hc   = HeroController.instance;
            _ac   = _hc.GetAttr <HeroController, HeroAudioController>("audioCtrl");
            _hero = _hc.gameObject;
            _sc   = _hc.spellControl;
            _pd   = PlayerData.instance;

            _musicObj = new GameObject("Doppelganger Music");

            _maxHealth = 2000 + (_pd.maxHealth + _pd.healthBlue) * 200;
            _hm.hp     = _maxHealth;

            #if DEBUG
            //_hm.hp = 1000;
            #endif

            _furyThreshold = _hm.hp / 10;

            _hm.OnDeath += OnDeath;
            HeroController.instance.OnDeath += OnHeroDeath;
            On.HealthManager.TakeDamage     += OnTakeDamage;
            On.MusicCue.GetChannelInfo      += MusicCueGetChannelInfo;
        }
Exemplo n.º 2
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
            }
        }