private void TryLogIn()
        {
            var validatorLogIn = new ValidatorLoginLogIn();

            Console.WriteLine("Enter your Login or exit(if you don't wont LogIn)");
            Login = ReadString.FromConsole(validatorLogIn);
            if (Login == "exit")
            {
                return;
            }
            Console.Clear();

            Console.WriteLine("Enter password or exit(if you don't wont LogIn)");
            Password = ReadString.FromConsole();
            if (Password == "exit")
            {
                return;
            }
            int countAttemps = 1;

            while (Password != UserRepo.Get(Login).Password)
            {
                if (countAttemps == Try)
                {
                    Password = "******";
                    Console.WriteLine("You use 3/3 attemps to enter.");
                    return;
                }
                Console.WriteLine("Not correct password. Enter password or if you foget password you can restore it. Type restore.");
                Password = ReadString.FromConsole();
                countAttemps++;
                if (Password == "restore")
                {
                    if (UserRepo.Get(Login).LogIn)
                    {
                        Console.WriteLine("Sorry, but this account is used now.");
                        Password = "******";
                        return;
                    }
                    RestorePassword();
                    return;
                }
            }

            if (Password == UserRepo.Get(Login).Password)
            {
                if (UserRepo.Get(Login).LogIn == true)
                {
                    Console.WriteLine("Error. Another user use this account");
                }
                else
                {
                    LogIn = true;
                }
            }
        }
        private void Registration()
        {
            var validatorLoginRegist    = new ValidatorLoginRegist();
            var validatorPasswordRegist = new ValidatorPasswordRegist();
            var validatorName           = new ValidatorName();

            Console.WriteLine("Create your Login (It should be begger than 4 letter)");
            Login = ReadString.FromConsole(validatorLoginRegist);

            Console.WriteLine("Create your Password (It should be begger than 6 letter)");
            Password = ReadString.FromConsole(validatorPasswordRegist);

            Console.WriteLine("Enter your name");
            Name = ReadString.FromConsole(validatorName);
        }
Exemple #3
0
        //LDH, txt 파일 전체 읽기
        public List <string> txtFileRead(string FilePath)
        {
            List <string> ReadList = new List <string>();

            if (File.Exists(FilePath))
            {
                StreamReader FileReader = new StreamReader(FilePath, Encoding.Default);

                foreach (string ReadString in FileReader.ReadToEnd().Split('\n'))
                {
                    ReadList.Add(ReadString.Replace("\r", ""));
                }
            }
            else
            {
                ReadList = null;
            }

            return(ReadList);
        }
        private void RestorePassword()
        {
            var validatorName           = new ValidatorName();
            var validatorLogIn          = new ValidatorLoginLogIn();
            var validatorPasswordRegist = new ValidatorPasswordRegist();

            Console.Clear();

            Console.WriteLine("Enter your Login");
            Login = ReadString.FromConsole(validatorLogIn);
            var user = UserRepo.Get(Login);

            Console.WriteLine("Enter Name, that you enter when you register");
            int count = 1;

            while (count <= Try)
            {
                var name = ReadString.FromConsole(validatorName);
                if (name == user.Name)
                {
                    Console.WriteLine("Enter new password");
                    Password      = ReadString.FromConsole(validatorPasswordRegist);
                    user.Password = Password;
                    UserRepo.Save(user);
                    break;
                }
                else
                {
                    if (Try != count)
                    {
                        Console.WriteLine($"Check correction of Name. You still have {Try - count} attempts.");
                    }
                    count++;
                }
            }

            Console.Clear();
        }
Exemple #5
0
 8 => new NbtString(ReadString(ReadShort())),
 9 => new NbtList(ReadNbtTagList()),
