예제 #1
0
        public void CheckDeath(Level randLevel, bool sendMsg)
        {
            for (int i = 0; i < gbPlayers.Count; i++)
            {
                string gbPlayer = gbPlayers[i];
                Player player = Player.Find(gbPlayer.Split(':')[0]);
                if (player != null)
                {
                    string state = gbPlayer.Split(':')[1];
                    int prevDeaths = int.Parse(gbPlayer.Split(':')[2]);
                    int newDeaths = player.overallDeath - prevDeaths;
                    int lives = 1 - newDeaths;
                    bool die = lives <= 0;
                    if ((randLevel != null) && (player.level != randLevel)) { move.Use(null, player.name + " " + randLevel.name); }
                    if (state != "dead")
                    {
                        if (die)
                        {
                            gbPlayers.Add(player.name + ":dead:0:" + player.prefix + ":" + player.color);
                            Kill(player);
                            gbPlayers.Remove(gbPlayer);
                        }

                    }
                    else { if (sendMsg) { Player.SendMessage(player, "You're dead. Waiting for next round..."); } }
                }
                else { gbPlayers.Remove(gbPlayer); }
            }
        }
예제 #2
0
 public static void placeBlock(Level l, Player p, ushort x, ushort y, ushort z, byte type)
 {
     if (p == null)
         l.Blockchange(x, y, z, type);
     else
         l.Blockchange(p, x, y, z, type);
 }
예제 #3
0
        public static void placeMine(Mine m, Player p, Level l, ushort[] loc)
        {
            try
            {
                Mines.Add(m);

            }
            catch { }
        }
예제 #4
0
 public static void deleteMine(Mine m, Player p, Level l, ushort[] loc, bool silent)
 {
     try
     {
         Mines.Remove(m);
         l.SetTile(loc[0], loc[1], loc[2], Block.air);
         if (!silent) p.SendMessage("Mine defused.");
     }
     catch { }
 }
예제 #5
0
 public static Mine Find(Level levelOn1, ushort[] loc1)
 {
     Mine Z = null; //MineZ... you geddit? LOL... ok maybe it isn't that funny.
     foreach (Mine m in Mines)
     {
         if (m.loc == loc1 && levelOn1 == m.levelOn)
         {
             return Z;
         }
     }
     return null;
 }
예제 #6
0
파일: PlayerBot.cs 프로젝트: 303i/MCDek
        public PlayerBot(string n, Level l)
        {
            Server.s.Log("adding " + n + " bot");
            name = n;
            color = "&1";
            id = FreeId();

            level = l;
            ushort x = (ushort)((0.5 + level.spawnx) * 32);
            ushort y = (ushort)((1 + level.spawny) * 32);
            ushort z = (ushort)((0.5 + level.spawnz) * 32);
            pos = new ushort[3] { x, y, z }; rot = new byte[2] { level.rotx, level.roty };
            GlobalSpawn();
        }
예제 #7
0
 public Mine(ushort[] loc, Player owner, Level levelon, bool active)
 {
     loc = this.loc;
     owner = this.owner;
     levelon = this.levelOn;
 }
예제 #8
0
 //converts the float into a ushort for map height
 ushort Evaluate(Level lvl, float height)
 {
     ushort temp = (ushort)(height * lvl.depth);
     if (temp < 0) return 0;
     if (temp > lvl.depth - 1) return (ushort)(lvl.depth - 1);
     return temp;
 }
예제 #9
0
파일: Window.cs 프로젝트: Jack1312/Evolve
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (levelGenerater != null)
     {
         levelGenerater.Save();
         levelGenerater = null;
     }
     else
     {
         foreach (Level l in Server.levels)
         {
             if (l.name == txtMapName.Text)
             {
                 MessageBox.Show("Already exist!");
                 return;
             }
         }
         levelGenerater = new Level(txtMapName.Text, ushort.Parse(x.SelectedItem.ToString()), ushort.Parse(y.SelectedItem.ToString()), ushort.Parse(z.SelectedItem.ToString()), cmbMapType.SelectedItem.ToString());
         levelGenerater.Save();
         levelGenerater = null;
     }
 }
예제 #10
0
        void GenerateFault(float[] array, Level Lvl, string type, Random rand)
        {
            float startheight = 0.5f;
            float dispAux;
            ushort i, j, k, halfX, halfZ;
            float a, b, c, w, d;

            float DispMax, DispMin, DispChange;
            DispMax = 0.01f;
            DispChange = -0.0025f;
            if (type.Equals("mountains"))
            {
                DispMax = 0.02f;
                startheight = 0.6f;
            }
            else if (type.Equals("overlay"))
            {
                DispMax = 0.02f;
                DispChange = -0.01f;
            }

            for (int x = 0; x < array.Length; x++)
            {
                array[x] = startheight;
                //overlay[x] = 0.5f;
            }
            DispMin = -DispMax;
            float disp = DispMax;
            //if (terrainHeights == NULL)
            //    return (TERRAIN_ERROR_NOT_INITIALISED);

            halfX = (ushort)(Lvl.width / 2);
            halfZ = (ushort)(Lvl.height / 2);
            int numIterations = (int)((Lvl.width + Lvl.height));
            Server.s.Log("Iterations = " + numIterations.ToString());
            for (k = 0; k < numIterations; k++)
            {
                //s.Log("itteration " + k.ToString());
                d = (float)Math.Sqrt(halfX * halfX + halfZ * halfZ);
                w = (float)(rand.NextDouble() * 360);
                //w = (float)(rand.NextDouble()*90);
                a = (float)Math.Cos(w);
                b = (float)Math.Sin(w);

                c = ((float)rand.NextDouble()) * 2 * d - d;
                //c = ((float)rand.NextDouble() / 1) * 2 * d - d;
                //float disp = (float)(rand.NextDouble()* 0.02f - 0.01f);
                //iterationsDone++;
                //if (iterationsDone < itMinDisp)
                //    disp = maxDisp + (iterationsDone / (itMinDisp + 0.0)) * (minDisp - maxDisp);
                //else
                //    disp = minDisp;
                for (i = 0; i < Lvl.height; i++)
                {
                    for (j = 0; j < Lvl.width; j++)
                    {
                        //switch (terrainFunction)
                        //{
                        //case STEP:
                        if ((i - halfZ) * a + (j - halfX) * b + c > 0)
                            dispAux = disp;
                        else
                            dispAux = -disp;
                        //    break;
                        /*case SIN:
                            pd = ((i - halfZ) * a + (j - halfX) * b + c) / terrainWaveSize;
                            if (pd > 1.57) pd = 1.57;
                            else if (pd < 0) pd = 0;
                            dispAux = -disp / 2 + sin(pd) * disp;
                            break;
                        case COS:
                            pd = ((i - halfZ) * a + (j - halfX) * b + c) / terrainWaveSize;
                            if (pd > 3.14) pd = 3.14;
                            else if (pd < -3.14) pd = -3.14;
                            dispAux = disp - (terrainWaveSize / (terrainGridWidth + 0.0)) + cos(pd) * disp;
                            break;
                    }*/
                        //s.Log("adding " + dispAux.ToString());
                        AddTerrainHeight(array, j, i, Lvl.width, dispAux);
                        //terrainHeights[i * terrainGridWidth + j] += dispAux;
                    }
                }

                disp += DispChange;
                if (disp < DispMin) { disp = DispMax; }
            }
        }
예제 #11
0
파일: Server.cs 프로젝트: Jack1312/Evolve
 public static void addLevel(Level level)
 {
     levels.Add(level);
 }
