Ejemplo n.º 1
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        float Multi = GameTime.Time.deltaTime * GameClock.TimeMultiplier / GameClock.Speed;

        Stats.Status(Energy).Add(-EnergyDrain * Multi);
        Stats.MoveSpeed = RunningSpeed;
    }
    public static IEnumerator WakeUpHospital()
    {
        GameTime.Clock.ResetSpeed();
        yield return(new WaitForSecondsRealtime(2));

        player.GetComponent <Animator>().enabled = true;
        Stats.Status(Type.Hunger).Set(float.MaxValue);
        Stats.Status(Type.Energy).Set(float.MaxValue);
        Stats.Status(Type.Health).Set(float.MaxValue);
        Stats.Status(Type.Mood).Set(float.MaxValue);
        Stats.Status(Type.Bladder).Set(100);
        Stats.Status(Type.Hunger).Set(100);
        Stats.Status(Type.Hygiene).Set(100);

        Vector3 tempRotation = new Vector3(0, 0, 0);

        player.transform.rotation = Quaternion.Euler(tempRotation);

        Stats.GetMoney(HospitalFee);

        passedOut = false;
        player.transform.position = new Vector2(HospitalRespawnPoint.position.x, HospitalRespawnPoint.position.y);
        blackScreen.CrossFadeAlpha(0, 2, false);
        cantMove = false;
        CameraFollow.Instance.ResetCamera();

        player.GetComponent <Animator>().SetBool("PassOut", false);

        yield break;
    }
Ejemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (Stats.Status(Type.Health).CurrentAmount / Stats.Status(Type.Health).MaxAmount > MinHealthPercentageForVeryPoorHealth)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (Stats.Status(Type.Health).CurrentAmount / Stats.Status(Type.Health).MaxAmount > MinHealthPercentageForPoorHealth || VeryPoorHealthDebuff.veryPoorHealthDebuffInstance)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 5
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);
        }
    }
Ejemplo n.º 6
0
 public void Interact()
 {
     if (Stats.Status(Energy).CurrentAmount <= 5 || Stats.Status(Health).CurrentAmount <= 5)
     {
         return;
     }
     PlayerCommands.JumpTo(this);
 }
Ejemplo n.º 7
0
 private void ApplyStatGains()
 {
     Stats.Status(Type.Hunger).Add(Hunger);
     Stats.Status(Type.Energy).Add(Energy);
     Stats.Status(Type.Health).Add(Health);
     Stats.Status(Type.Mood).Add(Mood);
     Stats.Status(Type.Thirst).Add(Thirst);
 }
Ejemplo n.º 8
0
 private void ApplyBonusGains()
 {
     Stats.Status(Type.Hunger).Add(Stats.Status(Type.Hunger).MaxAmount *HungerPercentBonus);
     Stats.Status(Type.Energy).Add(Stats.Status(Type.Energy).MaxAmount *EnergyPercentBonus);
     Stats.Status(Type.Health).Add(Stats.Status(Type.Health).MaxAmount *HealthPercentBonus);
     Stats.Status(Type.Mood).Add(Stats.Status(Type.Mood).MaxAmount *MoodPercentBonus);
     Stats.Status(Type.Thirst).Add(Stats.Status(Type.Thirst).MaxAmount *ThirstPercentBonus);
 }
Ejemplo n.º 9
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Stats.Status(Type.Bladder).Set(float.MaxValue);
        Stats.Status(Type.Hygiene).Set(0);

        GameLibOfMethods.cantMove       = true;
        GameLibOfMethods.canInteract    = false;
        GameLibOfMethods.doingSomething = true;
    }
Ejemplo n.º 10
0
    private void SimulateToilet()
    {
        float t = GameTime.Clock.InGameHoursSinceLastFrame;

        Stats.Status(Bladder).Add(t * BladderReduce);
        if (Stats.Status(Bladder).CurrentAmount == Stats.Status(Bladder).MaxAmount)
        {
            UsingToilet = false;
        }
    }
Ejemplo n.º 11
0
 void CheckPassOutReason(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (Stats.Status(Health).CurrentAmount <= 0)
     {
         WakeUpHospital().Start();
     }
     else if (Stats.Status(Energy).CurrentAmount <= 0)
     {
         animator.SetBool("Sleeping", true);
     }
 }
