제작 영상

뭐가 문제지?

by Mania posted Jul 13, 2012
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

        public class MAP : Database
        {
            public List<NPC> Npcs = new List<NPC>();

            static int MapID;

            static int Width;
            static int Height;

            static int[] Data = null;

            int XY;
           
            public int OnlineUsers = 0;

            public MAP(int map)
            {
                MySqlDataReader mdr = MySqlHelper.ExecuteReader(Connection, "SELECT * FROM npc WHERE map = '" + map + "';");

                int r = 0;

                while (true)
                {
                    if (!mdr.Read()) break;

                    NPC i = new NPC();

                    i.No = mdr.GetInt32("no");
                    i.Type = mdr.GetInt16("type");

                    i.Move = mdr.GetInt16("move") == 1 ? true : false;

                    i.Id = mdr.GetString("name");

                    i.Hp = mdr.GetInt32("hp");

                    i.Regen = mdr.GetInt32("rebirth");
                    i.Pure_Regen = i.Regen;

                    i.Handling = mdr.GetInt16("handling");
                    i.Time = i.Handling;

                    i.Damage = mdr.GetInt32("power");
                    i.Defense = mdr.GetInt32("defensive");

                    i.Map = mdr.GetInt16("map");
                    i.X = mdr.GetInt16("x");
                    i.Y = mdr.GetInt16("y");
                    i.D = mdr.GetInt16("d");

                    i.Image = mdr.GetString("image");

                    //i.Function = mdr.GetString("function");

                    i.rand = new Random(r);

                    Npcs.Add(i);
                    r++;
                }
                mdr.Close();

                string Name;

                if (map < 10) Name = "BMap00" + map;
                else if (map >= 10 && map < 100) Name = "BMap0" + map;
                else Name = "BMap" + map;

                if (File.Exists("./BMap/" + Name + ".map"))
                {
                    using (StreamReader outfile = File.OpenText("./BMap/" + Name + ".map"))
                    {
                        string read = outfile.ReadToEnd();
                        string[] result = Regex.Split(read, "\001");

                        MapID = int.Parse(result[3]);

                        Width = int.Parse(result[5]);
                        Height = int.Parse(result[6]);

                        while (0 <= Height - 1)
                        {
                            while (0 <= Width - 1)
                            {
                                Data[XY] = Data[7 + XY];
                                ++XY;
                            }
                        }

                        outfile.Close();
                    }
                }
            }

            static bool Valid(int x, int y)
            {
                return (x >= 0 && x < Width && y >= 0 && y < Height);
            }

            public static bool Passable(int x, int y)
            {
                if (!Valid(x, y)) return false;

                foreach (USER user in Handler.User.Values)
                    if (MapID == user.map && x == user.x && y == user.y) return false;

                foreach (MAP i in Handler.Map.Values)
                {
                    foreach (NPC npc in i.Npcs)
                        if (!npc.Die && MapID == npc.Map && x == npc.X && y == npc.Y) return false;
                }

                if (Data[x + (y * Width)] == 0) return false;

                return true;
            }

 

 

 

 

 

 

 

 

왜 오류가 뜨는 것이야

Who's Mania

?

2001년부터 쯔꾸르 RPG를 만진 사람.

게임 공작소, 창조도시 그 마니아. 맞습니다.