Esempio n. 1
0
    public void InitPreview(BlockData aBlockData)
    {
        this.size          = aBlockData.size;
        this.pos           = Vector2Int.zero;
        this.ghostPos      = Vector2Int.zero;
        this.type          = aBlockData.type;
        this.color         = aBlockData.color;
        this.isUnderEntity = false;

        this.name = "Block size: " + this.size + " not yet added";

        Vector3   thiccness = new Vector3(0, 0, 2f);
        Transform oldParent = this.transform.parent;

        this.transform.parent     = null;
        this.transform.localScale = GameUtil.V2IToV3(this.size) + thiccness;

        switch (this.type)
        {
        case BlockTypeEnum.FREE:
            SetState(BlockStateEnum.ACTIVE);
            break;

        case BlockTypeEnum.FIXED:
            this.color = Color.gray;
            SetState(BlockStateEnum.FIXED);
            break;
        }
        myRenderer.material.color = this.color;
        CreateStuds();
        this.transform.parent        = oldParent;
        this.transform.localPosition = Vector3.zero;
    }
Esempio n. 2
0
 public HitViewModel(BlockTypeEnum blockType,
                     int damage,
                     int lateDamage,
                     int stun,
                     int lateStun,
                     int meterGain,
                     CancelAbilityEnum[] cancelAbility,
                     int startup,
                     int active,
                     int recovery,
                     int onBlockAdvantage,
                     int onHitAdvantage,
                     string notes)
 {
     _blockType     = blockType;
     _damage        = damage;
     _lateDamage    = lateDamage;
     _stun          = stun;
     _lateStun      = lateStun;
     _meterGain     = meterGain;
     _cancelAbility = new List <CancelAbilityEnum>();
     _cancelAbility.AddRange(cancelAbility);
     _startup          = startup;
     _active           = active;
     _recovery         = recovery;
     _onBlockAdvantage = onBlockAdvantage;
     _onHitAdvantage   = onHitAdvantage;
     _notes            = notes;
 }
Esempio n. 3
0
    /// <summary>
    /// 获取方块网格数据
    /// </summary>
    public MeshDataCustom GetBlockMeshData()
    {
        BlockTypeEnum blockType = GetBlockType();
        TextAsset     textAsset = LoadAddressablesUtil.LoadAssetSync <TextAsset>($"Assets/Prefabs/BlockMeshData/Block{blockType.GetEnumName()}.txt");

        return(JsonUtil.FromJson <MeshDataCustom>(textAsset.text));
    }
Esempio n. 4
0
 public void Init(Vector2Int aSize, Vector2Int aPos, Color aColor, BlockTypeEnum aType)
 {
     this.size  = aSize;
     this.pos   = aPos;
     this.color = aColor;
     this.type  = aType;
 }
Esempio n. 5
0
 void ReadComputerDataAndUpdateScreen()
 {
     curComputer.AddInputData(0);
     for (int intI = 0; intI < requiredOutputPerCycle; intI++)
     {
         curComputer.ResumeProgram(); // 1
     }
     if (curComputer.HasOutputData())
     {
         int xLoc = (int)curComputer.ReadOutputData();
         int yLoc = (int)curComputer.ReadOutputData();
         if (xLoc < 0)
         {
             // score, not the other thing
             curScore = curComputer.ReadOutputData();
             Console.WriteLine(curScore);
             startDrawing = true;
             curComputer.AddInputData(0);
         }
         else
         {
             BlockTypeEnum bt = (BlockTypeEnum)curComputer.ReadOutputData();
             screen             = Helpers.ExpandListOfLists(screen, xLoc, yLoc);
             screen[yLoc][xLoc] = bt;
             if (startDrawing)
             {
                 //DrawScreen();
             }
         }
     }
 }
