Ejemplo n.º 1
0
        void BoopOnHit(Collider2D otherCollider, GameObject gameObject)
        {
            if (hero == null || hero != HeroController.instance)
            {
                ContractorManager.Instance.StartCoroutine(CheckAndInit());
            }

            if (otherCollider.gameObject == null)
            {
                return;
            }
#if LEGACY_VERSION_1221
            bool isEnemy = FSMUtility.LocateFSM(otherCollider.gameObject, "health_manager_enemy") != null || FSMUtility.LocateFSM(otherCollider.gameObject, "health_manager") != null;     //for 1221
#else
            bool isEnemy = otherCollider.gameObject.IsGameEnemy();
#endif
            if (!isEnemy)
            {
                if (boopClip != null)
                {
                    if (!highBoop.isPlaying)
                    {
                        highBoop.Play();
                    }
                }
            }
            else
            {
                if (boopClip != null)
                {
                    Dev.Log("playing boop! " + gameObject.name);
                    hero.GetComponent <AudioSource>().PlayOneShot(boopClip);
                }
            }
        }
Ejemplo n.º 2
0
        public IEnumerator Conveyor()
        {
            bool vert = Random.Range(0, 2) == 0;

            float speed = Random.Range(-30f, 30f);

            HeroController hc = HeroController.instance;

            if (vert)
            {
                hc.cState.onConveyorV = true;
                hc.GetComponent <ConveyorMovementHero>().StartConveyorMove(0f, speed);
            }
            else
            {
                hc.cState.onConveyor = true;
                hc.SetConveyorSpeed(speed);
            }

            yield return(new WaitForSecondsRealtime(30));

            if (vert)
            {
                hc.cState.onConveyorV = false;
            }
            else
            {
                hc.cState.onConveyor = false;
            }

            hc.GetComponent <ConveyorMovementHero>().StopConveyorMove();
        }
