Inheritance: MonoBehaviour
	void Awake ()
	{
		g_Instance=this;
		InitPool ();

//		CreateTestBlock();
	}
Beispiel #2
0
        public WorldManager()
        {
            levels = new Dictionary<string, Level>();
            levels.Add("title", new TitleLevel());
            levels.Add("tutorial", new TutorialLevel());
            currentLevel = levels["title"];

            entMan = new EntityManager();
            blockMan = new BlockManager();
            collideMan = new CollisionManager();
        }
	void Awake ()
	{
//		instance = this;
		bM = this.gameObject.GetComponentInChildren<BrickManager> ();
		pC = this.gameObject.GetComponentInChildren<PlayerController_old> ();
		pC.gameObject.SetActive (false);

		m_BlockMgr=this.gameObject.GetComponentInChildren<BlockManager> ();

		PlayGameInstance_old.INSTANCE=new PlayGameInstance_old(this);
	}
Beispiel #4
0
    void Awake()
    {
        //  Callbacks.OnSelectionData += OnSelectionData;

        GO.Create()
            .SetName("BlockManager")
            .AddComponent<BlockManager>((bm) => {
                blockManager = bm;
                bm.Init();
            });

        //  Vector3 v3 = Vector3.zero;
        //  Point3 p3 = Point3.ToWorldBlockCoord(v3).
    }
        public static new BlockDefinition LoadSectionDefinition(BlockManager manager, XmlNode node)
        {
            BlockDefinition ret = new BlockDefinition();
            ret.Manager = manager;

            ret.type = "overlay";

            foreach (XmlNode prop in node.ChildNodes)
            {
                if (TemplateDefinition.SkipNode(prop))
                {
                    continue;
                }
                if (prop.Name.Equals("location"))
                {
                    ret.location.x = int.Parse(prop.Attributes["x"].Value);
                    ret.location.y = int.Parse(prop.Attributes["y"].Value);
                    //if (prop.Attributes["rotate"] != null)
                    //{
                    //    ret.location.rotate = int.Parse(prop.Attributes["rotate"].Value);
                    //}
                    //if (prop.Attributes["altrotate"] != null)
                    //{
                    //    ret.location.altrotate = bool.Parse(prop.Attributes["altrotate"].Value);
                    //}
                    //if (prop.Attributes["flip"] != null)
                    //{
                    //    ret.location.flip = bool.Parse(prop.Attributes["flip"].Value);
                    //}
                }
                if(prop.Name.Equals("size"))
                {
                    ret.wordwrap.height = int.Parse(prop.Attributes["height"].Value);
                    ret.wordwrap.width = int.Parse(prop.Attributes["width"].Value);
                }
            }
            return (ret);
        }
Beispiel #6
0
    private IEnumerator SpawnPackOfBlocks(int countBlocks)
    {
        int bombsCount  = (int)Mathf.Lerp(0, countBlocks, bombCountPercentageOfPack);
        int heartsCount = playerController.HealthConfiguration.MaxHealth - playerController.GetHealth();

        while (countBlocks > 0)
        {
            Block block = ChooseZoneSpawnerByPriority().SpawnBlock(GetRandomBlock());
            BlockManager.GetInstance().Add(block);
            PhysicalObjectManager.GetInstance().Add(block);
            --countBlocks;
            if (bombsCount > 0 && Random.Range(0f, 1f) <= spawnBombChance)
            {
                BlockManager.GetInstance().Add(ChooseZoneSpawnerByPriority().SpawnBlock(bomb));
                --bombsCount;
            }
            if (heartsCount > 0 && Random.Range(0f, 1f) <= spawnHeartChance)
            {
                BlockManager.GetInstance().Add(ChooseZoneSpawnerByPriority().SpawnBlock(heart));
                --heartsCount;
            }
            yield return(new WaitForSeconds(LerpByDifficulty(maxIntervalBlock, minIntervalBlock)));
        }
    }
    void Awake()
    {
        GameObject board = GameObject.Find("Board");

        if (board != null)
        {
            blockManager = board.GetComponent <BlockManager>();
            boardRaiser  = board.GetComponent <BoardRaiser>();
        }

        GameObject particles = GameObject.Find("Particles");

        if (particles != null)
        {
            particleManager = particles.GetComponent <ParticleManager>();
        }

        hoppingSprites = new List <List <Sprite> >();
        hoppingSprites.Add(HoppingSprites0);
        hoppingSprites.Add(HoppingSprites1);
        hoppingSprites.Add(HoppingSprites2);
        hoppingSprites.Add(HoppingSprites3);
        hoppingSprites.Add(HoppingSprites4);
    }
Beispiel #8
0
        private static void MakeStreetLights(BlockManager bm)
        {
            StreetLights slCurrent = StreetLights.None;
            switch (City.streetLightType.ToLower())
            {
                case "glowstones":
                    slCurrent = StreetLights.Glowstone;
                    break;
                case "torches":
                    slCurrent = StreetLights.Torches;
                    break;
            }
            if (slCurrent == StreetLights.Glowstone || slCurrent == StreetLights.Torches)
            {
                for (int a = City.pathExtends + 1; a <= (City.mapLength / 2) - (City.edgeLength + 16); a += 8)
                {
                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) - a, (City.mapLength / 2) - (City.pathExtends + 1),
                                                   (City.mapLength / 2) - a, (City.mapLength / 2) - City.pathExtends);
                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) - a, (City.mapLength / 2) + (City.pathExtends + 1),
                                                   (City.mapLength / 2) - a, (City.mapLength / 2) + City.pathExtends);
                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) + a, (City.mapLength / 2) - (City.pathExtends + 1),
                                                   (City.mapLength / 2) + a, (City.mapLength / 2) - City.pathExtends);
                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) + a, (City.mapLength / 2) + (City.pathExtends + 1),
                                                   (City.mapLength / 2) + a, (City.mapLength / 2) + City.pathExtends);

                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) - (City.pathExtends + 1), (City.mapLength / 2) - a,
                                                   (City.mapLength / 2) - City.pathExtends, (City.mapLength / 2) - a);
                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) + (City.pathExtends + 1), (City.mapLength / 2) - a,
                                                   (City.mapLength / 2) + City.pathExtends, (City.mapLength / 2) - a);
                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) - (City.pathExtends + 1), (City.mapLength / 2) + a,
                                                   (City.mapLength / 2) - City.pathExtends, (City.mapLength / 2) + a);
                    MakeStreetLight(bm, slCurrent, (City.mapLength / 2) + (City.pathExtends + 1), (City.mapLength / 2) + a,
                                                   (City.mapLength / 2) + City.pathExtends, (City.mapLength / 2) + a);
                }
            }
        }
Beispiel #9
0
        private static void MakeGuardChest(BlockManager bm, int x, int y, int z, bool booIncludeItemsInChests)
        {
            TileEntityChest tec = new TileEntityChest();

            if (booIncludeItemsInChests)
            {
                for (int a = 0; a < 5; a++)
                {
                    tec.Items[a] = BlockHelper.MakeItem(RandomHelper.RandomNumber(ItemInfo.IronSword.ID,
                                                                                  ItemInfo.WoodenSword.ID,
                                                                                  ItemInfo.StoneSword.ID), 1);
                }
                tec.Items[6] = BlockHelper.MakeItem(ItemInfo.Bow.ID, 1);
                tec.Items[7] = BlockHelper.MakeItem(ItemInfo.Arrow.ID, 64);
                int intArmourStartID = RandomHelper.RandomNumber(ItemInfo.LeatherCap.ID, ItemInfo.ChainHelmet.ID,
                                                                 ItemInfo.IronHelmet.ID);
                for (int a = 9; a < 18; a++)
                {
                    tec.Items[a] = BlockHelper.MakeItem(intArmourStartID + RandomHelper.Next(4), 1); // random armour
                }
            }
            bm.SetID(x, y, z, (int)BlockType.CHEST);
            bm.SetTileEntity(x, y, z, tec);
        }
 private void Awake()
 {
     // 퀵등록
     script = this;
 }
Beispiel #11
0
 public static void SetupClass(BlockManager bmDest)
 {
     _bmDest = bmDest;
 }
Beispiel #12
0
 public static void SetupClass(BlockManager bmOriginal, int intMapSizeOriginal)
 {
     bm         = bmOriginal;
     intMapSize = intMapSizeOriginal;
 }
 private IndexNode(BlockManager blockManager)
 {
     _blockManager = blockManager;
 }
Beispiel #14
0
        //BlockManagerのテスト3
        public static void Test14()
        {
            BlockGenerator bg = new BlockGenerator();

            Block[] blks = new Block[100];
            BlockContext[] blkCons = new BlockContext[blks.Length];
            for (int i = 0; i < blks.Length; i++)
            {
                blkCons[i] = bg.CreateNextValidBlock();
                blks[i] = blkCons[i].block;
            }

            string basepath = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            BlockManagerDB bmdb = new BlockManagerDB(basepath);
            string bmdbPath = bmdb.GetPath();

            if (File.Exists(bmdbPath))
                File.Delete(bmdbPath);

            BlockDB bdb = new BlockDB(basepath);
            string bdbPath = bdb.GetPath(0);

            if (File.Exists(bdbPath))
                File.Delete(bdbPath);

            BlockFilePointersDB bfpdb = new BlockFilePointersDB(basepath);
            string bfpPath = bfpdb.GetPath();

            if (File.Exists(bfpPath))
                File.Delete(bfpPath);

            BlockManager blkmanager = new BlockManager(bmdb, bdb, bfpdb, 10, 10, 3);

            for (int i = 0; i < blks.Length; i++)
                blkmanager.AddMainBlock(blks[i]);

            Block[] blks2 = new Block[blks.Length];

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            for (int i = 0; i < blks.Length; i++)
                blks2[i] = blkmanager.GetMainBlock(i);

            stopwatch.Stop();

            Console.WriteLine(string.Join(":", "test14_1", stopwatch.ElapsedMilliseconds.ToString() + "ms"));

            for (int i = 0; i < blks.Length; i++)
                if (!blks2[i].Id.Equals(blks[i].Id))
                    throw new Exception("test14_2");

            Console.WriteLine("test14_succeeded");
        }
Beispiel #15
0
        public static void MakeGuardTowers(BlockManager bm, int intFarmSize, int intMapSize,
                                           bool booIncludeWalls, string strOutsideLights, string strFireBeacons)
        {
            // remove wall
            BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 11, 64, 79,
                                     intFarmSize + 5, intFarmSize + 11, (int)BlockType.AIR, 1);
            // add tower
            BlockShapes.MakeHollowBox(intFarmSize + 4, intFarmSize + 12, 63, 80,
                                      intFarmSize + 4, intFarmSize + 12, (int)BlockType.STONE, 1);
            // divide into two rooms
            BlockShapes.MakeSolidBox(intFarmSize + 4, intFarmSize + 12, 2, 72,
                                     intFarmSize + 4, intFarmSize + 12, (int)BlockType.STONE, 1);
            BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 11, 64, 67,
                                     intFarmSize + 5, intFarmSize + 11, (int)BlockType.AIR, 1);
            switch (strOutsideLights)
            {
            case "Fire":
                for (int y = 72; y <= 79; y += 7)
                {
                    BlockShapes.MakeBlock(intFarmSize + 6, y, intFarmSize + 3, (int)BlockType.NETHERRACK, 2);
                    BlockShapes.MakeBlock(intFarmSize + 6, y + 1, intFarmSize + 3, (int)BlockType.FIRE, 2);
                    BlockShapes.MakeBlock(intFarmSize + 10, y, intFarmSize + 3, (int)BlockType.NETHERRACK, 2);
                    BlockShapes.MakeBlock(intFarmSize + 10, y + 1, intFarmSize + 3, (int)BlockType.FIRE, 2);
                }
                break;

            case "Torches":
                for (int y = 73; y <= 80; y += 7)
                {
                    BlockHelper.MakeTorch(intFarmSize + 6, y, intFarmSize + 3, (int)BlockType.STONE, 2);
                    BlockHelper.MakeTorch(intFarmSize + 10, y, intFarmSize + 3, (int)BlockType.STONE, 2);
                }
                break;
            }
            // add torches
            BlockHelper.MakeTorch(intFarmSize + 6, 79, intFarmSize + 13, (int)BlockType.STONE, 2);
            BlockHelper.MakeTorch(intFarmSize + 10, 79, intFarmSize + 13, (int)BlockType.STONE, 2);
            // add torches inside
            BlockHelper.MakeTorch(intFarmSize + 6, 77, intFarmSize + 11, (int)BlockType.STONE, 2);
            BlockHelper.MakeTorch(intFarmSize + 10, 77, intFarmSize + 11, (int)BlockType.STONE, 2);
            BlockHelper.MakeTorch(intFarmSize + 5, 77, intFarmSize + 6, (int)BlockType.STONE, 2);
            BlockHelper.MakeTorch(intFarmSize + 5, 77, intFarmSize + 10, (int)BlockType.STONE, 2);
            // add openings to the walls
            BlockShapes.MakeBlock(intFarmSize + 7, 73, intFarmSize + 12, (int)BlockType.AIR, 2);
            BlockShapes.MakeBlock(intFarmSize + 9, 73, intFarmSize + 12, (int)BlockType.AIR, 2);
            BlockShapes.MakeBlock(intFarmSize + 7, 74, intFarmSize + 12, (int)BlockType.AIR, 2);
            BlockShapes.MakeBlock(intFarmSize + 9, 74, intFarmSize + 12, (int)BlockType.AIR, 2);
            // add blocks on top of the towers
            BlockShapes.MakeHollowLayers(intFarmSize + 4, intFarmSize + 12, 81, 81,
                                         intFarmSize + 4, intFarmSize + 12, (int)BlockType.STONE, 1);
            // alternating top blocks
            for (int x = intFarmSize + 4; x <= intFarmSize + 12; x += 2)
            {
                for (int z = intFarmSize + 4; z <= intFarmSize + 12; z += 2)
                {
                    if (x == intFarmSize + 4 || x == intFarmSize + 12 || z == intFarmSize + 4 || z == intFarmSize + 12)
                    {
                        BlockShapes.MakeBlock(x, 82, z, (int)BlockType.STONE, 1);
                    }
                }
            }
            // add central columns
            BlockShapes.MakeSolidBox(intFarmSize + 8, intFarmSize + 8, 73, 82,
                                     intFarmSize + 8, intFarmSize + 8, (int)BlockType.STONE, 1);
            BlockHelper.MakeLadder(intFarmSize + 7, 73, 82, intFarmSize + 8, 2);
            BlockHelper.MakeLadder(intFarmSize + 9, 73, 82, intFarmSize + 8, 2);
            // add torches on the roof
            BlockShapes.MakeBlock(intFarmSize + 6, 81, intFarmSize + 6, (int)BlockType.TORCH, 1);
            BlockShapes.MakeBlock(intFarmSize + 6, 81, intFarmSize + 10, (int)BlockType.TORCH, 2);
            BlockShapes.MakeBlock(intFarmSize + 10, 81, intFarmSize + 10, (int)BlockType.TORCH, 1);
            // add cobwebs
            BlockShapes.MakeBlock(intFarmSize + 5, 79, intFarmSize + 5, (int)BlockType.COBWEB, 1, 30);
            BlockShapes.MakeBlock(intFarmSize + 5, 79, intFarmSize + 11, (int)BlockType.COBWEB, 1, 30);
            BlockShapes.MakeBlock(intFarmSize + 11, 79, intFarmSize + 5, (int)BlockType.COBWEB, 1, 30);
            BlockShapes.MakeBlock(intFarmSize + 11, 79, intFarmSize + 11, (int)BlockType.COBWEB, 1, 30);
            // add chests
            MakeGuardChest(bm, intFarmSize + 11, 73, intFarmSize + 11);
            MakeGuardChest(bm, intMapSize - (intFarmSize + 11), 73, intFarmSize + 11);
            MakeGuardChest(bm, intFarmSize + 11, 73, intMapSize - (intFarmSize + 11));
            MakeGuardChest(bm, intMapSize - (intFarmSize + 11), 73, intMapSize - (intFarmSize + 11));
            // add archery slots
            BlockShapes.MakeSolidBox(intFarmSize + 4, intFarmSize + 4, 74, 77,
                                     intFarmSize + 8, intFarmSize + 8, (int)BlockType.AIR, 2);
            BlockShapes.MakeSolidBox(intFarmSize + 4, intFarmSize + 4, 76, 76,
                                     intFarmSize + 7, intFarmSize + 9, (int)BlockType.AIR, 2);
            if (!booIncludeWalls)
            {
                BlockHelper.MakeLadder(intFarmSize + 13, 64, 72, intFarmSize + 8, 2);
            }
            // include beds
            BlockHelper.MakeBed(intFarmSize + 5, intFarmSize + 6, 64, intFarmSize + 8, intFarmSize + 8, 2);
            BlockHelper.MakeBed(intFarmSize + 5, intFarmSize + 6, 64, intFarmSize + 10, intFarmSize + 10, 2);
            BlockHelper.MakeBed(intFarmSize + 11, intFarmSize + 10, 64, intFarmSize + 8, intFarmSize + 8, 2);
            // make columns to orientate torches
            BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 73, intFarmSize + 5, intFarmSize + 5, (int)BlockType.WOOD, 2);
            BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 5, intFarmSize + 5, (int)BlockType.WOOD, 2);
            BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.WOOD, 2);
            BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.WOOD, 2);
            // add ladders
            BlockHelper.MakeLadder(intFarmSize + 5, 64, 73, intFarmSize + 6, 2, (int)BlockType.WOOD);
            // make torches
            BlockHelper.MakeTorch(intFarmSize + 10, 66, intFarmSize + 5, (int)BlockType.WOOD, 2);
            BlockHelper.MakeTorch(intFarmSize + 6, 66, intFarmSize + 11, (int)BlockType.WOOD, 2);
            BlockHelper.MakeTorch(intFarmSize + 10, 66, intFarmSize + 11, (int)BlockType.WOOD, 2);
            // make columns for real
            BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 73, intFarmSize + 5, intFarmSize + 5, (int)BlockType.STONE, 2);
            BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 5, intFarmSize + 5, (int)BlockType.STONE, 2);
            BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.STONE, 2);
            BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.STONE, 2);
            // make cobwebs
            BlockShapes.MakeBlock(intFarmSize + 11, 67, intFarmSize + 8, (int)BlockType.COBWEB, 2, 75);
            // make doors from the city to the guard tower
            BlockShapes.MakeBlock(intFarmSize + 11, 65, intFarmSize + 11, (int)BlockType.GOLD_BLOCK, 1);
            BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 11, (int)BlockType.GOLD_BLOCK, 1);
            BlockHelper.MakeDoor(intFarmSize + 11, 64, intFarmSize + 12, (int)BlockType.GOLD_BLOCK, true, 2);
            BlockShapes.MakeBlock(intFarmSize + 11, 65, intFarmSize + 11, (int)BlockType.AIR, 1);
            BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 11, (int)BlockType.AIR, 1);
            BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 11, (int)BlockType.STONE_PLATE, 1);
            BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 13, (int)BlockType.STONE_PLATE, 2);
            // make beacon
            if (strFireBeacons == "Yes")
            {
                BlockShapes.MakeSolidBox(intFarmSize + 8, intFarmSize + 8, 83, 84,
                                         intFarmSize + 8, intFarmSize + 8, (int)BlockType.STONE, 1);
                BlockShapes.MakeSolidBox(intFarmSize + 6, intFarmSize + 10, 85, 85, intFarmSize + 6, intFarmSize + 10, (int)BlockType.STONE, 1);
                BlockShapes.MakeSolidBox(intFarmSize + 6, intFarmSize + 10, 86, 86, intFarmSize + 6, intFarmSize + 10, (int)BlockType.NETHERRACK, 1);
                BlockShapes.MakeSolidBox(intFarmSize + 6, intFarmSize + 10, 87, 87, intFarmSize + 6, intFarmSize + 10, (int)BlockType.FIRE, 1);
            }
        }
