private IEnumerator StartLineDrop(int lineId) { // Get lite top point //float lineTopPoint = linesArray[lineId].GetLineTopPoint(startY); // calculte start and finish float x = startX + offset * lineId; float y = PlaceToDropCoins.transform.position.y; float z = PlaceToDropCoins.transform.position.z; Vector3 start = new Vector3(x, y, z); Vector3 finish = new Vector3(x, yCoordinatForDestroyCoin, 0); while (!gameEnd) { //wait random time yield return(new WaitForSeconds(Random.RandomRange(1.0f, 3.0f))); if (gameEnd == true) { break; } // create coin currentCoin = Instantiate(coinPrefab) as Coin; CoinTypeConst coinType = currentCoin.GetRandomCoinType(); // set coin parametrs currentCoin.SetParametrsCoin(start, finish, coinType, Field, coinSpeed); //drop coin, set start and finish for droped coin currentCoin.DropCoin(); } }
public void SetParametrsCoin(Vector3 start, Vector3 finish, CoinTypeConst coinType, GameObject parentObject, float coinSpeed = 1.0f) { this.coinSpeed = coinSpeed; this.start = start; this.finish = finish; this.coinType = coinType; this.parentObject = parentObject; }
public CoinTypeConst GetRandomCoinType() { // get all coins types var allCoinTypes = System.Enum.GetValues(typeof(CoinTypeConst)); // get random coin type each iteration int randCoinTypeId = System.Convert.ToInt32(Random.RandomRange(0.0f, 2.0f)); CoinTypeConst coinType = (CoinTypeConst)allCoinTypes.GetValue(randCoinTypeId); return(coinType); }