예제 #12
0
        public override void Use(Player p, string message)
        {
            string path;

            if (message.Split(' ').Length == 1) path = "levels/" + message + ".lvl";
            else if (message.Split(' ').Length == 2) try { path = @Server.backupLocation + "/" + message.Split(' ')[0] + "/" + int.Parse(message.Split(' ')[1]) + "/" + message.Split(' ')[0] + ".lvl"; }
                catch { Help(p); return; }
            else { Help(p); return; }

            if (File.Exists(path))
            {
                FileStream fs = File.OpenRead(path);
                try
                {

                    GZipStream gs = new GZipStream(fs, CompressionMode.Decompress);
                    byte[] ver = new byte[2];
                    gs.Read(ver, 0, ver.Length);
                    ushort version = BitConverter.ToUInt16(ver, 0);
                    Level level;
                    if (version == 1874)
                    {
                        byte[] header = new byte[16]; gs.Read(header, 0, header.Length);
                        ushort width = BitConverter.ToUInt16(header, 0);
                        ushort height = BitConverter.ToUInt16(header, 2);
                        ushort depth = BitConverter.ToUInt16(header, 4);
                        level = new Level(name, width, depth, height, "empty");
                        level.spawnx = BitConverter.ToUInt16(header, 6);
                        level.spawnz = BitConverter.ToUInt16(header, 8);
                        level.spawny = BitConverter.ToUInt16(header, 10);
                        level.rotx = header[12]; level.roty = header[13];
                    }
                    else
                    {
                        byte[] header = new byte[12]; gs.Read(header, 0, header.Length);
                        ushort width = version;
                        ushort height = BitConverter.ToUInt16(header, 0);
                        ushort depth = BitConverter.ToUInt16(header, 2);
                        level = new Level(name, width, depth, height, "grass");
                        level.spawnx = BitConverter.ToUInt16(header, 4);
                        level.spawnz = BitConverter.ToUInt16(header, 6);
                        level.spawny = BitConverter.ToUInt16(header, 8);
                        level.rotx = header[10]; level.roty = header[11];
                    }

                    level.setPhysics(0);

                    byte[] blocks = new byte[level.width * level.height * level.depth];
                    gs.Read(blocks, 0, blocks.Length);
                    level.blocks = blocks;
                    gs.Close();

                    level.backedup = true;
                    level.permissionbuild = LevelPermission.Admin;

                    level.jailx = (ushort)(level.spawnx * 32); level.jaily = (ushort)(level.spawny * 32); level.jailz = (ushort)(level.spawnz * 32);
                    level.jailrotx = level.rotx; level.jailroty = level.roty;

                    p.Loading = true;
                    foreach (Player pl in Player.players) if (p.level == pl.level && p != pl) p.SendDie(pl.id);
                    foreach (PlayerBot b in PlayerBot.playerbots) if (p.level == b.level) p.SendDie(b.id);

                    Player.GlobalDie(p, true);

                    p.level = level;
                    p.SendMotd();

                    p.SendRaw(2);
                    byte[] buffer = new byte[level.blocks.Length + 4];
                    BitConverter.GetBytes(IPAddress.HostToNetworkOrder(level.blocks.Length)).CopyTo(buffer, 0);
                    //ushort xx; ushort yy; ushort zz;

                    for (int i = 0; i < level.blocks.Length; ++i)
                        buffer[4 + i] = Block.Convert(level.blocks[i]);

                    buffer = Player.GZip(buffer);
                    int number = (int)Math.Ceiling(((double)buffer.Length) / 1024);
                    for (int i = 1; buffer.Length > 0; ++i)
                    {
                        short length = (short)Math.Min(buffer.Length, 1024);
                        byte[] send = new byte[1027];
                        Player.HTNO(length).CopyTo(send, 0);
                        Buffer.BlockCopy(buffer, 0, send, 2, length);
                        byte[] tempbuffer = new byte[buffer.Length - length];
                        Buffer.BlockCopy(buffer, length, tempbuffer, 0, buffer.Length - length);
                        buffer = tempbuffer;
                        send[1026] = (byte)(i * 100 / number);
                        p.SendRaw(3, send);
                        Thread.Sleep(10);
                    } buffer = new byte[6];
                    Player.HTNO((short)level.width).CopyTo(buffer, 0);
                    Player.HTNO((short)level.depth).CopyTo(buffer, 2);
                    Player.HTNO((short)level.height).CopyTo(buffer, 4);
                    p.SendRaw(4, buffer);

                    ushort x = (ushort)((0.5 + level.spawnx) * 32);
                    ushort y = (ushort)((1 + level.spawny) * 32);
                    ushort z = (ushort)((0.5 + level.spawnz) * 32);

                    p.aiming = false;
                    Player.GlobalSpawn(p, x, y, z, level.rotx, level.roty, true);
                    p.ClearBlockchange();
                    p.Loading = false;

                    if (message.IndexOf(' ') == -1)
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + ")";
                    else
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")";

                    if (!p.hidden)
                    {
                        Player.GlobalChat(null, p.color + p.prefix + p.name + Server.DefaultColor + " went to the " + level.name, false);
                    }

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception ex) { Player.SendMessage(p, "Error loading level."); Server.ErrorLog(ex); return; }
                finally { fs.Close(); }
            }
            else { Player.SendMessage(p, "Level or backup could not be found."); return; }
        }
