public void Giveup(string giveupTip) { if (state != TOMATO_PLANT_STATE.Growing && state != TOMATO_PLANT_STATE.Pause && state < TOMATO_PLANT_STATE.Reaped) { throw new Exception("TomatoPlant giveup fail, state is " + state); } if (state < TOMATO_PLANT_STATE.Reaped) { state = TOMATO_PLANT_STATE.Giveup; OnGiveup?.Invoke(this); } else { state = TOMATO_PLANT_STATE.Finish; OnFinish?.Invoke(this); } TomatoMgr.OnTimeLoseSecond -= TimeLoseSecond; if (string.IsNullOrEmpty(giveupTip)) { throw new Exception("TomatoPlant giveup unexpect, giveupTip is empty"); } giveupRecord = giveupTip; }
public void Replay() { if (state != TOMATO_PLANT_STATE.Pause) { throw new Exception("TomatoPlant replay fail, state is " + state); } state = TOMATO_PLANT_STATE.Growing; }
public void Pause(string pauseTip) { if (state != TOMATO_PLANT_STATE.Growing) { throw new Exception("TomatoPlant pause fail, state is " + state); } state = TOMATO_PLANT_STATE.Pause; pasuseRecords.Add(pauseTip); }
private void RestTimeLoseSecond() { remainRestSeconds = Math.Max(0, remainRestSeconds - 1); OnRestRateChange?.Invoke(1 - remainRestSeconds / (double)TomatoPlantRestSeconds); if (remainRestSeconds <= 0) { TomatoMgr.OnTimeLoseSecond -= TimeLoseSecond; state = TOMATO_PLANT_STATE.Finish; OnFinish?.Invoke(this); } }
private void GrowingTimeLoseSecond() { remainLifeSeconds = Math.Max(0, remainLifeSeconds - 1); OnGrowingRateChange?.Invoke(GrowRate); if (remainLifeSeconds <= 0) { state = TOMATO_PLANT_STATE.Reaped; fruit = new TomatoFruit(this); OnReapFruit?.Invoke(fruit); } }
public void StartRest() { state = TOMATO_PLANT_STATE.Rest; }
public void StartGrow() { state = TOMATO_PLANT_STATE.Growing; TomatoMgr.OnTimeLoseSecond += TimeLoseSecond; }