Пример #1
0
    public IEnumerator TakingShower()
    {
        if (!GameLibOfMethods.canInteract)
        {
            GameLibOfMethods.cantMove = true;
            GameLibOfMethods.Walking  = false;

            GameLibOfMethods.animator.SetBool("Jumping", false);
            GameLibOfMethods.animator.SetBool("TakingShower", true);

            Emission.enabled = true;
            yield return(new WaitForEndOfFrame());

            SpriteControler.Instance.FaceDOWN();

            GameLibOfMethods.canInteract = true;
            yield return(new WaitForEndOfFrame());

            float timeWithFullBar = 0;

            while (!Input.GetKey(InteractionChecker.Instance.KeyToInteract) && !GameLibOfMethods.passedOut && !isBroken)
            {
                Stats.Status(Type.Hygiene).Add(HygieneGainAmount * Time.fixedDeltaTime);

                float chance = Random.Range(0f, 100f);
                if (chance <= breakChancePerSecond / 60)
                {
                    isBroken = true;
                    Break();
                }


                if (Stats.Status(Type.Hygiene).CurrentAmount >= Stats.Status(Type.Hygiene).MaxAmount)
                {
                    timeWithFullBar += Time.deltaTime;

                    if (timeWithFullBar >= 2)
                    {
                        GameLibOfMethods.CreateFloatingText("You are too clean for this.", 2);
                        break;
                    }
                }
                yield return(new WaitForFixedUpdate());
            }

            Emission.enabled = false;
            yield return(new WaitForEndOfFrame());

            PlayExitSound();


            GameLibOfMethods.animator.SetBool("TakingShower", false);
            yield return(new WaitForEndOfFrame());

            void act() => SpriteControler.Instance.ChangeSortingOrder(0);

            PlayerCommands.JumpOff(0, act);
        }
    }
Пример #2
0
        public override void FinishUsing(bool cancel)
        {
            ResetObjectState(cancel);
            if (breakFunctionality.DidBreakDuringLastUse())
            {
                gameObject.GetComponent <Interactivity>().options = brokenOptions; breakFunctionality.Break();
            }

            PlayerCommands.JumpOff(0, () => {
                SpriteControler.Instance.ChangeSortingOrder(0);
                SpriteControler.Instance.SetClothesState(true);
                SpriteControler.Instance.Censor.SetActive(false);
            });
        }
Пример #3
0
    public IEnumerator RunningOnTreadmill()
    {
        GameLibOfMethods.cantMove    = true;
        GameLibOfMethods.canInteract = true;

        SpriteControler.Instance.FaceLEFT();
        GameLibOfMethods.animator.SetBool("Jumping", false);
        GameLibOfMethods.animator.SetBool("Walking", true);
        GameLibOfMethods.animator.SetFloat("Horizontal", -1);

        yield return(new WaitForFixedUpdate());


        while (!Input.GetKey(InteractionChecker.Instance.KeyToInteract))
        {
            GameLibOfMethods.animator.SetBool("Walking", true);

            SpriteControler.Instance.FaceLEFT();

            Stats.AddXP(Fitness, 0.027777778f);
            Stats.Status(Energy).Remove(0.027777778f);

            if (Stats.Status(Energy).CurrentAmount <= 0 || Stats.Status(Health).CurrentAmount <= 0)
            {
                break;
            }


            yield return(new WaitForFixedUpdate());
        }
        GameLibOfMethods.animator.SetFloat("Horizontal", 0);

        Debug.Log("Playing exit sound");
        PlayExitSound();

        GameLibOfMethods.animator.SetBool("Walking", false);
        yield return(new WaitForEndOfFrame());


        if (Stats.Status(Energy).CurrentAmount <= 0 || Stats.Status(Health).CurrentAmount <= 0)
        {
            void act() => GameLibOfMethods.animator.SetBool("PassOut", true);

            PlayerCommands.JumpOff(0, act);
        }
        else
        {
            PlayerCommands.JumpOff();
        }
    }