Ejemplo n.º 12
0
 void Update()
 {
     Instance = gameObject;
     if (Stats.Status(Type.Health).CurrentAmount / Stats.Status(Type.Health).MaxAmount < MinHealthPercentageForPoorHealth && !PoorHealthDebuff.poorHealthDebuffInstance && !VeryPoorHealthDebuff.veryPoorHealthDebuffInstance)
     {
         Instantiate(poorHealthDebuff, Instance.transform);
     }
     if (Stats.Status(Type.Health).CurrentAmount / Stats.Status(Type.Health).MaxAmount < MinHealthPercentageForVeryPoorHealth && !VeryPoorHealthDebuff.veryPoorHealthDebuffInstance)
     {
         Instantiate(veryPoorHealthDebuff, Instance.transform);
     }
 }
Ejemplo n.º 13
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        float Multi = GameTime.Time.deltaTime * GameClock.TimeMultiplier / GameClock.Speed;

        Stats.Status(Energy).Add(EnergyGainPerSecond * Multi);

        bool ShouldExitState = Stats.Status(Energy).CurrentAmount >= EnergyRequiredToWakeUp || (Cancelable && Input.GetKeyDown(KeyCode.E));

        if (ShouldExitState)
        {
            animator.SetBool("Sleeping", false);
        }
    }
Ejemplo n.º 14
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();
        }
    }
Ejemplo n.º 15
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (Stats.Status(Bladder).CurrentAmount < (Stats.Status(Bladder).MaxAmount * .2) || UsingToilet)
        {
            UsingToilet = true;
            SimulateToilet();
        }
        if (Stats.Status(Thirst).CurrentAmount < (Stats.Status(Thirst).MaxAmount * .2) && !UsingToilet && !Drank)
        {
            SimulateDrinking();
        }

        if (Stats.Status(Hunger).CurrentAmount < (Stats.Status(Hunger).MaxAmount * .2) && !UsingToilet && !Ate)
        {
            SimulateEating();
        }
    }
Ejemplo n.º 16
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();
        }
    }
Ejemplo n.º 17
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);
    }
Ejemplo n.º 18
0
        public IEnumerator <float> GradualUse()
        {
            float t = 0;

            float GetProgress() => (t += GameTime.Time.deltaTime) / UsageTime;

            void ApplyGradualBonusGains()
            {
                Stats.Status(Type.Hunger).Add((Stats.Status(Type.Hunger).MaxAmount *HungerPercentBonus) / UsageTime * Time.deltaTime);
                Stats.Status(Type.Energy).Add((Stats.Status(Type.Energy).MaxAmount *EnergyPercentBonus) / UsageTime * Time.deltaTime);
                Stats.Status(Type.Health).Add((Stats.Status(Type.Health).MaxAmount *HealthPercentBonus) / UsageTime * Time.deltaTime);
                Stats.Status(Type.Mood).Add((Stats.Status(Type.Mood).MaxAmount *MoodPercentBonus) / UsageTime * Time.deltaTime);
                Stats.Status(Type.Thirst).Add((Stats.Status(Type.Thirst).MaxAmount *ThirstPercentBonus) / UsageTime * Time.deltaTime);
            }

            void ApplyGradualStatGains()
            {
                Stats.Status(Type.Hunger).Add((Hunger / UsageTime) * Time.deltaTime);
                Stats.Status(Type.Energy).Add((Energy / UsageTime) * Time.deltaTime);
                Stats.Status(Type.Health).Add((Health / UsageTime) * Time.deltaTime);
                Stats.Status(Type.Mood).Add((Mood / UsageTime) * Time.deltaTime);
                Stats.Status(Type.Thirst).Add((Thirst / UsageTime) * Time.deltaTime);
                Stats.Status(Type.Bladder).Add((Bladder / UsageTime) * Time.deltaTime);
            }

            while (GetProgress() < 1 && !cancel)
            {
                ApplyGradualBonusGains();
                ApplyGradualStatGains();

                yield return(0f);
            }

            PlayerBuff.GetRandomBuff();

            yield return(0f);
        }
Ejemplo n.º 19
0
 protected bool CanAct()
 {
     return(!onGoingAction &&
            Stats.Status(Type.Energy).CurrentAmount > 5 &&
            Stats.Status(Type.Health).CurrentAmount > 5);
 }
Ejemplo n.º 20
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();
    }