Exemple #6
0
        private void LoadPrjBtn_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            listBox3.Items.Clear();

            OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                Filter = "GO Project File |*.prj",
                Title  = "Select a Map Project File"
            };


            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string fullpath      = openFileDialog1.FileName;
                string directoryPath = Path.GetDirectoryName(fullpath);
                string filename      = Path.GetFileName(fullpath);

                ProjectHeader Project = new ProjectHeader();
                try
                {
                    string       path   = fullpath;
                    FileStream   fs     = new FileStream(path, FileMode.Open, FileAccess.Read);
                    BinaryReader reader = new BinaryReader(fs, Encoding.GetEncoding("EUC-KR"));
                    ReadString   str    = new ReadString();
                    CurrentEditLabel.Visible = true;
                    CurrentEditLabel.Text    = "Current Editing : " + filename;

                    str.FiersRead = reader.ReadBytes(0x50);
                    str.Decode();
                    reader.ReadInt32();
                    Project.MapName = str.Name;
                    Project.Theme   = reader.ReadInt32();
                    Project.Region  = reader.ReadInt32();
                    Project.MapType = reader.ReadInt32();


                    //sub_96FFE0
                    str.FiersRead = reader.ReadBytes(0x80);
                    str.Decode();
                    Project.BackgroundFile = str.Name;



                    str.FiersRead = reader.ReadBytes(0x80);
                    str.Decode();
                    Project.TileFile = str.Name;

                    str.FiersRead = reader.ReadBytes(0x80);
                    str.Decode();
                    Project.MapFile = str.Name;

                    MapName.Text        = Project.MapName;
                    ThemeMap.Text       = Project.Theme.ToString();
                    RegionMap.Text      = Project.Region.ToString();
                    BackgroundFile.Text = Project.BackgroundFile;
                    TileFile.Text       = Project.TileFile;
                    MapFile.Text        = Project.MapFile;
                    //////// OBJ
                    Project.ObjectCount = reader.ReadInt32();

                    SprResourceCountLabel.Text    = "Spr Resource Count : " + Project.ObjectCount.ToString();
                    SprResourceCountLabel.Visible = true;
                    for (int i = 0; i < Project.ObjectCount; i++)
                    {
                        string SprFile = "";
                        char   ch1;
                        while ((int)(ch1 = reader.ReadChar()) != 0)
                        {
                            SprFile = SprFile + ch1;
                        }
                        reader.ReadBytes(127 - SprFile.Length);// acc 128
                        Console.WriteLine(SprFile);
                        listBox1.Items.Insert(i, SprFile);
                    }

                    Project.MotCount = reader.ReadInt32();

                    for (int i = 0; i < Project.MotCount; i++)
                    {
                        string MotFile = "";
                        char   ch2;
                        while ((int)(ch2 = reader.ReadChar()) != 0)
                        {
                            MotFile = MotFile + ch2;
                        }
                        reader.ReadBytes(127 - MotFile.Length);// acc 128
                        Console.WriteLine(MotFile);
                        listBox2.Items.Insert(i, MotFile);
                    }



                    reader.ReadInt32();
                    reader.ReadInt32();
                    reader.ReadInt32();
                    for (int i = 0; i < Project.MotCount; i++)
                    {
                        string MotTFile = "";
                        char   ch3;
                        while ((int)(ch3 = reader.ReadChar()) != 0)
                        {
                            MotTFile = MotTFile + ch3;
                        }
                        reader.ReadBytes(127 - MotTFile.Length);// acc 128
                        Console.WriteLine(MotTFile);
                        listBox3.Items.Insert(i, MotTFile);
                    }


                    MotResourceCountLabel.Text    = "Mot Resource Count : " + Project.MotCount.ToString();
                    MotResourceCountLabel.Visible = true;
                }
                catch
                {
                    MessageBox.Show("Failed to read file", "");
                }
            }
        }