Пример #4
0
        public override void FinishUsing(bool cancel)
        {
            CurrentAction.EndAction();
            ResetObjectState(cancel);
            void ResetAction()
            {
                SpriteControler.Instance.ChangeSortingOrder(0);
                GetComponent <SpriteRenderer>().sortingOrder = 0;
            }

            PlayerAnimationHelper.ResetAnimations();
            PlayerCommands.WalkBackToLastPosition(ResetAction);
            PlayerCommands.JumpOff(0, action);
            void action() => SpriteControler.Instance.ChangeSortingOrder(0);
        }
Пример #5
0
        private IEnumerator FinishUsingDelay(bool cancel)
        {
            yield return(new WaitForSeconds(2));

            ResetObjectState(cancel);
            if (breakFunctionality.DidBreakDuringLastUse())
            {
                gameObject.GetComponent <Interactivity>().options = brokenOptions; breakFunctionality.Break();
            }

            PlayerCommands.JumpOff(0, () => {
                SpriteControler.Instance.ChangeSortingOrder(0);
                SpriteControler.Instance.Censor.SetActive(false);
                SpriteControler.Instance.SetClothesState(true);
            });
        }
Пример #6
0
    public IEnumerator StartLifting()
    {
        GameLibOfMethods.animator.SetBool("Jumping", false);
        GameLibOfMethods.animator.SetBool("Lifting", true);
        Weights.SetActive(false);

        yield return(new WaitForEndOfFrame());

        SpriteControler.Instance.FaceRIGHT();

        while (!Input.GetKey(InteractionChecker.Instance.KeyToInteract))
        {
            Stats.AddXP(Strength, 0.027777778f);
            Stats.Status(Energy).Remove(0.027777778f);

            if (Stats.Status(Energy).CurrentAmount <= 0 || Stats.Status(Health).CurrentAmount <= 0)
            {
                break;
            }

            yield return(new WaitForFixedUpdate());
        }

        Debug.Log("Playing exit sound");
        PlayExitSound();

        GameLibOfMethods.animator.SetBool("Lifting", false);
        yield return(new WaitForEndOfFrame());

        Weights.SetActive(true);


        if (Stats.Status(Energy).CurrentAmount <= 0 || Stats.Status(Health).CurrentAmount <= 0)
        {
            void act() => GameLibOfMethods.animator.SetBool("PassOut", true);

            PlayerCommands.JumpOff(0, act);
        }
        else
        {
            PlayerCommands.JumpOff();
        }
    }
Пример #7
0
    IEnumerator UseToilet()
    {
        GameLibOfMethods.cantMove = true;
        SpriteControler.Instance.FaceLEFT();
        GameLibOfMethods.animator.SetBool("Jumping", false);
        GameLibOfMethods.animator.SetBool("TakingADump", true);

        yield return(new WaitForFixedUpdate());

        SpriteControler.Instance.FaceLEFT();

        float timeWithFullBar = 0;

        while (!Input.GetKey(InteractionChecker.Instance.KeyToInteract) && !GameLibOfMethods.passedOut)
        {
            Stats.Status(Type.Bladder).Add(BladderGainAmount * Time.fixedDeltaTime);


            if (Stats.Status(Type.Bladder).CurrentAmount >= Stats.Status(Type.Bladder).MaxAmount)
            {
                timeWithFullBar += Time.deltaTime;

                if (timeWithFullBar >= 2)
                {
                    GameLibOfMethods.CreateFloatingText("You have no juice left in your body.", 2);
                    break;
                }
            }

            yield return(new WaitForFixedUpdate());
        }

        PlayExitSound();

        GameLibOfMethods.animator.SetBool("TakingADump", false);
        yield return(new WaitForEndOfFrame());

        void act() => SpriteControler.Instance.ChangeSortingOrder(0);

        PlayerCommands.JumpOff(0, act);
    }
