private void DealWithItemBlock(DeadBlockGeneratorData deadBlockGeneratorData, float3 position, MovableBlockStates movableBlockStates, EntityCommandBuffer commandBuffer, Entity headedBlock, PlayerStates playerStates) { var deadBlock = EntityManager.Instantiate(deadBlockGeneratorData.PrefabEntity); EntityManager.SetComponentData(deadBlock, new Translation {Value = position}); EntityManager.SetComponentData(deadBlock, movableBlockStates); commandBuffer.DestroyEntity(headedBlock); var itemBlockData = GetComponentDataFromEntity<ItemBlockData>()[headedBlock]; var generatorData = GetEntityQuery(typeof(ItemGeneratorData)).GetSingleton<ItemGeneratorData>(); Entity prefabEntity = Entity.Null; switch (itemBlockData.BlockItemType) { case BlockItemType.StarMan: prefabEntity = generatorData.Starman; break; case BlockItemType.OneUpMushroom: prefabEntity = generatorData.OneUpMushroom; break; case BlockItemType.MegaMushroomOrFireFlower: default: prefabEntity = playerStates.Level == PlayerLevel.Default ? generatorData.MegaMushroom : generatorData.FireFlower; break; } var itemEntity = EntityManager.Instantiate(prefabEntity); EntityManager.SetComponentData(itemEntity, new Translation { Value = position + new float3(0, GameEntry.Instance.Config.Global.Item.SpawnOffsetY, 0) }); GameEntry.Instance.Event.SendEvent(this, GameEntry.Instance.RefPool.GetOrAdd<ItemAppearsEventArgs>().Acquire()); }
private void DealWithCoinBrick(DeadBlockGeneratorData deadBlockGeneratorData, float3 position, MovableBlockStates movableBlockStates, EntityCommandBuffer commandBuffer, Entity headedBlock, PlayerStates playerStates, ComponentDataFromEntity<CoinBrickConfigData> coinBrickConfigDataEntities, ComponentDataFromEntity<CoinBrickStates> coinBrickStatesEntities) { var coinBrickStates = coinBrickStatesEntities[headedBlock]; var coinBrickConfigData = coinBrickConfigDataEntities[headedBlock]; if (!coinBrickStates.TimerStarted) { coinBrickStates.TimerStarted = true; coinBrickStates.CoinLeft = coinBrickConfigData.TotalCoins; coinBrickStates.TimeElapsed = 0; } Assert.IsTrue(coinBrickStates.CoinLeft > 0); coinBrickStates.CoinLeft -= 1; GameEntry.Instance.PlayerData.AddCoin(position, CoinType.Block); EntityManager.SetComponentData(headedBlock, coinBrickStates); EntityManager.SetComponentData(headedBlock, movableBlockStates); if (coinBrickStates.CoinLeft <= 0) { var deadBlock = EntityManager.Instantiate(deadBlockGeneratorData.PrefabEntity); EntityManager.SetComponentData(deadBlock, new Translation {Value = position}); EntityManager.SetComponentData(deadBlock, movableBlockStates); commandBuffer.DestroyEntity(headedBlock); } }
private void DealWithCoinQuestionMark(DeadBlockGeneratorData deadBlockGeneratorData, float3 position, MovableBlockStates movableBlockStates, EntityCommandBuffer commandBuffer, Entity headedBlock) { GameEntry.Instance.PlayerData.AddCoin(position, CoinType.Block); var deadBlock = EntityManager.Instantiate(deadBlockGeneratorData.PrefabEntity); EntityManager.SetComponentData(deadBlock, new Translation {Value = position}); EntityManager.SetComponentData(deadBlock, movableBlockStates); commandBuffer.DestroyEntity(headedBlock); }