Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 public MapBlock(MapBlock block)
 {
     position  = block.position;
     direction = block.direction;
     type      = block.type;
     team      = block.team;
 }
Ejemplo n.º 3
0
        public void ChangeTeam(Vector3Int position)
        {
            MapBlock block = blocks[position];

            if (block == null)
            {
                return;
            }

            block.ChangeTeam();
        }
Ejemplo n.º 4
0
        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
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public void AddBlock(Vector3Int position, MapBlock blockModel)
 {
     map.Set(position, new MapBlock(blockModel));
     GameEvents.Map.OnAddBlock.SafeInvoke(position, blockModel);
     BuildMapScene();
 }
Ejemplo n.º 7
0
 public void Set(Vector3Int position, MapBlock levelBlock)
 {
     blocks[position] = levelBlock;
 }