本文整理汇总了C#中Planet.addSatellite方法的典型用法代码示例。如果您正苦于以下问题:C# Planet.addSatellite方法的具体用法?C# Planet.addSatellite怎么用?C# Planet.addSatellite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Planet
的用法示例。
在下文中一共展示了Planet.addSatellite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
Material earthMaterial = Resources.Load("Materials/Earth/Earth") as Material;
Material sunMaterial = Resources.Load("Materials/Sun") as Material;
Material moonMaterial = Resources.Load("Materials/Moon/Moon") as Material;
Star sun = new Star("Sun", new Vector3(0,0,0), 10, sunMaterial);
IList planets = new ArrayList();
for(int i = 0; i < 10; i++) {
// TODO Change x/z random to randomize within a radius of sun instead of square
int x = Random.Range(-200, 200);
int y = 0;
int z = Random.Range(-200, 200);
float r = Random.Range(1, 4);
float spinSpeed = Random.Range(-20, 21);
Planet p = new Planet("Planet" + i, new Vector3(x, y, z), r, earthMaterial, spinSpeed, sun);
planets.Add(p);
int nSatellites = Random.Range(0, 4);
for(int j = 0; j < nSatellites; j++) {
float d = Random.Range(2*r, 8*r);
Vector3 satellitePosition = new Vector3(x+d, y, z);
float satelliteRadius = (float)Random.Range(r, r*5) / 10;
float satelliteSpinSpeed = Random.Range(-20, 21);
p.addSatellite("Satellite"+j+p.name,satellitePosition, satelliteRadius, moonMaterial, satelliteSpinSpeed);
}
}
startUI();
}