Ejemplo n.º 1
0
    public void RandomSpawn()
    {
        var combinedCallback = new CombinedEventHandler <Character>(SpawnedCharactersHandler);

        foreach (var prefabindex in nextPrefabIndexs)
        {
            var empty     = characterProvider.GetAllEmptyPosition();
            var index     = UnityEngine.Random.Range(0, empty.Count);
            var pos       = empty[index];
            var character = characterProvider.Create(pos.x, pos.y, prefabindex);

            if (character != null)
            {
                combinedCallback.BindCharacter(character);
                character.OnSpawned += combinedCallback.Callback;
            }
        }
    }