public Ship SpawnShip(Vector2 pos, float rotation, bool isPlayer, string name = "Random pilot", int team = 0) { ShipPoolEntry s = GetShip(); if (s == null) { s = CreateNewShip(); } else { inactiveList.Remove(s); activeList.Add(s); } s.Spawn(pos, rotation, isPlayer, name, team); s.spr.sprite = isPlayer ? smallShipSprite_player[Random.Range(0, smallShipSprite_player.Length)] : smallShipSprite_enemy[Random.Range(0, smallShipSprite_enemy.Length)]; s.spr.flipY = !isPlayer; GlobalEvents.ShipSpawned(s.ship); return(s.ship); }
void HideShip(ShipPoolEntry ship) { ship.Despawn(); inactiveList.Add(ship); activeList.Remove(ship); }
ShipPoolEntry CreateNewShip() { var go = Instantiate(_shipPrefab); ShipPoolEntry p = new ShipPoolEntry(go); GlobalEvents.ShipPoolCreatedNewInstance(p.ship); activeList.Add(p); return(p); }
void PreloadShips(int count) { for (int i = 0; i < count; i++) { var go = Instantiate(_shipPrefab); ShipPoolEntry p = new ShipPoolEntry(go); GlobalEvents.ShipPoolCreatedNewInstance(p.ship); inactiveList.Add(p); p.Despawn(); } }