public virtual IEnumerator Live(Animal script, TimeController timeController, byte[] stagePreps, byte[] stageEvents) { foreach (byte preparation in stagePreps) { GetPrep(preparation)(script); } while ((stageDays - livedDays) > 0) { byte dayThirds = 0; while (dayThirds < 3) { float thirdDuration = timeController.TimeSpeedMinuteSecs / Random.Range(2.5f, 3.2f); if (!script.busy) { foreach (byte myEvent in stageEvents) { GetEvent(myEvent)(script, thirdDuration); } } dayThirds++; yield return(new WaitForSeconds(thirdDuration)); } livedDays++; } script.lifeStage = GetNextStage(script.lifeStage); LifeStage.InitStage(script, timeController); }
private void OnNewDay(object data) { if (lifeCyclesDone) { return; } if (currentStage == null || currentStage.ID == "") { DebugUtil.LogWarningArgs($"[DuplicantLifeExpectancy]: Life Stage for Duplicant {gameObject.GetProperName()} was null during OnNewDay callback. Should have already been set."); currentStage = new LifeStage(LifeStagePreset.FirstState); } float currCycle = GameClock.Instance.GetCycle(); if (!currentStage.Started) { if (currentStage.BeginsOn >= currCycle) { Effect e = currentStage.GetEffect(); EffectInstance instance = effects.Add(e, true); currentStage.Started = true; } } else { if (currCycle >= currentStage.EndsAfter) { string nextStage = currentStage.NextStage; if (nextStage != "") { currentStage = new LifeStage(currentStage.NextStage); if (currentStage.BeginsOn == currCycle) { effects.Add(currentStage.GetEffect(), true); currentStage.Started = true; } } else { if (currentStage.IsDying()) { DeathMonitor.Instance smi = gameObject.GetSMI <DeathMonitor.Instance>(); if (smi != null) { Death OldAge = new Death("OldAge", Db.Get().Deaths, "Old Age", "{Target} has died of old age", "dead_on_back", "dead_on_back"); smi.Kill(OldAge); } } else { //There is no next stage. The current stage will be re-applied Effect e = currentStage.GetEffect(); effects.Add(e, true); currentStage.BeginsOn = currCycle; } } } } }
public static void Age(this Dragon dragon, LifeStage desiredLifeStage) { do { dragon.GrowOlder(); if (dragon.Stage == desiredLifeStage) { break; } } while (true); }
public void LifeStageBasedOnAgeUnitTest(int age, LifeStage expectedLifeStage) { // Arrange var dragon = new Tamagotchi("Dragon"); // Act dragon.Age = age; // Assert dragon.LifeStage.ShouldBe(expectedLifeStage); }
public virtual void Init() { Population.Add(gameObject); wholePopulation.Add(gameObject); HomeOrigin = transform.position; nav = GetComponent <NavMeshAgent>(); rig = GetComponent <Rigidbody>(); ChildStage.Fatten()(this, 0); ani = GetComponent <Animator>(); StartCoroutine(Restore()); LifeStage.Init(this, TimeController.timeController); }
private void BeginFirstStage() { if (currentStage == null) { float currCycle = GameClock.Instance.GetCycle(); float currTime = GameClock.Instance.GetTime(); currentStage = new LifeStage(LifeStagePreset.FirstState); if (currentStage.BeginsOn <= currCycle) { Effect e = currentStage.GetEffect(currTime * -1); effects.Add(e, true); currentStage.Started = true; } } }
public void PettingNeedRatesBaseOnLifeStageTest(LifeStage lifeStage, int rate) { // Arrange var dragon = new Tamagotchi("Dragon"); dragon.LifeStage = lifeStage; var happinessBefore = dragon.Happiness; var need = new PettingNeeds(); // Act need.Satisfy(dragon); var happinessAfter = dragon.Happiness; // Assert Math.Abs(happinessAfter - happinessBefore).ShouldBe(rate); }
private void SetLifeStage() { if (Age < 4) { Stage = LifeStage.Baby; } else if (Age >= 4 && Age < 8) { Stage = LifeStage.Child; } else if (Age >= 8 && Age < 12) { Stage = LifeStage.Teen; } else { Stage = LifeStage.Adult; } }
public LifeStageDTO(LifeStage lifeStage) { StageId = lifeStage.StageId; Stage = lifeStage.Stage; StageDuration = lifeStage.StageDuration; }
public CharaLifeStage(LifeStage lifeStage) { LifeStage = lifeStage; }