Esempio n. 6
0
        /**
         * Tile is passable, if its block type allows walking(like floor, ramp, etc.), plants are passable(not tree trunks), buildings are impassable.
         * TODO add water depth checking, etc.
         */
        public Passage calculateTilePassage(Vector3Int position)
        {
            Passage tilePassage = BlockTypeEnum.get(blockTypeMap.get(position)).PASSAGE;

            // TODO
            if (tilePassage == PASSABLE)   // tile still can be blocked by plants or buildings
            {
                bool plantPassable = true;
                //  GameModel.map(plantContainer => plantContainer.isPlantBlockPassable(position)).orElse(true);
                if (!plantPassable)
                {
                    return(IMPASSABLE);
                }

                bool buildingPassable = true;
                //        model.optional(BuildingContainer.class)
                //        .map(container -> container.buildingBlocks.get(position))
                //        .map(block -> block.passage == PASSABLE).orElse(true);
                if (!buildingPassable)
                {
                    return(IMPASSABLE);
                }

                bool waterPassable = true;
                //model.optional(LiquidContainer.class)
                //.map(container -> container.getTile(position))
                //.map(tile -> tile.amount <= 4).orElse(true);
                if (!waterPassable)
                {
                    return(IMPASSABLE);
                }
            }
            return(tilePassage);
        }
    public override void SetData(BlockTypeEnum blockType)
    {
        base.SetData(blockType);
        BlockShapeCustom blockShapeCustom = blockShape as BlockShapeCustom;

        BlockBaseCrop.InitCropVert(blockShapeCustom.vertsAdd);
    }
 public HitViewModel(BlockTypeEnum blockType,
     int damage,
     int lateDamage,
     int stun,
     int lateStun,
     int meterGain,
     CancelAbilityEnum[] cancelAbility,
     int startup,
     int active,
     int recovery,
     int onBlockAdvantage,
     int onHitAdvantage,
     string notes)
 {
     BlockType = blockType;
     Damage = damage;
     LateDamage = lateDamage;
     Stun = stun;
     LateStun = lateStun;
     MeterGain = meterGain;
     CancelAbility = new List<CancelAbilityEnum>();
     CancelAbility.AddRange(cancelAbility);
     Startup = startup;
     Active = active;
     Recovery = recovery;
     OnBlockAdvantage = onBlockAdvantage;
     OnHitAdvantage = onHitAdvantage;
     Notes = notes;
 }
Esempio n. 9
0
        /**
         * Checks that unit, standing in position will have access (to dig, open a chest) to target tile.
         * Same Z-level tiles are always accessible.
         * Tiles are accessible vertically with stairs or ramps.
         */
        public bool tileIsAccessibleFromNeighbour(int targetX, int targetY, int targetZ, int x, int y, int z, BlockType targetType)
        {
            if (!localMap.inMap(targetX, targetY, targetZ) || !localMap.inMap(x, y, z) || passage.get(x, y, z) == IMPASSABLE.VALUE)
            {
                return(false);
            }
            if (targetZ == z)
            {
                return(true);
            }
            BlockType fromType = BlockTypeEnum.get(blockTypeMap.get(x, y, z));
            BlockType lower    = targetZ < z ? targetType : fromType;

            if ((targetX == x) != (targetY == y))
            {
                return(lower == RAMP);                                  // ramp near and lower
            }
            if (targetX != x)
            {
                return(false);
            }
            BlockType upper = targetZ > z ? targetType : fromType;

            return(lower == STAIRS && (upper == STAIRS || upper == DOWNSTAIRS));
        }
Esempio n. 10
0
 public HitViewModel(BlockTypeEnum blockType,
     int damage,
     int lateDamage,
     int stun,
     int lateStun,
     int meterGain,
     CancelAbilityEnum[] cancelAbility,
     int startup,
     int active,
     int recovery,
     int onBlockAdvantage,
     int onHitAdvantage,
     string notes)
 {
     _blockType = blockType;
     _damage = damage;
     _lateDamage = lateDamage;
     _stun = stun;
     _lateStun = lateStun;
     _meterGain = meterGain;
     _cancelAbility = new List<CancelAbilityEnum>();
     _cancelAbility.AddRange(cancelAbility);
     _startup = startup;
     _active = active;
     _recovery = recovery;
     _onBlockAdvantage = onBlockAdvantage;
     _onHitAdvantage = onHitAdvantage;
     _notes = notes;
 }
