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

            if (block == null)
            {
                return;
            }

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