Beispiel #16
0
 public static void MakeMoat(frmMace frmLogForm, BlockManager bm)
 {
     frmLogForm.UpdateLog("Moat type: " + City.MoatType, true, true);
     switch (City.MoatType)
     {
         case "Drop to Bedrock":
             for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++)
             {
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 2, 63, a,
                                              City.MapLength - a, BlockInfo.Air.ID, 0, -1);
             }
             BlockShapes.MakeHollowLayers(City.EdgeLength - 2, City.MapLength - (City.EdgeLength - 2),
                                          64, 64,
                                          City.EdgeLength - 2, City.MapLength - (City.EdgeLength - 2), BlockInfo.Fence.ID, 0, -1);
             break;
         case "Cactus":
             for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++)
             {
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 63, 63, a,
                                              City.MapLength - a, BlockInfo.Sand.ID, 0, -1);
             }
             for (int a = City.EdgeLength + 1; a <= City.MapLength / 2; a += 2)
             {
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 64, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 65, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 64, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 65, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
             }
             for (int a = City.EdgeLength; a <= City.MapLength / 2; a += 2)
             {
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 64, City.EdgeLength, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 65, City.EdgeLength, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 64, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 65, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 64, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 65, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
             }
             if (City.HasGuardTowers)
             {
                 for (int a = City.EdgeLength + 3; a <= City.EdgeLength + 13; a += 2)
                 {
                     BlockShapes.MakeBlock(a, 64, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 65, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                 }
             }
             break;
         case "Cactus Low":
             for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++)
             {
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 59, 63,
                                              a, City.MapLength - a, BlockInfo.Air.ID, 0, -1);
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 58, 58,
                                              a, City.MapLength - a, BlockInfo.Sand.ID, 0, -1);
             }
             for (int a = City.EdgeLength + 1; a <= City.MapLength / 2; a += 2)
             {
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 59, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 60, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 59, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 60, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
             }
             for (int a = City.EdgeLength; a <= City.MapLength / 2; a += 2)
             {
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 59, City.EdgeLength, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 60, City.EdgeLength, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 59, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 60, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
                 if (RNG.NextDouble() > 0.5)
                 {
                     BlockShapes.MakeBlock(a, 59, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 60, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 50, -1);
                 }
             }
             if (City.HasGuardTowers)
             {
                 for (int a = City.EdgeLength + 3; a <= City.EdgeLength + 13; a += 2)
                 {
                     BlockShapes.MakeBlock(a, 59, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                     BlockShapes.MakeBlock(a, 60, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                 }
             }
             break;
         case "Lava":
             for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++)
             {
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 55, 56,
                                              a, City.MapLength - a, BlockInfo.Lava.ID, 0, -1);
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 57, 63,
                                              a, City.MapLength - a, BlockInfo.Air.ID, 0, -1);
             }
             break;
         case "Fire":
             for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++)
             {
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 56, 56,
                                              a, City.MapLength - a, BlockInfo.Netherrack.ID, 0, -1);
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 57, 57,
                                              a, City.MapLength - a, BlockInfo.Fire.ID, 0, -1);
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 58, 63,
                                              a, City.MapLength - a, BlockInfo.Air.ID, 0, -1);
             }
             break;
         case "Water":
             for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++)
             {
                 BlockShapes.MakeHollowLayers(a, City.MapLength - a, 59, 63,
                                              a, City.MapLength - a, BlockInfo.Water.ID, 0, -1);
             }
             break;
         default:
             Debug.Fail("Invalid switch result");
             break;
     }
     // drawbridge
     int intBridgeEnd = City.HasMoat ? -2 : 5;
     if (City.MoatType == "Lava" || City.MoatType == "Fire")
     {
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63,
                                  City.EdgeLength + intBridgeEnd, City.EdgeLength + 13, BlockInfo.StoneBrick.ID, 2);
     }
     else
     {
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63,
                                  City.EdgeLength + intBridgeEnd, City.EdgeLength + 13, BlockInfo.WoodPlank.ID, 2);
     }
     BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 64, 65,
                  City.EdgeLength + intBridgeEnd, City.EdgeLength + 13, BlockInfo.Air.ID, 2);
 }
Beispiel #17
0
 public void InsertAnd()
 {
     Point3d insPt;
     if (Lab2.Selector.Point("\nPunto de inserción", out insPt))
     {
         String dllPath =
         System.Reflection.Assembly.GetAssembly(typeof(Commands)).Location;
         String dir = dllPath.Substring(0, dllPath.LastIndexOf('\\'));
         string file = Path.Combine(dir, "Bloques", "AND.dwg");
         BlockManager blkMan;
         blkMan = new BlockManager(file);
         try
         {
             blkMan.Load("AND");
             ObjectId refId = blkMan.Insert(insPt);
             blkMan.CreateBBox(refId);
             //Dibujar las cajas
             DBMan.DrawGeometry(blkMan.Box.Geometry, true);
             DBMan.DrawGeometry(blkMan.BoxInputA.Geometry, true);
             DBMan.DrawGeometry(blkMan.BoxInputB.Geometry, true);
             DBMan.DrawGeometry(blkMan.BoxOutput.Geometry, true);
         }
         catch (System.Exception e)
         {
             Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
             ed.WriteMessage("\n", e.Message);
         }
     }
 }
Beispiel #18
0
 // Use this for initialization
 void Start()
 {
     blockManager = GameObject.Find("Block Manager").GetComponent<BlockManager>();
     grid = GameObject.Find("Grid").GetComponent<Grid>();
     game = GameObject.Find ("Game").GetComponent<Game>();
 }
Beispiel #19
0
    // Use this for initialization
    void Start()
    {
        _blockManager = FindObjectOfType (typeof(BlockManager)) as BlockManager;

        score = GetComponent<ScoreSystem>();

        _gameMatrix = new List<GridLayer>();

        for (int i = 0; i < _height; i++)
        {
            _gameMatrix.Add(new GridLayer());
        }
    }
 internal FileStream(uint fileNumber, BlockManager blockManager)
 {
     _blockManager = blockManager;
                 _indexNodeBlockIndex = IndexNode.CalculateBlock(fileNumber);
                 _indexNodeBlockRelativeIndex = IndexNode.CalculateBlockRelativeIndex(fileNumber);
 }
Beispiel #21
0
 // Use this for initialization
 void Start()
 {
     mGamaManager = GameManager.GetInstanc;
     mBlockMgr = mGamaManager.GetBlockManager();
 }
 public static IndexNode Deserialize(DataReader dataReader, BlockManager blockManager)
 {
     return new IndexNode(blockManager)
                         {
                                 DataBlocks = dataReader.ReadUInt32(),
                                 DirectPointer1 = dataReader.ReadUInt32(),
                                 DirectPointer2 = dataReader.ReadUInt32(),
                                 DirectPointer3 = dataReader.ReadUInt32(),
                                 DirectPointer4 = dataReader.ReadUInt32(),
                                 SingleIndirectPointer = dataReader.ReadUInt32(),
                                 DoubleIndirectPointer = dataReader.ReadUInt32(),
                                 TripleIndirectPointer = dataReader.ReadUInt32()
                         };
 }
        public virtual void TestProcessPendingReplications()
        {
            Configuration conf = new HdfsConfiguration();

            conf.SetLong(DFSConfigKeys.DfsNamenodeReplicationPendingTimeoutSecKey, Timeout);
            MiniDFSCluster      cluster = null;
            Block               block;
            BlockInfoContiguous blockInfo;

            try
            {
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(DatanodeCount).Build();
                cluster.WaitActive();
                FSNamesystem             fsn                 = cluster.GetNamesystem();
                BlockManager             blkManager          = fsn.GetBlockManager();
                PendingReplicationBlocks pendingReplications = blkManager.pendingReplications;
                UnderReplicatedBlocks    neededReplications  = blkManager.neededReplications;
                BlocksMap blocksMap = blkManager.blocksMap;
                //
                // Add 1 block to pendingReplications with GenerationStamp = 0.
                //
                block     = new Block(1, 1, 0);
                blockInfo = new BlockInfoContiguous(block, (short)3);
                pendingReplications.Increment(block, DatanodeStorageInfo.ToDatanodeDescriptors(DFSTestUtil
                                                                                               .CreateDatanodeStorageInfos(1)));
                BlockCollection bc = Org.Mockito.Mockito.Mock <BlockCollection>();
                Org.Mockito.Mockito.DoReturn((short)3).When(bc).GetBlockReplication();
                // Place into blocksmap with GenerationStamp = 1
                blockInfo.SetGenerationStamp(1);
                blocksMap.AddBlockCollection(blockInfo, bc);
                NUnit.Framework.Assert.AreEqual("Size of pendingReplications ", 1, pendingReplications
                                                .Size());
                // Add a second block to pendingReplications that has no
                // corresponding entry in blocksmap
                block = new Block(2, 2, 0);
                pendingReplications.Increment(block, DatanodeStorageInfo.ToDatanodeDescriptors(DFSTestUtil
                                                                                               .CreateDatanodeStorageInfos(1)));
                // verify 2 blocks in pendingReplications
                NUnit.Framework.Assert.AreEqual("Size of pendingReplications ", 2, pendingReplications
                                                .Size());
                //
                // Wait for everything to timeout.
                //
                while (pendingReplications.Size() > 0)
                {
                    try
                    {
                        Sharpen.Thread.Sleep(100);
                    }
                    catch (Exception)
                    {
                    }
                }
                //
                // Verify that block moves to neededReplications
                //
                while (neededReplications.Size() == 0)
                {
                    try
                    {
                        Sharpen.Thread.Sleep(100);
                    }
                    catch (Exception)
                    {
                    }
                }
                // Verify that the generation stamp we will try to replicate
                // is now 1
                foreach (Block b in neededReplications)
                {
                    NUnit.Framework.Assert.AreEqual("Generation stamp is 1 ", 1, b.GetGenerationStamp
                                                        ());
                }
                // Verify size of neededReplications is exactly 1.
                NUnit.Framework.Assert.AreEqual("size of neededReplications is 1 ", 1, neededReplications
                                                .Size());
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
        public virtual void TestPendingAndInvalidate()
        {
            Configuration Conf = new HdfsConfiguration();

            Conf.SetLong(DFSConfigKeys.DfsBlockSizeKey, 1024);
            Conf.SetLong(DFSConfigKeys.DfsHeartbeatIntervalKey, DfsReplicationInterval);
            Conf.SetInt(DFSConfigKeys.DfsNamenodeReplicationIntervalKey, DfsReplicationInterval
                        );
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(Conf).NumDataNodes(DatanodeCount
                                                                                   ).Build();

            cluster.WaitActive();
            FSNamesystem          namesystem = cluster.GetNamesystem();
            BlockManager          bm         = namesystem.GetBlockManager();
            DistributedFileSystem fs         = cluster.GetFileSystem();

            try
            {
                // 1. create a file
                Path filePath = new Path("/tmp.txt");
                DFSTestUtil.CreateFile(fs, filePath, 1024, (short)3, 0L);
                // 2. disable the heartbeats
                foreach (DataNode dn in cluster.GetDataNodes())
                {
                    DataNodeTestUtils.SetHeartbeatsDisabledForTests(dn, true);
                }
                // 3. mark a couple of blocks as corrupt
                LocatedBlock block = NameNodeAdapter.GetBlockLocations(cluster.GetNameNode(), filePath
                                                                       .ToString(), 0, 1).Get(0);
                cluster.GetNamesystem().WriteLock();
                try
                {
                    bm.FindAndMarkBlockAsCorrupt(block.GetBlock(), block.GetLocations()[0], "STORAGE_ID"
                                                 , "TEST");
                    bm.FindAndMarkBlockAsCorrupt(block.GetBlock(), block.GetLocations()[1], "STORAGE_ID"
                                                 , "TEST");
                }
                finally
                {
                    cluster.GetNamesystem().WriteUnlock();
                }
                BlockManagerTestUtil.ComputeAllPendingWork(bm);
                BlockManagerTestUtil.UpdateState(bm);
                NUnit.Framework.Assert.AreEqual(bm.GetPendingReplicationBlocksCount(), 1L);
                NUnit.Framework.Assert.AreEqual(bm.pendingReplications.GetNumReplicas(block.GetBlock
                                                                                          ().GetLocalBlock()), 2);
                // 4. delete the file
                fs.Delete(filePath, true);
                // retry at most 10 times, each time sleep for 1s. Note that 10s is much
                // less than the default pending record timeout (5~10min)
                int  retries    = 10;
                long pendingNum = bm.GetPendingReplicationBlocksCount();
                while (pendingNum != 0 && retries-- > 0)
                {
                    Sharpen.Thread.Sleep(1000);
                    // let NN do the deletion
                    BlockManagerTestUtil.UpdateState(bm);
                    pendingNum = bm.GetPendingReplicationBlocksCount();
                }
                NUnit.Framework.Assert.AreEqual(pendingNum, 0L);
            }
            finally
            {
                cluster.Shutdown();
            }
        }
Beispiel #25
0
 public Engine()
 {
     blockManager = new BlockManager(this);
     playerManager = new PlayerManager(this);
     doDraw = false;
 }
    int dir;        //random integer between 0 and amount of movable directions

    void Start()
    {
        BlockManagment = FindObjectOfType <BlockManager>();
        moveTime       = BlockManagment.cubeMoveTime;
        moveBlockTimer = BlockManagment.chooseCubeToMoveTime;
    }
Beispiel #27
0
 public Board(int width, int height)
 {
     this.Height = height;
     this.Width = width;
     _blockManager = new BlockManager();
 }
Beispiel #28
0
    private void PrepareList()
    {
        if (reorderableList == null || reorderableList.list != blockList.blocks)
        {
            reorderableList = new ReorderableList(blockList.blocks, typeof(Block), true, true, true, true);
        }

        reorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 4f + 20f;

        reorderableList.drawHeaderCallback = (rect) => {
            EditorGUI.LabelField(rect, "Blocks", EditorStyles.boldLabel);
        };

        reorderableList.drawElementCallback = (rect, index, isActive, isFocused) => {
            var block = (Block)reorderableList.list[index];

            textures.Add(GetTextureFromPath(block.texturePath));

            if (index < textures.Count)
            {
                textures[index] = (Texture2D)EditorGUI.ObjectField(new Rect(rect.x, rect.y, rect.width - 40, EditorGUIUtility.singleLineHeight), "Texture", textures[index], typeof(Texture2D), false);
                EditorGUI.TextField(new Rect(rect.x + rect.width - 30, rect.y, 30, EditorGUIUtility.singleLineHeight), index.ToString());

                if (block.texturePath == "" && GetPathFromTexture(textures[index]) != "")
                {
                    block.texturePath = GetPathFromTexture(textures[index]);
                }
            }

            rect.y         += 20;
            rect.height     = 30;
            block.blockType = (BlockType)EditorGUI.EnumPopup(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), "Block", block.blockType);

            rect.y        += 20;
            rect.height    = 30;
            block.itemType = (ItemType)EditorGUI.EnumPopup(new Rect(rect.x, rect.y, rect.width / 2, EditorGUIUtility.singleLineHeight), "Item", block.itemType);
            block.amount   = EditorGUI.IntField(new Rect(rect.width / 2 + 40, rect.y, rect.width / 2, EditorGUIUtility.singleLineHeight), "Amount", block.amount);

            rect.y     += 20;
            rect.height = 30;
            block.color = EditorGUI.ColorField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), block.color);
        };

        reorderableList.onSelectCallback = (list) => {
            selectedIndex = list.index;
        };

        reorderableList.onReorderCallback = (list) => {
            BlockManager.Write(blockList, null);
            Refresh();
        };

        reorderableList.onAddCallback = (list) => {
            var block = new Block(BlockType.Empty, Color.black, "", ItemType.Empty, 0);
            BlockManager.Write(blockList, block);
            Refresh();
        };

        reorderableList.onRemoveCallback = (list) => {
            if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete this block?", "Yes", "No"))
            {
                ReorderableList.defaultBehaviours.DoRemoveButton(list);
                BlockManager.Remove(blockList, selectedIndex);
            }
        };

        if (textures.Count > blockList.blocks.Count)
        {
            textures = new List <Texture2D>();
        }
    }
 void Start()
 {
     blockManager = GameObject.FindObjectOfType<BlockManager> ();
     if (blockManager == null) {
         Debug.LogError ("fruit manager - no block manager found. Aborting.");
         enabled = false;
     }
     fruitCollector = GameObject.FindObjectOfType<FruitCollector> ();
     if ( fruitCollector == null ) {
         Debug.LogError ("fruit manager - no fruit collector found. Aborting.");
         enabled = false;
     }
 }
