public void Init(Species species, GeoGroupInfo ci, float _size, bool randomSize = false) { MyGeoGroupInfo = ci; Rigidbody2D.mass = MyGeoGroupInfo.Mass; if (randomSize) { Size = Random.Range(MyGeoGroupInfo.MinSize, MyGeoGroupInfo.MaxSize); } else { Size = _size; } Life = ci.Life * Size / ci.MaxSize; Damage = ci.Damage * Size / ci.MaxSize; GeoGroup?.PoolRecycle(); GeoGroup = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.GeoGroup].AllocateGameObject <GeoGroup>(transform); My_Species = species; M_SpeciesName = species.MyGeoGroupInfo.Name; foreach (GeoInfo gi in species.MyGeoGroupInfo.GeoInfos) { GeoElement ge = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.GeoElement].AllocateGameObject <GeoElement>(GeoGroup.transform); ge.Collider.enabled = false; GeoGroup.AllGeos.Add(ge); GeoGroup.GeoGroupInfo = species.MyGeoGroupInfo; ge.transform.localPosition = (gi.Position - ci.Center) / GameManager.Instance.ScaleFactor / GameManager.Instance.ScaleFactor; ge.transform.rotation = gi.Rotation; ge.Initialize(gi.GeoType, gi.Size, gi.Color, gi.SortingOrder); } MyCollider.radius = MyGeoGroupInfo.ColliderRadius; }
void OnDestroy() { GeoGroup.PoolRecycle(); GeoGroup = null; }