Exemple #7
0
        public static void ParsePrjFile(Map Map)
        {
            string FileName = Application.LaunchPath + @"\Data\Project\t" + Map.MapX + "_s" + Map.MapY + ".prj";

            using (FileStream stream = new FileStream(FileName, FileMode.Open))
            {
                BinaryReader reader = new BinaryReader(stream);
                try
                {
                    Dictionary <int, string> prjStr = new Dictionary <int, string>();
                    ReadString str = new ReadString();
                    str.FiersRead = reader.ReadBytes(0xA0);
                    str.Decode();
                    string name = str.Name;
                    int    val1 = reader.ReadInt32();
                    int    val2 = reader.ReadInt32();
                    int    val3 = reader.ReadInt32();

                    //=========================================sub_655150
                    int strCount = reader.ReadInt32();

                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                        }
                    }

                    str.FiersRead = reader.ReadBytes(0x100);
                    str.Decode();

                    str.FiersRead = reader.ReadBytes(0x100);
                    str.Decode();


                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                        }
                    }

                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                        }
                    }

                    //=========================================sub_6531D0
                    int val5 = reader.ReadInt32();
                    int val6 = reader.ReadInt32();
                    int val7 = reader.ReadInt32();
                    str.FiersRead = reader.ReadBytes(0x100);
                    str.Decode();

                    str.FiersRead = reader.ReadBytes(0x100);
                    str.Decode();

                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                        }
                    }

                    //=========================================(1)sub_652FA0
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            reader.ReadBytes(0x10);
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(2)
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(3)sub_653460
                    //Map object
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            reader.ReadInt32();
                            reader.ReadInt32();
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadBytes(0x14);
                        }
                    }

                    //=========================================(4)sub_653750
                    //monster
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            int mv1 = reader.ReadInt32();
                            int mv2 = reader.ReadInt32();
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            int mv3 = reader.ReadInt32();
                            int mv4 = reader.ReadInt32();
                            int mv5 = reader.ReadInt32();
                            int mv6 = reader.ReadInt32();
                            int mv7 = reader.ReadByte();
                            int mv8 = reader.ReadInt32();
                            int mv9 = reader.ReadInt32();
                            reader.ReadBytes(0x14);
                        }
                    }

                    //=========================================(5)sub_653A20
                    //Read NPC information
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            reader.ReadInt32();
                            reader.ReadInt32();
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();

                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt16();
                            reader.ReadInt16();
                            reader.ReadInt32();
                            reader.ReadBytes(0xC);
                        }
                    }

                    //=========================================(6)sub_653CF0
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                            str.FiersRead = reader.ReadBytes(0x100);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadBytes(0x14);
                        }
                    }

                    //=========================================(7)sub_653E70
                    strCount = reader.ReadInt32();
                    reader.ReadInt32();
                    reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(8)sub_653E70
                    strCount = reader.ReadInt32();
                    reader.ReadInt32();
                    reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(9)sub_653E70
                    strCount = reader.ReadInt32();
                    reader.ReadInt32();
                    reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(10)sub_653E70
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(11)sub_653E70
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(12)sub_653E70
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(13)sub_67B180
                    //Monster Information
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            var MonsterID = reader.ReadInt32();
                            var Direction = reader.ReadByte();
                            var Speed     = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                            var PosX      = reader.ReadInt32();
                            var PosY      = reader.ReadInt32();
                            int ss        = reader.ReadInt32();
                            int ss2       = 0;
                            do
                            {
                                reader.ReadInt32();
                                reader.ReadInt32();
                                ++ss2;
                            } while (ss2 < ss);

                            //
                            char[] Value        = MonsterID.ToString().ToCharArray();
                            char[] MonsterLevel = new char[4];
                            MonsterLevel[0] = Value[1];
                            MonsterLevel[1] = Value[2];
                            MonsterLevel[2] = Value[3];
                            MonsterLevel[3] = Value[4];
                            //
                            int     Level       = int.Parse(new string(MonsterLevel));
                            int     MaxHP       = MobFactory.MonsterMaxHP(Level);
                            int     Exp         = MobFactory.MonsterExp(Level);
                            byte    MoveType    = MobFactory.MoveType(MonsterID);
                            byte    AttackType  = MobFactory.AttackType(MonsterID);
                            int     Attack1     = MobFactory.Attack1(MonsterID);
                            int     Attack2     = MobFactory.Attack2(MonsterID);
                            int     CrashAttack = MobFactory.CrashAttack(MonsterID);
                            int     Defense     = MobFactory.Defense(MonsterID);
                            byte    AddEffect   = MobFactory.AddEffect(MonsterID);
                            Monster Monster     = new Monster(i, MonsterID, Level, MaxHP, MaxHP, 0, Exp,
                                                              MoveType == 0 ? 0 : Speed, Direction, MoveType, AttackType, Attack1, Attack2,
                                                              CrashAttack, Defense, MoveType == 0 ? (byte)0 : (byte)1, 0, AddEffect, PosX, PosY,
                                                              true);
                            Map.Monster.Add(Monster);

                            // 修正怪物座標
                            sbyte NextPosition = Map.GetMapPexel(Monster.PositionX, Monster.PositionY);
                            while (NextPosition == -1)
                            {
                                Monster.PositionY  = (Monster.PositionY / 32);
                                Monster.PositionY += 1;
                                Monster.PositionY *= 32;
                                sbyte Next = Map.GetMapPexel(Monster.PositionX, Monster.PositionY);
                                if (Next != -1)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    for (int j = Map.Monster.Count; j < 50; j++)
                    {
                        Map.Monster.Add(null);
                    }
                    //=========================================(14)sub_653F60
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(15)sub_654050
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(16)sub_653E70
                    strCount = reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================(17)sub_653E70
                    strCount = reader.ReadInt32();
                    reader.ReadInt32();
                    reader.ReadInt32();
                    if (strCount > 0)
                    {
                        for (int i = 0; i < strCount; i++)
                        {
                            str.FiersRead = reader.ReadBytes(0x28);
                            str.Decode();
                            reader.ReadInt32();
                            reader.ReadByte();
                            reader.ReadInt32();
                            reader.ReadInt32();
                            reader.ReadInt32();
                        }
                    }

                    //=========================================
                }
                catch (Exception)
                {
                }
            }
        }