Ejemplo n.º 1
0
        public LifeWorld(Camera camera, String file, Game game)
            : base(camera)
        {
            // try
            //{
                //StreamReader read = new StreamReader(file);
                String path = string.Format("Content/lifeworld.txt");
                Stream fileStream = TitleContainer.OpenStream(path);

                StreamReader read = new StreamReader(fileStream);
                string line = read.ReadLine();
                char[] setMatrix = line.ToCharArray();
                char[] chars;

                /*String waste = setMatrix[0].ToString();

                dimension = (setMatrix[0] - 48);*/
                int count = 0;

                int.TryParse(line, out dimension);

                terrainMap = new int[dimension, dimension];
                line = read.ReadLine();
                while (line != null)
                {

                    chars = line.ToCharArray();

                    for (int i = 0; i < chars.Length; i++)
                    {
                        if (i < dimension)
                        {
                            terrainMap[count, i] = (chars[i] - 48);
                        }
                    }

                    line = read.ReadLine();
                    count++;
                }

                read.Close();
               // }

              /*  catch (FileNotFoundException e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }

            catch (DirectoryNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }*/
        }
Ejemplo n.º 2
0
        public GameWorld(Camera camera)
        {
            mCamera      = camera;

            mGameObjects = new List<GameObject>();
            mAddList     = new List<GameObject>();
            mRemoveList  = new List<GameObject>();

            mPhysicsWorld = new World(new Vector2(0, 0));
            mDebugView    = new DebugViewXNA(mPhysicsWorld);

            mAwake = false;
            mMaxFadeCountdown = 3f;
            mFadeCountdown = 0;

            mMonsterDeathVolume = .25f;
        }
Ejemplo n.º 3
0
        public Game1()
        {
            mGraphics = new GraphicsDeviceManager(this);
            mGraphics.PreferredBackBufferWidth  = 800;
            mGraphics.PreferredBackBufferHeight = 600;
            Content.RootDirectory = "Content";

            mCamera = new Camera(
                null, new Vector2(0, 0),
                new Vector2(mGraphics.PreferredBackBufferWidth, mGraphics.PreferredBackBufferHeight));

            mLifeWorld  = new LifeWorld(mCamera, "Content/lifeworld.txt", this);
            //puzzleChunks = graveyardMaker.generatePuzzleSections(8);
            mDeathWorld = new DeathWorld(mCamera);

            //
            mCurrentWorld = mLifeWorld;
            mDesiredWorld = mCurrentWorld;

            //FarseerPhysics.Settings.ContinuousPhysics = false;
        }
Ejemplo n.º 4
0
        public DeathWorld(Camera camera)
            : base(camera)
        {
            puzzleChunks = new List<int[,]>();
            graveyardMaker = new PuzzleGenerator();
            graveyardMap = new int[16, 16];
            puzzleChunks = graveyardMaker.generatePuzzleSections(32);

            List<int> selections = new List<int>();
            List<int[,]> initialMap = new List<int[,]>();
            for (int i = 0; i < 16; i++)
            {
                int temp = deathRand.Next(1, 32);
                selections.Add(temp);
            }

            foreach (int s in selections)
            {
                initialMap.Add(puzzleChunks.ElementAt(s-1));
            }

            for (int j = 0; j < 16; j++)
            {
                int[,] temp = initialMap.ElementAt(j);
                switch (j)
                {
                    case 0:
                        for (int k = 0; k < 4; k++)
                        {
                            for (int l = 0; l < 4; l++)
                            {
                                graveyardMap[k,l] = temp[k,l];
                            }

                        }
                        break;
                    case 1:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m+4,n] = temp[m,n];
                            }

                        }
                        break;
                    case 2:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m+8,n] = temp[m,n];
                            }

                        }
                        break;
                    case 3:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m+12,n] = temp[m,n];
                            }

                        }
                        break;
                    case 4:
                        for (int k = 0; k < 4; k++)
                        {
                            for (int l = 0; l < 4; l++)
                            {
                                graveyardMap[k, l+4] = temp[k, l];
                            }

                        }
                        break;
                    case 5:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 4, n+4] = temp[m, n];
                            }

                        }
                        break;
                    case 6:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m+8, n + 4] = temp[m, n];
                            }

                        }
                        break;
                    case 7:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 12, n + 4] = temp[m, n];
                            }

                        }
                        break;
                    case 8:
                        for (int k = 0; k < 4; k++)
                        {
                            for (int l = 0; l < 4; l++)
                            {
                                graveyardMap[k, l+8] = temp[k, l];
                            }

                        }
                        break;
                    case 9:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 4, n+8] = temp[m, n];
                            }

                        }
                        break;
                    case 10:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 8, n+8] = temp[m, n];
                            }

                        }
                        break;
                    case 11:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 12, n+8] = temp[m, n];
                            }

                        }
                        break;
                    case 12:
                        for (int k = 0; k < 4; k++)
                        {
                            for (int l = 0; l < 4; l++)
                            {
                                graveyardMap[k, l + 12] = temp[k, l];
                            }

                        }
                        break;
                    case 13:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 4, n + 12] = temp[m, n];
                            }

                        }
                        break;
                    case 14:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 8, n + 12] = temp[m, n];
                            }

                        }
                        break;
                    case 15:
                        for (int m = 0; m < 4; m++)
                        {
                            for (int n = 0; n < 4; n++)
                            {
                                graveyardMap[m + 12, n + 12] = temp[m, n];
                            }

                        }
                        break;

                }

            }
        }