예제 #1
0
 protected override void ReadData(ESPReader reader)
 {
     using (MemoryStream stream = new MemoryStream(reader.ReadBytes(size)))
         using (ESPReader subReader = new ESPReader(stream, reader.Plugin))
         {
             try
             {
                 Stone.ReadBinary(subReader);
                 Dirt.ReadBinary(subReader);
                 Grass.ReadBinary(subReader);
                 Glass.ReadBinary(subReader);
                 Metal.ReadBinary(subReader);
                 Wood.ReadBinary(subReader);
                 Organic.ReadBinary(subReader);
                 Cloth.ReadBinary(subReader);
                 Water.ReadBinary(subReader);
                 HollowMetal.ReadBinary(subReader);
                 OrganicBug.ReadBinary(subReader);
                 OrganicGlow.ReadBinary(subReader);
             }
             catch
             {
                 return;
             }
         }
 }
예제 #2
0
    void OnGUI()
    {
        GUILayout.Label("Character", EditorStyles.boldLabel);
        character = (Character)EditorGUILayout.ObjectField("Character", character, typeof(Character), false);

        tileGroupEnabled = EditorGUILayout.ToggleLeft("Tile Menu", tileGroupEnabled);
        float showTileGroup = 0;

        if (tileGroupEnabled)
        {
            showTileGroup = 1;
        }
        if (EditorGUILayout.BeginFadeGroup(showTileGroup))
        {
            dirt   = (Dirt)EditorGUILayout.ObjectField("Dirt", dirt, typeof(Dirt), false);
            water  = (Water)EditorGUILayout.ObjectField("Water", water, typeof(Water), false);
            spikes = (Spikes)EditorGUILayout.ObjectField("Spikes", spikes, typeof(Spikes), false);
        }
        EditorGUILayout.EndFadeGroup();

        doodadGroupEnabled = EditorGUILayout.ToggleLeft("Doodad Menu", doodadGroupEnabled);
        float showDoodadGroup = 0;

        if (doodadGroupEnabled)
        {
            showDoodadGroup = 1;
        }
        if (EditorGUILayout.BeginFadeGroup(showDoodadGroup))
        {
            entrance = (Entrance)EditorGUILayout.ObjectField("Entrance", entrance, typeof(Entrance), false);
            exit     = (Exit)EditorGUILayout.ObjectField("Exit", exit, typeof(Exit), false);
            boulder  = (Boulder)EditorGUILayout.ObjectField("Boulder", boulder, typeof(Boulder), false);
        }
        EditorGUILayout.EndFadeGroup();

        if (GUILayout.Button("Select stage file"))
        {
            stageFilePath = EditorUtility.OpenFilePanel("Load stage file", "", "");
        }
        if (stageFilePath != null)
        {
            GUILayout.Label("Stage File Path: " + stageFilePath);
        }
        if (GUILayout.Button("Generate Stage"))
        {
            if (stageFilePath == null)
            {
                EditorUtility.DisplayDialog("Error", "You need to select a stage file.", "OK");
            }
            else if (dirt == null || water == null || entrance == null || exit == null || boulder == null)
            {
                EditorUtility.DisplayDialog("Error", "You must assign prefabs to all tile and doodad fields.", "OK");
            }
            else
            {
                string stageStr = System.IO.File.ReadAllText(stageFilePath);
                CreateStage(stageStr);
            }
        }
    }