Beispiel #30
0
        public void BuildRoom(BlockManager bm, int x, int y, int z)
        {
            int ox = originx + (cellxlen + wallxwidth) * x;
            int oy = originy + (cellylen + wallywidth) * y;
            int oz = originz + (cellzlen + wallzwidth) * z;

            // Hollow out room
            for (int xi = 0; xi < cellxlen; xi++)
            {
                int xx = ox + wallxwidth + xi;
                for (int zi = 0; zi < cellzlen; zi++)
                {
                    int zz = oz + wallzwidth + zi;
                    for (int yi = 0; yi < cellylen; yi++)
                    {
                        int yy = oy + wallywidth + yi;
                        bm.SetID(xx, yy, zz, (int)BlockType.AIR);
                    }
                }
            }

            // Build walls
            for (int xi = 0; xi < cellxlen + 2 * wallxwidth; xi++)
            {
                for (int zi = 0; zi < cellzlen + 2 * wallzwidth; zi++)
                {
                    for (int yi = 0; yi < wallywidth; yi++)
                    {
                        bm.SetID(ox + xi, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                        bm.SetID(ox + xi, oy + yi + cellylen + wallywidth, oz + zi, (int)BlockType.BEDROCK);
                    }
                }
            }

            for (int xi = 0; xi < cellxlen + 2 * wallxwidth; xi++)
            {
                for (int zi = 0; zi < wallzwidth; zi++)
                {
                    for (int yi = 0; yi < cellylen + 2 * wallywidth; yi++)
                    {
                        bm.SetID(ox + xi, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                        bm.SetID(ox + xi, oy + yi, oz + zi + cellzlen + wallzwidth, (int)BlockType.BEDROCK);
                    }
                }
            }

            for (int xi = 0; xi < wallxwidth; xi++)
            {
                for (int zi = 0; zi < cellzlen + 2 * wallzwidth; zi++)
                {
                    for (int yi = 0; yi < cellylen + 2 * wallywidth; yi++)
                    {
                        bm.SetID(ox + xi, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                        bm.SetID(ox + xi + cellxlen + wallxwidth, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                    }
                }
            }

            // Torchlight
            bm.SetID(ox + wallxwidth, oy + wallywidth + 2, oz + wallzwidth + 1, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 2, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 1, oy + wallywidth + 2, oz + wallzwidth + 1, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 1, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 2, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + 1, oy + wallywidth + 2, oz + wallzwidth, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 2, oy + wallywidth + 2, oz + wallzwidth, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + 1, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 1, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 2, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 1, (int)BlockType.TORCH);
        }
Beispiel #31
0
        public static BlockDefinition LoadSectionDefinition(BlockManager manager, XmlNode node)
        {
            BlockDefinition ret = new BlockDefinition();
            ret.Manager = manager;

            ret.id = node.Attributes["id"].Value;
            ret.type = node.Attributes["type"].Value;
            if (node.Attributes["src"] != null)
            {
                ret.src = node.Attributes["src"].Value;
            }
            foreach (XmlNode prop in node.ChildNodes)
            {
                if (TemplateDefinition.SkipNode(prop))
                {
                    continue;
                }
                if (prop.Name.Equals("location"))
                {
                    ret.location.x = int.Parse(prop.Attributes["x"].Value);
                    ret.location.y = int.Parse(prop.Attributes["y"].Value);
                    if (prop.Attributes["rotate"] != null)
                    {
                        ret.location.rotate = int.Parse(prop.Attributes["rotate"].Value);
                    }
                    if (prop.Attributes["altrotate"] != null)
                    {
                        ret.location.altrotate = bool.Parse(prop.Attributes["altrotate"].Value);
                    }
                    if (prop.Attributes["flip"] != null)
                    {
                        ret.location.flip = bool.Parse(prop.Attributes["flip"].Value);
                    }
                }
                if (prop.Name.Equals("text"))
                {
                    ret.text.color = ColorTranslator.FromHtml(prop.Attributes["color"].Value);
                    ret.text.size = int.Parse(prop.Attributes["size"].Value);
                    if (prop.Attributes["font"] != null)
                    {
                        string relativePath = prop.Attributes["font"].Value;
                        string rootPath = manager.RootPath;
                        string combined = Path.Combine(rootPath, relativePath);
                        if (File.Exists(combined))
                        {
                            ret.text.font = relativePath;
                        }
                    }
                }
                if (prop.Name.Equals("border"))
                {
                    ret.border.color = ColorTranslator.FromHtml(prop.Attributes["color"].Value);
                    ret.border.size = int.Parse(prop.Attributes["size"].Value);
                }
                if (prop.Name.Equals("wordwrap"))
                {
                    ret.wordwrap.height = int.Parse(prop.Attributes["height"].Value);
                    ret.wordwrap.width = int.Parse(prop.Attributes["width"].Value);
                    if (prop.Attributes["align"] != null)
                    {
                        ret.wordwrap.align = prop.Attributes["align"].Value;
                    }
                    if (prop.Attributes["valign"] != null)
                    {
                        ret.wordwrap.valign = prop.Attributes["valign"].Value;
                    }
                    if (prop.Attributes["shrinktofit"] != null)
                    {
                        ret.wordwrap.shrinkToFit = bool.Parse(prop.Attributes["shrinktofit"].Value);
                    }
                }
            }

            return (ret);
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: BlockReplace <world> <jsonFile>");
                return;
            }

            StreamReader streamReader = new StreamReader(args [1]);
            string       json         = streamReader.ReadToEnd();

            streamReader.Close();

            JObject o = JObject.Parse(json);


            IList <int> elevations = o.SelectToken("elevation-flat").Select(s => (int)s).ToList();

            Console.WriteLine("Load Elevations...");
            string dest = args [0];

            AnvilWorld   world = AnvilWorld.Open(dest);
            BlockManager bm    = world.GetBlockManager();

            bm.AutoLight = true;


            // Set Elevations
            int i = 0;

            while (i < elevations.Count)
            {
                if (i % 100 == 0)
                {
                    //RegionChunkManager cm = world.GetChunkManager();
                    //cm.RelightDirtyChunks();
                }
                int el = elevations[i];
                int x  = i / 1001 | 0;
                int y  = i % 1001;
                x  = 1001 - x; // Symetry
                x -= 500;
                y -= 500;

                bm.SetID(x, el, y, (int)BlockType.GRASS);

                if (el > 1)
                {
                    bm.SetID(x, el - 1, y, (int)BlockType.DIRT);
                }
                if (el > 2)
                {
                    bm.SetID(x, el - 2, y, (int)BlockType.DIRT);
                }
                if (el > 3)
                {
                    bm.SetID(x, el - 3, y, (int)BlockType.DIRT);
                }
                if (el > 4)
                {
                    bm.SetID(x, el - 4, y, (int)BlockType.DIRT);
                }
                ++i;
            }

            Console.WriteLine("Load Mods...");
            IList <int> mods = o.SelectToken("mods").Select(s => (int)s).ToList();

            Console.WriteLine(mods.Count);
            i = 0;
            while (i < mods.Count - 4)
            {
                int x = (int)mods [i++];
                int y = (int)mods [i++];
                int z = (int)mods [i++];
                int t = (int)mods [i++];

                if (t > 126)
                {
                    Console.WriteLine("Failed");
                    Console.WriteLine(t);
                    Console.WriteLine(x);
                    Console.WriteLine(y);
                    Console.WriteLine(z);
                    continue;
                }

                x = 1001 - x; // Symetry

                x -= 500;
                y -= 500;
                // Check if valid block
                if (t < 256 && z > 0 && z <= 255)
                {
                    bm.SetID(x, z, y, t);
                }
            }
            Console.WriteLine("over generation");

            world.Save();
        }
Beispiel #33
0
        public void InsertTrafficLight()
        {
            //validar la carga de la interfaz
            if (this.ctrl_blockTab == null)
                return;
            String pthTL = System.IO.Path.Combine(this.ctrl_blockTab.Directory_Path, "trafficLight.dwg");
            String pthTLI = System.IO.Path.Combine(this.ctrl_blockTab.Directory_Path, "trafficLightIndicator.dwg");

            if (File.Exists(pthTL) && File.Exists(pthTLI))
            {
                BlockManager blkManTL = new BlockManager(pthTL);
                BlockManager blkManTLI = new BlockManager(pthTLI);
                Point3d pos;
                if (Selector.Point("Select the point to insert the Traffic Light (Point3D)", out pos))
                {
                    blkManTL.Load("TL"+this.semaforosCounter.ToString("D3"));
                    blkManTLI.Load("TLI" + this.semaforosCounter.ToString("D3"));
                    //
                    ObjectId idTLI = blkManTLI.Insert(Point3d.Origin);
                    pos = new Point3d(pos.X, pos.Y, float.Parse(StringNull( this.ctrl_blockTab.tbZpos.Text) ));
                    ObjectId idTL = blkManTL.Insert( pos );
                    this.semaforos.Add( new Semaforo( ref idTL, semaforos.Count,int.Parse(StringNull( this.ctrl_blockTab.tbStopGo.Text )), int.Parse( StringNull( this.ctrl_blockTab.tbCaution.Text) ), ref idTLI));
                    semaforosCounter++;
                    //
                    this.ctrl_blockTab.PrintValues(this.moviles, this.semaforos, this.paths);
                }
            }
        }
Beispiel #34
0
 // Use this for initialization
 void Start()
 {
     manager = BlockManager.Instance;
 }
Beispiel #35
0
        public void InsertVehicle()
        {
            //validar la carga de la interfaz
            if (this.ctrl_blockTab == null)
                return;
            String pth = System.IO.Path.Combine(this.ctrl_blockTab.Directory_Path,
                "vehicle.dwg");

            if (File.Exists(pth))
            {
                BlockManager blkMan = new BlockManager(pth);
                ObjectId rutaId;
                if (Selector.ObjectId("Select the Path to insert the Vehicle (Polyline)", "", typeof(Polyline), out rutaId))
                {
                    AddPath(rutaId);
                    blkMan.Load("V"+this.movilesCounter.ToString("D3"));
                    ObjectId id = blkMan.Insert(Point3d.Origin);
                    AttributeManager attMan = new AttributeManager(id);
                    //
                    this.moviles.Add(new Movil(ref rutaId, ref id, double.Parse(StringNull(this.ctrl_blockTab.tbMin.Text)), double.Parse(StringNull(this.ctrl_blockTab.tbMax.Text)), this.ctrl_blockTab.cbLoopTravel.Checked));
                    this.movilesCounter++;
                    attMan.SetAttribute("ID", "V" + this.moviles.Count);
                    //
                    this.ctrl_blockTab.PrintValues(this.moviles, this.semaforos, this.paths);
                }
            }
        }
Beispiel #36
0
 public static void MakeDrawbridges(BlockManager bm)
 {
     if (City.HasWalls)
     {
         // drawbridge
         int intBridgeEnd = City.HasMoat ? -2 : 5;
         if (City.MoatType == "Lava" || City.MoatType == "Fire")
         {
             BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63,
                                      City.FarmLength + intBridgeEnd, City.FarmLength + 13, BlockInfo.Stone.ID, 2);
         }
         else
         {
             BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63,
                                      City.FarmLength + intBridgeEnd, City.FarmLength + 13, BlockInfo.WoodPlank.ID, 2);
         }
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 64, 64,
                                  City.FarmLength + intBridgeEnd, City.FarmLength + 13, BlockInfo.Air.ID, 2);
         // carve out the entrance/exit
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 64, 67,
                                  City.FarmLength + intBridgeEnd, City.FarmLength + 10, BlockInfo.Air.ID, 2);
         if (Utils.IsValidSign(City.Name))
         {
             BlockHelper.MakeSign((City.MapLength / 2) - 3, 65, City.FarmLength + 5,
                                  Utils.ConvertStringToSignText(City.Name.Replace("City of ", "City of~")),
                                  City.WallMaterialID, 2);
         }
         // add the bottom of a portcullis
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 67, 67,
                                  City.FarmLength + 6, City.FarmLength + 6, BlockInfo.Fence.ID, 2);
         // add room for murder holes
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, (City.MapLength / 2) + 2, 69, 71,
                                  City.FarmLength + 8, City.FarmLength + 9, BlockInfo.Air.ID, 2);
         BlockShapes.MakeSolidBox(City.MapLength / 2, City.MapLength / 2, 69, 72,
                                  City.FarmLength + 8, City.FarmLength + 9, BlockInfo.Air.ID, 2);
         BlockHelper.MakeLadder(City.MapLength / 2, 69, 72, City.FarmLength + 9, 2, City.WallMaterialID);
         BlockShapes.MakeSolidBoxWithData(City.MapLength / 2, City.MapLength / 2, 72, 72,
                                          City.FarmLength + 8, City.FarmLength + 8,
                                          City.WallMaterialID, 2, City.WallMaterialData);
         // murder holes
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, (City.MapLength / 2) - 2, 68, 68,
                                  City.FarmLength + 8, City.FarmLength + 8, BlockInfo.Air.ID, 2);
         BlockShapes.MakeSolidBox(City.MapLength / 2, City.MapLength / 2, 68, 68,
                                  City.FarmLength + 8, City.FarmLength + 8, BlockInfo.Air.ID, 2);
         BlockShapes.MakeSolidBox((City.MapLength / 2) + 2, (City.MapLength / 2) + 2, 68, 68,
                                  City.FarmLength + 8, City.FarmLength + 8, BlockInfo.Air.ID, 2);
         // chests
         BlockShapes.MakeBlock((City.MapLength / 2) - 4, 69, City.FarmLength + 9, BlockInfo.Gravel.ID, 2, 100, -1);
         BlockShapes.MakeBlock((City.MapLength / 2) + 4, 69, City.FarmLength + 9, BlockInfo.Gravel.ID, 2, 100, -1);
         BlockShapes.MakeBlock((City.MapLength / 2) - 3, 70, City.FarmLength + 9, BlockInfo.Air.ID, 2, 100, -1);
         BlockShapes.MakeBlock((City.MapLength / 2) + 3, 70, City.FarmLength + 9, BlockInfo.Air.ID, 2, 100, -1);
         TileEntityChest tec = new TileEntityChest();
         if (City.HasItemsInChests)
         {
             tec.Items[0] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1);
             tec.Items[1] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1);
             tec.Items[2] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1);
         }
         BlockHelper.MakeChest((City.MapLength / 2) - 3, 69, City.FarmLength + 9, BlockInfo.Gravel.ID, tec, 2);
         // add torches
         BlockHelper.MakeTorch((City.MapLength / 2) - 1, 70, City.FarmLength + 9, City.WallMaterialID, 2);
         BlockHelper.MakeTorch((City.MapLength / 2) + 1, 70, City.FarmLength + 9, City.WallMaterialID, 2);
         // link to main roads
         //BlockShapes.MakeSolidBox((City.intMapLength / 2) - 1, (City.intMapLength / 2) + 1, 63, 63,
         //                         City.intFarmSize + 11, City.intFarmSize + 13, BlockType.DOUBLE_SLAB, 0);
     }
     else if (City.HasMoat)
     {
         BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63,
                                  City.FarmLength - 2, City.FarmLength + 6, BlockInfo.Stone.ID, 2);
     }
 }
