Ejemplo n.º 1
0
        internal PhysicsHandler(Level l, bool enabled)
        {
            Level = l;
            IsEnabled = enabled;

            new Thread(TickTimer).Start();
        }
Ejemplo n.º 2
0
 public BlockPos(ushort x, ushort y, ushort z, Level l)
 {
     X = x;
     Y = y;
     Z = z;
     Level = l;
     Index = l.PosToInt(X, Y, Z);
     InBounds = !l.NotInBounds(X, Y, Z);
     BlockType = !InBounds ? (byte)255 : l.GetTile(Index);
     BlockMCType = (MCBlocks)BlockType;
 }
Ejemplo n.º 3
0
 public BlockPos(int x, int y, int z, Level l)
 {
     X = (ushort)x;
     Y = (ushort)y;
     Z = (ushort)z;
     Level = l;
     Index = l.PosToInt(X, Y, Z);
     InBounds = !l.NotInBounds(X, Y, Z);
     BlockType = !InBounds ? (byte)255 : l.GetTile(Index);
     BlockMCType = (MCBlocks)BlockType;
 }
Ejemplo n.º 4
0
        public LevelHandler()
        {
            Lobby = new Level("Lobby", true);

            LevelSaveCheckTimer.Elapsed += delegate
            {
                LevelSaveCheckTimer.Interval = 15000;
                LevelSaveUpdateCheck();
            };
            LevelSaveCheckTimer.Start();
        }
Ejemplo n.º 5
0
 public BlockPos(int x, int y, int z, Level l)
 {
     Stopwatch sw = Stopwatch.StartNew();
     X = (ushort)x;
     Y = (ushort)y;
     Z = (ushort)z;
     Level = l;
     Index = l.PosToInt(X, Y, Z);
     InBounds = !l.NotInBounds(X, Y, Z);
     BlockType = !InBounds ? (byte)255 : l.GetTile(Index);
     BlockMCType = (MCBlocks)BlockType;
     Level.BlockPosCreationAverager.Add(sw.ElapsedTicks);
 }
Ejemplo n.º 6
0
 public BlockPos(ushort x, ushort y, ushort z, int pos, Level l)
 {
     Stopwatch sw = Stopwatch.StartNew();
     X = x;
     Y = y;
     Z = z;
     Level = l;
     Index = pos;
     InBounds = !l.NotInBounds(X, Y, Z);
     BlockType = !InBounds ? (byte)255 : l.GetTile(Index);
     BlockMCType = (MCBlocks)BlockType;
     Level.BlockPosCreationAverager.Add(sw.ElapsedTicks);
 }