예제 #3
0
        protected override void GenerateLandType(string[,] biomeMap, ProtoArray <Chunk> map, Random random)
        {
            int xSize = biomeMap.GetLength(0);
            int ySize = biomeMap.GetLength(1);

            int chunkHeight = Chunk.Height;
            int chunkWidth  = Chunk.Width;

            ProtoArray <Chunk> ret = map;

            for (int x = 0; x < xSize; x++)
            {
                for (int y = 0; y < ySize; y++)
                {
                    for (int cx = 0; cx < chunkWidth; cx++)
                    {
                        Chunk chunk = ret[x, y];

                        for (int cy = 0; cy < chunkHeight; cy++)
                        {
                            Dirt dirt = new Dirt(new Point2D((chunkWidth * x) + cx, (chunkHeight * y) + cy));
                            if (random.Next(4) == 2)
                            {
                                dirt.Resources  = new MarbleResource(random.Next(25));
                                dirt.IsWalkable = false;
                            }

                            chunk.Tiles[cx, cy] = dirt;
                        }
                    }
                }
            }
        }
 /// <inheritdoc />
 public override void BlockUpdate(World world, Vector3i position, uint data, BlockSide side)
 {
     if (side == BlockSide.Top && world.HasOpaqueTop(position))
     {
         world.SetBlock(Dirt.AsInstance(), position);
     }
 }
 private void OnDestroy()
 {
     if (cleaning)
     {
         cleaningTarget = null;
     }
 }
예제 #6
0
    IEnumerator BuildChunk(int sizeX, int sizeY, int sizeZ)
    {
        chunkData = new Block[sizeX, sizeY, sizeZ];
        for (int z = 0; z < sizeZ; ++z)
        {
            for (int y = 0; y < sizeY; ++y)
            {
                for (int x = 0; x < sizeX; ++x)
                {
                    Vector3 pos = new Vector3(x, y, z);
                    chunkData[x, y, z] = new Dirt(pos, chunk, this);
                }
            }
        }

        for (int z = 0; z < sizeZ; ++z)
        {
            for (int y = 0; y < sizeY; ++y)
            {
                for (int x = 0; x < sizeX; ++x)
                {
                    chunkData[x, y, z].CreateBlock();
                }
            }
        }

        CombineQuads();
        yield return(null);
    }
예제 #7
0
        public void Spawn(int amount)
        {
            for (int i = 0; i < amount; i++)
            {
                string name = DirtSpeck + (++spawned);

                Triangle t = statueInformation.Triangles[r.Next(statueInformation.Triangles.Count)];

                Transform transform = new Transform();
                transform.Position = Triangle.GetRandomPointInside(r,
                                                                   t.A,
                                                                   t.B,
                                                                   t.C);

                AddScale grow = new AddScale();
                grow.Maximum = statueInformation.StatueSettings.MaximumDirtScale;
                grow.Minimum = transform.Scale;

                float n = (float)r.NextDouble() * 0.05f;

                grow.Amount = new Vector3(n);

                Dirt blob = new Dirt();
                blob.TriangleHost = t;

                Repository.Delegater.Bind(name, transform);
                Repository.Delegater.Bind(name, grow);
                Repository.Delegater.Bind(name, blob);
            }
        }
예제 #8
0
        public override void PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Block block = world.GetBlock(blockCoordinates);

            if (block is Grass || (block is Dirt && block.Metadata != 1) || block is GrassPath)
            {
                Farmland farmland = new Farmland
                {
                    Coordinates = blockCoordinates,
                    Metadata    = 0
                };

                if (farmland.FindWater(world, blockCoordinates, new List <BlockCoordinates>(), 0))
                {
                    Log.Warn("Found water source");
                    farmland.Metadata = 7;
                }

                world.SetBlock(farmland);
            }
            else if (block is Dirt && block.Metadata == 1)
            {
                Dirt dirt = new Dirt
                {
                    Coordinates = blockCoordinates
                };

                world.SetBlock(dirt);
            }
        }
예제 #9
0
    private void GenerateTileContent(int mapWide, int mapHeight)
    {
        float halfWide   = (mapWide / 2f);
        float halfHeight = (mapHeight / 2f);
        float left       = (tileCenterOffset - halfWide);
        float bottom     = (tileCenterOffset - halfHeight);

        //Debug.LogFormat(" map x/2:{0} map y/2:{1}", halfWide, halfHeight);
        for (float i = 0; i < mapWide; i++)
        {
            for (float j = 0; j < mapHeight; j++)
            {
                //Vector3 pos = new Vector3(left +i, bottom+j, 0);
                float   posX = (left + i) * tileScale;
                float   posY = (bottom + j) * tileScale;
                Vector3 pos  = new Vector3(posX, posY, 0);
                //Debug.LogFormat(" pos x:{0} y/2:{1}", left + i, bottom + j);
                Dirt newtile = Instantiate(tile, pos, Quaternion.identity);
                newtile.transform.localScale = new Vector3(tileScale, tileScale, 0f);

                int seq = (int)(i * mapWide + j);
                //Debug.LogFormat("seq {0}", seq);
                tiles[seq] = newtile;
            }
        }
    }
 /// <inheritdoc />
 public void LiquidChange(World world, Vector3i position, Liquid liquid, LiquidLevel level)
 {
     if (liquid.IsLiquid)
     {
         world.SetBlock(Dirt.AsInstance(), position);
     }
 }