예제 #13
0
 //return true if tree is near
 private bool TreeCheck(Level Lvl, ushort x, ushort z, ushort y, short dist)
 {
     for (short xx = (short)-dist; xx <= +dist; ++xx)
     {
         for (short yy = (short)-dist; yy <= +dist; ++yy)
         {
             for (short zz = (short)-dist; zz <= +dist; ++zz)
             {
                 byte foundTile = Lvl.GetTile((ushort)(x + xx), (ushort)(z + zz), (ushort)(y + yy));
                 if (foundTile == Block.trunk || foundTile == Block.green)
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
예제 #14
0
        //Forces the edge of a map to slope lower for island map types
        float NegateEdge(ushort x, ushort y, Level Lvl)
        {
            float tempx = 0.0f, tempy = 0.0f;
            float temp;
            if (x != 0) { tempx = ((float)x / (float)Lvl.width) * 0.5f; }
            if (y != 0) { tempy = ((float)y / (float)Lvl.height) * 0.5f; }
            tempx = Math.Abs(tempx - 0.25f);
            tempy = Math.Abs(tempy - 0.25f);
            if (tempx > tempy)
            {
                temp = tempx - 0.15f;
            }
            else
            {
                temp = tempy - 0.15f;
            }

            //s.Log("temp = " + temp.ToString());
            if (temp > 0.0f) { return temp; }
            return 0.0f;
        }
예제 #15
0
        public bool GenerateMap(Level Lvl, string type)
        {
            Server.s.Log("Attempting map gen");
            if (Inuse) { Server.s.Log("Generator in use"); return false; }
            Random rand = new System.Random();
            try
            {
                Inuse = true;
                terrain = new float[Lvl.width * Lvl.height];
                overlay = new float[Lvl.width * Lvl.height];

                if (!type.Equals("ocean"))
                { overlay2 = new float[Lvl.width * Lvl.height]; }

                //float dispAux, pd;
                ushort WaterLevel = (ushort)(Lvl.depth / 2 + 2);

                if (type.Equals("ocean"))
                {
                    WaterLevel = (ushort)(Lvl.depth * 0.85f);
                }

                //Generate the level
                GenerateFault(terrain, Lvl, type, rand);

                //APPLY FILTER to terrain
                FilterAverage(Lvl);

                //CREATE OVERLAY
                //GenerateFault(overlay, Lvl, "overlay", rand);
                Server.s.Log("Creating overlay");
                GeneratePerlinNoise(overlay, Lvl, "", rand);

                if (!type.Equals("ocean") && type != "desert")
                {
                    Server.s.Log("Planning trees");
                    GeneratePerlinNoise(overlay2, Lvl, "", rand);
                }

                Server.s.Log("Converting height map");
                Server.s.Log("And applying overlays");
                float RangeLow = 0.2f;
                float RangeHigh = 0.8f;
                float TreeDens = 0.35f;
                short TreeDist = 3;
                //changes the terrain range based on type, also tree threshold
                switch (type)
                {
                    case "island":
                        RangeLow = 0.4f;
                        RangeHigh = 0.75f;
                        break;
                    case "forest":
                        RangeLow = 0.45f;
                        RangeHigh = 0.8f;
                        TreeDens = 0.7f;
                        TreeDist = 2;
                        break;
                    case "mountains":
                        RangeLow = 0.3f;
                        RangeHigh = 0.9f;
                        TreeDist = 4;
                        break;
                    case "ocean":
                        RangeLow = 0.1f;
                        RangeHigh = 0.6f;
                        break;
                    case "desert":
                        RangeLow = 0.5f;
                        RangeHigh = 0.85f;
                        WaterLevel = 0;
                        TreeDist = 24;
                        break;
                    default:
                        break;
                }

                //loops though evey X/Z coordinate
                for (int bb = 0; bb < terrain.Length; bb++)
                {
                    ushort x = (ushort)(bb % Lvl.width);
                    ushort y = (ushort)(bb / Lvl.width);
                    ushort z;
                    if (type.Equals("island"))
                    {
                        z = Evaluate(Lvl, Range(terrain[bb], RangeLow - NegateEdge(x, y, Lvl), RangeHigh - NegateEdge(x, y, Lvl)));
                    }
                    else
                    {
                        z = Evaluate(Lvl, Range(terrain[bb], RangeLow, RangeHigh));
                    }
                    if (z > WaterLevel)
                    {
                        for (ushort zz = 0; z - zz >= 0; zz++)
                        {
                            if (type == "desert")
                            {
                                Lvl.skipChange(x, (ushort)(z - zz), y, Block.sand);
                            }
                            else if (overlay[bb] < 0.72f)    //If not zoned for rocks or gravel
                            {
                                if (type.Equals("island"))      //increase sand height for island
                                {
                                    if (z > WaterLevel + 2)
                                    {
                                        if (zz == 0) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.grass); }      //top layer
                                        else if (zz < 3) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.dirt); }   //next few
                                        else { Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock); }               //ten rock it
                                    }
                                    else
                                    {
                                        Lvl.skipChange(x, (ushort)(z - zz), y, Block.sand);                        //SAAAND extra for islands
                                    }
                                }
                                else if (type == "desert")
                                {
                                    Lvl.skipChange(x, (ushort)(z - zz), y, Block.sand);
                                }
                                else
                                {
                                    if (zz == 0) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.grass); }
                                    else if (zz < 3) { Lvl.skipChange(x, (ushort)(z - zz), y, Block.dirt); }
                                    else { Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock); }
                                }
                            }
                            else
                            {
                                Lvl.skipChange(x, (ushort)(z - zz), y, Block.rock);    //zoned for above sea level rock floor
                            }
                        }

                        if (overlay[bb] < 0.25f && type != "desert")    //Zoned for flowers
                        {
                            int temprand = rand.Next(12);

                            switch (temprand)
                            {
                                case 10:
                                    Lvl.skipChange(x, (ushort)(z + 1), y, Block.redflower);
                                    break;
                                case 11:
                                    Lvl.skipChange(x, (ushort)(z + 1), y, Block.yellowflower);
                                    break;
                                default:
                                    break;
                            }
                        }

                        if (!type.Equals("ocean"))
                        {
                            if (overlay[bb] < 0.65f && overlay2[bb] < TreeDens)
                            {
                                if (Lvl.GetTile(x, (ushort)(z + 1), y) == Block.air)
                                {
                                    if (Lvl.GetTile(x, z, y) == Block.grass || type == "desert")
                                    {
                                        if (rand.Next(13) == 0)
                                        {
                                            if (!TreeCheck(Lvl, x, z, y, TreeDist))
                                            {
                                                if (type == "desert")
                                                    AddCactus(Lvl, x, (ushort)(z + 1), y, rand);
                                                else
                                                    AddTree(Lvl, x, (ushort)(z + 1), y, rand);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                    }
                    else    //Must be on/under the water line then
                    {
                        for (ushort zz = 0; WaterLevel - zz >= 0; zz++)
                        {
                            if (WaterLevel - zz > z)
                            { Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.water); }    //better fill the water aboce me
                            else if (WaterLevel - zz > z - 3)
                            {
                                if (overlay[bb] < 0.75f)
                                {
                                    Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.sand);   //sand top
                                }
                                else
                                {
                                    Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.gravel);  //zoned for gravel
                                }
                            }
                            else
                            {
                                Lvl.skipChange(x, (ushort)(WaterLevel - zz), y, Block.rock);
                            }
                        }
                    }
                }

            }
            catch (Exception e)
            {
                Server.ErrorLog(e);
                Server.s.Log("Gen Fail");
                Inuse = false;
                return false;
            }

            terrain = new float[0]; //Derp
            overlay = new float[0]; //Derp
            overlay2 = new float[0]; //Derp

            Inuse = false;

            return true;
        }
예제 #16
0
 //returns the valve of a x,y terrain coordinate
 float GetPixel(ushort x, ushort y, Level Lvl)
 {
     if (x < 0) { return 0.0f; }
     if (x >= Lvl.width) { return 0.0f; }
     if (y < 0) { return 0.0f; }
     if (y >= Lvl.height) { return 0.0f; }
     divide += 1.0f;
     return terrain[x + y * Lvl.width];
 }
예제 #17
0
        //Averages over 9 points
        float GetAverage9(ushort x, ushort y, Level Lvl)
        {
            divide = 0.0f;
            float temp = GetPixel(x, y, Lvl);
            temp += GetPixel((ushort)(x + 1), y, Lvl);
            temp += GetPixel((ushort)(x - 1), y, Lvl);
            temp += GetPixel(x, (ushort)(y + 1), Lvl);
            temp += GetPixel(x, (ushort)(y - 1), Lvl);

            temp += GetPixel((ushort)(x + 1), (ushort)(y + 1), Lvl);
            temp += GetPixel((ushort)(x - 1), (ushort)(y + 1), Lvl);
            temp += GetPixel((ushort)(x + 1), (ushort)(y - 1), Lvl);
            temp += GetPixel((ushort)(x - 1), (ushort)(y - 1), Lvl);

            return temp / divide;
        }
예제 #18
0
 void GeneratePerlinNoise(float[] array, Level Lvl, string type, Random rand)
 {
     GenerateNormalized(array, 0.7f, 8, Lvl.width, Lvl.height, rand.Next(), 64);
 }