Esempio n. 11
0
    protected override void UseForPlayer(Player player, ItemsBean itemData, ItemUseTypeEnum useType)
    {
        //检测玩家前方是否有方块
        if (player.playerRay.RayToChunkBlock(out RaycastHit hit, out Vector3Int targetBlockPosition))
        {
            ChunkComponent chunkForHit = hit.collider.GetComponentInParent <ChunkComponent>();
            if (chunkForHit != null)
            {
                //获取位置和方向
                player.playerRay.GetHitPositionAndDirection(hit, out Vector3Int targetPosition, out Vector3Int closePosition, out BlockDirectionEnum direction);
                if (useType == ItemUseTypeEnum.Left)
                {
                    TargetBreak(itemData, targetPosition);
                }
                else
                {
                    Vector3Int localPosition = targetPosition - chunkForHit.chunk.chunkData.positionForWorld;
                    //获取原位置方块
                    Block tagetBlock = chunkForHit.chunk.chunkData.GetBlockForLocal(localPosition);

                    //如果不能锄地
                    if (tagetBlock.blockInfo.plough_state == 0)
                    {
                        return;
                    }

                    //获取上方方块
                    Block upBlock = chunkForHit.chunk.chunkData.GetBlockForLocal(localPosition + Vector3Int.up);

                    //如果上方有方块 则无法使用锄头
                    if (upBlock != null && upBlock.blockType != BlockTypeEnum.None)
                    {
                        return;
                    }
                    //扣除道具耐久
                    if (this is ItemBaseTool itemTool)
                    {
                        ItemsDetailsToolBean itemsDetailsTool = itemData.GetMetaData <ItemsDetailsToolBean>();
                        //如果没有耐久 不能锄地
                        if (itemsDetailsTool.life <= 0)
                        {
                            return;
                        }
                        itemsDetailsTool.AddLife(-1);
                        //保存数据
                        itemData.SetMetaData(itemsDetailsTool);
                        //回调
                        EventHandler.Instance.TriggerEvent(EventsInfo.ItemsBean_MetaChange, itemData);
                    }

                    BlockTypeEnum ploughBlockType = (BlockTypeEnum)tagetBlock.blockInfo.remark_int;
                    //替换为耕地方块
                    chunkForHit.chunk.SetBlockForLocal(localPosition, ploughBlockType, direction);

                    //播放粒子特效
                    BlockCptBreak.PlayBlockCptBreakEffect(ploughBlockType, targetPosition + new Vector3(0.5f, 0.5f, 0.5f));
                }
            }
        }
    }
Esempio n. 12
0
 /// <summary>
 /// 处理-基础地形方块
 /// </summary>
 /// <param name="chunk"></param>
 public void HandleForBaseBlock()
 {
     //获取地图数据
     BiomeMapData[,] mapData = BiomeHandler.Instance.GetBiomeMapData(this);
     //遍历map,生成其中每个Block的信息
     //生成基础地形数据
     for (int x = 0; x < chunkData.chunkWidth; x++)
     {
         for (int z = 0; z < chunkData.chunkWidth; z++)
         {
             BiomeMapData biomeMapData = mapData[x, z];
             for (int y = 0; y < chunkData.chunkHeight; y++)
             {
                 Vector3Int position = new Vector3Int(x, y, z);
                 //获取方块类型
                 BlockTypeEnum blockType = BiomeHandler.Instance.CreateBiomeBlockType(this, biomeMapData, position);
                 //如果是空 则跳过
                 if (blockType == BlockTypeEnum.None)
                 {
                     continue;
                 }
                 Block block = BlockHandler.Instance.manager.GetRegisterBlock(blockType);
                 //添加方块
                 chunkData.SetBlockForLocal(x, y, z, block, BlockDirectionEnum.UpForward);
             }
         }
     }
     //生成洞穴 不放在每一个方块里去检测 提升效率
     //BiomeCreateTool.BiomeForCaveData caveData = new BiomeCreateTool.BiomeForCaveData();
     //caveData.minDepth = 100;
     //caveData.maxDepth = 200;
     //caveData.minSize = 3;
     //caveData.maxSize = 5;
     //BiomeCreateTool.AddCave(this, mapData, caveData);
 }
