void SpawnShip()
    {
        Vector2    spawnPoint = Vector2.zero;
        Collider2D hit        = null; //assigned just to get the compiler to shut up

        for (int i = 0; i < 10; i++)
        {
            spawnPoint = spawningRange * Random.insideUnitCircle;
            hit        = Physics2D.OverlapCircle(spawnPoint, spawningClearance, shipLayerMask);
            if (hit == null)
            {
                break;
            }
        }

        if (hit != null)
        {
            Debug.Log("No Valid Spawning Places found");
        }

        Ship spawnedShip = (Instantiate(shipPrefab, spawnPoint, RandomLib.Random2DRotation()) as GameObject).GetComponent <Ship>();

        spawnedShip.Side = side;
        spawnedShip.Subscribe <ShipDestroyedMessage>(this);
        Debug.Log("Spawned New Ship!");
    }
Beispiel #2
0
    public void Notify(DoubleLeftMouseClickMessage m)
    {
        Ship spawnedShip = (Instantiate(enemyShip, m.worldPoint, RandomLib.Random2DRotation()) as GameObject).GetComponent <Ship>();

        spawnedShip.Side = 1;
    }