예제 #19
0
        public static Level Load(Stream lvlStream, string fileName)
        {
            byte[] temp = new byte[8];
            Level lvl = new Level(fileName, 0, 0, 0, "empty");
            byte[] data;
            int length;
            try {
                lvlStream.Seek( -4, SeekOrigin.End );
                lvlStream.Read( temp, 0, sizeof( int ) );
                lvlStream.Seek( 0, SeekOrigin.Begin );
                length = BitConverter.ToInt32( temp, 0 );
                data = new byte[length];
                using( GZipStream reader = new GZipStream( lvlStream, CompressionMode.Decompress, true ) ) {
                    reader.Read( data, 0, length );
                }

                for( int i = 0; i < length - 1; i++ ) {
                    if( data[i] == 0xAC && data[i + 1] == 0xED ) {

                        // bypassing the header crap
                        int pointer = i + 6;
                        Array.Copy( data, pointer, temp, 0, sizeof( short ) );
                        pointer += IPAddress.HostToNetworkOrder( BitConverter.ToInt16( temp, 0 ) );
                        pointer += 13;

                        int headerEnd = 0;
                        // find the end of serialization listing
                        for( headerEnd = pointer; headerEnd < data.Length - 1; headerEnd++ ) {
                            if( data[headerEnd] == 0x78 && data[headerEnd + 1] == 0x70 ) {
                                headerEnd += 2;
                                break;
                            }
                        }

                        // start parsing serialization listing
                        int offset = 0;
                        while( pointer < headerEnd ) {
                            if( data[pointer] == 'Z' ) offset++;
                            else if( data[pointer] == 'I' || data[pointer] == 'F' ) offset += 4;
                            else if( data[pointer] == 'J' ) offset += 8;

                            pointer += 1;
                            Array.Copy( data, pointer, temp, 0, sizeof( short ) );
                            short skip = IPAddress.HostToNetworkOrder( BitConverter.ToInt16( temp, 0 ) );
                            pointer += 2;

                            // look for relevant variables
                            Array.Copy( data, headerEnd + offset - 4, temp, 0, sizeof( int ) );
                            if( MemCmp( data, pointer, "width" ) ) {
                                lvl.width = (ushort)IPAddress.HostToNetworkOrder( BitConverter.ToInt32( temp, 0 ) );
                            } else if( MemCmp( data, pointer, "depth" ) ) {
                                lvl.depth = (ushort)IPAddress.HostToNetworkOrder( BitConverter.ToInt32( temp, 0 ) );
                            } else if( MemCmp( data, pointer, "height" ) ) {
                                lvl.height = (ushort)IPAddress.HostToNetworkOrder( BitConverter.ToInt32( temp, 0 ) );
                            }

                            pointer += skip;
                        }

                        lvl.spawnx = (ushort)(lvl.width / 1.3);
                        lvl.spawny = (ushort)(lvl.depth / 1.3);
                        lvl.spawnz = (ushort)(lvl.height / 1.3);

                        // find the start of the block array
                        bool foundBlockArray = false;
                        offset = Array.IndexOf<byte>( data, 0x00, headerEnd );
                        while( offset != -1 && offset < data.Length - 2 ) {
                            if( data[offset] == 0x00 && data[offset + 1] == 0x78 && data[offset + 2] == 0x70 ) {
                                foundBlockArray = true;
                                pointer = offset + 7;
                            }
                            offset = Array.IndexOf<byte>( data, 0x00, offset + 1 );
                        }

                        // copy the block array... or fail
                        if( foundBlockArray ) {
                            lvl.CopyBlocks( data, pointer );
                            lvl.Save(true);
                        } else {
                            throw new Exception( "Could not locate block array." );
                        }
                        break;
                    }
                }

            } catch( Exception ex ) {
                Server.s.Log("Conversion failed");
                Server.ErrorLog(ex);
                return null;
            }

            return lvl;
        }
