示例#1
0
        public ResourceManager()
        {
            string DataLocation = @"data\";

            AllBlocks = new ResourceImg(System.IO.Path.Combine(DataLocation, "full.png"), 21728, 16);
            Bar       = new ResourceImg(System.IO.Path.Combine(DataLocation, "bar.png"), 641, 30);
            Outline   = new ResourceImg(System.IO.Path.Combine(DataLocation, "outline.png"), 16, 16);
            Smiley    = new ResourceImg(System.IO.Path.Combine(DataLocation, "cm0.png"), 26, 26);
            Aura      = new ResourceImg(System.IO.Path.Combine(DataLocation, "aura.png"), 64, 64);
            this.Chat = new ResourceImg(System.IO.Path.Combine(DataLocation, "chat.png"), 211, 500);

            AuraFile = new ResourceText(System.IO.Path.Combine(DataLocation, "aura.txt"));
            Hotbar   = new ResourceText(System.IO.Path.Combine(DataLocation, "hotbar.txt"));

            if (System.IO.File.Exists(System.IO.Path.Combine(DataLocation, "valid.txt")))
            {
                Valid = new ResourceText(System.IO.Path.Combine(DataLocation, "valid.txt"));
            }
            else
            {
                Valid = null;
            }
        }
示例#2
0
文件: World.cs 项目: notcarksss/OffEE
        /// <summary>
        /// Load the world from a file
        /// </summary>
        /// <param name="file"></param>
        public void Load(string file)
        {
            var w = new ResourceText(@"data\world.txt");

            string[] datal = w.GetData;
            System.Text.StringBuilder datab = new System.Text.StringBuilder();

            string[] rep =
            {
                "\r",
                "\n",
                "\n\n"
            };

            foreach (string i in datal)
            {
                datab.Append(i.Replace(rep[0], rep[1]).Replace(rep[2], rep[1]) + "\n");
            }

            string data = datab.ToString();

            bool[] chkmarks =
            {
                false                                                   //Got WW
                , false                                                 //Got WH
                , false                                                 //Found block id
                , false                                                 //Got pos x
                , false                                                 // y
            };

            uint
                BlockId = 0
            ; int

                x = 0
            , y   = 0

            ;
            foreach (string i in data.Split('\n'))
            {
                if (i.Length != 0)
                {
                    if (!chkmarks[0])
                    {
                        //Get world width
                        if (Int32.TryParse(i, out _width))
                        {
                            chkmarks[0] = true;
                        }
                    }
                    else
                    {
                        if (!chkmarks[1])
                        {
                            //Get world height
                            if (Int32.TryParse(i, out _height))
                            {
                                chkmarks[1] = true;
                            }

                            Blocks = new uint[2, _width, _height];
                        }
                        else
                        {
                            if (i.Substring(0, 1) == "b" &&
                                chkmarks[3] == false)
                            {
                                chkmarks[2] = false;
                            }
                            if (!chkmarks[2])
                            {
                                //Store block id
                                if (i.Substring(0, 1) == "b")
                                {
                                    if (UInt32.TryParse(i.Substring(1), out BlockId))
                                    {
                                        chkmarks[2] = true;
                                    }
                                }
                            }
                            else
                            {
                                if (!chkmarks[3])
                                {
                                    //Store x
                                    if (Int32.TryParse(i, out x))
                                    {
                                        chkmarks[3] = true;
                                    }
                                }
                                else
                                {
                                    if (chkmarks[4])
                                    {
                                        int bid = 0;

                                        if (Int32.TryParse(i, out bid))
                                        {
                                            if (bid == 0 || bid == 1)
                                            {
                                                if (x < Width && y < Height)
                                                {
                                                    Blocks[bid, x, y] = BlockId;
                                                }
                                                chkmarks[4] = false;
                                                chkmarks[3] = false;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        //Store y
                                        if (Int32.TryParse(i, out y))
                                        {
                                            chkmarks[4] = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }