상속: Asset
예제 #1
0
        /// <summary>
        /// Loads tiles from world that are contained within chunkBounds
        /// </summary>
        /// <param name="world"></param>
        /// <param name="chunkBounds"></param>
        public TerrainChunk(World world, RectangleF chunkBounds)
            : this()
        {
            //Calculate total tiles
            int totalTiles = (int)chunkBounds.Width * (int)chunkBounds.Height;

            //Loop through each tile
            for (int index = 0; index < totalTiles; index++)
            {
                //Convert index value into x and y coordinates.
                int cellX = (int)(index / chunkBounds.Height) + (int)chunkBounds.X;
                int cellY = (int)(index % chunkBounds.Height) + (int)chunkBounds.Y;

                //Load tile.
                TerrainTile tile = world.LoadTile(cellX, cellY, this);

                m_tileCount[tile.Terrain]++;

                //Insert new tile into chunk QuadTree
                m_tiles.Insert(tile);
            }

            //Assign local variables
            m_world = world;
            m_bounds = chunkBounds;
        }
예제 #2
0
        public XGMiniMap(Rectangle rectangle, World world, int tileSize)
            : base(rectangle, true)
        {
            m_world = world;
            m_tileSize = tileSize;

            Init();

            CenterTile(0, 0);
        }
예제 #3
0
        public TerrainTile(VectorID tileID, TerrainChunk chunk)
            : base(tileID)
        {
            m_chunk = chunk;

            if (chunk != null)
            {
                m_world = m_chunk.World;
            }
        }
예제 #4
0
        public WorldAdapter(PropertyGrid grid, World world)
        {
            m_parent = grid;
            m_world = world;

            Seed = world.Seed;
            WorldID = world.AssetID;
            SnowLine = world.SnowLine * 100;
            TreeLine = world.TreeLine * 100;
            ShoreLine = world.ShoreLine * 100;
            TerrainHeight = world.TerrainHeight;
            CoastLine = world.CoastLine;
        }