Esempio n. 13
0
    public void Init(BlockData aBlockData)
    {
        this.size          = aBlockData.size;
        this.pos           = aBlockData.pos;
        this.ghostPos      = aBlockData.pos;
        this.type          = aBlockData.type;
        this.color         = aBlockData.color;
        this.isUnderEntity = false;
        this.isHighlighted = false;

        this.name = "Block size: " + this.size + " startingpos: " + this.pos;

        Vector3 thiccness = new Vector3(0, 0, 2f);

        this.transform.localScale = GameUtil.V2IToV3(this.size) + thiccness;

        switch (this.type)
        {
        case BlockTypeEnum.FREE:
            SetState(BlockStateEnum.ACTIVE);
            break;

        case BlockTypeEnum.FIXED:
            this.color = Color.gray;
            SetState(BlockStateEnum.FIXED);
            break;
        }
        myRenderer.material.color = this.color;
        CreateStuds();
    }
Esempio n. 14
0
    /// <summary>
    /// 设置数据
    /// </summary>
    /// <param name="blockType"></param>
    /// <param name="localposition"></param>
    /// <param name="worldPosition"></param>
    public void SetData(Vector3Int localPosition, BlockTypeEnum blockType = BlockTypeEnum.None, BlockDirectionEnum direction = BlockDirectionEnum.UpForward, string meta = null)
    {
        this.localPosition = localPosition;

        this.blockId   = (ushort)blockType;
        this.direction = (byte)direction;
        this.meta      = meta;
    }
Esempio n. 15
0
    BlockData MakeBlock(int aWidth, int aHeight, int aX, int aY, BlockTypeEnum aType)
    {
        BlockData newBlockData = ScriptableObject.CreateInstance("BlockData") as BlockData;
        Color     newColor     = Color.magenta;

        newBlockData.Init(new Vector2Int(aWidth, aHeight), new Vector2Int(aX, aY), newColor, aType);
        return(newBlockData);
    }
Esempio n. 16
0
    public override string ItemUseMetaData(Vector3Int worldPosition, BlockTypeEnum blockType, BlockDirectionEnum direction, string curMeta)
    {
        BlockMetaDoor blockDoor = new BlockMetaDoor();

        blockDoor.level            = 0;
        blockDoor.linkBasePosition = new Vector3IntBean(worldPosition);
        return(ToMetaData(blockDoor));
    }
Esempio n. 17
0
    public static void AddBlock(int aWidth, int aHeight, int aX, int aY, BlockTypeEnum aType, LevelData aLevelData)
    {
        BlockData testBlockData = ScriptableObject.CreateInstance("BlockData") as BlockData;
        Color     newColor      = RandomColor();

        testBlockData.Init(new Vector2Int(aWidth, aHeight), new Vector2Int(aX, aY), newColor, aType);
        aLevelData.blockDataList.Add(testBlockData);
    }
Esempio n. 18
0
 private void SetType(int x, int y, BlockTypeEnum type, Color color)
 {
     try
     {
         cells[x, y].BlockType = type;
         cells[x, y].Obj.GetComponent <Renderer>().material.color = color;
     }
     catch (Exception ex)
     {
         throw new Exception("x:" + x + "====y:" + y);
     }
 }