예제 #20
0
파일: Window.cs 프로젝트: Jack1312/Evolve
        //generates map for Standart of Height Mask
        private Bitmap GenerateMap(Level lvl)
        {
            int pixels;
            SolidBrush brush = new SolidBrush(Color.FromArgb(255, Color.Black));
            if (Math.Max(lvl.height, lvl.width) < 256)
            {
                pixels = 256 / lvl.height;
                if (lvl.height > lvl.width)
                {
                    pixels = 256 / lvl.height;
                }
                else if (lvl.height < lvl.width)
                {
                    pixels = 256 / lvl.width;
                }
            }
            else
            {
                pixels = 2;
            }
            if (pixels > 16) { pixels = 16; }
            Bitmap bm;
            try
            {
                bm = new Bitmap("extra/textures/terrain" + pixels + ".png");
            }
            catch
            {
                MessageBox.Show("Missed texture files.");
                return new Bitmap(256, 256);
            }
            Bitmap test = new Bitmap(lvl.width * pixels, lvl.height * pixels);
            Graphics g = Graphics.FromImage(test);
            byte type;
            List<byte> above = new List<byte>();
            Bitmap[] textures = new Bitmap[50];
            for (int i = 0; i < 50; i++)
            {
                textures[i] = bm.Clone(new Rectangle(pixels * i, 0, pixels, pixels), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            }
            int highterBlock = 0;
            int lovestBlock = 0;
            if (mapStyle.SelectedItem.ToString() == "Height mask")
            {
                for (int y = (lvl.depth - 1); y >= 0; y--)
                {
                    for (ushort z = 0; z < lvl.height; z++)
                    {
                        for (ushort x = 0; x < lvl.width; x++)
                        {
                            type = lvl.GetTile(x, (ushort)y, z);
                            type = Block.Convert(type);
                            if (type != 8 || type != 9 || type != 20 || !(type >= 37 && type <= 40) || type != 18 || type != 0)
                            {
                                highterBlock = lvl.depth - y;
                                y = -1;
                                z = lvl.height;
                                x = lvl.width;
                            }
                        }
                    }
                }
                for (int y = 0; y < lvl.depth; y++)
                {
                    for (ushort z = 0; z < lvl.height; z++)
                    {
                        for (ushort x = 0; x < lvl.width; x++)
                        {
                            type = lvl.GetTile(x, (ushort)y, z);
                            type = Block.Convert(type);
                            if (type == 8 || type == 9 || type == 18 || type == 0)
                            {
                                lovestBlock = (int)y;
                                y = lvl.depth;
                                z = lvl.height;
                                x = lvl.width;
                            }
                        }
                    }
                }
            }
            double param = lvl.depth * 2 / double.Parse(txtLayer.Text.ToString());
            int meta, array;
            double modifyer = 1;
            switch (lvl.depth)
            {
                case 32:
                    modifyer = 1;
                    break;
                case 64:
                    modifyer = 1.4;
                    break;
                case 128:
                    modifyer = 1.7;
                    break;
                case 256:
                    modifyer = 1.9;
                    break;
                case 512:
                    modifyer = 2;
                    break;
                case 1024:
                    modifyer = 2;
                    break;
            }
            for (ushort x = 0; x < lvl.width; x++)
            {
                for (ushort z = 0; z < lvl.height; z++)
                {
                    for (int y = (lvl.depth - 1); y >= 0; y--)
                    {
                        type = lvl.GetTile(x, (ushort)y, z);
                        type = Block.Convert(type);
                        if (type == 8 || type == 9 || type == 20 || (type >= 37 && type <= 40) || type == 18)
                        {
                            above.Add(type);
                        }
                        else if (lvl.GetTile(x, (ushort)y, z) != 0)
                        {
                            g.DrawImage(textures[type], x * pixels, z * pixels);
                            if (mapStyle.SelectedItem.ToString() == "Height mask")
                            {
                                meta = (int)(param * (y - modifyer * lovestBlock / 2 - highterBlock));
                                if (meta > 255) { meta = 255; }
                                else if (meta < 0) { meta = 0; }
                                brush = new SolidBrush(Color.FromArgb((255 - meta), Color.Black));
                                g.FillRectangle(brush, x * pixels, z * pixels, pixels, pixels);
                            }
                            if (above.Count != 0)
                            {
                                array = 1;
                                while (above[0] != 0)
                                {
                                    g.DrawImage(textures[above[above.Count - array]], x * pixels, z * pixels);
                                    above[above.Count - array] = 0;
                                    array++;
                                }
                            }

                            y = -1;
                        }
                    }
                }
            }
            g.Dispose();
            return test;
        }
예제 #21
0
파일: PlayerBot.cs 프로젝트: 303i/MCDek
        public PlayerBot(string n, Level l, ushort x, ushort y, ushort z, byte rotx, byte roty)
        {
            name = n;
            color = "&1";
            id = FreeId();

            level = l;
            pos = new ushort[3] { x, y, z }; rot = new byte[2] { rotx, roty };
            GlobalSpawn();

            foreach (Player p in Player.players)
            {
                if (p.level == level)
                {
                    Player.SendMessage(p, color + name + Server.DefaultColor + ", the bot, has been added.");
                }
            }

            botTimer.Elapsed += delegate
            {
                int currentNum, foundNum = (32 * 75);
                Random rand = new Random();

                x = (ushort)Math.Round((decimal)pos[0] / (decimal)32);
                y = (ushort)((pos[1] - 33) / 32);
                z = (ushort)Math.Round((decimal)pos[2] / (decimal)32);

                if (kill)
                {
                    foreach (Player p in Player.players)
                    {
                        if ((ushort)(p.pos[0] / 32) == x)
                        {
                            if (Math.Abs((ushort)(p.pos[1] / 32) - y) < 2)
                            {
                                if ((ushort)(p.pos[2] / 32) == z)
                                {
                                    p.HandleDeath(Block.Zero);
                                }
                            }
                        }
                    }
                }

                if (Waypoints.Count < 1)
                {
                    if (hunt)
                        Player.players.ForEach(delegate(Player p)
                        {
                            if (p.level == level && !p.invincible)
                            {
                                currentNum = Math.Abs(p.pos[0] - pos[0]) + Math.Abs(p.pos[1] - pos[1]) + Math.Abs(p.pos[2] - pos[2]);
                                if (currentNum < foundNum)
                                {
                                    foundNum = currentNum;
                                    foundPos = p.pos;
                                    foundRot = p.rot;
                                    movement = true;
                                    rot[1] = (byte)(255 - foundRot[1]);
                                    if (foundRot[0] < 128) rot[0] = (byte)(foundRot[0] + 128);
                                    else rot[0] = (byte)(foundRot[0] - 128);
                                }
                            }
                        });
                }
                else
                {
                    bool skip = false;
                    movement = false;

                retry: switch (Waypoints[currentPoint].type)
                    {
                        case "walk":
                            foundPos[0] = Waypoints[currentPoint].x;
                            foundPos[1] = Waypoints[currentPoint].y;
                            foundPos[2] = Waypoints[currentPoint].z;
                            movement = true;

                            if ((ushort)(pos[0] / 32) == (ushort)(Waypoints[currentPoint].x / 32))
                            {
                                if ((ushort)(pos[2] / 32) == (ushort)(Waypoints[currentPoint].z / 32))
                                {
                                    rot[0] = Waypoints[currentPoint].rotx;
                                    rot[1] = Waypoints[currentPoint].roty;
                                    currentPoint++;
                                    movement = false;

                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            break;
                        case "teleport":
                            pos[0] = Waypoints[currentPoint].x;
                            pos[1] = Waypoints[currentPoint].y;
                            pos[2] = Waypoints[currentPoint].z;
                            rot[0] = Waypoints[currentPoint].rotx;
                            rot[1] = Waypoints[currentPoint].roty;
                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            return;
                        case "wait":
                            if (countdown != 0)
                            {
                                countdown--;
                                if (countdown == 0)
                                {
                                    currentPoint++;
                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            else
                            {
                                countdown = Waypoints[currentPoint].seconds;
                            }
                            return;
                        case "nod":
                            if (countdown != 0)
                            {
                                countdown--;

                                if (nodUp)
                                {
                                    if (rot[1] > 32 && rot[1] < 128) nodUp = !nodUp;
                                    else
                                    {
                                        if (rot[1] + (byte)Waypoints[currentPoint].rotspeed > 255) rot[1] = 0;
                                        else rot[1] += (byte)Waypoints[currentPoint].rotspeed;
                                    }
                                }
                                else
                                {
                                    if (rot[1] > 128 && rot[1] < 224) nodUp = !nodUp;
                                    else
                                    {
                                        if (rot[1] - (byte)Waypoints[currentPoint].rotspeed < 0) rot[1] = 255;
                                        else rot[1] -= (byte)Waypoints[currentPoint].rotspeed;
                                    }
                                }

                                if (countdown == 0)
                                {
                                    currentPoint++;
                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            else
                            {
                                countdown = Waypoints[currentPoint].seconds;
                            }
                            return;
                        case "spin":
                            if (countdown != 0)
                            {
                                countdown--;

                                if (rot[0] + (byte)Waypoints[currentPoint].rotspeed > 255) rot[0] = 0;
                                else if (rot[0] + (byte)Waypoints[currentPoint].rotspeed < 0) rot[0] = 255;
                                else rot[0] += (byte)Waypoints[currentPoint].rotspeed;

                                if (countdown == 0)
                                {
                                    currentPoint++;
                                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                                    if (!skip) { skip = true; goto retry; }
                                }
                            }
                            else
                            {
                                countdown = Waypoints[currentPoint].seconds;
                            }
                            return;
                        case "speed":
                            movementSpeed = (int)Math.Round((decimal)((decimal)24 / (decimal)100 * (decimal)Waypoints[currentPoint].seconds));
                            if (movementSpeed == 0) movementSpeed = 1;

                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            if (!skip) { skip = true; goto retry; }
                            return;
                        case "reset":
                            currentPoint = 0;
                            return;
                        case "remove":
                            removeBot();
                            return;
                        case "linkscript":
                            if (File.Exists("bots/" + Waypoints[currentPoint].newscript))
                            {
                                Command.all.Find("botset").Use(null, this.name + " " + Waypoints[currentPoint].newscript);
                                return;
                            }

                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            if (!skip) { skip = true; goto retry; }
                            return;
                        case "jump":
                            jumpTimer.Elapsed += delegate
                            {
                                currentjump++;
                                switch (currentjump)
                                {
                                    case 1:
                                    case 2: pos[1] += 24; break;
                                    case 3: break;
                                    case 4: pos[1] -= 24; break;
                                    case 5: pos[1] -= 24; jumping = false; currentjump = 0; jumpTimer.Stop(); break;
                                }
                            };
                            jumpTimer.Start();

                            currentPoint++;
                            if (currentPoint == Waypoints.Count) currentPoint = 0;
                            if (!skip) { skip = true; goto retry; }
                            break;
                    }

                    if (currentPoint == Waypoints.Count) currentPoint = 0;
                }

                if (!movement)
                {
                    if (rot[0] < 245) rot[0] += 8;
                    else rot[0] = 0;

                    if (rot[1] > 32 && rot[1] < 64) rot[1] = 224;
                    else if (rot[1] > 250) rot[1] = 0;
                    else rot[1] += 4;
                }
            };

            botTimer.Start();

            moveTimer.Elapsed += delegate
            {
                moveTimer.Interval = Server.updateTimer.Interval / movementSpeed;
                if (!movement) return;
                int newNum; Random rand = new Random();

                if ((pos[1] - 19) % 32 != 0 && !jumping)
                {
                    pos[1] = (ushort)((pos[1] + 19) - (pos[1] % 32));
                }

                x = (ushort)Math.Round((decimal)(pos[0] - 16) / (decimal)32);
                y = (ushort)((pos[1] - 64) / 32);
                z = (ushort)Math.Round((decimal)(pos[2] - 16) / (decimal)32);

                byte b = Block.Convert(level.GetTile(x, y, z));
                byte b1, b2, b3;//, b4;

                if (Block.Walkthrough(b) && !jumping)
                {
                    pos[1] = (ushort)(pos[1] - 32);
                }

                y = (ushort)((pos[1] - 64) / 32);   //Block below feet

                newNum = level.PosToInt((ushort)(x + Math.Sign(foundPos[0] - pos[0])), y, (ushort)(z + Math.Sign(foundPos[2] - pos[2])));
                b = Block.Convert(level.GetTile(newNum));
                b1 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 1, 0)));
                b2 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 2, 0)));
                b3 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 3, 0)));

                if (Block.Walkthrough(b2) && Block.Walkthrough(b3) && !Block.Walkthrough(b1))
                {     //Get ready to go up step
                    pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
                    pos[1] += (ushort)32;
                    pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
                }
                else if (Block.Walkthrough(b1) && Block.Walkthrough(b2))
                {                        //Stay on current level
                    pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
                    pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
                }
                else if (Block.Walkthrough(b) && Block.Walkthrough(b1))
                {                         //Drop a level
                    pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
                    pos[1] -= (ushort)32;
                    pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
                }

                x = (ushort)Math.Round((decimal)(pos[0] - 16) / (decimal)32);
                y = (ushort)((pos[1] - 64) / 32);
                z = (ushort)Math.Round((decimal)(pos[2] - 16) / (decimal)32);

                b1 = Block.Convert(level.GetTile(x, (ushort)(y + 1), z));
                b2 = Block.Convert(level.GetTile(x, (ushort)(y + 2), z));
                b3 = Block.Convert(level.GetTile(x, y, z));

                /*
                if ((ushort)(foundPos[1] / 32) > y) {
                    if (b1 == Block.water || b1 == Block.waterstill || b1 == Block.lava || b1 == Block.lavastill) {
                        if (Block.Walkthrough(b2)) {
                            pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
                        }
                    } else if (b2 == Block.water || b2 == Block.waterstill || b2 == Block.lava || b2 == Block.lavastill) {
                        pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
                    }
                } else if ((ushort)(foundPos[1] / 32) < y) {
                    if (b3 == Block.water || b3 == Block.waterstill || b3 == Block.lava || b3 == Block.lavastill) {
                        pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
                    }
                }*/
            };
            moveTimer.Start();
        }