Ejemplo n.º 7
0
 public override void Generate(Level lvl)
 {
     var half = (ushort)(lvl.SizeY / 2);
     for (ushort x = 0; x < lvl.SizeX; ++x)
     {
         for (ushort z = 0; z < lvl.SizeZ; ++z)
         {
             for (ushort y = 0; y < lvl.SizeY; ++y)
             {
                 if (y != half)
                 {
                     lvl.SetTile(x, y, z, (byte)((y >= half) ? MCBlocks.Air : MCBlocks.Dirt));
                 }
                 else
                 {
                     lvl.SetTile(x, y, z, (byte)MCBlocks.Grass);
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// This method adds a byte to the Otherdata dictionary for physics
 /// This method will clear out any existing otherdata for the block position
 /// </summary>
 /// <param name="level">The level your working with</param>
 /// <param name="pos">The Block position index in the level block data array</param>
 /// <param name="value">The "OtherData" value to set for this block.</param>
 public void AddOtherData(Level level, int pos, byte value)
 {
     RemoveOtherData(level, pos);
     level.Physics.OtherData.Add(pos, value);
 }
Ejemplo n.º 9
0
        public override void PlayerUse(Player p, string[] parameters, string fullCommand)
        {
            if (parameters.Length == 0)
            {
                PlayerHelp(p);
                return;
            }

            if (parameters[0].Equals("create", StringComparison.OrdinalIgnoreCase) || parameters[0].Equals("new", StringComparison.OrdinalIgnoreCase))
            {
                if (parameters.Length == 2)
                {
                    Level lfind = Level.Find(parameters[1]);
                    if (lfind != null)
                    {
                        //Called when a player types /level create <name> or /level new <name> and the name is already used for another level
                        p.SendMessage("Level Already Exists!");
                    }
                    else
                    {
                        //Called when a player types /level create <name> or /level new <name> and the name isn't already a level
                        Level level = new Level(parameters[1], 256, 256, 256);
                    }
                }
                else if (parameters.Length == 3)
                {
                    //Called when a player types /level create <name> <type> or /level new <name> <type>
                    if (parameters[2].Equals("flatgrass", StringComparison.OrdinalIgnoreCase))
                    {
                        Level level = new Level(parameters[1], 256, 256, 256, parameters[2]);
                    }
                    else if (parameters[2].Equals("pixel", StringComparison.OrdinalIgnoreCase))
                    {
                        Level level = new Level(parameters[1], 256, 256, 256, parameters[2]);
                    }
                    else
                    {
                        //Called when a player types /level create <name> <type> or /level new <name> <type> and the type is invalid.
                        p.SendMessage("Invalid world type! Valid types are flatgrass and pixel.");
                    }
                }
                else
                {
                    //This is called when the player types /level create or /level new
                    Level level = new Level("temporary", 256, 256, 256);
                }
            }
            if (parameters[0].Equals("load", StringComparison.OrdinalIgnoreCase))
            {
                //This is called when the player types /level load
                if (parameters.Length < 2) { PlayerHelp(p); return; }
                Level level = Level.Find(parameters[1]);
                if (level != null) p.SendMessage("Level Already Loaded! found!");
                else
                {
                    new Level(parameters[1], false);
                }
            }
            if (parameters[0].Equals("unload", StringComparison.OrdinalIgnoreCase))
            {
                //This is called when the player types /level unload
                if (parameters.Length < 2) { PlayerHelp(p); return; }
                Level level = Level.Find(parameters[1]);
                if (level == null) p.SendMessage("Level not found!");
                else
                {
                    level.Unload();
                }
            }
        }
Ejemplo n.º 10
0
 public virtual void OnPlace(Player p, Level level, int pos)
 {
 }
Ejemplo n.º 11
0
 public virtual void Physics(Level level, int pos)
 {
 }
Ejemplo n.º 12
0
 /// <summary>
 /// This will remove any "OtherData" for the specified block index
 /// </summary>
 /// <param name="level">The level your working with</param>
 /// <param name="pos">The index to remove from the list</param>
 public void RemoveOtherData(Level level, int pos)
 {
     level.Physics.OtherData.Remove(pos);
 }
Ejemplo n.º 13
0
        public void SwitchMap(Level l)
        {
            Stopwatch sw = Stopwatch.StartNew();
            OldLevel = Level;
            Level = l;

            SendMap();
            sw.Stop();
            Console.WriteLine("Level sent to player in: " + sw.ElapsedMilliseconds + " ms!");
        }
Ejemplo n.º 14
0
 internal void AddMapData(Level l)
 {
     for (int index = 0; index < l.BlockData.Length; index++)
     {
         byte t = l.BlockData[index];
         Bytes.Add(t);
     }
 }
Ejemplo n.º 15
0
        internal void SwitchMap(Level l)
        {
            OldLevel = Level;
            Level = l;

            SendMap();
        }
Ejemplo n.º 16
0
 public virtual void OnBreak(Player p, Level level, int pos)
 {
 }
Ejemplo n.º 17
0
 public abstract void Generate(Level lvl);
Ejemplo n.º 18
0
 public FlatGrassGenerator(Level lvl)
 {
     Generate(lvl);
 }