Ejemplo n.º 1
0
        /// <summary>
        /// The constructor for worldManager.
        /// </summary>
        /// <param name="worldOptions">The options for the world configuration.</param>
        public WorldManager(WorldOptions worldOptions)
        {
            WorldOptions = worldOptions;
            ChunkMap     = new Chunk[WorldOptions.WorldChunkWidth, WorldOptions.WorldChunkHeight];
            ChunkIndex   = new Dictionary <string, Chunk>();

            _worldGenerator = worldOptions.WorldGenerator?.Invoke(WorldOptions);
        }
Ejemplo n.º 2
0
 public void OnValidate()
 {
     P_Options = physicsoptions;
     G_Options = gameOptions;
     S_Options = scoreOptions;
     I_Options = inputOptions;
     M_Options = menuOptions;
     W_Options = worldOptions;
 }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------
        // Reads a char array mario world along with some worldoptions and stores
        // it in a buffer.
        //    M: char[,] the world to be read in
        //    W: char[,] reference to the buffer to store the world
        //    Opt: WorldOptions options with which to apply to the world
        //-------------------------------------------------------------------
        public static void ReadWorld(char[,] M, ref char[,] W, WorldOptions Opt)
        {
            //Console.WriteLine("Reading the world");
            //MapBuffer M;
            int x;

            //Move(Opt, Buffers.Options, Buffers.Options.SizeOf());
            Buffers.Options = Opt;

            //M = Map;
            //FillChar(W, W.size(), ' ');
            for (int i = 0; i < W.GetLength(0); i++)
            {
                for (int j = 0; j < W.GetLength(1); j++)
                {
                    W[i, j] = ' ';
                }
            }

            for (int i = 0; i < EX; i++)
            {
                for (int j = 0; j < NV + EY2 + EY1; j++)
                {
                    W[i, j] = '@';
                }
            }

            x = 0;

            while (M[x, 0] != (0) && (x < MaxWorldSize))
            {
                for (int i = 0; i < NV; i++)
                {
                    W[x, NV - i] = (char)M[x, i];
                }
                W[x, W.GetLength(1) - EY1] = (char)(0);
                for (int i = 0; i < EY2 + EY1; i++)
                {
                    W[x, NV + i] = W[x, NV - 1];
                }
                x++;
            }

            Buffers.Options.XSize = x;
            for (int i = x; i < x + EX; i++)
            {
                for (int j = 0; j < (NV + EY2 + EY1); j++)
                {
                    W[i, j] = '@';
                }
            }
        }
Ejemplo n.º 4
0
        public FakeCustomWorldBootstrap(
            List <CustomWorldBootstrap.WorldOption> worldOptions = null,
            bool createDefaultWorld = true,
            string defaultWorldName = "")
        {
            if (worldOptions != null)
            {
                WorldOptions.AddRange(worldOptions);
            }

            CreateDefaultWorld = createDefaultWorld;
            DefaultWorldName   = defaultWorldName;
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------
        // Will change the WorldOptions of a single world so that the world
        // does not change.
        //-------------------------------------------------------------------
        public static void Swap()
        {
            WorldOptions TempOptions;
            byte         C;

            TempOptions = Options;
            Options     = SaveOptions;
            SaveOptions = TempOptions;
            for (int i = EX; i < MaxWorldSize - 1 + EX; i++)
            {
                for (int j = EY1; j < NV - 1 + EY2; j++)
                {
                    C = (byte)WorldMap[i, j];
                    WorldMap[i, j]     = SaveWorldMap[i, j];
                    SaveWorldMap[i, j] = (char)C;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructs a simulation
        /// </summary>
        /// <param name="gameMode"></param>
        /// <param name="worldOptions">Given world options that is given to the world manager</param>
        /// <param name="tickSpeed">A optional parameter used for indicating the ticks per second. (20tps is the default)</param>
        public Simulation(SimulationGameMode gameMode, WorldOptions worldOptions, int tickSpeed = 20)
        {
            _lock            = new object();
            GameMode         = gameMode;
            _state           = SimulationState.Shutdown;
            _tickSpeed       = 1000 / tickSpeed;
            _random          = new Random();
            Tick             = 0;
            ConnectedClients = 0;

            World = new WorldManager(worldOptions);

            SimulationDistance = 3;

            //entities
            _entitiesIndex       = new Dictionary <string, SimulationEntity>();
            _playerEntitiesIndex = new Dictionary <string, SimulationEntity>();

            TileComponentManager.LoadTileComponents();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Generates a remote world.
 /// </summary>
 /// <param name="options">Options used to generate the world.</param>
 public RemoteWorld(WorldOptions options) : base(options)
 {
 }
Ejemplo n.º 8
0
 /// <summary>
 /// The generator of the world.
 /// </summary>
 /// <param name="options">The options used for the world generation.</param>
 protected WorldGenerator(WorldOptions options)
 {
     WorldOptions = options;
 }
Ejemplo n.º 9
0
 public TileGenerator(WorldOptions options)
 {
     this._options = options;
 }
Ejemplo n.º 10
0
 //-------------------------------------------------------------------
 // Will change the WorldOptions of a single world so that the world
 // does not change.
 //-------------------------------------------------------------------
 public static void Swap()
 {
     WorldOptions TempOptions;
      byte C;
      TempOptions = Options;
      Options = SaveOptions;
      SaveOptions = TempOptions;
      for (int i = EX; i < MaxWorldSize - 1 + EX; i++)
       	   for (int j = EY1; j < NV -1 + EY2; j++)
       	   {
       		   C = (byte)WorldMap[i,j];
        WorldMap[i, j] = SaveWorldMap[i, j];
       		   SaveWorldMap[i,j] = (char)C;
       	   }
 }
Ejemplo n.º 11
0
        //-------------------------------------------------------------------
        // Reads a char array mario world along with some worldoptions and stores
        // it in a buffer.
        //    M: char[,] the world to be read in
        //    W: char[,] reference to the buffer to store the world
        //    Opt: WorldOptions options with which to apply to the world
        //-------------------------------------------------------------------
        public static void ReadWorld(char[,] M, ref char[,] W, WorldOptions Opt)
        {
            //Console.WriteLine("Reading the world");
             //MapBuffer M;
             int x;

             //Move(Opt, Buffers.Options, Buffers.Options.SizeOf());
             Buffers.Options = Opt;

             //M = Map;
             //FillChar(W, W.size(), ' ');
             for (int i = 0; i < W.GetLength(0); i++)
            for (int j = 0; j < W.GetLength(1); j++)
               W[i,j] = ' ';

             for (int i = 0; i < EX; i++)
              	   for (int j = 0; j < NV + EY2 + EY1; j++)
              		   W[i,j] = '@';

             x = 0;

             while (M[x,0] != (0) && (x < MaxWorldSize))
             {
              	   for (int i = 0; i < NV; i++)
               W[x, NV - i] = (char)M[x, i];
              	   W[x, W.GetLength(1) - EY1] = (char)(0);
            for (int i = 0; i < EY2 + EY1; i++)
               W[x, NV + i] = W[x, NV - 1];
              	   x++;
             }

             Buffers.Options.XSize = x;
             for (int i = x; i < x + EX; i++)
              	   for (int j = 0; j < (NV + EY2 + EY1); j++)
              		   W[i, j] = '@';
        }