void GenerateCoin() { fTimeCounter = 0; do { row = Random.Range(0, MapManager.MaxRow + 1); col = Random.Range(0, MapManager.MaxCol + 1); } while (!MapManager.Instance.IsPointClear(row, col)); NavLibrary.SetPointStatus(row, col, MapManager.Instance.nBigCoinValue); MapManager.Instance.OnBigCoinRefresh.Invoke(new MapPoint(row, col)); }
void RefreshMap() { if (nEaterNum != listEaters.Count) { if (listEaters.Count > nBigCoinNum) { for (int i = nBigCoinNum; i < listEaters.Count; ++i) { Destroy(listEaters[i].gameObject); listEaters.RemoveAt(i); } } else { for (int i = listBigCoins.Count; i < nBigCoinNum; ++i) { BigCoin coin = new BigCoin(); coin.Init(); listBigCoins.Add(coin); } } } if (nBigCoinNum != listBigCoins.Count) { if (listBigCoins.Count > nBigCoinNum) { for (int i = nBigCoinNum; i < listBigCoins.Count; ++i) { if (listBigCoins[i].Alive) { NavLibrary.SetPointStatus(listBigCoins[i].row, listBigCoins[i].col, 1); } listBigCoins.RemoveAt(i); } } else { GameObject objPrefab = Resources.Load <GameObject>("Prefabs/CoinEater"); for (int i = listBigCoins.Count; i < nBigCoinNum; ++i) { GameObject objEater = Instantiate(objPrefab, transform); int row, col; do { row = Random.Range(0, MaxRow + 1); col = Random.Range(0, MaxCol + 1); } while (!IsPointClear(row, col)); CoinEater eater = objPrefab.GetComponent <CoinEater>(); eater.Init(row, col); listEaters.Add(eater); } } } for (int i = 0; i < MaxRow; ++i) { for (int j = 0; j < MaxCol; ++j) { if (GetPointValue(i, j) != nBigCoinValue) { NavLibrary.SetPointStatus(i, j, GeneratePointStatus(i, j)); } } } OnMapRefresh.Invoke(); }