private void HandleBlockSpawned(BlockView blockView, BlockData data) { var storeView = blockView.GetComponentInChildren <StoreView>(); if (storeView != null) { var storeController = new StoreController() { Position = storeView.transform.position }; stores[storeView] = storeController; storeController.OnStoreOpened += storeView.OpenTheDoor; storeController.OnStoreOpened += HandleStoreOpened; } }
private void HandleBlockSpawned(BlockView blockView, BlockData data) { var trashViews = blockView.GetComponentsInChildren <TrashView>(); foreach (var trashView in trashViews) { var trashController = new TrashController(modelController, trashConfig) { Position = trashView.transform.position }; trashes[trashView] = trashController; trashController.OnEmptyHit += trashView.HitEmpty; trashController.OnHit += trashView.Hit; trashController.OnHit += HandleTrashHit; trashView.OnHit += HandleTrashViewHit; } }
public BlockData SpawnLeftBlock(BlockView blockView) { var halfWidth = blockView.Width / 2f; var y = config.SpawnYRange.GetRandom(); var z = config.InheritSpawnZFromY ? y : config.SpawnZ; var data = new BlockData { HalfWidth = halfWidth, Center = new Vector3(GetLeftEnd() - halfWidth, y, z) }; leftBlocks.Add(data); if (OnBlockSpawned != null) { OnBlockSpawned(blockView, data); } return(data); }