예제 #22
0
파일: Window.cs 프로젝트: Jack1312/Evolve
 //Set's picbox width/height, chooses, form or picbox in console
 private void switcherMap(Level level)
 {
     if (level.width < 256 && level.height < 256)
     {
         map1.Size = new System.Drawing.Size(256, 256);
         if (level.height > level.width && Math.Max(level.height, level.width) < 256)
         {
             map1.Size = new System.Drawing.Size(256 / (level.height / level.width), 256);
         }
         else if (level.height < level.width && Math.Max(level.height, level.width) < 256)
         {
             map1.Size = new System.Drawing.Size(256, 256 / (level.width / level.height));
         }
         if (mapStyle.SelectedItem.ToString() == "Standart" || mapStyle.SelectedItem.ToString() == "Height mask")
         {
             map1.Image = GenerateMap(level);
             map1.Refresh();
         }
         else
         {
             map1.Image = GenerateMap(level, ushort.Parse(txtLayer.Text.ToString()));
             map1.Refresh();
         }
     }
     else
     {
         if (mapStyle.SelectedItem.ToString() == "Standart" || mapStyle.SelectedItem.ToString() == "Height mask")
         {
             mapFormGen();
         }
         else
         {
             mapFormGen(ushort.Parse(txtLayer.Text.ToString()));
         }
     }
 }
