Esempio n. 1
0
        private void StartWallRunning(HeroController hc)
        {
            // Check for incompatible hero state
            if (_wallRunning || hc.controlReqlinquished || hc.hero_state != ActorStates.idle &&
                hc.hero_state != ActorStates.running && hc.hero_state != ActorStates.airborne)
            {
                return;
            }

            // Completely remove control of the character from the game
            hc.RelinquishControl();
            hc.GetComponent <HeroAnimationController>().StopControl();
            hc.AffectedByGravity(false);

            // Rotate towards the wall and move a little bit away to prevent clipping
            hc.transform.SetPositionX(transform.position.x + _box.size.x + .15f);
            hc.transform.rotation = Quaternion.Euler(0, 0, -90);

            // Make sure the hero is inside the vertical bounds of the collider
            // They can otherwise be quite a ways above it after the rotation
            if (hc.transform.position.y > transform.position.y + _box.size.y / 2)
            {
                hc.transform.SetPositionY(transform.position.y + _box.size.y / 2);
            }
            else if (hc.transform.position.y < transform.position.y - _box.size.y / 2)
            {
                hc.transform.SetPositionY(transform.position.y - _box.size.y / 2);
            }

            _wallRunning = true;
        }
Esempio n. 2
0
        private void FixedUpdate()
        {
            if (!running)
            {
                return;
            }

            if (checkPointIndex < points.Length)
            {
                Vector2 heroPos  = heroController.transform.position;
                Vector2 distance = points[checkPointIndex] + heroGoPos - heroPos;

                if (distance.magnitude <= 0.5)
                {
                    //Log("Passed Waypoint " + checkPointIndex);
                    checkPointIndex++;
                }

                distance.Normalize();
                distance.Scale(new Vector2(speed, speed));

                heroController.cState.falling = false;
                heroResetAttacksFunction?.Invoke(heroController, null);

                heroRb2d.velocity = distance;
                heroController.current_velocity = distance;
            }
            else
            {
                heroController.cState.falling       = true;
                heroController.cState.doubleJumping = false;
                heroController.cState.dashing       = false;
                heroController.cState.backDashing   = false;
                heroController.cState.preventDash   = false;
                heroController.SetAttr("doubleJump_steps", 0);
                heroController.SetAttr("dash_timer", 0.0f);
                heroController.SetAttr("airDashed", false);
                heroController.SetAttr("doubleJumped", false);
                heroController.hero_state = ActorStates.airborne;
                heroController.AffectedByGravity(true);

                if (currentSecondsDelayBeforeInputAccepting < secondsDelayBeforeInputAccepting)
                {
                    currentSecondsDelayBeforeInputAccepting += Time.fixedDeltaTime;
                }
                else
                {
                    running = false;
                    _moving = false;
                    heroController.AcceptInput();
                }
            }
        }
Esempio n. 3
0
        private void FixHero(HeroController hc)
        {
            if (hc == null)
            {
                return;
            }

            // Return control to the game, reset rotation
            hc.AffectedByGravity(true);
            hc.RegainControl();
            hc.GetComponent <HeroAnimationController>().StartControl();
            hc.gameObject.transform.rotation = Quaternion.identity;

            _wallRunning = false;
        }
Esempio n. 4
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
            }
        }