public void fromSaveData(SaveData saveData) { PlanetSaveData data = (PlanetSaveData)saveData; this.areaCount = data.areaCount; this.radius = data.radius; this.transform.localScale = new Vector3(radius / ORIGIN_RADIUS, radius / ORIGIN_RADIUS, 1); this.lands = data.lands; this.transform.position = data.position.GetData(); // 加载资源 this.resources = gameObject.AddComponent <PlanetResource>(); this.resources.Init(data.resourcesID, this); GenerateOutLook(); if (data.colonyID != null) { data.colonyID.Init(); GameObject go = new GameObject("Colony"); this.colony = go.AddComponent <Colony>(); this.colony.id = data.colonyID; this.colony.BindPlanet(this); this.colony.transform.SetParent(transform); SaveManager.Instance.Load(this.colony, data.colonyID); } else { this.colony = null; } }
// 设置星球资源 void InitResource() { this.resources = gameObject.AddComponent <PlanetResource>(); this.resources.Init(this); }