示例#1
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;
            }
        }
示例#2
0
        private float FaceHero()
        {
            var heroSignX = Mathf.Sign(_target.transform.GetPositionX() - gameObject.transform.GetPositionX());
            var pScale    = gameObject.transform.localScale;

            gameObject.transform.localScale = new Vector2(Mathf.Abs(pScale.x) * heroSignX, pScale.y);
            if (heroSignX > 0)
            {
                _target.FaceLeft();
            }
            else
            {
                _target.FaceRight();
            }
            return(heroSignX);
        }
示例#3
0
        IEnumerator IntroText()
        {
            yield return(new WaitForSeconds(1f));

            if (!ArenaFinder.foundBoss)
            {
                GameObject text   = Instantiate(GameObject.Find("DialogueManager"));
                var        txtfsm = text.LocateMyFSM("Box Open");
                txtfsm.SendEvent("BOX UP");
                yield return(null);

                GameManager.instance.playerData.disablePause = true;
                _target.RelinquishControl();
                _target.StopAnimationControl();
                _target.gameObject.GetComponent <tk2dSpriteAnimator>().Play("Idle");
                _target.FaceRight();
                GameObject sec = text.transform.Find("Text").gameObject;
                sec.GetComponent <DialogueBox>().StartConversation("FENNEL_INTRO", "testudo");
                yield return(new WaitWhile(() => sec.GetComponent <DialogueBox>().currentPage <= 1));

                _anim.Play("intro2");
                _aud.clip = ArenaFinder.audioClips["sndIntroHead"];
                _aud.Play();
                yield return(new WaitWhile(() => _anim.IsPlaying()));

                yield return(new WaitWhile(() => sec.GetComponent <DialogueBox>().currentPage <= 3));

                txtfsm.SendEvent("BOX DOWN");
                text.SetActive(false);
                _target.RegainControl();
                GameManager.instance.playerData.disablePause = false;
                _target.StartAnimationControl();
                ArenaFinder.foundBoss = true;
            }
            introTextDone = true;
        }