private void SpawnSceneBlock(Vector3Int position, MapBlock levelBlock) { var block = GetSceneBlock(position); if (block != null) { block.UpdateBlockState(); if (block.Block == levelBlock) { return; } } RemoveSceneBlock(position); block = MapManager.Instance.InstantiateSceneBlock(levelBlock); if (block != null) { block.transform.position = position; block.transform.parent = BlocksParent.transform; block.UpdateBlockState(); block.SpawnProps(map.Get(new Vector3Int(position.x, position.y + 1, position.z)) == null ? true : false); } levelBlocks[position] = block; }
public MapBlock(MapBlock block) { position = block.position; direction = block.direction; type = block.type; team = block.team; }
public void ChangeTeam(Vector3Int position) { MapBlock block = blocks[position]; if (block == null) { return; } block.ChangeTeam(); }
public void SetCursorBlock(MapBlock block) { if (blockController != null) { Destroy(blockController.gameObject); } blockController = MapManager.Instance.InstantiateSceneBlock(block); if (blockController != null) { blockController.transform.position = transform.position; blockController.transform.parent = transform; SetLayerRecursive(blockController.transform, 2); // ignore raycast } }
public MapBlockController InstantiateSceneBlock(MapBlock mapBlock) { MapBlockController blockController = null; if (mapBlock == null) { return(null); } var prefab = FindBlockPrefabWithType(mapBlock.Type); if (prefab == null) { return(null); } blockController = Instantiate(prefab).GetComponent <MapBlockController>(); blockController.Block = mapBlock; blockController.UpdateBlockState(); return(blockController); }
public void AddBlock(Vector3Int position, MapBlock blockModel) { map.Set(position, new MapBlock(blockModel)); GameEvents.Map.OnAddBlock.SafeInvoke(position, blockModel); BuildMapScene(); }
public void Set(Vector3Int position, MapBlock levelBlock) { blocks[position] = levelBlock; }