/// <summary>
        /// Visits the specified entity.
        /// See the <see cref="IEntityVisitor"/> for more details.
        /// </summary>
        public override void Visit(DxfInsert insert)
        {
            InsertInfo info           = insertStack.Peek();
            BlockData  blockData      = blockDataByName[insert.Block.Name];
            DxfLayer   effectiveLayer = info.GetEffectiveLayer(insert);
            DxfBlock   block          = blockData.GetBlock(effectiveLayer);

            if (block.Entities.Count == 0)
            {
                // no need to keep insert if block is empty
                info.currentCollection.RemoveAt(info.currentIndex);
            }
            else
            {
                // overwrite block with reduced one
                insert.Block = block;
                // take care of attributes
                for (int a = insert.Attributes.Count - 1; a >= 0; --a)
                {
                    DxfAttribute attrib      = insert.Attributes[a];
                    DxfLayer     attribLayer = attrib.Layer.IsZeroLayer
                                               ? effectiveLayer
                                               : attrib.Layer;
                    if (IsRemovedLayer(attribLayer))
                    {
                        insert.Attributes.RemoveAt(a);
                    }
                }
            }
        }
Esempio n. 2
0
        public override TerraCubeResult GetCube(Vector3I internalPosition)
        {
            TerraCubeResult res;
            TerraCube       cube;

            cube.Id               = BlockData.GetBlock(internalPosition);
            cube.EmissiveColor    = _lights[((internalPosition.Z * BlockData.ChunkSize.X) + internalPosition.X) * BlockData.ChunkSize.Y + internalPosition.Y];
            cube.IsSunLightSource = cube.EmissiveColor.A == 255;
            res.Cube              = cube;
            res.IsValid           = true;
            return(res);
        }
Esempio n. 3
0
        Models.Model GetViewModel(BlockData blockData)
        {
            var block = blockData.GetBlock();

            if (block == default)
            {
                throw new NotImplementedException();
            }
            var blockModel = block.model;

            if (!models.TryGetValue(blockModel, out var viewModel))
            {
                viewModel = LoadModel(blockModel);
                models.Add(blockModel, viewModel);
            }
            return(viewModel);
        }
Esempio n. 4
0
    public void CreateBlockSet(int index = -1)
    {   //TODO: add rotation and position change to the newly creaed blockset
        FastMotionFlag = false;
        scoreText.text = score.ToString();
        speed          = 1 + speedFlag;
        BottomRotationTriggerTransform.transform.position = new Vector3(0, 4.5f, 0);
        BlockSet = new List <GameObject>();
        List <Vector3> BlockSetArray;

        if (index == -1)
        {
            BlockSetArray = BlockData.GetBlock();
        }
        else
        {
            BlockSetArray = BlockData.GetBlock(index);
        }
        string    tag  = "";
        BlockType type = new BlockType();

        bool flag = false;

        if (specialCubeFlag)
        {
            specialCubeFlag = false;
            flag            = true;
            type            = SelectSpecialTag();
        }
        else
        {
            type = (BlockType)Random.Range(0, (int)BlockType.Count - 3);
        }

        switch (type)   //picking a random type of block
        {
        case BlockType.Blue:
            tag = "Blue";
            break;

        case BlockType.Green:
            tag = "Green";
            break;

        case BlockType.Yellow:
            tag = "Yellow";
            break;

        case BlockType.Red:
            tag = "Red";
            break;

        case BlockType.Violet:
            tag = "Violet";
            break;

        case BlockType.Magic01:
            tag = "Magic01";
            break;

        case BlockType.Magic02:
            tag = "Magic02";
            break;

        case BlockType.Magic03:
            tag = "Magic03";
            break;
        }
        for (int i = 0; i < BlockSetArray.Count; i++)
        {
            if (!flag)
            {
                BlockSet.Add(Instantiate(blockPrefab, BlockSetArray[i], Quaternion.identity, BlockBody.transform));
                BlockSet[i].GetComponent <Renderer>().material           = BlockMaterials[(int)type];
                BlockSet[i].GetComponent <TrailRenderer>().colorGradient = ColorGradioant[(int)type];
            }
            else
            {
                switch (tag)
                {
                case "Magic01":
                    BlockSet.Add(Instantiate(MagicCube01, BlockSetArray[i], Quaternion.identity, BlockBody.transform));
                    break;

                case "Magic02":
                    BlockSet.Add(Instantiate(MagicCube02, BlockSetArray[i], Quaternion.identity, BlockBody.transform));
                    break;

                case "Magic03":
                    BlockSet.Add(Instantiate(MagicCube03, BlockSetArray[i], Quaternion.identity, BlockBody.transform));
                    break;
                }
            }
            BlockSet[i].tag = tag;
            AllBlastFlag    = false;
        }  // initializing the block set through itrating with values
        canRotate = true;
    }      //creates a set of blocks when the older set has reached the body
Esempio n. 5
0
        public override void Execute()
        {
            var block = blockData.GetBlock();

            block.OnBlockChange(this);
        }