예제 #5
0
        //private XGListBoxItem liPerlin = new XGListBoxItem("Perlin Noise", NoiseTypes.Perlin);
        //private XGListBoxItem liSimplex = new XGListBoxItem("Simplex Noise", NoiseTypes.Simplex);
        public frmCreatePlayer(AzmythGame game)
            : base(new Rectangle(0, 0, 300, 300), true)
        {
            Game = game;
            m_viewport = game.GraphicsDevice.Viewport;

            Rectangle = new Rectangle(0, 0, m_viewport.Width, m_viewport.Height);

            m_world = new World(new VectorID(1, 1), new Random().Next(500, 9999));

            XnaGUIManager.Controls.Add(this);

            pnlMain             = new XGPanel(        new Rectangle(20, 20, 600, 600));
            pnlTitle            = new XGPanel(        new Rectangle(20, 20, 600, 600));
            lblTitle            = new XGLabel(        new Rectangle(20, 30, 50, 30), "Generate a New Adventure");
            lblPlayerName        = new XGLabel(        new Rectangle(20, 20, 100, 30), "Name:");
            txtPlayerName        = new XGTextBox(      new Rectangle(140, 20, pnlMain.Rectangle.Width- 300 , 30));
            btnRandomName       = new XGButton(       new Rectangle(pnlMain.Rectangle.Width, 20, 125, 30), "Random Name", this.btnRandomName_Clicked);
            btnCreatePlayer     = new XGButton(       new Rectangle(m_viewport.Width - 210, m_viewport.Height - 40, 200, 30), "Create World", this.btnCreatePlayer_Clicked);

            pnlMain.CanFocus = false;
            lblPlayerName.CanFocus = false;

            nameGenerator = new MarkovNameGenerator("Acalia,Aldaire,Aldebron,Vulcan,Earth,Romulus,Andor,Adair,Adara,Adriel,Alaire,Alixandra,Altair,Amara,Anatola,Arcadia,Aurelia,Aurelian,Aurelius,Avalon,Bastian,Breen,Briallan,Brielle,Briseis,Cambria,Caspian,Cassia,Cassiel,Cassiopeia,Cassius,Chaniel,Cora,Corbin,Cyprian,Dagen,Daire,Darius,Destin,Devlin,Devlyn,Drake,Drystan,Eira,Eirian,Eliron,Elysia,Eoin,Evadne,Evanth,Fineas,Finian,Fyodor,Gaerwn,Gareth,Gavriel,Ginerva,Griffin,Guinevere,Hadriel,Hannelore,Hermione,Hesperos,Iagan,Ianthe,Ignacia,Ignatius,Iseult,Isolde,Jessalyn,Kara,Katriel,Kerensa,Korbin,Kyler,Kyra,Kyrielle,Leala,Leila,Leira,Lilith,Liora,Liriene,Liron,Lucien,Lyra,Maia,Marius,Mathieu,Maylea,Meira,Mireille,Mireya,Natania,Neirin,Nerys,Nuriel,Nyfain,Nyssa,Oisin,Oleisa,Oralie,Orinthea,Orion,Orpheus,Ozara,Peregrine,Persephone,Perseus,Petronela,Phelan,Pryderi,Pyralia,Pyralis,Qadira,Quinevere,Quintessa,Raisa,Remus,Renfrew,Rhyan,Rhydderch,Riona,Saira,Saoirse,Sarai,Sarielle,Sebastian,Seraphim,Seraphina,Serian,Sirius,Sorcha,Severin,Tavish,Tearlach,Terra,Thalia,Thaniel,Theia,Torian,Torin,Tressa,Tristana,Ulyssia,Uriela,Urien,Vanora,Vasilis,Vespera,Xanthus,Xara,Xylia,Yadira,Yakira,Yeira,Yeriel,Yestin,Yseult,Zaira,Zaniel,Zarek,Zephyr,Zora,Zorion".Split(','), 3);

            lblTitle.Alignment = GUIAlignment.HCenter | GUIAlignment.VCenter;
            txtPlayerName.Text = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(nameGenerator.Next());

            Children.Add(pnlMain);
            Children.Add(pnlTitle);
            pnlTitle.Children.Add(lblTitle);
            pnlMain.Children.Add(lblPlayerName);
            pnlMain.Children.Add(txtPlayerName);
            pnlMain.Children.Add(btnRandomName);
            pnlMain.Children.Add(btnCreatePlayer);

            focusControl = pnlMain;

            pnlMain.ActivateFirst();

            XnaGUIManager.ActivateNext();
        }
예제 #6
0
        /// <summary>
        /// Loads tiles from world that are contained within chunkBounds
        /// </summary>
        /// <param name="world"></param>
        /// <param name="chunkBounds"></param>
        public TerrainChunk(World world, int offsetX, int offsetY, int radius)
            : this()
        {
            int x, y;

            for (y = -radius; y <= radius; y++)
                for (x = -radius; x <= radius; x++)
                    if ((x * x) + (y * y) <= (radius * radius))
                    {
                        //chunkBounds = new System.Drawing.RectangleF(x, y, 1, 1);

                        TerrainTile tile = world.LoadTile(x + offsetX, y + offsetY, this);

                       m_tileCount[tile.Terrain]++;

                       //Insert new tile into chunk QuadTree
                       m_tiles.Insert(tile);
                    }

            //Assign local variables
            m_world = world;
            m_bounds = new RectangleF(offsetX, offsetY, radius * 2, radius * 2);
        }
예제 #7
0
        private void SaveWorld(World world, string strFileName)
        {
            System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(World));

            System.IO.StreamWriter file = new System.IO.StreamWriter(strFileName);
            writer.Serialize(file, world);
            file.Close();
        }
예제 #8
0
        public void LoadPlane(int seed, int x, int y, int radius)
        {
            world = new World(seed);

            chunk = new TerrainChunk(world, x, y, radius);
        }
