예제 #1
0
        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;
        }
예제 #2
0
 public void Replay()
 {
     if (state != TOMATO_PLANT_STATE.Pause)
     {
         throw new Exception("TomatoPlant replay fail, state is " + state);
     }
     state = TOMATO_PLANT_STATE.Growing;
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
 public void StartRest()
 {
     state = TOMATO_PLANT_STATE.Rest;
 }
예제 #7
0
 public void StartGrow()
 {
     state = TOMATO_PLANT_STATE.Growing;
     TomatoMgr.OnTimeLoseSecond += TimeLoseSecond;
 }