public void SetConfig(SPlanetConfig cfg) { config = cfg; m_Config = cfg; }
public static Planet CreatePlanet(Vector3 pos, string pname, int idx, WorldSpace space, SPlanetConfig config) { GameObject p = GameObject.Instantiate(space.planetPrefab); Planet pl = p.GetComponent <Planet>(); p.transform.position = pos; p.transform.SetParent(space.transform); p.transform.localScale = config.scale; p.name = pname; //"Planet_" + idx; config.obj = p; config.resource = ERESOURCE.FUEL; switch (config.celestType) { case ECELESTIALTYPE.PLANET: float rand = UnityEngine.Random.Range(0f, 1f); if (rand > 0.6f) { config.resource = ERESOURCE.INVESTIGATION; } break; default: break; } pl.SetConfig(config); Material t = space.GetPlanetMaterial(config.celestType); p.GetComponent <MeshRenderer>().material = t; GameObject.DestroyImmediate(p.GetComponent <SphereCollider>()); return(pl); }