当前位置: 首页>>代码示例>>C#>>正文


C# World.Save方法代码示例

本文整理汇总了C#中World.Save方法的典型用法代码示例。如果您正苦于以下问题:C# World.Save方法的具体用法?C# World.Save怎么用?C# World.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NewWorld

        public static void NewWorld(Player p, string message)
        {
            if (message.Trim().Equals(""))
            {
                Help(p, "newworld");
                return;
            }

            string[] args = message.Trim().Split(' ');
            if (args.Length != 4)
            {
                Help(p, "newworld");
                return;
            }

            string worldname = args[0];
            short w = Int16.Parse(args[1]);
            short h = Int16.Parse(args[2]);
            short d = Int16.Parse(args[3]);
            worldname += ".umw";

            if (System.IO.File.Exists("maps/" + worldname))
            {
                p.SendMessage(0xFF, "That filename already exists!");
                return;
            }

            World newworld = new World(worldname, w, h, d);
            newworld.Save();

            p.SendMessage(0xFF, "Created new world: " + worldname);
        }
开发者ID:roy12345,项目名称:uMiner,代码行数:32,代码来源:WorldCommand.cs

示例2: World_SaveLoad_Test

        public void World_SaveLoad_Test()
        {
            WorldExtensions.ForEach(ext =>
            {
                string name = "World";
                string fileName = name + ext;

                AssetLoadArguments args = new AssetLoadArguments();
                args.Add("cube", true);

                var world1 = new World(Device, name, AssetManager);
                world1.Skybox.SkyTexture = AssetManager.Load(@"Test\SpaceSkyCubeMap.dds", args) as CubeTexture;
                world1.DarkenBorder.IsEnabled = false;
                world1.DarkenBorder.BorderTexture = AssetManager.Load(@"Engine\ScreenBorderFadeout.dds") as Texture;
                world1.Glow.IsEnabled = false;
                world1.Glow.RadialBlurScaleFactor = 1.0f;
                world1.Glow.BlurWidth = 7.0f;
                world1.Glow.GlowIntensity = 0.6f;
                world1.Glow.HighlightIntensity = 0.3f;
                world1.Save(fileName);

                var world2 = World.Load(Device, fileName, name, AssetManager);
                Assert.AreEqual(name, world2.Name);
                Assert.AreEqual(world1.Skybox.SkyTexture, world2.Skybox.SkyTexture);
                Assert.AreEqual(world1.DarkenBorder.IsEnabled, world2.DarkenBorder.IsEnabled);
                Assert.AreEqual(world1.DarkenBorder.BorderTexture, world2.DarkenBorder.BorderTexture);
                Assert.AreEqual(world1.Glow.IsEnabled, world2.Glow.IsEnabled);
                Assert.AreEqual(world1.Glow.RadialBlurScaleFactor, world2.Glow.RadialBlurScaleFactor);
                Assert.AreEqual(world1.Glow.BlurWidth, world2.Glow.BlurWidth);
                Assert.AreEqual(world1.Glow.GlowIntensity, world2.Glow.GlowIntensity);
                Assert.AreEqual(world1.Glow.HighlightIntensity, world2.Glow.HighlightIntensity);
            });
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:33,代码来源:WorldTest.cs

示例3: Init

        public void Init()
        {
            logger.log("Server initialized");
            //Init salt
            string saltChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~";
            Random rand = new Random();
            int saltLength = rand.Next(12, 16);
            for (int i = 0; i < saltLength; i++)
            {
                salt += saltChars[rand.Next(0, saltChars.Length - 1)];
            }

            //Load config
            LoadConfig();
            //Put server name in console title
            Console.Title = this.serverName;
            if (!this.isPublic) { Console.Title += " (PRIVATE)"; }

            playerlist = new Player[maxPlayers + 2];  //Extra slot is for rejects, and another one (for some odd reason it's less by one)
            for (int i = 0; i < maxPlayers + 2; i++)
            {
                playerlist[i] = null;
            }

            //Load world and start save timer
            if (!Directory.Exists("maps"))
            {
                Directory.CreateDirectory("maps");
            }
            if (!File.Exists("maps/" + worldPath))
            {
                world = new World(worldPath, 256, 64, 256);
                world.Save();
            }
            else
            {
                world = new World(worldPath);
                //world.Save();
            }
            worldSaveTimer = new System.Timers.Timer(60000.0);
            worldSaveTimer.Elapsed += new System.Timers.ElapsedEventHandler(delegate
            {
                world.Save();
            });

            physics = new BasicPhysics(world, lavaSpongeEnabled);
            this.physThread = new System.Threading.Thread(PhysicsUpdateLoop);
            physThread.Start();
            logger.log("Started BasicPhysics Engine");

            //Intercept Ctrl+C
            Console.CancelKeyPress += new ConsoleCancelEventHandler(delegate
                {
                    world.Save();
                });

            //Load Commands
            Command.Init();
            consolePlayer = new ConsolePlayer();

            //Load blocks
            Blocks.Init();

            //Load special chars
            Player.specialChars = new Dictionary<string, char>();
            Player.specialChars.Add(@"\:D", (char)2);        //☻
            Player.specialChars.Add(@"\<3", (char)3);        //♥
            Player.specialChars.Add(@"\<>", (char)4);        //♦
            Player.specialChars.Add(@"\club", (char)5);      //♣
            Player.specialChars.Add(@"\spade", (char)6);     //♠
            Player.specialChars.Add(@"\boy", (char)11);      //♂
            Player.specialChars.Add(@"\girl", (char)12);     //♀
            Player.specialChars.Add(@"\8note", (char)13);    //♪
            Player.specialChars.Add(@"\16note", (char)14);   //♫
            Player.specialChars.Add(@"\*", (char)15);        //☼
            Player.specialChars.Add(@"\>", (char)16);        //►
            Player.specialChars.Add(@"\<-", (char)27);       //←
            Player.specialChars.Add(@"\<", (char)17);        //◄
            Player.specialChars.Add(@"\updn", (char)18);     //↕
            Player.specialChars.Add(@"\2!", (char)19);       //‼
            Player.specialChars.Add(@"\p", (char)20);        //¶
            Player.specialChars.Add(@"\sec", (char)21);      //§
            Player.specialChars.Add(@"\|up", (char)24);      //↑
            Player.specialChars.Add(@"\|dn", (char)25);      //↓
            Player.specialChars.Add(@"\->", (char)26);       //→
            //** The ← symbol was moved before ◄ due to parsing order issues
            Player.specialChars.Add(@"\lr", (char)29);       //↔
            Player.specialChars.Add(@"\up", (char)30);       //▲
            Player.specialChars.Add(@"\dn", (char)31);       //▼

            //Load ranks
            playerRanksDict = new Dictionary<string, byte>();
            try
            {
                if (File.Exists("ranks.txt"))
                {
                    StreamReader sr = new StreamReader(File.OpenRead("ranks.txt"));
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();
//.........这里部分代码省略.........
开发者ID:roy12345,项目名称:uMiner,代码行数:101,代码来源:Server.cs

示例4: Control

        public void Control(World world)
        {   //Handles input
            bool keyW = Keyboard.GetState().IsKeyDown(Keys.W);
            bool keyS = Keyboard.GetState().IsKeyDown(Keys.S);
            bool keyA = Keyboard.GetState().IsKeyDown(Keys.A);
            bool keyD = Keyboard.GetState().IsKeyDown(Keys.D);

            if (keyW)
            {
                velocity.Y += -speed;
            }

            if (keyS)
            {
                velocity.Y += speed;
            }

            if (keyA)
            {
                velocity.X += -speed;
            }

            if (keyD)
            {
                velocity.X += speed;
            }

            if (Game1.keyPress(Keys.I))
            {
                if (guiInventory.active)
                    guiInventory.Close();
                else guiInventory.Open();
            }

            if (Game1.keyPress(Keys.L))
            {
                world.Save();
            }
            if (Game1.keyPress(Keys.K))
            {
                world.LoadWorldFromFile("strings\\maps\\map1.gff");
            }
            if (Game1.keyPress(Keys.F))//Keyboard.GetState().IsKeyDown(Keys.F))
            {
                ItemEntity.CreateItemEntity(center, Vector2.Zero, new ItemStack(ItemWeapon.CreateItemWeapon(1), 1), 1);
            }
            if (Game1.keyPress(Keys.G))
            {
                World.cutscene.StartCutscene(0, this);
                //CloseDialogue();
            }
            if (Game1.keyPress(Keys.OemTilde))
            {
                world.drawTileDEBUG = !world.drawTileDEBUG;
            }

            if (Game1.mouse.LeftClick())
            {
                //Vector2 dPos = (Game1.mouse.positionRelativeWorld - position);

                //float angleToMouse = (float)Math.Atan2(dPos.X, dPos.Y);

                Vector2 positionToRotation = Vector2.Transform(new Vector2(center.X, center.Y + 32) - center, Matrix.CreateRotationZ(-angleToMouse)) + center;

                createHurtBox(this, new Rectangle((int)positionToRotation.X, (int)positionToRotation.Y, 64, 32), new Vector2(center.X, center.Y + 32) - center, damage, 5, -angleToMouse);
            }

            if ((keyW && keyS && keyA && keyD) == false)
            {   //if the player is holding none of the movement keys down
                isFriction = true;  //turn off friction
            }
            else
                isFriction = false;
        }
开发者ID:BlueTRaven,项目名称:Lemonade,代码行数:74,代码来源:Player.cs


注:本文中的World.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。