Пример #8
0
        IEnumerator <float> JumpOffFromBed(bool cancel)
        {
            Player.anim.SetBool("Sleeping", false);
            yield return(0f);

            while (true)
            {
                var state = Player.anim.GetCurrentAnimatorStateInfo(0);
                if (!state.IsName("JumpOffToBed"))
                {
                    Debug.Log("Something is wrong.. this finished before firing the method. Make sure you don't call this from FixedUpdate.");
                    break;
                }

                if (state.normalizedTime >= 40 / 50f)
                {
                    break;
                }
                yield return(0f);
            }

            //Covers.sortingOrder = 0;
            HandlePlayerSprites(enable: true);

            void action()
            {
                Player.col.enabled = true;
                //SpriteControler.Instance.ChangeSortingOrder(0);
                //Covers.sortingOrder = 0;
                GameLibOfMethods.player.transform.parent.transform.parent = null;
                PlayerBuff.Remove <DeepSleep>();
            }

            PlayerCommands.JumpOff(useableFunctionality.CustomSpeedToPosition, action);
            //try { FinishUsing(cancel); }
            //catch { Debug.Log("TODO: Fix error on bed after animations btw."); }
        }
Пример #9
0
    IEnumerator <float> Sleeping()
    {
        HandlePlayerSprites(enable: false);

        //PlayerAnimationHelper.ResetPlayer();
        yield return(0f);

        Debug.Log("Went to sleep");

        Physics2D.IgnoreLayerCollision(GameLibOfMethods.player.layer, 10, true);
        GameLibOfMethods.isSleeping = true;
        GameLibOfMethods.cantMove   = true;
        GameLibOfMethods.animator.SetBool("Sleeping", true);
        GameLibOfMethods.player.GetComponent <Rigidbody2D>().velocity = Vector2.zero;

        yield return(MEC.Timing.WaitForSeconds(0.5f));

        GameLibOfMethods.AddChatMessege("Went to sleep.");

        float T = 0;

        GameClock.ChangeSpeedToSleepingSpeed();
        while (true)
        {
            GameLibOfMethods.concecutiveSleepTime += (Time.deltaTime * GameClock.TimeMultiplier) * GameClock.Speed;
            float Multi = (Time.deltaTime / GameClock.Speed) * GameClock.TimeMultiplier;

            Stats.Status(Type.Energy).Add(EnergyGainPerHour * Multi);
            Stats.Status(Type.Mood).Add(MoodGainPerHour * Multi);
            Stats.Status(Type.Health).Add(HealthGainPerHour * Multi);

            if (Input.GetKeyUp(KeyCode.E))
            {
                break;
            }

            if (Stats.Status(Type.Energy).CurrentAmount >= Stats.Status(Type.Energy).MaxAmount)
            {
                T += Time.deltaTime;

                if (T >= 2)
                {
                    GameLibOfMethods.CreateFloatingText("Can't sleep more", 2);
                    break;
                }
            }
            yield return(0f);
        }

        PlayExitSound();

        GameLibOfMethods.animator.SetBool("Sleeping", false);
        yield return(0f);

        while (true)
        {
            var state = GameLibOfMethods.animator.GetCurrentAnimatorStateInfo(0);
            if (!state.IsName("JumpOffToBed"))
            {
                Debug.Log("Something is wrong.. this finished before firing the method. Make sure you don't call this from FixedUpdate.");
                break;
            }

            if (state.normalizedTime >= 40 / 50f)
            {
                break;
            }
            yield return(0f);
        }

        HandlePlayerSprites(enable: true);

        PlayerCommands.JumpOff(JumpOffSpeed);

        GameClock.ResetSpeed();
    }
Пример #10
0
 public override void FinishUsing(bool cancel)
 {
     ResetObjectState(cancel);
     Weights.SetActive(true);
     PlayerCommands.JumpOff(0);
 }