예제 #9
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            InputManager.Update(gameTime);

            if(m_lastTime == null)
                m_lastTime = gameTime.TotalGameTime;

            if (InputManager.PadPressed(PlayerIndex.One, Buttons.Back) || InputManager.KeyReleased(Keys.OemTilde))
            {
                Exit();
            }

            m_elapsedTime += gameTime.ElapsedGameTime;

            if (m_elapsedTime > TimeSpan.FromSeconds(1))
            {
                m_elapsedTime -= TimeSpan.FromSeconds(1);
                m_frameRate = m_frameCounter;
                m_frameCounter = 0;
            }

            switch(m_stateManager.State)
            {
                case GameStates.Intro:
                    ShowMiniMap(false);
                    ShowCreateWorld(false);
                    ShowSettings(false);
                    ShowMenu(false);

                    if (InputManager.AnyKeyPressed() || InputManager.PadPressed(PlayerIndex.One, Buttons.Start) || InputManager.PadPressed(PlayerIndex.One, Buttons.A))
                    {
                        m_stateManager.SetState(GameStates.MainMenu);
                    }

                    if (World == null || gameTime.TotalGameTime.Subtract(m_lastTime).Seconds >= 5)
                    {
                        World = new World(new VectorID(1, 1), new Random().Next(500, 9999));

                        m_terrainManager.UpdateChunks(new Vector2(0, 0));

                        m_lastTime = gameTime.TotalGameTime;
                    }
                    break;
                case GameStates.MainMenu:
                    ShowMiniMap(false);
                    ShowCreateWorld(false);
                    ShowSettings(false);
                    ShowMenu(true);

                    if (InputManager.PadPressed(PlayerIndex.One, Buttons.B))
                    {
                        m_stateManager.PrevState();
                    }

                    if (InputManager.KeyPressed(Keys.Escape) || InputManager.PadPressed(PlayerIndex.One, Buttons.Start))
                    {
                        if(m_stateManager.LastState == GameStates.Playing)
                            m_stateManager.SetState(GameStates.Playing);
                    }
                    break;
                case GameStates.Settings:
                    ShowMiniMap(false);
                    ShowCreateWorld(false);
                    ShowMenu(false);
                    ShowSettings(true);

                    if(InputManager.PadPressed(PlayerIndex.One, Buttons.B))
                    {
                        m_stateManager.PrevState();
                    }
                    break;
                case GameStates.CreateWorld:
                    ShowSettings(false);
                    ShowMenu(false);
                    ShowCreateWorld(true);

                    if (InputManager.PadPressed(PlayerIndex.One, Buttons.B))
                    {
                        m_stateManager.PrevState();
                    }
                    break;
                case GameStates.CreatePlayer:
                    ShowSettings(false);
                    ShowMenu(false);
                    ShowCreateWorld(false);

                    if (InputManager.PadPressed(PlayerIndex.One, Buttons.B))
                    {
                        m_stateManager.PrevState();
                    }
                    break;
                case GameStates.Playing:
                    ShowCreateWorld(false);
                    ShowSettings(false);
                    ShowMenu(false);
                    ShowMiniMap(true);

                    XnaGUIManager.Activate(false);

                    if (InputManager.KeyPressed(Keys.Escape) || InputManager.PadPressed(PlayerIndex.One, Buttons.Start))
                    {
                        m_stateManager.SetState(GameStates.MainMenu);
                    }

                    if (InputManager.KeyPressed(Keys.W) || InputManager.ThumbUpPressed(PlayerIndex.One, ThumbSticks.Left))
                    {
                        m_playerManager.Move(Directions.North);
                    }

                    if (InputManager.KeyPressed(Keys.S) || InputManager.ThumbDownPressed(PlayerIndex.One, ThumbSticks.Left))
                    {
                        m_playerManager.Move(Directions.South);
                    }

                    if (InputManager.KeyPressed(Keys.A) || InputManager.ThumbLeftPressed(PlayerIndex.One, ThumbSticks.Left))
                    {
                        m_playerManager.Move(Directions.West);
                    }

                    if (InputManager.KeyPressed(Keys.D) || InputManager.ThumbRightPressed(PlayerIndex.One, ThumbSticks.Left))
                    {
                        m_playerManager.Move(Directions.East);
                    }

                    m_playerManager.Update(gameTime);

                    m_terrainManager.Update(gameTime);

                    m_miniMap.CenterTile((int)m_playerManager.Position.X, (int)m_playerManager.Position.Y);

                    break;
            }

            XnaGUIManager.Update(gameTime);
        }