Esempio n. 19
0
    protected override void UseForPlayer(Player player, ItemsBean itemData, ItemUseTypeEnum useType)
    {
        //检测玩家前方是否有方块
        if (player.playerRay.RayToChunkBlock(out RaycastHit hit, out Vector3Int targetBlockPosition))
        {
            ChunkComponent chunkForHit = hit.collider.GetComponentInParent <ChunkComponent>();
            if (chunkForHit != null)
            {
                //获取位置和方向
                player.playerRay.GetHitPositionAndDirection(hit, out Vector3Int targetPosition, out Vector3Int closePosition, out BlockDirectionEnum direction);

                Vector3Int localPosition = targetPosition - chunkForHit.chunk.chunkData.positionForWorld;
                //获取原位置方块
                Block tagetBlock = chunkForHit.chunk.chunkData.GetBlockForLocal(localPosition);

                //如果不能种地
                if (tagetBlock.blockInfo.plant_state == 0)
                {
                    return;
                }

                //种植位置
                Vector3Int upLocalPosition = localPosition + Vector3Int.up;
                //获取上方方块
                Block upBlock = chunkForHit.chunk.chunkData.GetBlockForLocal(upLocalPosition);

                //如果上方有方块 则无法种植
                if (upBlock != null && upBlock.blockType != BlockTypeEnum.None)
                {
                    return;
                }

                //种植的方块
                ItemsInfoBean itemsInfo      = GetItemsInfo(itemData.itemId);
                BlockTypeEnum plantBlockType = (BlockTypeEnum)itemsInfo.type_id;
                //初始化meta数据
                BlockMetaCrop blockCropData = new BlockMetaCrop();
                blockCropData.isStartGrow = false;
                blockCropData.growPro     = 0;
                string metaData = BlockBaseCrop.ToMetaData(blockCropData);
                //替换为种植
                chunkForHit.chunk.SetBlockForLocal(upLocalPosition, plantBlockType, BlockDirectionEnum.UpForward, metaData);

                //扣除道具
                UserDataBean userData = GameDataHandler.Instance.manager.GetUserData();
                userData.AddItems(itemData, -1);
                //刷新UI
                UIHandler.Instance.RefreshUI();
            }
        }
    }
Esempio n. 20
0
    public override void SetData(BlockTypeEnum blockType)
    {
        base.SetData(blockType);
        BlockShapeCustomDirection blockShapeCustomDirection = blockShape as BlockShapeCustomDirection;

        for (int i = 0; i < blockShapeCustomDirection.colorsAddDirection.Length; i++)
        {
            blockShapeCustomDirection.colorsAddDirection[i].a = 2;
        }
        for (int i = 0; i < blockShapeCustomDirection.colorsAdd.Length; i++)
        {
            blockShapeCustomDirection.colorsAdd[i].a = 2;
        }
    }
Esempio n. 21
0
        // when current tile is SPACE, draw special topping tile if lower tile is not SPACE.
        private void setToppingForSpace(int x, int y, int z)
        {
            if (z <= 0)
            {
                return;
            }
            string    material  = selectMaterial(x, y, z - 1);
            BlockType blockType = BlockTypeEnum.get(map.blockType.get(x, y, z - 1));

            if (blockType != SPACE && blockType != FLOOR)
            {
                string type = (blockType == RAMP ? selectRamp(x, y, z - 1) : blockType.PREFIX) + "F";
                layers[z].SetTile(floorPosition, tileSetHolder.tilesets[material][type]); // topping corresponds lower tile
            }
        }
Esempio n. 22
0
        public static BlockTypeEnum TagBlockTargetTypesCheck(string tag)
        {
            BlockTypeEnum result   = BlockTypeEnum.None;
            var           tagSplit = ProcessTag(tag);

            if (tagSplit.Length == 2)
            {
                if (BlockTypeEnum.TryParse(tagSplit[1], out result) == false)
                {
                    return(BlockTypeEnum.None);
                }
            }

            return(result);
        }
Esempio n. 23
0
        /// <summary>
        /// Gets the ground level.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <returns></returns>
        private float GetGroundLevel(Entity column)
        {
            // calculates the ground level of the column by player distance to the entities

            // falling to infinite!!
            float res = float.MinValue;

            float       minDistance       = float.MaxValue;
            Transform3D minBlockTransform = null;

            if (column != null)
            {
                foreach (Entity element in column.ChildEntities)
                {
                    // get the type of every block... only GROUND and BOX can walk over
                    BlockTypeEnum blockType = BlockTypeEnum.EMPTY;
                    Enum.TryParse <BlockTypeEnum>(element.Tag, out blockType);

                    // only the blocks you can walk over used to calculate grounds
                    if (blockType == BlockTypeEnum.GROUND || blockType == BlockTypeEnum.BOX || blockType == BlockTypeEnum.SPEEDERBLOCK)
                    {
                        Transform3D blockTransform = element.FindComponent <Transform3D>();

                        // use the nearest under player block as ground
                        if (this.playerTransform.Position.Y >= blockTransform.Position.Y + this.modelFactoryService.Scale.Y)
                        {
                            var distance = Vector3.Distance(this.playerTransform.Position, blockTransform.Position);
                            // updates the lower block
                            if (distance < minDistance)
                            {
                                minDistance       = distance;
                                minBlockTransform = blockTransform;
                            }
                        }
                    }
                }

                // If there are any nearest block update ground level, otherwise then level is float.Minimum
                if (minBlockTransform != null)
                {
                    res = minBlockTransform.Position.Y + this.modelFactoryService.Scale.Y / 2;
                }
            }
            return(res);
        }