예제 #11
0
        public override ProtoArray <Tile> GenerateLandType(string[,] biomeMap, Random r)
        {
            int xSize = biomeMap.GetLength(0);
            int ySize = biomeMap.GetLength(1);

            int x = 0;
            int y = 0;

            ProtoArray <Tile> ret = new ProtoArray <Tile>(xSize, ySize);

            //Iterate over each row.
            for (int i = 0; i < xSize; i++)
            {
                //Iterate over each column
                for (int ii = 0; ii < ySize; ii++)
                {
                    ret[x, y] = new Dirt(new Point(x, y));
                    y++;
                }
                y = 0;
                x++;
            }

            return(ret);
        }
예제 #12
0
        public override ProtoArray <Tile> GenerateLandType(string[,] biomeMap, Random random)
        {
            int x     = 0;
            int y     = 0;
            int xSize = biomeMap.GetLength(0);
            int ySize = biomeMap.GetLength(1);

            ProtoArray <Tile> tiles = new ProtoArray <Tile>(xSize, ySize);

            while (x < xSize)
            {
                while (y < ySize)
                {
                    Dirt dirt = new Dirt(new Point(x, y));

                    if (random.Next(4) == 2)
                    {
                        dirt.Resources  = new MarbleResource(random.Next(25));
                        dirt.IsWalkable = false;
                    }
                    tiles[x, y] = dirt;
                    y++;
                }
                x++;
                y = 0;
            }

            return(tiles);
        }
예제 #13
0
        protected override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin(SpriteSortMode.BackToFront, // sort mode
                               BlendState.AlphaBlend,
                               SamplerState.PointClamp,    // resizing algorithm?
                               DepthStencilState.None,
                               RasterizerState.CullNone,
                               null);

            GraphicsDevice.Clear(bg_color);

            Dino.Draw(_spriteBatch);

            foreach (CDirt Dirt in Dirts)
            {
                Dirt.Draw(_spriteBatch);
            }


            _spriteBatch.DrawString(font, "Score: " + score, new Vector2(400, 100), Color.White);

            _spriteBatch.End();

            base.Draw(gameTime);
        }
예제 #14
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("ConcreteSolid", true, out subEle);
            subEle.Value = ConcreteSolid.ToHex();

            ele.TryPathTo("ConcreteBroken", true, out subEle);
            subEle.Value = ConcreteBroken.ToHex();

            ele.TryPathTo("MetalSolid", true, out subEle);
            subEle.Value = MetalSolid.ToHex();

            ele.TryPathTo("MetalHollow", true, out subEle);
            subEle.Value = MetalHollow.ToHex();

            ele.TryPathTo("MetalSheet", true, out subEle);
            subEle.Value = MetalSheet.ToHex();

            ele.TryPathTo("Wood", true, out subEle);
            subEle.Value = Wood.ToHex();

            ele.TryPathTo("Sand", true, out subEle);
            subEle.Value = Sand.ToHex();

            ele.TryPathTo("Dirt", true, out subEle);
            subEle.Value = Dirt.ToHex();

            ele.TryPathTo("Grass", true, out subEle);
            subEle.Value = Grass.ToHex();

            ele.TryPathTo("Water", true, out subEle);
            subEle.Value = Water.ToHex();
        }
예제 #15
0
 public static void AddDirt(Dirt d)
 {
     if (DirtList == null)
     {
         DirtList = new List <Dirt>();
     }
     DirtList.Add(d);
 }
예제 #16
0
        private void TileTest()
        {
            string data = Convert.ToBase64String(ProtoUtil.Serialize <Dirt>(new Dirt(3, 2)));
            Dirt   dirt = ProtoUtil.Deserialize <Dirt>(data);

            Assert.AreEqual(dirt.Location, new Point2D(3, 2));
            Assert.IsNotNull(dirt.ID);
        }
 private void OnBecameInvisible()
 {
     if (cleaning)
     {
         cleaningTarget = null;
         Laser.ClearTarget();
     }
 }
예제 #18
0
 public void RemoveDirt(Dirt t)
 {
     if (dirts.Contains(t))
     {
         dirts.Remove(t);
         updateTextCounters();
     }
 }
예제 #19
0
 //------------------------------------------------------------------------
 //                          makeInitialDirt
 //------------------------------------------------------------------------
 private void makeInitialDirt()
 {
     for (int i = 0; i < 50; i++)
     {
         Dirt dirt = new Dirt(ref cleanMeter);
         sponge.addDirt(dirt);
         AddChild(dirt);
     }
 }
예제 #20
0
    public void TargetSetAndApplyMap(NetworkConnection conn, byte[] serverMapData)
    {
        string        dirt       = new Dirt().Encode();
        NetworkReader reader     = new NetworkReader(serverMapData);
        MapData       newMapData = new MapData();

        newMapData.Deserialize(reader);
        mapData = newMapData;
        BuildGameWorld();
    }
예제 #21
0
 protected virtual void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.GetComponent <Arrow> ())
     {
         Dirt dirt = this.gameObject.AddComponent <Dirt> ();
         dirt.Initialize(collision.gameObject.transform.position);
         arrowCollisionSound = (AudioClip)Resources.Load("Audio/shieldBlock");
         AudioSource.PlayClipAtPoint(arrowCollisionSound, this.gameObject.transform.position);
     }
 }
예제 #22
0
 //Loads all the sprites once Unity is ready
 private void LoadSprites()
 {
     Dirt.LoadSprites();
     Ladder.LoadSprites();
     Bridge.LoadSprites();
     Trench.LoadSprites();
     Roof.LoadSprites();
     Platform.LoadSprites();
     BackgroundBlock.LoadSprites();
     Box.LoadSprites();
 }
예제 #23
0
 /// <inheritdoc />
 protected override void DoPlace(World world, Vector3i position, PhysicsEntity?entity)
 {
     if (world.HasOpaqueTop(position))
     {
         Dirt.Place(world, position, entity);
     }
     else
     {
         world.SetBlock(this.AsInstance(), position);
     }
 }
예제 #24
0
        private Tile GenerateTile(int x, int y, Random seededRandom)
        {
            Dirt dirt = new Dirt(x, y, this.Dimension);

            if (seededRandom.Next(0, 5) == 3)
            {
                dirt.MainObject = new Rock(seededRandom.Next(1, 170));
            }

            return(dirt);
        }
예제 #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCleanupObjectWithAppropriateCloseMethod() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCleanupObjectWithAppropriateCloseMethod()
        {
            // GIVEN
            CleanupRule rule    = new CleanupRule();
            Dirt        toClose = rule.Add(mock(typeof(Dirt)));

            // WHEN
            SimulateTestExecution(rule);

            // THEN
            verify(toClose).shutdown();
        }
 public void RemoveOldDirt()
 {
     for (int spot = 0; spot < 9; spot++)
     {
         if (dirts[spot] != null)
         {
             Dirt dirtToRemove = dirts[spot];
             Destroy(dirtToRemove.gameObject);
             dirts[spot] = null;
         }
     }
 }
예제 #27
0
        private static void FillDirt(Tile[,] tiles)
        {
            for (int y = 0; y < tiles.GetLength(0); y++)
            {
                for (int x = 0; x < tiles.GetLength(1); x++)
                {
                    tiles[y, x] = new Dirt(x, y);
                }
            }

            return;
        }
