protected override void OnCreate()
 {
     blockGroupSystem              = World.GetExistingSystem <BlockGroupSystem>();
     minDepthResult                = new NativeArray <float>(1, Allocator.Persistent);
     query                         = GetEntityQuery(typeof(Block), typeof(Depth));
     blockGroupSystem.OnWillBuild += async() => await OnBuild();
 }
        protected override async Task OnInit()
        {
            blockGroupSystem    = World.GetOrCreateSystem <BlockGroupSystem>();
            workerFactorySystem = World.GetExistingSystem <WorkerFactorySystem>();
            customWorker        = Object.Instantiate(workerFactorySystem.DefaultWorker);
            StorageUtil.DeserializeScriptable(customWorker);
            customWorker.displayName = "Manual";
            await workerFactorySystem.Register(customWorker);

            await SetActiveWorker(customWorker);

            while (blockGroupSystem.IsReady == false)
            {
                await Task.Yield();
            }
            isReady = true;
        }
Exemplo n.º 3
0
Arquivo: Level.cs Projeto: damrem/ld48
    public Level Init(LevelDef def, Block blockPrefab, Exit exitPrefab, Coin coinPrefab, Gem gemPrefab, int seed, Color[] colors)
    {
        Def = def;

        PRNG = new PRNG();

        BlockPrefab = blockPrefab;
        ExitPrefab  = exitPrefab;
        CoinPrefab  = coinPrefab;
        GemPrefab   = gemPrefab;
        Colors      = PRNG.Shuffle(colors, Def.ColorCount);

        Blocks = new Block[def.Width, def.Depth + 2];
        Blocks.Fill((x, y) => CreateBlock(x, y));

        Blocks.GetRow(0).ToList()
        .FindAll(block => block != null)
        .ForEach(block => {
            DestroyBlock(block, false);
        });

        CreateBottom();
        Exit = CreateExit();

        BlockGroupSystem = GetComponent <BlockGroupSystem>().Init(this);

        AddGemRandomlyInRows();

        Coins = new Coin[def.Width, def.Depth + 2];
        Coins.Fill(CreateCoin);
        Coins.ForEach(item => {
            if (!item)
            {
                return;
            }
            DestroyBlock(item.Cell, false);
        });

        return(this);
    }