void ConfirmAction() { if (!chosen) { return; } StoredSeeds grenierStorage = chosen.Storage; StoredSeeds pointerStorage = Pointer.Instance.GetComponent <StoredSeeds>(); if (!pointerStorage) { return; } Seed[] seeds = grenierStorage.RemoveAllSeed(); pointerStorage.AddSeeds(seeds); owner.SelectedGrenierId = chosen.Id; owner.ChosenGrenierId = chosen.Id; SoundBox.Instance.PlaySeedTake(); owner.State = Plateau.pState.turnPlay; }
IEnumerator Earn() { StoredSeeds lastGrenierStorage = owner.GetGrenier(owner.SelectedGrenierId).Storage; if (lastGrenierStorage.SeedNumber == 2 || lastGrenierStorage.SeedNumber == 3) { Seed[] seeds = lastGrenierStorage.RemoveAllSeed(); foreach (Seed seed in seeds) { if (seed.gameObject.activeSelf) { seed.enabled = false; seedsEarning.Add(seed); } else { EarnSeed(seed); } yield return(new WaitForSeconds(timeBetweenEachEarn)); } --owner.SelectedGrenierId; if (owner.SelectedGrenierId == -1) { owner.SelectedGrenierId = owner.NbGrenier - 1; } yield return(Earn()); } else { while (seedsEarning.Count != 0) { yield return(null); } if (owner.CheckGameOver()) { owner.State = Plateau.pState.gameOver; } else { owner.State = Plateau.pState.turnChose; } } }