예제 #28
0
    public InventorySlot SearchItem(int type, int itemClass)
    { // Return an item, as well as all its properties
        InventorySlot item = new Empty();

        if (itemClass == 0)
        { // Is it a resource?
            switch (type)
            {
            case 0:     // Wood
                item = new Wood();
                break;

            case 1:     // Dirt
                item = new Dirt();
                break;

            case 2:     // Stone
                item = new Stone();
                break;

            case 3:     // Grass
                item = new Grass();
                break;
            }
        }
        else
        { // Is it a tool?
            switch (type)
            {
            case 11:     // Spear
                item = new Spear();
                break;

            case 12:     // Fence
                item = new Fence();
                break;

            case 13:     // CampFire
                item = new CampFire();
                break;

            case 14:     // Rope
                item = new Rope();
                break;

            case 15:     // Hammer
                item = new Hammer();
                break;
            }
        }
        return(item);
    }
    public void Clean(int x, int y)
    {
        int spot = x + 1 + 3 * (y + 1);

        tiles[spot].hasDirt = false;
        if (dirts[spot] != null)
        {
            dirtRemaining--;
            Dirt dirtToRemove = dirts[spot];
            Destroy(dirtToRemove.gameObject);
            dirts[spot] = null;
        }
    }
예제 #30
0
    //------------------------------------------------------------------------
    //                          makeDirt
    //------------------------------------------------------------------------
    private void makeDirt()
    {
        dirtTimer -= Time.deltaTime;

        if (dirtTimer <= 0)
        {
            Dirt dirt = new Dirt(ref cleanMeter);
            sponge.addDirt(dirt);
            AddChild(dirt);
            SetChildIndex(dirt, 2);
            dirtTimer = maxDirtTimer;
        }
    }
예제 #31
0
파일: Chunk.cs 프로젝트: shd101wyy/Lone
	void createBlock(Vector3 blockPos) {
		int y = (int)blockPos.y;
		if (y < -128)
			return;

		// plain 2
		int heightScale = 20; // 40+
		float detailScale = 70.0f;
		int p_y = (int)(Mathf.PerlinNoise ((blockPos.x + this.seed)/detailScale, (blockPos.z + this.seed)/detailScale) * heightScale); 
		
		Block block;

		if (y > p_y /*42*/) {
			return; // air
		} else if (y > 38) {
			block = new Snow ();
		} else if (y > 5 && y == p_y) {
			block = new Grass ();
			/*
			if (UnityEngine.Random.Range (0, 10) <= 2) {
				addBlock (blockPos + new Vector3 (0, 1, 0), new Fern ());
			} else if (UnityEngine.Random.Range (0, 50) <= 2) {
				addBlock (blockPos + new Vector3 (0, 1, 0), new Rose ());
			}
			*/
		} else if (y > 5) {
			block = new Dirt ();
		} else if (y == -128) {
			block = new BedRock ();
		} else {
			block = new Sand ();
		}
			
		addBlock(blockPos, block);
	}
예제 #32
0
    // Use this for initialization
    void Start()
    {
        Application.targetFrameRate = 60;

        data = new Block[worldX, worldY, worldZ];

        for (int x = 0; x < worldX; x++) {
            for (int z = 0; z < worldZ; z++) {
                int stone = PerlinNoise (x, 0, z, 10, 3, 1.2f);
                stone += PerlinNoise (x, 300, z, 20, 4, 0) + 10;
                int dirt = PerlinNoise (x, 100, z, 50, 6, 0) + 2;

                for (int y = 0; y < worldY; y++) {
                    if (y <= stone) data[x,y,z] = new Rock();
                    else if (y < dirt+stone) data[x,y,z] = new Dirt();
                    else if (y == dirt+stone) data[x,y,z] = new Grass();
                    else data[x, y, z] = new Air();
                }
            }
        }

        if (isClient) {
            Cursor.lockState = CursorLockMode.Locked;
            chunks = new Chunk[Mathf.FloorToInt(worldX/chunkSize), Mathf.FloorToInt(worldY/chunkSize), Mathf.FloorToInt(worldZ/chunkSize)];
            GenerateChunks();
        }
    }