Esempio n. 1
0
 void CreateHoldBlockList()
 {
     lp.maxX = maxX;
     lp.minX = minX;
     lp.maxY = maxY;
     lp.minY = minY;
     lp.maxZ = maxZ;
     lp.minZ = minZ;
     lp.holdBlocks.Clear();
     for (int y = minY; y < maxY + 1; y++)
     {
         for (int x = minX; x < maxX + 1; x++)
         {
             for (int z = minZ; z < maxZ + 1; z++)
             {
                 if (!(x == 0 && y == 0 && z == 0))
                 {
                     LevelPiece.Hold newHold = new LevelPiece.Hold();
                     newHold.offset.x = x;
                     newHold.offset.y = y;
                     newHold.offset.z = z;
                     newHold.isSolid  = false;
                     lp.holdBlocks.Add(newHold);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void PlaceBlockHold(WorldPos _bPos, int _id, LevelPiece _piece, bool _isErase)
        {
//			Debug.Log ("[" + _bPos.ToString () + "](" + _id.ToString () + ")-" + (_isErase?"Delete":"Add"));
            for (int i = 0; i < _piece.holdBlocks.Count; i++)
            {
                LevelPiece.Hold bh = _piece.holdBlocks [i];
                int             x  = _bPos.x + bh.offset.x;
                int             y  = _bPos.y + bh.offset.y;
                int             z  = _bPos.z + bh.offset.z;

                BlockHold.piecePos bhData = new BlockHold.piecePos();
                bhData.blockPos = _bPos;
                bhData.pieceID  = _id;

                Predicate <BlockHold.piecePos> samePiecePos;
                samePiecePos = delegate(BlockHold.piecePos obj) {
                    return(obj.blockPos.Compare(bhData.blockPos) && obj.pieceID == bhData.pieceID);
                };

                BlockHold bhBlock = GetBlock(x, y, z) as BlockHold;
                if (_isErase)
                {
                    if (bhBlock != null && bhBlock.roots.Exists(samePiecePos))
                    {
                        bhBlock.roots.RemoveAt(bhBlock.roots.FindIndex(samePiecePos));
                    }
                    if (bhBlock.roots.Count == 0)
                    {
                        SetBlock(x, y, z, null);
                    }
                }
                else
                {
                    if (bhBlock != null)
                    {
                        if (!bhBlock.roots.Exists(samePiecePos))
                        {
                            bhBlock.roots.Add(bhData);
                        }
                    }
                    else
                    {
                        SetBlock(x, y, z, new BlockHold());
                        bhBlock = GetBlock(x, y, z) as BlockHold;
                        if (bhBlock != null)
                        {
                            bhBlock.roots.Add(bhData);
                        }
                    }
                    if (bhBlock != null && bh.isSolid)
                    {
                        bhBlock.SetSolid(true);
                    }
                }
            }
        }
Esempio n. 3
0
 void DrawList()
 {
     using (var v = new EditorGUILayout.VerticalScope("HelpBox")) {
         for (int i = 0; i < lp.holdBlocks.Count; i++)
         {
             LevelPiece.Hold holdBlock = lp.holdBlocks [i];
             using (var h = new EditorGUILayout.HorizontalScope("textfield")) {
                 GUILayout.Label(" (" + holdBlock.offset.x + "," + holdBlock.offset.y + "," + holdBlock.offset.z + ")", "In TitleText");
                 GUILayout.Space(Screen.width - 200);
                 GUILayout.Label("Solid", "miniLabel");
                 holdBlock.isSolid = EditorGUILayout.Toggle(holdBlock.isSolid);
                 if (GUILayout.Button("Remove", "miniButton"))
                 {
                     lp.holdBlocks.Remove(holdBlock);
                 }
             }
         }
     }
 }