Esempio n. 24
0
    /// <summary>
    /// 注册所有方块
    /// </summary>
    public void RegisterBlock()
    {
        List <BlockTypeEnum> listBlockType = EnumExtension.GetEnumValue <BlockTypeEnum>();

        for (int i = 0; i < listBlockType.Count; i++)
        {
            BlockTypeEnum blockType = listBlockType[i];
            //获取方块数据
            BlockInfoBean blockInfo     = GetBlockInfo(blockType);
            string        blockTypeName = EnumExtension.GetEnumName(blockType);
            //通过反射获取类
            Block block = ReflexUtil.CreateInstance <Block>($"BlockType{blockTypeName}");
            if (block == null)
            {
                block = new Block();
            }
            block.SetData(blockType);
            block.blockInfo = blockInfo;
            arrayBlockRegister[(int)blockType] = block;
        }
    }
Esempio n. 25
0
        /// <summary>
        /// Frees the column from parent. Don't remove the element cause it calls Dispose, and we need recycle the object at the pool
        /// </summary>
        /// <param name="entityColumn">The entity column.</param>
        public void FreeColumn(Entity entityColumn)
        {
            // Creates a list (to allow iterate)
            var tempChildrenCollection = entityColumn.ChildEntities.ToList();

            foreach (Entity sub in tempChildrenCollection)
            {
                // Detach the entity from the parent
                entityColumn.DetachChild(sub.Name);

                // add the free block to the pool
                BlockTypeEnum blockType = BlockTypeEnum.EMPTY;
                if (Enum.TryParse <BlockTypeEnum>(sub.Tag, out blockType))
                {
                    this.blockPool[blockType].Push(sub);
                }

                sub.IsVisible = false;
                sub.IsActive  = false;
            }
        }
Esempio n. 26
0
    public void SetBlockForLocal(Vector3Int localPosition, BlockTypeEnum blockType, BlockDirectionEnum direction = BlockDirectionEnum.UpForward, string meta = null, bool isRefreshMesh = true, bool isSaveData = true, bool isRefreshBlockRange = true)
    {
        if (localPosition.y > chunkData.chunkHeight)
        {
            return;
        }
        //首先移除方块
        Block oldBlock = chunkData.GetBlockForLocal(localPosition);

        if (oldBlock != null && oldBlock.blockType != BlockTypeEnum.None)
        {
            //先删除方块 再删除老数据 因为再删除方块时会用到老数据
            oldBlock.DestoryBlock(this, localPosition, direction);
            //删除老数据
            ClearBlockData(localPosition);
        }
        //设置新方块
        Block newBlock = BlockHandler.Instance.manager.GetRegisterBlock(blockType);

        chunkData.SetBlockForLocal(localPosition, newBlock, direction);

        //保存数据
        if (isSaveData)
        {
            BlockBean blockData = new BlockBean(localPosition, blockType, direction, meta);
            SetBlockData(blockData);
        }
        //刷新blockMesh
        if (isRefreshMesh)
        {
            WorldCreateHandler.Instance.manager.AddUpdateChunk(this, 1);
        }
        //初始化方块(放再这里是等处理完数据和mesh之后再初始化)
        newBlock.InitBlock(this, localPosition, 1);
        //刷新六个方向的方块
        if (isRefreshBlockRange)
        {
            newBlock.RefreshBlockRange(this, localPosition, direction);
        }
    }