예제 #23
0
파일: Server.cs 프로젝트: Jack1312/Evolve
        public void Start()
        {
            shuttingDown = false;
            Log("Starting Server");

            if (!Directory.Exists("properties")) Directory.CreateDirectory("properties");
            if (!Directory.Exists("bots")) Directory.CreateDirectory("bots");
            if (!Directory.Exists("text")) Directory.CreateDirectory("text");

            if (!Directory.Exists("extra")) Directory.CreateDirectory("extra");
            if (!Directory.Exists("extra/undo")) Directory.CreateDirectory("extra/undo");
            if (!Directory.Exists("extra/undoPrevious")) Directory.CreateDirectory("extra/undoPrevious");
            if (!Directory.Exists("extra/copy/")) { Directory.CreateDirectory("extra/copy/"); }
            if (!Directory.Exists("extra/copyBackup/")) { Directory.CreateDirectory("extra/copyBackup/"); }
            if (!Directory.Exists("extra/textures/")) { Directory.CreateDirectory("extra/textures/"); }

            try
            {
                if (File.Exists("server.properties")) File.Move("server.properties", "properties/server.properties");
                if (File.Exists("rules.txt")) File.Move("rules.txt", "text/rules.txt");
                if (File.Exists("welcome.txt")) File.Move("welcome.txt", "text/welcome.txt");
                if (File.Exists("messages.txt")) File.Move("messages.txt", "text/messages.txt");
                if (File.Exists("externalurl.txt")) File.Move("externalurl.txt", "text/externalurl.txt");
                if (File.Exists("autoload.txt")) File.Move("autoload.txt", "text/autoload.txt");
                if (File.Exists("IRC_Controllers.txt")) File.Move("IRC_Controllers.txt", "ranks/IRC_Controllers.txt");
                if (Server.useWhitelist) if (File.Exists("whitelist.txt")) File.Move("whitelist.txt", "ranks/whitelist.txt");
            } catch { }

            Properties.Load("properties/server.properties");
            Updater.Load("properties/update.properties");

            Group.InitAll();
            Command.InitAll();
            GrpCommands.fillRanks();
            Block.SetBlocks();
            Awards.Load();

            if (File.Exists("text/emotelist.txt"))
            {
                foreach (string s in File.ReadAllLines("text/emotelist.txt"))
                {
                    Player.emoteList.Add(s);
                }
            }
            else
            {
                File.Create("text/emotelist.txt");
            }

            timeOnline = DateTime.Now;

            try
            {
                MySQL.executeQuery("CREATE DATABASE if not exists `" + MySQLDatabaseName + "`", true);
            }
            catch (Exception e)
            {
                Server.s.Log("MySQL settings have not been set! Please reference the MySQL_Setup.txt file on setting up MySQL!");
                Server.ErrorLog(e);
                //process.Kill();
                return;
            }

            MySQL.executeQuery("CREATE TABLE if not exists Players (ID MEDIUMINT not null auto_increment, Name VARCHAR(20), IP CHAR(15), FirstLogin DATETIME, LastLogin DATETIME, totalLogin MEDIUMINT, Title CHAR(20), TotalDeaths SMALLINT, Money MEDIUMINT UNSIGNED, totalBlocks BIGINT, totalKicked MEDIUMINT, color VARCHAR(6), title_color VARCHAR(6), PRIMARY KEY (ID));");

            // Check if the color column exists.
            DataTable colorExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='color'");

            if (colorExists.Rows.Count == 0)
            {
                MySQL.executeQuery("ALTER TABLE Players ADD COLUMN color VARCHAR(6) AFTER totalKicked");
            }
            colorExists.Dispose();

            // Check if the title color column exists.
            DataTable tcolorExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='title_color'");

            if (tcolorExists.Rows.Count == 0)
            {
                MySQL.executeQuery("ALTER TABLE Players ADD COLUMN title_color VARCHAR(6) AFTER color");
            }
            tcolorExists.Dispose();

            if (levels != null)
                foreach (Level l in levels) { l.Unload(); }
            ml.Queue(delegate
            {
                try
                {
                    levels = new List<Level>(Server.maps);
                    MapGen = new MapGenerator();

                    Random random = new Random();

                    if (File.Exists("levels/" + Server.level + ".lvl"))
                    {
                        mainLevel = Level.Load(Server.level);
                        mainLevel.unload = false;
                        if (mainLevel == null)
                        {
                            if (File.Exists("levels/" + Server.level + ".lvl.backup"))
                            {
                                Log("Attempting to load backup.");
                                File.Copy("levels/" + Server.level + ".lvl.backup", "levels/" + Server.level + ".lvl", true);
                                mainLevel = Level.Load(Server.level);
                                if (mainLevel == null)
                                {
                                    Log("BACKUP FAILED!");
                                    Console.ReadLine(); return;
                                }
                            }
                            else
                            {
                                Log("mainlevel not found");
                                mainLevel = new Level(Server.level, 128, 64, 128, "flat");

                                mainLevel.permissionvisit = LevelPermission.Guest;
                                mainLevel.permissionbuild = LevelPermission.Guest;
                                mainLevel.Save();
                            }
                        }
                    }
                    else
                    {
                        Log("mainlevel not found");
                        mainLevel = new Level(Server.level, 128, 64, 128, "flat");

                        mainLevel.permissionvisit = LevelPermission.Guest;
                        mainLevel.permissionbuild = LevelPermission.Guest;
                        mainLevel.Save();
                    }
                    addLevel(mainLevel);
                    mainLevel.physThread.Start();
                } catch (Exception e) { Server.ErrorLog(e); }
            });

            ml.Queue(delegate
            {
                bannedIP = PlayerList.Load("banned-ip.txt", null);
                ircControllers = PlayerList.Load("IRC_Controllers.txt", null);

                foreach (Group grp in Group.GroupList)
                    grp.playerList = PlayerList.Load(grp.fileName, grp);
                if (Server.useWhitelist)
                    whiteList = PlayerList.Load("whitelist.txt", null);
            });

            ml.Queue(delegate
            {
                if (File.Exists("text/autoload.txt"))
                {
                    try
                    {
                        string[] lines = File.ReadAllLines("text/autoload.txt");
                        foreach (string line in lines)
                        {
                            //int temp = 0;
                            string _line = line.Trim();
                            try
                            {
                                if (_line == "") { continue; }
                                if (_line[0] == '#') { continue; }
                                int index = _line.IndexOf("=");

                                string key = _line.Split('=')[0].Trim();
                                string value;
                                try
                                {
                                    value = _line.Split('=')[1].Trim();
                                }
                                catch
                                {
                                    value = "0";
                                }

                                if (!key.Equals(mainLevel.name))
                                {
                                    Command.all.Find("load").Use(null, key + " " + value);
                                    Level l = Level.FindExact(key);
                                }
                                else
                                {
                                    try
                                    {
                                        int temp = int.Parse(value);
                                        if (temp >= 0 && temp <= 3)
                                        {
                                            mainLevel.setPhysics(temp);
                                        }
                                    }
                                    catch
                                    {
                                        Server.s.Log("Physics variable invalid");
                                    }
                                }

                            }
                            catch
                            {
                                Server.s.Log(_line + " failed.");
                            }
                        }
                    }
                    catch
                    {
                        Server.s.Log("autoload.txt error");
                    }
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                else
                {
                    Log("autoload.txt does not exist");
                }
            });

            ml.Queue(delegate
            {
                Log("Creating listening socket on port " + Server.port + "... ");
                if (Setup())
                {
                    try
                    {
                        if (!File.Exists("Meebey.SmartIrc4net.dll"))
                        {
                            s.Log("You are missing Meebey.SmartIrc4net.dll, let me download that for you...");
                            using (WebClient WC = new WebClient())
                            {
                                WC.DownloadFile("http://www.evolvemc.net/Meebey.SmartIrc4net.dll", "Meebey.SmartIrc4net.dll");
                            }
                        }
                    }
                    catch { s.Log("Failed to download Meebey.SmartIrc4net.dll."); }
                    bool foundone = false;
                    try
                    {
                        if (!File.Exists("extra/textures/terrain2.png"))
                        {
                            if (foundone == false)
                            {
                                s.Log("Downloading necessary textures for map viewer...");
                            }
                            foundone = true;
                            using (WebClient WC = new WebClient())
                            {
                                WC.DownloadFile("http://www.evolvemc.net/terrain2.png", "extra/textures/terrain2.png");
                            }
                        }
                        if (!File.Exists("extra/textures/terrain4.png"))
                        {
                            if (foundone == false)
                            {
                                s.Log("Downloading necessary textures for map viewer...");
                            }
                            foundone = true;
                            using (WebClient WC = new WebClient())
                            {
                                WC.DownloadFile("http://www.evolvemc.net/terrain4.png", "extra/textures/terrain4.png");
                            }
                        }
                        if (!File.Exists("extra/textures/terrain8.png"))
                        {
                            if (foundone == false)
                            {
                                s.Log("Downloading necessary textures for map viewer...");
                            }
                            foundone = true;
                            using (WebClient WC = new WebClient())
                            {
                                WC.DownloadFile("http://www.evolvemc.net/terrain8.png", "extra/textures/terrain8.png");
                            }
                        }
                        if (!File.Exists("extra/textures/terrain16.png"))
                        {
                            if (foundone == false)
                            {
                                s.Log("Downloading necessary textures for map viewer...");
                            }
                            foundone = true;
                            using (WebClient WC = new WebClient())
                            {
                                WC.DownloadFile("http://www.evolvemc.net/terrain16.png", "extra/textures/terrain16.png");
                            }
                        }
                    }
                    catch
                    {
                        s.Log("Failed to download map viewer textures.");
                        s.Log("Please notify the Evolve Team!");
                    }
                    if (foundone)
                    {
                        s.Log("Successfully downloaded textures for map viewer.");
                    }
                    s.Log("Done");
                }
                else
                {
                    s.Log("Could not create socket connection.  Shutting down.");
                    return;
                }
            });

            ml.Queue(delegate
            {
                updateTimer.Elapsed += delegate
                {
                    Player.GlobalUpdate();
                    PlayerBot.GlobalUpdatePosition();
                };

                updateTimer.Start();
            });

            // Heartbeat code here:

            ml.Queue(delegate
            {
                try
                {
                    Heartbeat.Init();
                }
                catch (Exception e)
                {
                    Server.ErrorLog(e);
                }
            });

            // END Heartbeat code

            /*
            Thread processThread = new Thread(new ThreadStart(delegate
            {
                try
                {
                    PCCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
                    ProcessCounter = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName);
                    PCCounter.BeginInit();
                    ProcessCounter.BeginInit();
                    PCCounter.NextValue();
                    ProcessCounter.NextValue();
                }
                catch { }
            }));
            processThread.Start();
            */

            ml.Queue(delegate
            {
                messageTimer.Elapsed += delegate
                {
                    RandomMessage();
                };
                messageTimer.Start();

                process = System.Diagnostics.Process.GetCurrentProcess();

                if (File.Exists("text/messages.txt"))
                {
                    StreamReader r = File.OpenText("text/messages.txt");
                    while (!r.EndOfStream)
                        messages.Add(r.ReadLine());
                    r.Dispose();
                }
                else File.Create("text/messages.txt").Close();

                if (Server.irc)
                {
                    new IRCBot();
                }

                //      string CheckName = "FROSTEDBUTTS";

                //       if (Server.name.IndexOf(CheckName.ToLower())!= -1){ Server.s.Log("FROSTEDBUTTS DETECTED");}
                new AutoSaver(Server.backupInterval);     //2 and a half mins

                blockThread = new Thread(new ThreadStart(delegate
                {
                    while (true)
                    {
                        //Thread.Sleep(blockInterval * 1000);
                        foreach (Level l in levels)
                        {
                            l.saveChanges();
                        }
                    }
                }));
                blockThread.Start();

                locationChecker = new Thread(new ThreadStart(delegate
                {
                    while (true)
                    {
                        //Thread.Sleep(3);
                        for (int i = 0; i < Player.players.Count; i++)
                        {
                            try
                            {
                                Player p = Player.players[i];

                                if (p.frozen)
                                {
                                    unchecked { p.SendPos((byte)-1, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]); } continue;
                                }
                                else if (p.following != "")
                                {
                                    Player who = Player.Find(p.following);
                                    if (who == null || who.level != p.level)
                                    {
                                        p.following = "";
                                        if (!p.canBuild)
                                        {
                                            p.canBuild = true;
                                        }
                                        if (who != null && who.possess == p.name)
                                        {
                                            who.possess = "";
                                        }
                                        continue;
                                    }
                                    if (p.canBuild)
                                    {
                                        unchecked { p.SendPos((byte)-1, who.pos[0], (ushort)(who.pos[1] - 16), who.pos[2], who.rot[0], who.rot[1]); }
                                    }
                                    else
                                    {
                                        unchecked { p.SendPos((byte)-1, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); }
                                    }
                                } else if (p.possess != "") {
                                    Player who = Player.Find(p.possess);
                                    if (who == null || who.level != p.level)
                                        p.possess = "";
                                }

                                ushort x = (ushort)(p.pos[0] / 32);
                                ushort y = (ushort)(p.pos[1] / 32);
                                ushort z = (ushort)(p.pos[2] / 32);

                                if (p.level.Death)
                                    p.RealDeath(x, y, z);
                                p.CheckBlock(x, y, z);

                                p.oldBlock = (ushort)(x + y + z);
                            } catch (Exception e) { Server.ErrorLog(e); }
                        }
                    }
                }));

                locationChecker.Start();

                Log("Finished setting up server");
            });
        }