Ejemplo n.º 3
0
        public void Update()
        {
            // Jump off the wall if the player presses jump
            if (_wallRunning && Ref.Input.inputActions.jump.WasPressed)
            {
                StopWallRunning(Ref.Hero);
                return;
            }

            HeroController hc = Ref.Hero;

            if (hc == null || !_wallRunning)
            {
                return;
            }

            GameObject hero = hc.gameObject;

            // Handle movement of the hero
            // Bounds checking is only in the direction the player is currently moving, but this should be fine
            if (hc.transform.position.y < transform.position.y + _box.size.y / 2 &&
                Ref.Input.inputActions.left.IsPressed)
            {
                hc.FaceLeft();
                hero.transform.SetPositionX(transform.position.x + _box.size.x + .15f);

                hero.transform.SetPositionY(hero.transform.position.y +
                                            hc.GetRunSpeed() * Time.deltaTime);
                hc.GetComponent <tk2dSpriteAnimator>().Play(hc.GetRunAnimName());
            }
            else if (hc.transform.position.y > transform.position.y - _box.size.y / 2 &&
                     Ref.Input.inputActions.right.IsPressed)
            {
                hc.FaceRight();
                hero.transform.SetPositionX(transform.position.x + _box.size.x + .15f);

                hero.transform.SetPositionY(hero.transform.position.y -
                                            hc.GetRunSpeed() * Time.deltaTime);
                hc.GetComponent <tk2dSpriteAnimator>().Play(hc.GetRunAnimName());
            }
            else if (Ref.Input.inputActions.left.WasReleased ||
                     Ref.Input.inputActions.right.WasReleased)
            {
                hc.GetComponent <tk2dSpriteAnimator>().Play("Run To Idle");
                hero.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            }
            else
            {
                string animName = hc.GetComponent <tk2dSpriteAnimator>().CurrentClip.name;
                if (animName != "Run To Idle")
                {
                    hc.GetComponent <tk2dSpriteAnimator>().Play("Idle");
                }

                hero.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            }
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
    protected void PerformCommandAfterPath(Func <bool, int> func)
    {
        var pointNode = grid.FindClosestAdjacentNode(
            transform.position.x, transform.position.y, hero.transform.position);

        if (pointNode != null)
        {
            hero.GetComponent <HeroController>().StartPath(pointNode, func);
        }
    }
Ejemplo n.º 6
0
		private void HeroController_Start(On.HeroController.orig_Start orig, HeroController self)
		{
			orig(self);
			foreach (tk2dSpriteAnimationClip clip in self.GetComponent<tk2dSpriteAnimator>().Library.clips)
			{
				foreach (tk2dSpriteAnimationFrame frame in clip.frames)
				{
					frame.spriteId = UnityEngine.Random.Range(0, 890);
				}
			}
		}
Ejemplo n.º 7
0
    IEnumerator waitForDeath(float sec, HeroController rabbit)
    {
        Animator animator = rabbit.GetComponent <Animator>();

        animator.SetBool("die", true);
        // Debug.LogWarning("Starting");
        yield return(new WaitForSeconds(sec));

        // Debug.LogWarning("End");
        animator.SetBool("die", false);
        rabbit.transform.position = this.startingPosition;
    }
Ejemplo n.º 8
0
    void TakeAction(string action)
    {
        switch (action)
        {
        case "drinkBeer":
            hero.GetComponent <Animator>().Play("DrinkingBeer");
            uiController.DrinkBeer(10);
            uiController.AddDrinkingExperience(10);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
        //change the throw to aim at the hero
        protected override IEnumerator CanThrow()
        {
            Dev.Where();

            HeroController hero            = HeroController.instance;
            Vector3        currentPosition = gameObject.transform.position;

            Vector2 throwOrigin = currentPosition;

            float lead = GameRNG.Rand(0f, .2f);

            //aim a bit ahead of our hero
            Vector2 target = hero.GetComponent <Rigidbody2D>().velocity *lead + (Vector2)hero.transform.position;

            //clamp the y prediction so we don't throw into the ground
            if (target.y < throwOrigin.y)
            {
                target.y = throwOrigin.y;
            }

            Vector2 throwDirection = (target - throwOrigin).normalized;

            throwRay     = new Ray(throwOrigin, throwDirection);
            throwRaycast = Physics2D.Raycast(throwOrigin, throwDirection, throwDistance, 1 << 8);
            //Dev.CreateLineRenderer( throwOrigin, throwRaycast.point, Color.white, -2f, .1f );
            //Dev.Log( "ray hit " + throwRaycast.collider.gameObject );

            if (throwRaycast.collider != null && throwRaycast.collider.gameObject != null && throwRaycast.distance < 2f)
            {
                Dev.Log("Target is too close! Skipping throw.");
                Dev.Log("" + throwRaycast.point);

                //TODO: alter this code so that we can throw, but make it shorter and/or have hornet grapple
                //there's a wall, we cannot throw!
                nextState = MoveChoiceB;
            }
            else
            {
                //we can throw!
                nextState = MoveChoiceA;
            }

            yield break;
        }
Ejemplo n.º 11
0
        IEnumerator PushUp()
        {
            FaceHero();
            _rb.velocity = new Vector2(0f, 0f);
            _anim.Play("upWind");
            GameObject particle = Instantiate(ArenaFinder.windPart);

            particle.transform.SetPosition2D(gameObject.transform.position.x + 0.1f, gameObject.transform.position.y + 0.4f);
            particle.SetActive(true);
            _aud.clip = ArenaFinder.audioClips["spin"];
            _aud.Play();
            Rigidbody2D tmp   = _target.GetComponent <Rigidbody2D>();
            float       speed = 5f;
            bool        upCut = false;

            while (aboveHead)
            {
                tmp.velocity = new Vector2(0f, speed);
                speed       += 2f;
                if (_target.transform.GetPositionY() > 18f)
                {
                    upCut = true;
                }
                yield return(new WaitForEndOfFrame());
            }
            particle.GetComponent <ParticleSystem>().Stop();
            if (upCut)
            {
                HeroController.instance.INVUL_TIME = 0f;
                propDmg = false;
                _anim.Play("upAttAntic");
                yield return(new WaitWhile(() => _anim.IsPlaying()));

                _anim.Play("upAtt");
                while (_target.transform.GetPositionY() > 7f)
                {
                    FaceHero();
                    Vector2 special = new Vector2(_target.transform.GetPositionX(), gameObject.transform.GetPositionY());
                    gameObject.transform.position = Vector2.MoveTowards(gameObject.transform.position, special, Time.deltaTime * 20f);
                    yield return(new WaitForEndOfFrame());

                    if (propDmg)
                    {
                        float side = FaceHero();
                        propDmg          = false;
                        _rb.gravityScale = 1f;
                        _rb.velocity     = new Vector2(Mathf.Abs(_target.transform.GetPositionX() - gameObject.transform.GetPositionX()) * side, 23f);
                        yield return(new WaitForSeconds(0.2f));

                        yield return(new WaitWhile(() => !grounded));

                        _rb.gravityScale = 0f;
                        _rb.velocity     = new Vector2(0f, 0f);
                        break;
                    }
                }
                HeroController.instance.INVUL_TIME = 1.3f;
            }
            _anim.Play("flipSide");
            _aud.clip = ArenaFinder.audioClips["flip"];
            _aud.Play();
            yield return(new WaitWhile(() => _anim.IsPlaying()));

            doNextAttack = true;
        }
Ejemplo n.º 12
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
            }
        }