Esempio n. 27
0
    public override string ItemUseMetaData(Vector3Int worldPosition, BlockTypeEnum blockType, BlockDirectionEnum blockDirection, string curMeta)
    {
        BlockMetaCubeHalf blockMeta = FromMetaData <BlockMetaCubeHalf>(curMeta);

        if (blockMeta == null)
        {
            blockMeta = new BlockMetaCubeHalf();
        }
        int direction = MathUtil.GetUnitTen((int)blockDirection);

        switch (direction)
        {
        case 1:
            blockMeta.SetHalfPosition(DirectionEnum.Down);
            break;

        case 2:
            blockMeta.SetHalfPosition(DirectionEnum.UP);
            break;

        case 3:
            blockMeta.SetHalfPosition(DirectionEnum.Right);
            break;

        case 4:
            blockMeta.SetHalfPosition(DirectionEnum.Left);
            break;

        case 5:
            blockMeta.SetHalfPosition(DirectionEnum.Forward);
            break;

        case 6:
            blockMeta.SetHalfPosition(DirectionEnum.Back);
            break;
        }
        return(ToMetaData(blockMeta));
    }
Esempio n. 28
0
        char GetCharForBlockType(BlockTypeEnum bt)
        {
            switch (bt)
            {
            case BlockTypeEnum.EMPTY:
                return('.');

            case BlockTypeEnum.BLOCK:
                return('#');

            case BlockTypeEnum.WALL:
                return('W');

            case BlockTypeEnum.HORIZONTAL_PADDLE:
                return('_');

            case BlockTypeEnum.BALL:
                return('O');

            default:
                return('F');
            }
        }
Esempio n. 29
0
        public void updateTile(int x, int y, int z, bool withRamps)
        {
            wallPosition.Set(x, y, WALL_LAYER);
            floorPosition.Set(x, y, FLOOR_LAYER);
            string    material  = selectMaterial(x, y, z);
            BlockType blockType = BlockTypeEnum.get(map.blockType.get(x, y, z));
            Tile      floorTile = null;
            Tile      wallTile  = null;

            if (blockType != SPACE)
            {
                string type = blockType == RAMP?selectRamp(x, y, z) : blockType.PREFIX;

                floorTile = tileSetHolder.tilesets[material]["WALLF"]; // floor is drawn under all tiles
                wallTile  = tileSetHolder.tilesets[material][type];    // draw wall part
            }
            layers[z].SetTile(floorPosition, floorTile);
            layers[z].SetTile(wallPosition, wallTile);
            if (blockType == SPACE)
            {
                setToppingForSpace(x, y, z);
            }
        }
Esempio n. 30
0
        public void Sphere(Player player, int radiusX, int radiusY = 0, int radiusZ = 0, BlockTypeEnum tileName = null, int tileData = 0, bool filled = true)
        {
            if (tileName == null)
            {
                tileName = new BlockTypeEnum {
                    Value = "stone"
                }
            }
            ;
            if (radiusY == 0)
            {
                radiusY = radiusX;
            }
            if (radiusZ == 0)
            {
                radiusZ = radiusX;
            }

            var id = BlockFactory.GetBlockIdByName(tileName.Value);

            var pattern = new Pattern(id, tileData);

            EditSession.MakeSphere((BlockCoordinates)player.KnownPosition, pattern, radiusX, radiusY, radiusZ, filled);
        }
Esempio n. 31
0
    /// <summary>
    /// 根据生物生态 创造方块
    /// </summary>
    /// <param name="listBiome"></param>
    /// <param name="wPos"></param>
    /// <param name="width"></param>
    /// <param name="height"></param>
    /// <returns></returns>
    public BlockTypeEnum CreateBiomeBlockType(Chunk chunk, BiomeMapData biomeMapData, Vector3Int blockLocalPosition)
    {
        //当前方块位置高于随机生成的高度值时,当前方块类型为空
        if (blockLocalPosition.y > biomeMapData.maxHeight)
        {
            if (blockLocalPosition.y <= biomeMapData.biome.biomeInfo.GetWaterPlaneHeight())
            {
                return(BlockTypeEnum.Water);
            }
            else
            {
                return(BlockTypeEnum.None);
            }
        }

        int   maxHeight = biomeMapData.maxHeight;
        Biome biome     = biomeMapData.biome;

        //边缘处理 逐渐减缓到最低高度
        if (blockLocalPosition.y > maxHeight &&// 在基础高度-4以上
            biomeMapData.offsetDis <= 20)    //在20范围以内
        {
            maxHeight = Mathf.CeilToInt((biomeMapData.maxHeight - biome.biomeInfo.min_height) / 20f) * Mathf.CeilToInt(biomeMapData.offsetDis) + maxHeight;

            //当前方块位置高于随机生成的高度值时,当前方块类型为空
            if (blockLocalPosition.y > maxHeight)
            {
                return(BlockTypeEnum.None);
            }
        }
        Vector3Int    wPos      = blockLocalPosition + chunk.chunkData.positionForWorld;
        BlockTypeEnum blockType = biome.GetBlockType(chunk, biome.biomeInfo, maxHeight, blockLocalPosition, wPos);

        //获取方块
        return(blockType);
    }