예제 #24
0
        //applys the average filter
        void FilterAverage(Level Lvl)
        {
            Server.s.Log("Applying average filtering");

            float[] filtered = new float[terrain.Length];

            for (int bb = 0; bb < terrain.Length; bb++)
            {
                ushort x = (ushort)(bb % Lvl.width);
                ushort y = (ushort)(bb / Lvl.width);
                filtered[bb] = GetAverage9(x, y, Lvl);
            }

            for (int bb = 0; bb < terrain.Length; bb++)
            {
                terrain[bb] = filtered[bb];
            }
        }
예제 #25
0
파일: Window.cs 프로젝트: Jack1312/Evolve
 //generates map for Layer
 private Bitmap GenerateMap(Level lvl, ushort layer)
 {
     int pixels;
     if (Math.Max(lvl.height, lvl.width) < 256)
     {
         pixels = 256 / lvl.height;
         if (lvl.height > lvl.width)
         {
             pixels = 256 / lvl.height;
         }
         else if (lvl.height < lvl.width)
         {
             pixels = 256 / lvl.width;
         }
     }
     else
     {
         pixels = 2;
     }
     if (pixels > 16) { pixels = 16; }
     Bitmap bm = new Bitmap("extra/textures/terrain" + pixels + ".png");
     Bitmap test = new Bitmap(lvl.width * pixels, lvl.height * pixels);
     Graphics g = Graphics.FromImage(test);
     byte type;
     Bitmap[] textures = new Bitmap[50];
     for (int i = 0; i < 50; i++)
     {
         textures[i] = bm.Clone(new Rectangle(pixels * i, 0, pixels, pixels), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     }
     for (ushort x = 0; x < lvl.width; x++)
     {
         for (ushort z = 0; z < lvl.height; z++)
         {
             if (layer > lvl.depth - 1) { layer = (ushort)(lvl.depth - 1); }
             type = lvl.GetTile(x, (ushort)(layer - 1), z);
             type = Block.Convert(type);
             g.DrawImage(textures[type], x * pixels, z * pixels);
         }
     }
     g.Dispose();
     return test;
 }
예제 #26
0
파일: CmdNewLvl.cs 프로젝트: dekema2/MCDek
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }

            string[] parameters = message.Split(' '); // Grab the parameters from the player's message
            if (parameters.Length == 5) // make sure there are 5 params
            {
                switch (parameters[4])
                {
                    case "flat":
                    case "pixel":
                    case "island":
                    case "mountains":
                    case "ocean":
                    case "forest":
                    case "desert":
                        break;

                    default:
                        Player.SendMessage(p, "Valid types: island, mountains, forest, ocean, flat, pixel, desert"); return;
                }

                string name = parameters[0].ToLower();
                ushort x = 1, y = 1, z = 1;
                try
                {
                    x = Convert.ToUInt16(parameters[1]);
                    y = Convert.ToUInt16(parameters[2]);
                    z = Convert.ToUInt16(parameters[3]);
                }
                catch { Player.SendMessage(p, "Invalid dimensions."); return; }
                if (!isGood(x)) { Player.SendMessage(p, x + " is not a good dimension! Use a power of 2 next time."); }
                if (!isGood(y)) { Player.SendMessage(p, y + " is not a good dimension! Use a power of 2 next time."); }
                if (!isGood(z)) { Player.SendMessage(p, z + " is not a good dimension! Use a power of 2 next time."); }

                if (!Player.ValidName(name)) { Player.SendMessage(p, "Invalid name!"); return; }

                try
                {
                    if (p != null)
                    if (p.group.Permission < LevelPermission.Admin)
                    {
                        if (x * y * z > 30000000) { Player.SendMessage(p, "Cannot create a map with over 30million blocks"); return; }
                    }
                    else
                    {
                        if (x * y * z > 225000000) { Player.SendMessage(p, "You cannot make a map with over 225million blocks"); return; }
                    }
                }
                catch
                {
                    Player.SendMessage(p, "An error occured");
                }

                // create a new level...
                try
                {
                    Level lvl = new Level(name, x, y, z, parameters[4]);
                    lvl.Save(true); //... and save it.
                }
                finally
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                Player.GlobalMessage("Level " + name + " created"); // The player needs some form of confirmation.
            }
            else
                Help(p);
        }
예제 #27
0
파일: Window.cs 프로젝트: Jack1312/Evolve
 private void btnGenerate_Click(object sender, EventArgs e)
 {
     if (txtMapName.Text == "")
     {
         MessageBox.Show("Please enter a map name first", "No map name entered");
     }
     else
     {
         string lvl = txtMapName.Text;
         foreach (Level l in Server.levels)
         {
             if (l.name == lvl)
             {
                 MessageBox.Show("Already exist!");
                 return;
             }
         }
         levelGenerater = new Level(lvl, ushort.Parse(x.SelectedItem.ToString()), ushort.Parse(y.SelectedItem.ToString()), ushort.Parse(z.SelectedItem.ToString()), cmbMapType.SelectedItem.ToString());
         generatorUsed = true;
         switcherMap(levelGenerater);
     }
 }
예제 #28
0
        public static ushort writeLetter(Level l, Player p, char c, ushort x, ushort y, ushort z, byte b, int directionToGo)
        {
            switch (c)
            {
                case 'A':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'B':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'C':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'D':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'E':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'F':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'G':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'H':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'I':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'J':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'K':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'L':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case 'M':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'N':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'O':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'P':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'Q':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'R':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case 'S':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'T':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'U':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'V':
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'W':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'X':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'Y':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case 'Z':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;

                case '0':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case '1':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '2':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '3':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '4':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    break;
                case '5':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '6':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '7':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '8':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '9':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;

                case ':':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case '\\':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '/':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case '.':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '!':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    break;
                case ',':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    break;
                case '\'':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case '"':
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 4), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;
                case ' ':
                    break;

                case '+':
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    break;
                case '-':
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 2), z, b);
                    break;
                case '_':
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 0), z, b);
                    break;
                case '=':
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    placeBlock(l, p, x, (ushort)(y + 1), z, b);
                    placeBlock(l, p, x, (ushort)(y + 3), z, b);
                    break;

                default:
                    Player.SendMessage(p, "\"" + c + "\" is currently not supported. Space left");
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    if (directionToGo == 0) x++; else if (directionToGo == 1) x--; else if (directionToGo == 2) z++; else z--;
                    break;
            }

            if (directionToGo == 0) return (ushort)(x + 2);
            else if (directionToGo == 1) return (ushort)(x - 2);
            else if (directionToGo == 2) return (ushort)(z + 2);
            else return (ushort)(z - 2);
        }
예제 #29
0
파일: Window.cs 프로젝트: Jack1312/Evolve
        private void btnShow_Click(object sender, EventArgs e)
        {
            string lvlName;
            try
            {
                lvlName = LoadedMaps.SelectedItem.ToString();
            }
            catch
            {
                return;
            }

            generatorUsed = false;
            foreach (Level l in Server.levels)
            {
                if (l.name == lvlName) { levelExisted = l; }
            }
            if (levelExisted != null)
            {
                switcherMap(levelExisted);
            }
            else { return; }
        }
예제 #30
0
        //
        void AddTree(Level Lvl, ushort x, ushort y, ushort z, Random Rand)
        {
            byte height = (byte)Rand.Next(5, 8);
            for (ushort yy = 0; yy < height; yy++) Lvl.skipChange(x, (ushort)(y + yy), z, Block.trunk);

            short top = (short)(height - Rand.Next(2, 4));

            for (short xx = (short)-top; xx <= top; ++xx)
            {
                for (short yy = (short)-top; yy <= top; ++yy)
                {
                    for (short zz = (short)-top; zz <= top; ++zz)
                    {
                        short Dist = (short)(Math.Sqrt(xx * xx + yy * yy + zz * zz));
                        if (Dist < top + 1)
                        {
                            if (Rand.Next((int)(Dist)) < 2)
                            {
                                try
                                {
                                    Lvl.skipChange((ushort)(x + xx), (ushort)(y + yy + height), (ushort)(z + zz), Block.leaf);
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
        }