Beispiel #37
0
 void Awake()
 {
     GameObject cubeManager = GameObject.FindGameObjectWithTag("manager");
     manager = cubeManager.GetComponent<BlockManager>();
 }
            public static HttpResponseMessage ExportCustomBlock(int PortalID, string GUID)
            {
                HttpResponseMessage Response    = new HttpResponseMessage();
                CustomBlock         customBlock = BlockManager.GetByLocale(PortalID, GUID, null);

                if (customBlock != null)
                {
                    string         Theme          = Core.Managers.ThemeManager.GetCurrentThemeName();
                    ExportTemplate exportTemplate = new ExportTemplate
                    {
                        Guid      = Guid.NewGuid().ToString(),
                        Type      = TemplateType.BlockTemplate.ToString(),
                        UpdatedOn = DateTime.UtcNow,
                        Templates = new List <Layout>(),
                        ThemeName = Theme,
                        ThemeGuid = "49A70BA1-206B-471F-800A-679799FF09DF"
                    };
                    Dictionary <string, string> Assets = new Dictionary <string, string>();
                    Layout layout = new Layout();
                    layout.Blocks = new List <CustomBlock>()
                    {
                        customBlock
                    };
                    if (layout.Blocks != null)
                    {
                        foreach (CustomBlock block in layout.Blocks)
                        {
                            if (!string.IsNullOrEmpty(block.Html))
                            {
                                block.Html = PageManager.TokenizeTemplateLinks(PageManager.DeTokenizeLinks(block.Html, PortalID), false, Assets);
                            }
                            if (!string.IsNullOrEmpty(block.Css))
                            {
                                block.Css = PageManager.DeTokenizeLinks(block.Css, PortalID);
                            }
                        }
                        CacheFactory.Clear(CacheFactory.GetCacheKey(CacheFactory.Keys.CustomBlock + "ALL", PortalID));
                    }
                    layout.Name        = customBlock.Name;
                    layout.Content     = "";
                    layout.SVG         = "";
                    layout.ContentJSON = "";
                    layout.Style       = "";
                    layout.StyleJSON   = "";
                    layout.Type        = "";
                    exportTemplate.Templates.Add(layout);
                    string serializedExportTemplate = JsonConvert.SerializeObject(exportTemplate);
                    if (!string.IsNullOrEmpty(serializedExportTemplate))
                    {
                        byte[] fileBytes = null;
                        using (MemoryStream memoryStream = new MemoryStream())
                        {
                            using (ZipArchive zip = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                            {
                                AddZipItem("ExportTemplate.json", Encoding.ASCII.GetBytes(serializedExportTemplate), zip);

                                if (Assets != null && Assets.Count > 0)
                                {
                                    foreach (KeyValuePair <string, string> asset in Assets)
                                    {
                                        string FileName = asset.Key.Replace(PageManager.ExportTemplateRootToken, "");
                                        string FileUrl  = asset.Value;
                                        if (FileUrl.StartsWith("/"))
                                        {
                                            FileUrl = string.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority, FileUrl);
                                        }
                                        AddZipItem("Assets/" + FileName, new WebClient().DownloadData(FileUrl), zip);
                                    }
                                }
                            }
                            fileBytes = memoryStream.ToArray();
                        }
                        string fileName = customBlock.Name + "_BlockTemplate.zip";
                        Response.Content = new ByteArrayContent(fileBytes.ToArray());
                        Response.Content.Headers.Add("x-filename", fileName);
                        Response.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
                        Response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                        {
                            FileName = fileName
                        };
                        Response.StatusCode = HttpStatusCode.OK;
                    }
                }
                return(Response);
            }
			public ByteBucket (BlockManager blocks)
			{
				if (blocks == null)
					blocks = new BlockManager ();

				this.blocks = blocks;
				start = blocks.Position;
			}
        public virtual void TestBlockReceived()
        {
            Configuration conf = new HdfsConfiguration();

            conf.SetLong(DFSConfigKeys.DfsBlockSizeKey, 1024);
            MiniDFSCluster cluster = null;

            try
            {
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(DatanodeCount).Build();
                cluster.WaitActive();
                DistributedFileSystem hdfs       = cluster.GetFileSystem();
                FSNamesystem          fsn        = cluster.GetNamesystem();
                BlockManager          blkManager = fsn.GetBlockManager();
                string file       = "/tmp.txt";
                Path   filePath   = new Path(file);
                short  replFactor = 1;
                DFSTestUtil.CreateFile(hdfs, filePath, 1024L, replFactor, 0);
                // temporarily stop the heartbeat
                AList <DataNode> datanodes = cluster.GetDataNodes();
                for (int i = 0; i < DatanodeCount; i++)
                {
                    DataNodeTestUtils.SetHeartbeatsDisabledForTests(datanodes[i], true);
                }
                hdfs.SetReplication(filePath, (short)DatanodeCount);
                BlockManagerTestUtil.ComputeAllPendingWork(blkManager);
                NUnit.Framework.Assert.AreEqual(1, blkManager.pendingReplications.Size());
                INodeFile fileNode = fsn.GetFSDirectory().GetINode4Write(file).AsFile();
                Block[]   blocks   = fileNode.GetBlocks();
                NUnit.Framework.Assert.AreEqual(DatanodeCount - 1, blkManager.pendingReplications
                                                .GetNumReplicas(blocks[0]));
                LocatedBlock locatedBlock = hdfs.GetClient().GetLocatedBlocks(file, 0).Get(0);
                DatanodeInfo existingDn   = (locatedBlock.GetLocations())[0];
                int          reportDnNum  = 0;
                string       poolId       = cluster.GetNamesystem().GetBlockPoolId();
                // let two datanodes (other than the one that already has the data) to
                // report to NN
                for (int i_1 = 0; i_1 < DatanodeCount && reportDnNum < 2; i_1++)
                {
                    if (!datanodes[i_1].GetDatanodeId().Equals(existingDn))
                    {
                        DatanodeRegistration           dnR    = datanodes[i_1].GetDNRegistrationForBP(poolId);
                        StorageReceivedDeletedBlocks[] report = new StorageReceivedDeletedBlocks[] { new
                                                                                                     StorageReceivedDeletedBlocks("Fake-storage-ID-Ignored", new ReceivedDeletedBlockInfo
                                                                                                                                  [] { new ReceivedDeletedBlockInfo(blocks[0], ReceivedDeletedBlockInfo.BlockStatus
                                                                                                                                                                    .ReceivedBlock, string.Empty) }) };
                        cluster.GetNameNodeRpc().BlockReceivedAndDeleted(dnR, poolId, report);
                        reportDnNum++;
                    }
                }
                NUnit.Framework.Assert.AreEqual(DatanodeCount - 3, blkManager.pendingReplications
                                                .GetNumReplicas(blocks[0]));
                // let the same datanodes report again
                for (int i_2 = 0; i_2 < DatanodeCount && reportDnNum < 2; i_2++)
                {
                    if (!datanodes[i_2].GetDatanodeId().Equals(existingDn))
                    {
                        DatanodeRegistration           dnR    = datanodes[i_2].GetDNRegistrationForBP(poolId);
                        StorageReceivedDeletedBlocks[] report = new StorageReceivedDeletedBlocks[] { new
                                                                                                     StorageReceivedDeletedBlocks("Fake-storage-ID-Ignored", new ReceivedDeletedBlockInfo
                                                                                                                                  [] { new ReceivedDeletedBlockInfo(blocks[0], ReceivedDeletedBlockInfo.BlockStatus
                                                                                                                                                                    .ReceivedBlock, string.Empty) }) };
                        cluster.GetNameNodeRpc().BlockReceivedAndDeleted(dnR, poolId, report);
                        reportDnNum++;
                    }
                }
                NUnit.Framework.Assert.AreEqual(DatanodeCount - 3, blkManager.pendingReplications
                                                .GetNumReplicas(blocks[0]));
                // re-enable heartbeat for the datanode that has data
                for (int i_3 = 0; i_3 < DatanodeCount; i_3++)
                {
                    DataNodeTestUtils.SetHeartbeatsDisabledForTests(datanodes[i_3], false);
                    DataNodeTestUtils.TriggerHeartbeat(datanodes[i_3]);
                }
                Sharpen.Thread.Sleep(5000);
                NUnit.Framework.Assert.AreEqual(0, blkManager.pendingReplications.Size());
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
 private ContainerFile(string filePath)
 {
     _filePath = filePath;
                 _blockManager = new BlockManager(new BlockModifier(filePath));
 }
Beispiel #42
0
 public void Awake()
 {
     BlockManager.instance = this;
 }
Beispiel #43
0
 public BlockEventArgs(BlockManager blockManager)
 {
     Manager = blockManager;
 }
Beispiel #44
0
 // Use this for initialization
 void Start()
 {
     blockManager = GetComponent <BlockManager>();
 }
        public static void Run()
        {
            GraphicsContext context = new GraphicsContext()
            {
                Camera = new FirstPersonCamera(new Vector3(4, 3, 3), Vector3.UnitY)
            };
            Matrix4 World = Matrix4.Identity;

            VoxelTypeMap v = new VoxelTypeMap();
            v[0] = new VoxelTypeMap.VoxelTypeData()
            {
                Color = Vector4.One,
                Visible = false
            };

            v[1] = new VoxelTypeMap.VoxelTypeData()
            {
                Color = Vector4.UnitY * 0.7f + Vector4.UnitW,
                Visible = true
            };

            v[2] = new VoxelTypeMap.VoxelTypeData()
            {
                Color = Vector4.UnitX + Vector4.UnitW,
                Visible = true
            };

            BlockManager man = new BlockManager();
            man.Side = 32;
            man.VoxelTypes = v;

            //Rendering stuff
            ShaderProgram prog = null;

            GraphicsDevice.Load += () =>
            {
                //GraphicsDevice.Winding = FaceWinding.Clockwise;
                GraphicsDevice.CullMode = OpenTK.Graphics.OpenGL4.CullFaceMode.Back;
                GraphicsDevice.DepthTestEnabled = true;
                GraphicsDevice.Window.KeyUp += (k, e) =>
                {
                    if (e.Key == OpenTK.Input.Key.Z) GraphicsDevice.Wireframe = !GraphicsDevice.Wireframe;
                    else if (e.Key == OpenTK.Input.Key.C) GraphicsDevice.CullEnabled = !GraphicsDevice.CullEnabled;
                };

                Random rng = new Random(0);
                double n = 64;

                v.UpdateBuffers();
                GraphicsDevice.SetBufferTexture(0, v.ColorData);

                ShaderSource vShader = ShaderSource.Load(OpenTK.Graphics.OpenGL4.ShaderType.VertexShader, "Testing/VoxTest/vertex.glsl");
                ShaderSource fShader = ShaderSource.Load(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader, "Testing/VoxTest/fragment.glsl");

                prog = new ShaderProgram(vShader, fShader);
                prog.Set("materialColors", 0);

            };

            GraphicsDevice.Update += (e) =>
            {
                context.Update(e);

                //World *= Matrix4.CreateRotationY(0.01f);

                prog.Set("World", Matrix4.Identity);
                prog.Set("View", context.View);
                prog.Set("Proj", context.Projection);
                prog.Set("Fcoef", (float)(2.0f / Math.Log(1000001) / Math.Log(2)));
                prog.Set("lightDir", new Vector3(5, 10, 5).Normalized());

            };

            GraphicsDevice.Render += (e) =>
            {
                GraphicsDevice.Clear();

                for (int k = -2; k < 0; k++)
                {
                    Vector3 a = new Vector3();
                    a.Y = k * man.Side;
                    for (int i = -5; i <= 5; i++)
                    {
                        a.Z = i * man.Side;
                        for (int j = -5; j <= 5; j++)
                        {
                            a.X = j * man.Side;
                            Vector3 dir = (context.Camera as FirstPersonCamera).Direction;
                            if (Vector3.Dot(dir.Normalized(), a.Normalized()) >= -0.3)
                            {
                                //Chunk c = man.Draw(-Vector3.UnitY * 123, out World);
                                Chunk c = man.Draw(context.Camera.Position + a, out World);
                                if (c.ChunkReady)
                                {
                                    c.Bind();
                                    prog.Set("World", World);

                                    prog.Set("range1", c.NormalOffsets[1]);
                                    prog.Set("range2", c.NormalOffsets[2]);
                                    prog.Set("range3", c.NormalOffsets[3]);
                                    prog.Set("range4", c.NormalOffsets[4]);
                                    prog.Set("range5", c.NormalOffsets[5]);
                                    GraphicsDevice.SetShaderProgram(prog);

                                    GraphicsDevice.Draw(OpenTK.Graphics.OpenGL4.PrimitiveType.Triangles, 0, c.NormalGroupSizes[6]);
                                }
                            }
                        }
                    }
                }

                GraphicsDevice.SwapBuffers();
            };

            GraphicsDevice.Name = "Voxel Test";
            GraphicsDevice.Run(60, 0);
            if (GraphicsDevice.Cleanup != null) GraphicsDevice.Cleanup();
        }
Beispiel #46
0
 public void OnPointerUp(PointerEventData eventData)
 {
     BlockManager.FinishOperation(typeOfMovable);
     _underPlayerControl          = false;
     _rectTransform.localPosition = _idlePosition;
 }
Beispiel #47
0
        static public void Generate(frmMace frmLogForm, string UserWorldName, string strWorldSeed,
                                    string strWorldType, bool booWorldMapFeatures, int TotalCities, string[] strCheckedThemes,
                                    int ChunksBetweenCities, string strSpawnPoint, bool booExportSchematics,
                                    string strSelectedNPCs, string strUndergroundOres)
        {
            frmLogForm.UpdateLog("Started at " + DateTime.Now.ToLocalTime(), false, true);

            worldCities = new WorldCity[TotalCities];
            lstCityNames.Clear();
            Chunks.biomes.Clear();

            RNG.SetRandomSeed();

            #region create minecraft world directory from a random unused world name
            string strFolder = String.Empty, strWorldName = String.Empty;

            UserWorldName = UserWorldName.ToSafeFilename();
            if (UserWorldName.Trim().Length == 0)
            {
                UserWorldName = "random";
            }

            if (UserWorldName.ToLower().Trim() != "random")
            {
                if (Directory.Exists(UserWorldName.ToMinecraftSaveDirectory()))
                {
                    if (MessageBox.Show("A world called \"" + UserWorldName + "\" already exists. " +
                                        "Would you like to use a random name instead?", "World already exists",
                                        MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                    {
                        frmLogForm.UpdateLog("Cancelled, because a world with this name already exists.", false, false);
                        return;
                    }
                }
                else
                {
                    strWorldName = UserWorldName;
                    strFolder    = strWorldName.ToMinecraftSaveDirectory();
                }
            }
            if (strWorldName.Length == 0)
            {
                strWorldName = Utils.GenerateWorldName();
                strFolder    = strWorldName.ToMinecraftSaveDirectory();
            }
            Directory.CreateDirectory(strFolder);
            frmLogForm.btnSaveLogNormal.Tag  = Path.Combine(strFolder, "LogNormal.txt");
            frmLogForm.btnSaveLogVerbose.Tag = Path.Combine(strFolder, "LogVerbose.txt");
            frmLogForm.UpdateLog("World name: " + strWorldName, false, true);
            #endregion

            #region get handles to world, chunk manager and block manager
            AnvilWorld worldDest = AnvilWorld.Create(@strFolder);
            worldDest.Level.LevelName = "Creating. Don't open until Mace is finished.";
            RegionChunkManager cmDest = worldDest.GetChunkManager();
            BlockManager       bmDest = worldDest.GetBlockManager();
            bmDest.AutoLight = false;
            #endregion

            #region Determine themes
            // "how does this work, robson?"
            // well, I'm glad you asked!
            // we keep selecting a random unused checked theme, until they've all been used once.
            // after that, all other cities will have a random checked theme

            int maxFarmSize = 0;

            strCheckedThemes = RNG.ShuffleArray(strCheckedThemes);
            for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++)
            {
                if (CurrentCityID <= strCheckedThemes.GetUpperBound(0))
                {
                    worldCities[CurrentCityID].ThemeName = strCheckedThemes[CurrentCityID];
                }
                else
                {
                    worldCities[CurrentCityID].ThemeName = RNG.RandomItem(strCheckedThemes);
                }
                City.themeName = worldCities[CurrentCityID].ThemeName;
                worldCities[CurrentCityID].ChunkLength = GetThemeRandomXMLElementNumber("options", "city_size");
                int farmSize = GetThemeLastXMLElementNumber("options", "farm_size");
                maxFarmSize = Math.Max(maxFarmSize, farmSize);
            }
            #endregion

            GenerateCityLocations(TotalCities, ChunksBetweenCities + maxFarmSize);

            int intRandomCity = RNG.Next(TotalCities);

            for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++)
            {
                MakeCitySettings(frmLogForm, worldCities[CurrentCityID].ThemeName, CurrentCityID, strSelectedNPCs);
                if (!GenerateCity.Generate(frmLogForm, worldDest, cmDest, bmDest, worldCities[CurrentCityID].x, worldCities[CurrentCityID].z, booExportSchematics, strUndergroundOres))
                {
                    frmLogForm.UpdateLog("World generation failed/cancelled.", false, false);
                    return;
                }
                #region set spawn point
                if (City.id == intRandomCity)
                {
                    switch (strSpawnPoint)
                    {
                    case "Away from the cities":
                        worldDest.Level.Spawn = new SpawnPoint(0, 65, 0);
                        break;

                    case "Inside a random city":
                        worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2),
                                                               65,
                                                               ((worldCities[intRandomCity].z + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2));
                        break;

                    case "Outside a random city":
                        worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2),
                                                               65,
                                                               ((worldCities[intRandomCity].z + Chunks.CITY_RELOCATION_CHUNKS) * 16) + 2);
                        break;

                    default:
                        Debug.Fail("invalid spawn point");
                        break;
                    }
                    frmLogForm.UpdateLog("Spawn point set to " + worldDest.Level.Spawn.X + "," + worldDest.Level.Spawn.Y + "," + worldDest.Level.Spawn.Z, false, true);
                }
                #endregion
            }

            #region weather
            frmLogForm.UpdateLog("Setting weather", false, true);
            worldDest.Level.Time = RNG.Next(24000);
            if (RNG.NextDouble() < 0.15)
            {
                frmLogForm.UpdateLog("Rain", false, true);
                worldDest.Level.IsRaining = true;
                // one-quarter to three-quarters of a day
                worldDest.Level.RainTime = RNG.Next(6000, 18000);
                if (RNG.NextDouble() < 0.25)
                {
                    frmLogForm.UpdateLog("Thunder", false, true);
                    worldDest.Level.IsThundering = true;
                    worldDest.Level.ThunderTime  = worldDest.Level.RainTime;
                }
            }
            #endregion

            #region world details
            worldDest.Level.LevelName = strWorldName;
            frmLogForm.UpdateLog("Setting world type: " + strWorldType, false, true);
            switch (strWorldType.ToLower())
            {
            case "creative":
                worldDest.Level.GameType = GameType.CREATIVE;
                break;

            case "survival":
                worldDest.Level.GameType = GameType.SURVIVAL;
                break;

            case "hardcore":
                worldDest.Level.GameType = GameType.SURVIVAL;
                worldDest.Level.Hardcore = true;
                break;

            default:
                Debug.Fail("Invalidate world type selected.");
                break;
            }
            frmLogForm.UpdateLog("World map features: " + booWorldMapFeatures.ToString(), false, true);
            worldDest.Level.UseMapFeatures = booWorldMapFeatures;
            if (strWorldSeed != String.Empty)
            {
                long seed = 0;
                if (long.TryParse(strWorldSeed, out seed))
                {
                    worldDest.Level.RandomSeed = seed;
                    frmLogForm.UpdateLog("Specified world seed: " + worldDest.Level.RandomSeed, false, true);
                }
                else
                {
                    worldDest.Level.RandomSeed = strWorldSeed.ToJavaHashCode();
                    frmLogForm.UpdateLog("Specified world seed: " + strWorldSeed, false, true);
                    frmLogForm.UpdateLog("Specified world seed converted to a number: " + worldDest.Level.RandomSeed, false, true);
                }
            }
            else
            {
                worldDest.Level.RandomSeed = RNG.Next();
                frmLogForm.UpdateLog("Random world seed: " + worldDest.Level.RandomSeed, false, true);
            }
            worldDest.Level.LastPlayed = (DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks) / 10000;
            frmLogForm.UpdateLog("World time: " + worldDest.Level.LastPlayed, false, true);
            #endregion

            cmDest.Save();
            worldDest.Save();

            Chunks.SetBiomeData(@strFolder);

            frmLogForm.UpdateLog("\nCreated the " + strWorldName + "!", false, false);
            frmLogForm.UpdateLog("It'll be at the top of your MineCraft world list.", false, false);

            frmLogForm.UpdateLog("Finished at " + DateTime.Now.ToLocalTime(), false, true);
        }
