public void StopSleep()
 {
     if (is_sleep)
     {
         is_sleep     = false;
         sleep_target = null;
         TheGame.Get().SetGameSpeedMultiplier(1f);
     }
 }
        //---- Special actions

        public void Sleep(ActionSleep sleep_target)
        {
            if (!is_sleep && !is_riding && !IsSwimming())
            {
                this.sleep_target = sleep_target;
                is_sleep          = true;
                auto_move         = false;
                auto_move_attack  = null;
                TheGame.Get().SetGameSpeedMultiplier(sleep_target.sleep_speed_mult);
            }
        }
Example #3
0
        void Update()
        {
            if (TheGame.Get().IsPaused())
            {
                return;
            }

            if (character.IsDead())
            {
                return;
            }

            //Update attributes
            float game_speed = TheGame.Get().GetGameTimeSpeedPerSec();

            //Update Attributes
            foreach (AttributeData attr in attributes)
            {
                float update_value = attr.value_per_hour + GetBonusEffectTotal(BonusEffectData.GetAttributeBonusType(attr.type));
                update_value = update_value * game_speed * Time.deltaTime;
                CharacterData.AddAttributeValue(attr.type, update_value, attr.max_value);
            }

            //Penalty for depleted attributes
            move_speed_mult = 1f;
            attack_mult     = 1f;
            depleting       = false;

            foreach (AttributeData attr in attributes)
            {
                if (GetAttributeValue(attr.type) < 0.01f)
                {
                    move_speed_mult = move_speed_mult * attr.deplete_move_mult;
                    attack_mult     = attack_mult * attr.deplete_attack_mult;
                    float update_value = attr.deplete_hp_loss * game_speed * Time.deltaTime;
                    AddAttribute(AttributeType.Health, update_value);
                    if (attr.deplete_hp_loss < 0f)
                    {
                        depleting = true;
                    }
                }
            }

            //Dying
            float health = GetAttributeValue(AttributeType.Health);

            if (health < 0.01f)
            {
                character.Kill();
            }

            //Sleeps add attributes
            if (character.IsSleeping())
            {
                ActionSleep sleep_target = character.GetSleepTarget();
                AddAttribute(AttributeType.Health, sleep_target.sleep_hp_hour * game_speed * Time.deltaTime);
                AddAttribute(AttributeType.Hunger, sleep_target.sleep_hunger_hour * game_speed * Time.deltaTime);
                AddAttribute(AttributeType.Thirst, sleep_target.sleep_thirst_hour * game_speed * Time.deltaTime);
                AddAttribute(AttributeType.Happiness, sleep_target.sleep_hapiness_hour * game_speed * Time.deltaTime);
            }
        }