예제 #1
0
        internal PhysicsHandler(Level l, bool enabled)
        {
            Level = l;
            IsEnabled = enabled;

            new Thread(TickTimer).Start();
        }
예제 #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;
 }
예제 #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;
 }
예제 #4
0
        public LevelHandler()
        {
            Lobby = new Level("Lobby", true);

            LevelSaveCheckTimer.Elapsed += delegate
            {
                LevelSaveCheckTimer.Interval = 15000;
                LevelSaveUpdateCheck();
            };
            LevelSaveCheckTimer.Start();
        }
예제 #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);
 }
예제 #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);
 }
예제 #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);
                 }
             }
         }
     }
 }
예제 #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);
 }
예제 #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();
                }
            }
        }
예제 #10
0
 public virtual void OnPlace(Player p, Level level, int pos)
 {
 }
예제 #11
0
 public virtual void Physics(Level level, int pos)
 {
 }
예제 #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);
 }
예제 #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!");
        }
예제 #14
0
 internal void AddMapData(Level l)
 {
     for (int index = 0; index < l.BlockData.Length; index++)
     {
         byte t = l.BlockData[index];
         Bytes.Add(t);
     }
 }
예제 #15
0
        internal void SwitchMap(Level l)
        {
            OldLevel = Level;
            Level = l;

            SendMap();
        }
예제 #16
0
 public virtual void OnBreak(Player p, Level level, int pos)
 {
 }
예제 #17
0
 public abstract void Generate(Level lvl);
예제 #18
0
 public FlatGrassGenerator(Level lvl)
 {
     Generate(lvl);
 }