Beispiel #48
0
 protected override void Start()
 {
     base.Start();
     block_manager = GetComponent <BlockManager>();
 }
Beispiel #49
0
 private void Awake()
 {
     mBlockManager = gameObject.AddComponent<BlockManager>();
     mUIContller = gameObject.AddComponent<UIContller>();
 }
Beispiel #50
0
        //BlockManagerのテスト1
        public static void Test9()
        {
            string basepath = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            BlockManagerDB bmdb = new BlockManagerDB(basepath);
            string bmdbPath = bmdb.GetPath();

            if (File.Exists(bmdbPath))
                File.Delete(bmdbPath);

            BlockDB bdb = new BlockDB(basepath);
            string bdbPath = bdb.GetPath(0);

            if (File.Exists(bdbPath))
                File.Delete(bdbPath);

            BlockFilePointersDB bfpdb = new BlockFilePointersDB(basepath);
            string bfpPath = bfpdb.GetPath();

            if (File.Exists(bfpPath))
                File.Delete(bfpPath);

            BlockManager blkmanager = new BlockManager(bmdb, bdb, bfpdb, 10, 10, 3);

            if (blkmanager.headBlockIndex != -1)
                throw new InvalidOperationException("test9_1");
            if (blkmanager.finalizedBlockIndex != -1)
                throw new InvalidOperationException("test9_2");
            if (blkmanager.mainBlocksCurrent.value != 0)
                throw new InvalidOperationException("test9_16");
            if (blkmanager.mainBlocks[blkmanager.mainBlocksCurrent.value] != null)
                throw new InvalidOperationException("test9_3");

            bool flag = false;
            try
            {
                blkmanager.GetMainBlock(-1);
            }
            catch (InvalidOperationException)
            {
                flag = true;
            }
            if (!flag)
                throw new Exception("test9_5");

            bool flag2 = false;
            try
            {
                blkmanager.GetMainBlock(1);
            }
            catch (InvalidOperationException)
            {
                flag2 = true;
            }
            if (!flag2)
                throw new Exception("test9_6");

            bool flag9 = false;
            try
            {
                blkmanager.GetMainBlock(0);
            }
            catch (InvalidOperationException)
            {
                flag9 = true;
            }
            if (!flag9)
                throw new Exception("test9_28");

            blkmanager.AddMainBlock(new GenesisBlock());

            if (blkmanager.headBlockIndex != 0)
                throw new InvalidOperationException("test9_29");
            if (blkmanager.finalizedBlockIndex != 0)
                throw new InvalidOperationException("test9_30");
            if (blkmanager.mainBlocksCurrent.value != 1)
                throw new InvalidOperationException("test9_31");
            if (blkmanager.mainBlocks[blkmanager.mainBlocksCurrent.value] == null)
                throw new InvalidOperationException("test9_32");
            if (!(blkmanager.mainBlocks[blkmanager.mainBlocksCurrent.value] is GenesisBlock))
                throw new InvalidOperationException("test9_33");

            Block block1 = blkmanager.GetMainBlock(0);
            Block block2 = blkmanager.GetHeadBlock();

            if (!(block1 is GenesisBlock))
                throw new Exception("test9_10");
            if (!(block2 is GenesisBlock))
                throw new Exception("test9_11");

            bool flag3 = false;
            try
            {
                blkmanager.DeleteMainBlock(-1);
            }
            catch (InvalidOperationException)
            {
                flag3 = true;
            }
            if (!flag3)
                throw new Exception("test9_7");

            bool flag4 = false;
            try
            {
                blkmanager.DeleteMainBlock(1);
            }
            catch (InvalidOperationException)
            {
                flag4 = true;
            }
            if (!flag4)
                throw new Exception("test9_8");

            bool flag5 = false;
            try
            {
                blkmanager.DeleteMainBlock(0);
            }
            catch (InvalidOperationException)
            {
                flag5 = true;
            }
            if (!flag5)
                throw new Exception("test9_9");

            TestBlock testblk1 = new TestBlock(1);

            blkmanager.AddMainBlock(testblk1);

            if (blkmanager.headBlockIndex != 1)
                throw new InvalidOperationException("test9_12");
            if (blkmanager.finalizedBlockIndex != 0)
                throw new InvalidOperationException("test9_13");
            if (blkmanager.mainBlocksCurrent.value != 2)
                throw new InvalidOperationException("test9_17");
            if (blkmanager.mainBlocks[blkmanager.mainBlocksCurrent.value] == null)
                throw new InvalidOperationException("test9_14");
            if (!(blkmanager.mainBlocks[blkmanager.mainBlocksCurrent.value] is TestBlock))
                throw new InvalidOperationException("test9_15");

            blkmanager.DeleteMainBlock(1);

            if (blkmanager.headBlockIndex != 0)
                throw new InvalidOperationException("test9_18");
            if (blkmanager.finalizedBlockIndex != 0)
                throw new InvalidOperationException("test9_19");
            if (blkmanager.mainBlocksCurrent.value != 1)
                throw new InvalidOperationException("test9_20");
            if (blkmanager.mainBlocks[blkmanager.mainBlocksCurrent.value] == null)
                throw new InvalidOperationException("test9_21");
            if (!(blkmanager.mainBlocks[blkmanager.mainBlocksCurrent.value] is GenesisBlock))
                throw new InvalidOperationException("test9_22");

            TestBlock testblk2 = new TestBlock(2);

            bool flag6 = false;
            try
            {
                blkmanager.AddMainBlock(testblk2);
            }
            catch (InvalidOperationException)
            {
                flag6 = true;
            }
            if (!flag6)
                throw new Exception("test9_23");

            for (int i = 1; i < 18; i++)
            {
                TestBlock testblk = new TestBlock(i);

                blkmanager.AddMainBlock(testblk);
            }

            for (int i = 17; i > 0; i--)
            {
                if (i == 14)
                {
                    bool flag7 = false;
                    try
                    {
                        blkmanager.DeleteMainBlock(i);
                    }
                    catch (InvalidOperationException)
                    {
                        flag7 = true;
                    }
                    if (!flag7)
                        throw new Exception("test9_24");

                    break;
                }

                blkmanager.DeleteMainBlock(i);
            }

            Block block3 = blkmanager.GetHeadBlock();

            if (block3.Index != 14)
                throw new Exception("test9_25");

            for (int i = 17; i > 0; i--)
            {
                if (i > 14)
                {
                    bool flag8 = false;
                    try
                    {
                        blkmanager.GetMainBlock(i);
                    }
                    catch (InvalidOperationException)
                    {
                        flag8 = true;
                    }
                    if (!flag8)
                        throw new Exception("test9_26");

                    continue;
                }

                Block block4 = blkmanager.GetMainBlock(i);

                if (block4.Index != i)
                    throw new Exception("test9_27");
            }

            Console.WriteLine("test9_succeeded");
        }
