本文整理汇总了C#中Planet.createPlanet方法的典型用法代码示例。如果您正苦于以下问题:C# Planet.createPlanet方法的具体用法?C# Planet.createPlanet怎么用?C# Planet.createPlanet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Planet
的用法示例。
在下文中一共展示了Planet.createPlanet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createSystem
public bool createSystem()
{
bool system_created = false;
if(num_planets > 0 ){
//create the system!
base.sub_spheres = new SphereRenderer[num_planets];
/*create the sun!*/
int ptype = 101;
float pmass = 1000000f;
string pname = name + " - Sun";
float pradius = 12f;
float pdistance = 0f;
Vector3 pposition = new Vector3(position.x, Random.Range(-400, 400), position.z);
Debug.Log(pposition);
Planet planet = new Planet(ptype, pmass, pname, pradius, pdistance, pposition);
planet.createPlanet();
factory = (SphereRendererFactory)GameObject.Find("SphereRendererFactory").GetComponent("SphereRendererFactory");
base.sub_spheres[0] = factory.createSphereRenderer();
base.sub_spheres[0].initialize(0, 0, planet_threshold,1 , planet);
base.sub_spheres[0].setIsDisplayed(true);
/* end create sun */
pdistance += 15f;
/*create planets*/
for(int i = 1; i < (num_planets); i++){
float omega = Random.Range(0, 2*Mathf.PI);
/* sphere types
* 0 - Dead
* 1 - Fuel Source
* 2 - Habitable
* 3 - Sun
* 4 - Planetary System
* 5 - System Cluster
*/
ptype = Random.Range(0, 100);
pmass = Random.Range(1000f, 10000f);
pname = name + " - " + i;
pradius = Random.Range(10f, 20f);
pdistance = Random.Range(pdistance, pdistance + 100f);
pposition = new Vector3(position.x + pdistance*Mathf.Cos(omega) , Random.Range(-100, 100), position.z + pdistance*Mathf.Sin(omega));
planet = new Planet(ptype, pmass, pname, pradius, pdistance, pposition);
planet_threshold = pradius + 10f;
if(!planet.createPlanet()){
system_created = false;
break;
}
else{
factory = (SphereRendererFactory)GameObject.Find("SphereRendererFactory").GetComponent("SphereRendererFactory");
base.sub_spheres[i] = factory.createSphereRenderer();
base.sub_spheres[i].initialize(0, 0, planet_threshold,1 , planet);
base.sub_spheres[i].setIsDisplayed(true);
}
system_created = true;
}
}
return system_created;
}