Пример #1
0
    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);
    }
Пример #2
0
    void HideShip(ShipPoolEntry ship)
    {
        ship.Despawn();

        inactiveList.Add(ship);
        activeList.Remove(ship);
    }
Пример #3
0
    ShipPoolEntry CreateNewShip()
    {
        var           go = Instantiate(_shipPrefab);
        ShipPoolEntry p  = new ShipPoolEntry(go);

        GlobalEvents.ShipPoolCreatedNewInstance(p.ship);

        activeList.Add(p);

        return(p);
    }
Пример #4
0
    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();
        }
    }