Beispiel #51
0
 public static void Postfix(ref BlockManager __instance, ref TankBlock block, ref bool isPropogating, ref bool rootTransfer)
 {
     ManDamage.DamageInfo damageInfo = new ManDamage.DamageInfo(float.PositiveInfinity, ManDamage.DamageType.Standard, (Component)null, (Tank)null, block.transform.position, default(Vector3), 0.0f, 0.0f);
     block.visible.damageable.TryToDamage(damageInfo, true);
     return;
 }
Beispiel #52
0
 // Use this for initialization
 void Awake()
 {
     blockmanager = GetComponent <BlockManager>();
 }
 void Start()
 {
     blockManager = GameObject.Find("BlockManager").GetComponent <BlockManager>();
 }
Beispiel #54
0
    // Update is called once per frame
    void Update()
    {
        Vector3 movementVector = Vector3.zero;

        if (Input.GetKey(KeyCode.W))
        {
            movementVector += transform.forward;
        }
        if (Input.GetKey(KeyCode.S))
        {
            movementVector += -transform.forward;
        }
        if (Input.GetKey(KeyCode.A))
        {
            movementVector += -transform.right;
        }
        if (Input.GetKey(KeyCode.D))
        {
            movementVector += transform.right;
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            equippedBlockType = typeof(GrassBlock);
            equippedText.text = "Grass";
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            equippedBlockType = typeof(DirtBlock);
            equippedText.text = "Dirt";
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            equippedBlockType = typeof(GlassBlock);
            equippedText.text = "Glass";
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            equippedBlockType = typeof(StoneBlock);
            equippedText.text = "Stone";
        }
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            equippedBlockType = typeof(GlowstoneBlock);
            equippedText.text = "Glowstone";
        }

        movementVector.Normalize();
        movementVector *= movementSpeed;

        if (Input.GetKey(KeyCode.Space) && rb.velocity.y < 0.001f)
        {
            movementVector += Vector3.up * jumpPower;
        }

        rb.velocity = new Vector3(movementVector.x, rb.velocity.y + movementVector.y, movementVector.z);

        //TODO: Make this original, credit https://answers.unity.com/questions/29741/mouse-look-script.html
        rotationX += Input.GetAxis("Mouse X") * sensitivityX;
        rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
        rotationX  = ClampAngle(rotationX, minimumX, maximumX);
        rotationY  = ClampAngle(rotationY, minimumY, maximumY);
        Quaternion xQuaternion = Quaternion.Euler(rotationX * Vector3.up);
        Quaternion yQuaternion = Quaternion.Euler(rotationY * -Vector3.right);

        rb.MoveRotation(originalRotation * xQuaternion);
        cameraGameObject.transform.rotation = transform.rotation * yQuaternion;


        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (Cursor.lockState == CursorLockMode.Locked)
            {
                Cursor.lockState = CursorLockMode.None;
            }
            else
            {
                Cursor.lockState = CursorLockMode.Locked;
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Display.main.renderingWidth / 2, Display.main.renderingHeight / 2));
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 1000))
            {
                if (!Physics.CheckBox(new Vector3(Mathf.Round(hit.point.x + (hit.normal.x * 0.01f)), Mathf.Round(hit.point.y + (hit.normal.y * 0.01f)), Mathf.Round(hit.point.z + (hit.normal.z * 0.01f))), Vector3.one * 0.45f))
                {
                    if (hit.collider.gameObject.CompareTag("Block"))
                    {
                        IBlock block = (IBlock)System.Activator.CreateInstance(equippedBlockType, new object[] { new Vector3(Mathf.Round(hit.point.x + (hit.normal.x * 0.01f)), Mathf.Round(hit.point.y + (hit.normal.y * 0.01f)), Mathf.Round(hit.point.z + (hit.normal.z * 0.01f))) }); //new DirtBlock(new Vector3(Mathf.Round(hit.point.x + (hit.normal.x * 0.01f)), Mathf.Round(hit.point.y + (hit.normal.y * 0.01f)), Mathf.Round(hit.point.z + (hit.normal.z * 0.01f))));
                        BlockManager.AddBlock(block);
                    }
                }
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Display.main.renderingWidth / 2, Display.main.renderingHeight / 2));
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 1000))
            {
                Vector3 blockPos = new Vector3(Mathf.Round(hit.point.x + (hit.normal.x * -0.01f)), Mathf.Round(hit.point.y + (hit.normal.y * -0.01f)), Mathf.Round(hit.point.z + (hit.normal.z * -0.01f)));
                BlockManager.RemoveBlock(blockPos);
            }
        }
    }
Beispiel #55
0
 void Awake()
 {
     Instance = this;
 }
Beispiel #56
0
 public void Start()
 {
     blockManager = GetComponentInParent <BlockManager>();
 }
 private void OnTriggerExit2D(Collider2D collision)
 {
     TriggeredBlockManager = null;
     ResetOrginalColor();
 }