public EnemyShipController PrefabInstantiate(PlanetController planet, Vector2 orbit, Vector2 position, bool immobile) { EnemyShipController ship = ((GameObject)Object.Instantiate(gameObject)).GetComponent <EnemyShipController>(); FlyController fly = ship.GetComponent <FlyController>(); PointGravityController pgrav = ship.GetComponent <PointGravityController>(); HullController hull = ship.GetComponent <HullController>(); Animator anim = ship.GetComponent <Animator>(); ship.PrefabName = name; if (immobile) { ship.state = Modes.Appearing; ship.GetComponent <Rigidbody2D>().isKinematic = hull.InitialShieldPower > 0; ship.transform.position = orbit; fly.enabled = false; pgrav.enabled = false; GetComponent <Collider2D>().enabled = false; anim.SetTrigger("Appear"); } else { ship.state = Modes.Flying; fly.PrepareFly(orbit, planet); ship.transform.position = position; } ship.Planet = planet; return(ship); }
void Awake() { PointGravity = GetComponent <PointGravityController>(); Planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <PlanetController>(); }