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

            if (block == null)
            {
                return;
            }

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