public int getWeatherId(){ //get season string yearSeason = PlayerPrefs.GetString ("yearSeason"); char[] delimiterChars = {','}; string[] yearSeasonList = yearSeason.Split (delimiterChars); int nowSeason = int.Parse (yearSeasonList [1]); int weatherId = 0; //1:normal, 2:rain, 3:snow if (nowSeason == 1 || nowSeason == 3) { //Spring & Fall float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= 70) { weatherId = 1; } else if (70 < percent && percent <= 90) { weatherId = 2; } else if (90 < percent && percent <= 100) { weatherId = 3; } } else if (nowSeason == 2) { //Summer float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= 60) { weatherId = 1; } else if (60 < percent && percent <= 100) { weatherId = 2; } } else if (nowSeason == 4) { //Winter //Check snow area or not int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); KuniInfo kuni = new KuniInfo (); bool isSnowFlg = kuni.getKuniIsSnowFlg(activeKuniId); if (isSnowFlg) { weatherId = 3; } else { float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= 50) { weatherId = 1; } else if (50 < percent && percent <= 70) { weatherId = 2; } else if (70 < percent && percent <= 100) { weatherId = 3; } } } //Set Object by wether Id if (weatherId == 2) { //rain string path = "Prefabs/PreKassen/particle/PreRain"; GameObject particle = Instantiate (Resources.Load (path)) as GameObject; }else if(weatherId == 3){ //snow string path = "Prefabs/PreKassen/particle/PreSnow"; GameObject particle = Instantiate (Resources.Load (path)) as GameObject; } return weatherId; }