Esempio n. 32
0
    /// <summary>
    ///  创建掉落道具实例
    /// </summary>
    public void CreateItemCptDrop(BlockTypeEnum blockType, int itemsNumber, string meta, Vector3 position, ItemDropStateEnum ItemCptDropState, Vector3 dropDirection)
    {
        ItemsInfoBean itemsInfo = manager.GetItemsInfoByBlockType(blockType);

        CreateItemCptDrop(itemsInfo.id, itemsNumber, meta, position, ItemCptDropState, dropDirection);
    }
Esempio n. 33
0
        /// <summary>
        /// Creates the Block.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="color">The color.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="entityType">Type of the entity.</param>
        /// <returns></returns>
        public Entity CreateBlock(Vector3 position, Color color, Vector3 scale, BlockTypeEnum entityType)
        {
            Entity entity = null;

            // Check if there are any block free in the pool of the type we need
            if (this.blockPool[entityType].Count > 0)
            {
                // pop from pool
                entity = this.blockPool[entityType].Pop();

                // Reset visibility and active property
                entity.IsVisible = true;
                entity.IsActive = true;

                // reset position
                Transform3D transform = entity.FindComponent<Transform3D>();
                transform.Position = position;
                transform.Scale = scale;

                // IMPORTANT: DO NOT REMOVE!! We need to Refresh boundbox of the model to locate it at right position.
                entity.FindComponent<Model>(false).BoundingBoxRefreshed = true;

                // change color map if needed
                MaterialsMap materialMap = entity.FindComponent<MaterialsMap>();
                BasicMaterial basicMaterial = (BasicMaterial)materialMap.DefaultMaterial;
                basicMaterial.DiffuseColor = color;
            }
            else
            {
                // If there are not entities in the pool of the type we need, then we should create one
                Model entityModel = null;

                // It will be better to use FBX models than primitives to optimize (primitives do not share vertexmodel)
                // but we use primitives here
                switch (entityType)
                {
                    case BlockTypeEnum.GROUND:
                    case BlockTypeEnum.BOX:
                    case BlockTypeEnum.SPEEDERBLOCK:
                        entityModel = Model.CreateCube();
                        break;
                    case BlockTypeEnum.PYRAMID:
                        entityModel = Model.CreateCone();
                        break;
                    default:
                    case BlockTypeEnum.EMPTY:
                        // SHOULD NOT HAPPEND, this method NEVER will be called if BlockType is EMPTY... but in case we forgotten this then it's controlled
                        break;
                }

                // Creates the new entity
                if (entityModel != null)
                {
                    entity = new Entity()
                        .AddComponent(new Transform3D() { Position = position, Scale = scale })
                        .AddComponent(new MaterialsMap(new BasicMaterial(color) { LightingEnabled = true, AmbientLightColor = Color.White * 0.25f }))
                        .AddComponent(entityModel)
                        .AddComponent(new BoxCollider())
                        .AddComponent(new ModelRenderer());
                    entity.Tag = entityType.ToString();

                    // DO NOT push in pool here!!, only add to cache on remove!
                    // this.blockPool[entityType].Push(entity);
                }
            }
            return entity;
        }
Esempio n. 34
0
 public Block(BlockTypeEnum currentBlockType)
 {
     Type = currentBlockType;
     Status = BlockStatusEnum.NotInPlay;
 }