public void InitMe(string OldAddr, SegmentConfig S) { if (S.CheckWords != null) { string[] CWS = S.CheckWords.Split(','); foreach (string CW in CWS) { string[] Parts = CW.Split(':'); if (Parts.Length == 4) { if (!comboCheckword.Items.Contains(Parts[3])) { comboCheckword.Items.Add(Parts[3]); } } } } if (OldAddr.Length > 0) { string[] Extras = OldAddr.Split(','); foreach (string Extra in Extras) { listExtra.Items.Add(Extra); } } }
public void AddLumberDoubleRow(string data1, string data2) { //data1 is the first line, data2 is the second int LumberNumber = Convert.ToInt32(data1.Substring(3, 2)); int Grade = Convert.ToInt32(data1.Substring(7, 2)); double Depth = Convert.ToDouble(data1.Substring(11, 4)); double Thick = Convert.ToDouble(data1.Substring(16, 4)); string Description = data1.Substring(21); int E = scientificNumber(data2.Substring(42, 9)); int Fb = Convert.ToInt32(data2.Substring(53, 4)); int Fc = Convert.ToInt32(data2.Substring(58, 4)); int Ft = Convert.ToInt32(data2.Substring(63, 4)); int Fcp = Convert.ToInt32(data2.Substring(68, 4)); int Fv = Convert.ToInt32(data2.Substring(73, 4)); MSR MSR = enumMSRCheck(data2[77]); CW CW = enumCWCheck(data2.Substring(79, 3)); int pointer = 83; while (data2[pointer] != ' ') { pointer++; } string SizeName = data2.Substring(81, pointer - 83); Lumbers.Add(new Lumber(LumberNumber, Grade, Depth, Thick, Description, E, Fb, Fc, Ft, Fcp, Fb, MSR, CW, SizeName)); }
public void Dump(string name, CW cw) { if (cw != null) { cw("Point <" + name + "> ( " + x + " ; " + y + " )"); } }
public void ReDrawLog() { LineHeightPos = 0; string FillText = ""; LineHeightPos = 0; for (int i = 0; i < Console.WindowWidth - LogPosStart.X; i++) { FillText += "o"; } CW.FillOutStringBorder(FillText, true, LogPosStart.X, LogPosStart.Y + LineHeightPos); LineHeightPos++; int TimesToWrite; if (DrawInfoBox.Inputs.Count < 10) { TimesToWrite = DrawInfoBox.Inputs.Count; } else { TimesToWrite = 10; } for (int i = 0; i < TimesToWrite; i++) { CW.Write(Side, LogPosStart.X, LogPosStart.Y + LineHeightPos); CW.Write(DrawInfoBox.Inputs[i], LogPosStart.X + 2, LogPosStart.Y + LineHeightPos); CW.Write(Side, LogPosStart.X + (Console.WindowWidth - (LogPosStart.X + 1)), LogPosStart.Y + LineHeightPos); LineHeightPos++; } CW.FillOutStringBorder(FillText, false, LogPosStart.X, LogPosStart.Y + LineHeightPos); }
public void ReDrawStats() { LineHeightPos = 0; string BigestText = ""; List <string> StatTexts = new List <string>(); StatTexts.Add(" Health: " + SingleTon.GetPlayerController().Skills.Vitallity.HealthCurrent + "/" + SingleTon.GetPlayerController().Skills.Vitallity.Health + " "); StatTexts.Add(" Mana: " + SingleTon.GetPlayerController().Skills.Magic.ManaCurrent + "/" + SingleTon.GetPlayerController().Skills.Magic.Mana + " "); StatTexts.Add(" Damage: " + SingleTon.GetPlayerController().Skills.Power.ExtraAttack + " + " + SingleTon.GetPlayerController().Skills.Power.Buff + " "); StatTexts.Add(" Armor: " + SingleTon.GetPlayerController().Armor + " "); foreach (string element in StatTexts) { if (element.Length > BigestText.Length) { BigestText = element + " "; } } CW.FillOutStringBorder(BigestText, true, StatsPosStart.X, StatsPosStart.Y + LineHeightPos); LineHeightPos++; foreach (string element in StatTexts) { CW.Write(Side, StatsPosStart.X, StatsPosStart.Y + LineHeightPos); CW.Write(element, StatsPosStart.X + 1, StatsPosStart.Y + LineHeightPos); CW.Write(Side, StatsPosStart.X + (BigestText.Length - 1), StatsPosStart.Y + LineHeightPos); LineHeightPos++; } CW.FillOutStringBorder(BigestText, false, StatsPosStart.X, StatsPosStart.Y + LineHeightPos); //enemy LineHeightPos = 0; BigestText = ""; StatTexts.Clear(); StatTexts.Add(" Health: " + SingleTon.GetPlayerController().CBM.enemyFighting.Health + "/" + SingleTon.GetPlayerController().CBM.enemyFighting.MaxHp + " "); StatTexts.Add(" Damage: " + SingleTon.GetPlayerController().CBM.enemyFighting.Damage + " "); StatTexts.Add(" "); StatTexts.Add(" "); foreach (string element in StatTexts) { if (element.Length > BigestText.Length) { BigestText = element + " "; } } int Lenght = StatsPosStart.X + (Console.WindowWidth - (StatsPosStart.X + 1 + BigestText.Length)); CW.FillOutStringBorder(BigestText, true, Lenght, StatsPosStart.Y + LineHeightPos); LineHeightPos++; foreach (string element in StatTexts) { CW.Write(Side, Lenght, StatsPosStart.Y + LineHeightPos); CW.Write(element, Lenght + 1, StatsPosStart.Y + LineHeightPos); CW.Write(Side, Lenght + (BigestText.Length - 1), StatsPosStart.Y + LineHeightPos); LineHeightPos++; } CW.FillOutStringBorder(BigestText, false, Lenght, StatsPosStart.Y + LineHeightPos); }
public void ProcessMatchInit(CW.NetworkResponse response) { CW.ResponseMatchInit args = response as CW.ResponseMatchInit; if (args.status == 0) { Debug.Log("MatchID set to: " + args.matchID); Game.SwitchScene ("CWBattle"); } }
public void Dump(string name, CW cw) { if (cw == null) { return; } cw(" --- IntersectionRecord <" + name + ">--- "); cw(" u = " + u + " ; v = " + v); cw(" TubeVerts (" + tubeEdge1 + " ; " + tubeEdge2 + ") and PlaneVerts (" + planeEdge1 + " ; " + planeEdge2 + ")"); }
public void DrawGold() { lineheight = 0; string GoldText = "║ Gold: " + SingleTon.GetPlayerController().Inventory.Gold + " ║"; CW.FillOutStringBorder(GoldText, true, GoldHeight.X, GoldHeight.Y + lineheight); lineheight++; CW.Write(GoldText, GoldHeight.X, GoldHeight.Y + lineheight); lineheight++; CW.FillOutStringBorder(GoldText, false, GoldHeight.X, GoldHeight.Y + lineheight); }
public void Draw(Cord _Pos) { CW.Clear(); Pos = _Pos; LineHeightPos = 0; string BigLine = Side + " Round: " + SingleTon.GetPlayerController().CBM.Rounds + " " + Side; CW.FillOutStringBorder(BigLine, true, Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; CW.Write(BigLine, Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; CW.FillOutStringBorder(BigLine, false, Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; BigLine = Side + " Name: " + SingleTon.GetPlayerController().PlayerName + " " + Side; CW.Write("", Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; CW.FillOutStringBorder(BigLine, true, Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; CW.Write(BigLine, Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; CW.FillOutStringBorder(BigLine, false, Pos.X, Pos.Y + LineHeightPos); LineHeightPos += 2; StatsPosStart = new Cord { X = Pos.X, Y = Pos.Y + LineHeightPos }; ReDrawStats(); LineHeightPos += 9; ActionMenuStart = new Cord { X = Pos.X, Y = Pos.Y + LineHeightPos }; RedrawAcionMenu(); LineHeightPos = 10 + ActionMenuStart.Y; LogPosStart = new Cord { X = Pos.X, Y = Pos.Y + LineHeightPos }; ReDrawLog(); //Other Side BigLine = Side + " Name: " + SingleTon.GetPlayerController().CBM.enemyFighting.Name + " " + Side; Pos = new Cord() { X = Console.WindowWidth - (BigLine.Length + 1), Y = Pos.Y + 4 }; LineHeightPos = 0; CW.FillOutStringBorder(BigLine, true, Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; CW.Write(BigLine, Pos.X, Pos.Y + LineHeightPos); LineHeightPos++; CW.FillOutStringBorder(BigLine, false, Pos.X, Pos.Y + LineHeightPos); }
public IEnumerable <ClientView> GetClientsView(IEnumerable <Client> CurrentClients) { var ClientsViewEnumerable = from Clients in CurrentClients join Cities in DB.City on Clients.CityId equals Cities.Id into CW from subset in CW.DefaultIfEmpty <City>(new City() { Id = 0, Name = string.Empty }) select new ClientView() { Id = Clients.Id, Name = Clients.Name, Surname = Clients.Surname, CityId = Clients.CityId, City = subset.Name }; return(ClientsViewEnumerable); }
public void RedrawAcionMenu() { string Filler = "oooo oooo oooo oooo oooo oooo"; LineHeightPos = 0; switch (MenuState) { case ActionMenus.Ablilites: ActiveMenuList = SingleTon.GetPlayerController().AquiredAbilites.Select(x => x.Name).ToList(); break; case ActionMenus.Items: ActiveMenuList = SingleTon.GetPlayerController().Inventory.Inventory.Where(x => x.UseInCombat == true).Select(x => x.name).ToList(); break; case ActionMenus.Main: ActiveMenuList = MenuTextOptions; CW.FillOutStringBorder(Filler, true, ActionMenuStart.X, ActionMenuStart.Y + LineHeightPos); LineHeightPos++; int CurrentHeight = LineHeightPos; for (int i = 0; i < MenuTextOptions.Count; i++) { if (IndexMenu == i) { CW.Write(" [" + MenuTextOptions[i] + "] ", ActionMenuStart.X + 1, ActionMenuStart.Y + LineHeightPos); LineHeightPos++; } else { CW.Write(" " + MenuTextOptions[i] + " ", ActionMenuStart.X + 1, ActionMenuStart.Y + LineHeightPos); LineHeightPos++; } } for (int x = CurrentHeight; x < 11; x++) { CW.Write(Side, ActionMenuStart.X, ActionMenuStart.Y + CurrentHeight); CW.Write(Side, ActionMenuStart.X + 28, ActionMenuStart.Y + CurrentHeight); CurrentHeight++; } CW.FillOutStringBorder(Filler, false, ActionMenuStart.X, ActionMenuStart.Y + 11); break; } }
private void ConnectToServer(object sender, RoutedEventArgs e) { Socket client = null; try { IPPD = GetIpPortData(CW); if (IPPD != null) { client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); if (CW.IsBind) { client.Bind(new IPEndPoint(CW.InternetController.GetIPProperties().UnicastAddresses.First(x => x.Address.AddressFamily == AddressFamily.InterNetwork).Address, CW.BindPort)); } client.Connect(IPPD.Ip, IPPD.Port); if (registrationProcess(client, CW)) { LogWriter.SendLog("Процесс регистрации на сервере успешно пройден, подключение установлено."); if (CW.SaveChange) { CW.SaveConfig(); } else { CW.DeliteConfig(); } Visibility = Visibility.Collapsed; TerminalWindowView twv = new TerminalWindowView(client, this); twv.Show(); } else { throw new Exception("Получен не верный ответ от сервера, регистрация не подтверждена."); } } } catch (Exception ex) { Protocol.ProtectedCloseSocket(client); LogWriter.SendLog(ex.Message, ConsoleColor.Red); } }
public bool AddLumber(string data) { //this if is to check that E is starting when it's supposed to if (data[40] != '1' && data[40] != '2' && data[40] != '3' && data[40] != '4' && data[40] != '5' && data[40] != '6' && data[40] != '7' && data[40] != '8' && data[40] != '9' && data[40] != '0') { return(false); } int LumberNumber = Convert.ToInt32(data.Substring(3, 2)); int Grade = Convert.ToInt32(data.Substring(7, 2)); double Depth = Convert.ToDouble(data.Substring(11, 4)); double Thick = Convert.ToDouble(data.Substring(16, 4)); int pointer = 39; char fun = data[40]; while (data[pointer] == ' ') { pointer--; } string Description = data.Substring(21, pointer - 21); int E = scientificNumber(data.Substring(40, 9)); int Fb = Convert.ToInt32(data.Substring(51, 4)); int Fc = Convert.ToInt32(data.Substring(56, 4)); int Ft = Convert.ToInt32(data.Substring(61, 4)); int Fcp = Convert.ToInt32(data.Substring(66, 4)); int Fv = Convert.ToInt32(data.Substring(71, 4)); MSR MSR = enumMSRCheck(data[75]); CW CW = enumCWCheck(data.Substring(77, 3)); pointer = 81; while (data[pointer] != ' ') { pointer++; } string SizeName = data.Substring(81, pointer - 81); Lumbers.Add(new Lumber(LumberNumber, Grade, Depth, Thick, Description, E, Fb, Fc, Ft, Fcp, Fb, MSR, CW, SizeName)); return(true); }
public void DrawTabs() { lineheight = 0; string[] Tabs = new string[] { "All", "Weapon", "Armor", "Consumable", "Misc" }; string tabString = "║"; for (int i = 0; i < Tabs.Length; i++) { if ((int)state == i) { tabString += " [" + Tabs[i] + "] ║"; } else { tabString += " " + Tabs[i] + " ║"; } } CW.FillOutStringBorder(tabString, true, TabHeight.X, TabHeight.Y + lineheight); lineheight++; CW.Write(tabString, TabHeight.X, TabHeight.Y + lineheight); lineheight++; CW.FillOutStringBorder(tabString, false, TabHeight.X, TabHeight.Y + lineheight); }
public CombatMenuReturn CombatMenuNavigation() { switch (CW.ReadKey().Key) { case ConsoleKey.UpArrow: if (CombatDraw.IndexMenu > 0) { CombatDraw.IndexMenu--; } return(CombatMenuReturn.Menu); case ConsoleKey.DownArrow: if (CombatDraw.ActiveMenuList.Count - 1 > CombatDraw.IndexMenu && CombatDraw.IndexMenu < 10) { CombatDraw.IndexMenu++; } return(CombatMenuReturn.Menu); case ConsoleKey.Enter: switch (CombatDraw.MenuState) { case CombatDraw.ActionMenus.Ablilites: throw new NotImplementedException(); break; case CombatDraw.ActionMenus.Items: throw new NotImplementedException(); break; case CombatDraw.ActionMenus.Main: switch (CombatDraw.IndexMenu) { case 0: SingleTon.GetPlayerController().CBM.enemyFighting.SetDamage(); DrawInfoBox.AddToBox("You attacked " + SingleTon.GetPlayerController().CBM.enemyFighting.Name + " and dealt " + SingleTon.GetPlayerController().Skills.Vitallity.TakeDamage(SingleTon.GetPlayerController().CBM.enemyFighting.Damage) + ", " + SingleTon.GetPlayerController().CBM.enemyFighting.Name + " hits back and damages you " + SingleTon.GetPlayerController().CBM.enemyFighting.TakeDamage(SingleTon.GetPlayerController().Skills.Power.Buff + SingleTon.GetPlayerController().Skills.Power.ExtraAttack)); if (SingleTon.GetPlayerController().Skills.Vitallity.HealthCurrent == 0) { } else if (SingleTon.GetPlayerController().CBM.enemyFighting.Health == 0) { if (SingleTon.GetCursorInstance().CurrentTile.MyType == TileType.Dungeon) { PlayManager.State = PlayerState.Dungeon; } else if (SingleTon.GetCursorInstance().CurrentTile.MyType == TileType.Normal) { PlayManager.State = PlayerState.WorldMap; } SingleTon.GetPlayerController().AddXP(SingleTon.GetPlayerController().CBM.enemyFighting.Xp); SingleTon.GetPlayerController().Inventory.AddGold(SingleTon.GetPlayerController().CBM.enemyFighting.GetGold()); SingleTon.GetPlayerController().CBM.enemyFighting.EndCombat(); CW.Clear(); MapD.DrawMap(); return(CombatMenuReturn.None); } break; case 1: CombatDraw.MenuState = CombatDraw.ActionMenus.Items; break; case 2: CombatDraw.MenuState = CombatDraw.ActionMenus.Ablilites; break; case 3: DrawInfoBox.AddToBox("You tried to flee from " + SingleTon.GetPlayerController().CBM.enemyFighting.Name); if (SingleTon.PercentChance(SingleTon.GetPlayerController().CBM.enemyFighting.FleeChance)) { DrawInfoBox.AddToBox("You succeded and escaped " + SingleTon.GetPlayerController().CBM.enemyFighting.Name); if (SingleTon.GetCursorInstance().CurrentTile.MyType == TileType.Dungeon) { PlayManager.State = PlayerState.Dungeon; } else if (SingleTon.GetCursorInstance().CurrentTile.MyType == TileType.Normal) { PlayManager.State = PlayerState.WorldMap; } CW.Clear(); MapD.DrawMap(); return(CombatMenuReturn.None); } else { DrawInfoBox.AddToBox("You failed and didn't escape " + SingleTon.GetPlayerController().CBM.enemyFighting.Name); } break; } break; } return(CombatMenuReturn.All); default: return(CombatMenuReturn.None); } }
public void Draw() { int line; line = 0; Cord Pos = CW.GetPos(); string FillerLine = "│"; string Firsslot = "│ Name: " + SingleTon.GetPlayerController().PlayerName + " │ Level: " + SingleTon.GetPlayerController().Level + " │ Job: " + SingleTon.GetPlayerController().PlayerClass.Name + " "; string SecSlot = "│ Race: " + SingleTon.GetPlayerController().PlayerRace.Name + " │ Health: " + SingleTon.GetPlayerController().Skills.Vitallity.HealthCurrent + "/" + SingleTon.GetPlayerController().Skills.Vitallity.Health + " │ Mana: " + SingleTon.GetPlayerController().Skills.Magic.ManaCurrent + "/" + SingleTon.GetPlayerController().Skills.Magic.Mana + " "; if (Firsslot.Length > SecSlot.Length) { Lenght = Firsslot.Length; for (int i = 1; i < Firsslot.Length; i++) { FillerLine += "─"; } } else { Lenght = SecSlot.Length; for (int i = 1; i < SecSlot.Length; i++) { FillerLine += "─"; } } FillerLine += "│"; CW.Write(FillerLine, Pos.X, Pos.Y + line); line++; if (Firsslot.Length > SecSlot.Length) { CW.Write(Firsslot + "│", Pos.X, Pos.Y + line); line++; CW.Write(SecSlot, Pos.X, Pos.Y + line); CW.WriteLine("│", Pos.X + (Lenght), Pos.Y + line); line++; } else { CW.Write(Firsslot, Pos.X, Pos.Y + line); CW.WriteLine("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.Write(SecSlot + "│", Pos.X, Pos.Y + line); line++; } CW.Write(FillerLine, Pos.X, Pos.Y + line); line++; CW.Write("│ Skil: " + "Base" + " │ " + "Buff" + " │ " + "Skil", Pos.X, Pos.Y + line); CW.Write("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.Write("│ Powe: " + SingleTon.GetPlayerController().Skills.Power._lvl, Pos.X, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Power.Buff, Pos.X + 12, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Power.ExtraAttack, Pos.X + 19, Pos.Y + line); CW.Write("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.Write("│ Vita: " + SingleTon.GetPlayerController().Skills.Vitallity._lvl, Pos.X, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Vitallity.Buff, Pos.X + 12, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Vitallity.Health, Pos.X + 19, Pos.Y + line); CW.Write("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.Write("│ Magi: " + SingleTon.GetPlayerController().Skills.Magic._lvl, Pos.X, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Magic.Buff, Pos.X + 12, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Magic.Mana, Pos.X + 19, Pos.Y + line); CW.Write("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.Write("│ Luck: " + SingleTon.GetPlayerController().Skills.Luck._lvl, Pos.X, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Luck.Buff, Pos.X + 12, Pos.Y + line); CW.Write(" │ " + SingleTon.GetPlayerController().Skills.Luck.critChanceInPercentage, Pos.X + 19, Pos.Y + line); CW.Write("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.WriteLine(FillerLine, Pos.X, Pos.Y + line); line++; CW.Write("│ XP: " + SingleTon.GetPlayerController().Xp + "/" + SingleTon.GetPlayerController().NextLevelXP, Pos.X, Pos.Y + line); CW.Write("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.Write("│ |" + CalculateLevelProgress() + "|", Pos.X, Pos.Y + line); CW.Write("│", Pos.X + (Lenght), Pos.Y + line); line++; CW.WriteLine(FillerLine, Pos.X, Pos.Y + line); }
public void Draw(int x, int y) { CW.SetPos(x, y); Draw(); }
private static void NidaleeOnDraw(EventArgs args) { if (Target != null && MainMenu.Item("drawline").GetValue <bool>()) { if (Me.IsDead) { return; } Render.Circle.DrawCircle(Target.Position, Target.BoundingRadius - 50, Color.Yellow); } foreach (var spell in CougarList) { var circle = MainMenu.Item("draw" + spell.Slot).GetValue <Circle>(); if (circle.Active && CougarForm && !Me.IsDead) { Render.Circle.DrawCircle(Me.Position, spell.Range, circle.Color, 2); } } foreach (var spell in HumanList) { var circle = MainMenu.Item("draw" + spell.Slot).GetValue <Circle>(); if (circle.Active && !CougarForm && !Me.IsDead) { Render.Circle.DrawCircle(Me.Position, spell.Range, circle.Color, 2); } } if (!MainMenu.Item("drawcds").GetValue <bool>()) { return; } var wts = Drawing.WorldToScreen(Me.Position); if (!CougarForm) // lets show cooldown timers for the opposite form :) { if (Me.Spellbook.CanUseSpell(SpellSlot.Q) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Null"); } else if (CQ == 0) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Ready"); } else { Drawing.DrawText(wts[0] - 80, wts[1], Color.Orange, "Q: " + CQ.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.W) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Null"); } else if (CW == 0) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Ready"); } else { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.Orange, "W: " + CW.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.E) == SpellState.NotLearned) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Null"); } else if (CE == 0) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Ready"); } else { Drawing.DrawText(wts[0], wts[1], Color.Orange, "E: " + CE.ToString("0.0")); } } else { if (Me.Spellbook.CanUseSpell(SpellSlot.Q) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Null"); } else if (HQ == 0) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Ready"); } else { Drawing.DrawText(wts[0] - 80, wts[1], Color.Orange, "Q: " + HQ.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.W) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Null"); } else if (HW == 0) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Ready"); } else { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.Orange, "W: " + HW.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.E) == SpellState.NotLearned) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Null"); } else if (HE == 0) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Ready"); } else { Drawing.DrawText(wts[0], wts[1], Color.Orange, "E: " + HE.ToString("0.0")); } } }
public void Draw() { int line = 0; Cord pos = CW.GetPos(); int Lenght = 8; int Height = 1; int LinesToWrite = 0; string TopLine = ""; string BottomLine = ""; line = (MapDraw.ViewSize.X * 2) + 40; line += -2; TopLine += Cor[0]; BottomLine += Cor[3]; for (int b = 0; b < line; b++) { TopLine += TopBot; BottomLine += TopBot; } TopLine += Cor[1]; BottomLine += Cor[2]; if (Inputs.Count < Lenght) { LinesToWrite = Inputs.Count; } else if (60 - Index > Lenght) { LinesToWrite = Lenght; } else { LinesToWrite = 60 - Index; } CW.SetPos(pos.X, (MapDraw.ViewSize.Y) + 3 + Height); Height++; CW.Write(TopLine); string FillText = ""; for (int x = 0; x < line + 1; x++) { FillText += " "; } for (int c = Index; c < LinesToWrite; c++) { CW.SetPos(pos.X, (MapDraw.ViewSize.Y) + 3 + Height); CW.Write(FillText); Height++; } Height = 2; for (int i = Index; i < LinesToWrite + Index; i++) { CW.SetPos(pos.X, (MapDraw.ViewSize.Y) + 3 + Height); CW.Write(Side + " " + Inputs[i]); CW.SetPos(pos.X + line + 1, (MapDraw.ViewSize.Y) + 3 + Height); CW.WriteLine(Side); Height++; } CW.SetPos(pos.X, (MapDraw.ViewSize.Y) + 3 + Height); CW.WriteLine(BottomLine); }
public void Read_User_Input() { #region USER DATA List <string> lst_content = new List <string>(File.ReadAllLines(user_input_file)); string kStr = ""; MyList mList = null; string VarName = ""; #endregion int indx = -1; try { for (int i = 0; i < lst_content.Count; i++) { kStr = MyList.RemoveAllSpaces(lst_content[i]); mList = new MyList(kStr, '='); VarName = MyList.RemoveAllSpaces(mList.StringList[0]); #region SWITCH switch (VarName) { case "D": D = mList.GetDouble(1); txt_D.Text = D.ToString(); break; case "CW": CW = mList.GetDouble(1); txt_CW.Text = CW.ToString(); break; case "FP": FP = mList.GetDouble(1); txt_FP.Text = FP.ToString(); break; case "L": L = mList.GetDouble(1); txt_L.Text = L.ToString(); break; case "support_width": support_width = mList.GetDouble(1); txt_width_support.Text = support_width.ToString(); break; case "W": W1 = mList.GetDouble(1); txt_W1.Text = W1.ToString(); break; case "conc_grade": conc_grade = mList.GetDouble(1); txt_concrete_grade.Text = conc_grade.ToString(); break; case "st_grade": st_grade = mList.GetDouble(1); txt_steel_grade.Text = st_grade.ToString(); break; case "sigma_cb": sigma_cb = mList.GetDouble(1); txt_sigma_cb.Text = sigma_cb.ToString(); break; case "sigma_st": sigma_st = mList.GetDouble(1); txt_sigma_st.Text = sigma_st.ToString(); break; case "m": m = mList.GetDouble(1); txt_m.Text = m.ToString(); break; case "j": j = mList.GetDouble(1); txt_j.Text = j.ToString(); break; case "Q": Q = mList.GetDouble(1); txt_Q.Text = Q.ToString(); break; case "a1": a1 = mList.GetDouble(1); txt_a1.Text = a1.ToString(); break; case "b1": b1 = mList.GetDouble(1); txt_b1.Text = b1.ToString(); break; case "W1": W1 = mList.GetDouble(1); txt_W1.Text = W1.ToString(); break; case "cover": cover = mList.GetDouble(1); txt_cover.Text = cover.ToString(); break; case "delta_c": delta_c = mList.GetDouble(1); txt_delta_c.Text = delta_c.ToString(); break; case "delta_wc": delta_wc = mList.GetDouble(1); txt_delta_wc.Text = delta_wc.ToString(); break; } #endregion } } catch (Exception ex) { } lst_content.Clear(); }
public void CW_ProcessPlayerSelect(CW.NetworkResponse response) { CW.ResponsePlayerSelect args = response as CW.ResponsePlayerSelect; }
public void DrawInventoryContainer() { lineheight = 0; List <string> ItemLine = new List <string>(); ItemLine.Add(SizeAble("Name", "Description", "Stats", "Value", "Type", ItemLine.Count, false, true)); switch (state) { case InventoryDrawMenuState.All: foreach (BaseItem element in SingleTon.GetPlayerController().Inventory.Inventory) { if (element is EquippableItem item) { ItemLine.Add(SizeAble(element.name, element.describtion, element.Effect, element.Value.ToString(), element.itemType.ToString(), ItemLine.Count, SingleTon.GetPlayerController().Inventory.CheckIfItemsIsEquipped(item))); } else { ItemLine.Add(SizeAble(element.name, element.describtion, element.Effect, element.Value.ToString(), element.itemType.ToString(), ItemLine.Count)); } } break; case InventoryDrawMenuState.Armor: foreach (BaseItem element in (SingleTon.GetPlayerController().Inventory.Inventory.Where(x => x is ArmorItem).ToList())) { ItemLine.Add(SizeAble(element.name, element.describtion, element.Effect, element.Value.ToString(), element.itemType.ToString(), ItemLine.Count, SingleTon.GetPlayerController().Inventory.CheckIfItemsIsEquipped((EquippableItem)element))); } break; case InventoryDrawMenuState.Weapon: foreach (BaseItem element in (SingleTon.GetPlayerController().Inventory.Inventory.Where(x => x is WeaponItem).ToList())) { ItemLine.Add(SizeAble(element.name, element.describtion, element.Effect, element.Value.ToString(), element.itemType.ToString(), ItemLine.Count, SingleTon.GetPlayerController().Inventory.CheckIfItemsIsEquipped((EquippableItem)element))); } break; case InventoryDrawMenuState.Consumeable: foreach (BaseItem element in (SingleTon.GetPlayerController().Inventory.Inventory.Where(x => x is ConsumableItem))) { ItemLine.Add(SizeAble(element.name, element.describtion, element.Effect, element.Value.ToString(), element.itemType.ToString(), ItemLine.Count)); } break; case InventoryDrawMenuState.Misc: foreach (BaseItem element in (SingleTon.GetPlayerController().Inventory.Inventory.Where(x => x is MiscItem))) { ItemLine.Add(SizeAble(element.name, element.describtion, "", element.Value.ToString(), element.itemType.ToString(), ItemLine.Count)); } break; } CW.FillOutStringBorder(ItemLine[0], true, InventoryContainerHeight.X, InventoryContainerHeight.Y + lineheight); lineheight++; CW.Write(ItemLine[0], InventoryContainerHeight.X, InventoryContainerHeight.Y + lineheight); lineheight++; CW.FillOutStringSplitter(ItemLine[0], InventoryContainerHeight.X, InventoryContainerHeight.Y + lineheight); lineheight++; for (int i = 1; i < ItemLine.Count; i++) { CW.Write(ItemLine[i], InventoryContainerHeight.X, InventoryContainerHeight.Y + lineheight); lineheight++; } CW.FillOutStringBorder(ItemLine[0], false, InventoryContainerHeight.X, InventoryContainerHeight.Y + lineheight); }
public Lumber(int LumberNumber, int Grade, double Depth, double Thick, string Description, int E, int Fb, int Fc, int Ft, int Fcp, int Fv, MSR MSR, CW CW, string SizeName) { this.LumberNumber = LumberNumber; this.Grade = Grade; this.DepthInches = Depth; this.ThickInches = Thick; this.Description = Description; this.EPSI = E; this.FbPSI = Fb; this.FcPSI = Fc; this.FtPSI = Ft; this.FcpPSI = Fcp; this.FvPSI = Fv; this.MSR = MSR; this.CW = CW; this.SizeName = SizeName; }
public bool CheckMoveMent() { Input = CW.ReadKey(); switch (Input.Key) { case ConsoleKey.UpArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y - 1)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y - 1]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.DownArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y + 1)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y + 1]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.LeftArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X - 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X - 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.RightArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X + 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X + 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.S: DrawStats = !DrawStats; if (DrawStats) { statsD.Draw(CW.GetPos().X + (MapDraw.ViewSize.X * 2) + 6, 2); return(false); } else { CW.Clear(); return(true); } case ConsoleKey.Enter: if (SingleTon.GetCursorInstance().CurrentTile is CityTile) { CityTile CT = (CityTile)SingleTon.GetCursorInstance().CurrentTile; DrawInfoBox.AddToBox("You have entered " + CT.CityName); CT.LoadMap().MapTile = SingleTon.GetCursorInstance().CurrentTile; SingleTon.GetCursorInstance().CurrentTile = CT.CityMap.SpawnPoint; SingleTon.GetMapManagerInstance().CurrentMap = CT.LoadMap(); CW.Clear(); return(true); } else if (SingleTon.GetCursorInstance().CurrentTile is Dungeon) { Dungeon DG = (Dungeon)SingleTon.GetCursorInstance().CurrentTile; DrawInfoBox.AddToBox("You have entered a dungeon"); DG.ParrentMap = SingleTon.GetMapManagerInstance().CurrentMap; SingleTon.GetMapManagerInstance().CurrentMap = DG.LoadMap(); DG.DungeonMap.MyTile = SingleTon.GetCursorInstance().CurrentTile; SingleTon.GetCursorInstance().CurrentTile = DG.LoadMap().SpawnPoint; PlayManager.State = PlayerState.Dungeon; return(true); } else { return(false); } case ConsoleKey.Escape: CityTile cityTile = (CityTile)SingleTon.GetMapManagerInstance().CurrentMap.MapTile; if (cityTile != null && cityTile.ParrentMap != null) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.MapTile; cityTile = (CityTile)SingleTon.GetMapManagerInstance().CurrentMap.MapTile; SingleTon.GetMapManagerInstance().CurrentMap = cityTile.ParrentMap; } return(true); case ConsoleKey.O: if (IntroMenu.test) { PlayManager.State = PlayerState.Combat; new CombatDraw().Draw(new Cord { X = 2, Y = 2 }); CW.ReadKey(); } return(false); case ConsoleKey.I: PlayManager.State = PlayerState.Inventory; CW.Clear(); new InventoryDraw().Draw(); return(false); default: return(false); } }
private void Process() { if (tcpClient.Connected) { Console.WriteLine(DateTime.Now + " [DEBUG][TCP] " + tcpClient.Client.RemoteEndPoint + " подключился"); //АВТОРИЗАЦИЯ Status = ClientStatus.Authorization; try { if (Authorization()) { Status = ClientStatus.Logged; } } catch (Exception) { tcpServer.ClientClosed(this); return; } if (Status == ClientStatus.Logged) { //if (Program.DEBUG) Console.WriteLine(DateTime.Now + " [DEBUG][TCP] " + tcpClient.Client.RemoteEndPoint + " авторизовался как " + Login); Status = ClientStatus.LoadData; { Send(JsonConvert.SerializeObject(new CW("dat", JsonConvert.SerializeObject(new CW.Data { login = Login, online = tcpServer.Online })))); CW.MessageToClient[] history = MySql_Client.LoadMessagePublic(Id); if (history != null) { for (int i = 0; i < history.Length; i++) { Send(JsonConvert.SerializeObject(new CW("mes", JsonConvert.SerializeObject(history[i])))); } } } Status = ClientStatus.Ready; Count++; Task.Factory.StartNew(() => tcpServer.ClientLogged(this)); try { while (true) { string inputData = Read(); if (inputData.Length == 2 && inputData[0] == 3 && inputData[1] == 65533) { Count--; Status = ClientStatus.Stopped; tcpServer.ClientClosed(this); return; } else if (inputData.Length > 1500) { continue; /*string json = JsonConvert.SerializeObject(new CW("err", "LEN"));*/ } else if (inputData.Length > 20) { CW wrap = JsonConvert.DeserializeObject <CW>(inputData); if (wrap.type == "mes") { CW.MessageFromClient json = JsonConvert.DeserializeObject <CW.MessageFromClient>(wrap.body); if (json.message.Length > 0) { Task.Factory.StartNew(() => tcpServer.Message(this, json.to, json.message)); } //if (Program.DEBUG) //Console.WriteLine(DateTime.Now + " [DEBUG][TCP] " + Login + ": " + json.message.Replace()); } else if (wrap.type == "getm") { Task.Factory.StartNew(() => { CW.MessageToClient[] history = MySql_Client.LoadMessagePrivate(Id, wrap.body); if (history != null) { for (int i = 0; i < history.Length; i++) { Send(JsonConvert.SerializeObject(new CW("mes", JsonConvert.SerializeObject(history[i])))); } } }); } } } } catch (System.IO.IOException) { Count--; Status = ClientStatus.Stopped; tcpServer.ClientClosed(this); return; } } else { tcpServer.ClientClosed(this); } } else { tcpServer.ClientClosed(this); } }
public bool MovementInDungeon() { Input = CW.ReadKey(); switch (Input.Key) { case ConsoleKey.UpArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y - 1)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y - 1]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.DownArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y + 1)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X, SingleTon.GetCursorInstance().CurrentTile.Pos.Y + 1]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.LeftArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X - 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X - 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.RightArrow: if (SingleTon.GetMapManagerInstance().CurrentMap.CheckLocation(SingleTon.GetCursorInstance().CurrentTile.Pos.X + 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y)) { SingleTon.GetCursorInstance().CurrentTile = SingleTon.GetMapManagerInstance().CurrentMap.Tiles[SingleTon.GetCursorInstance().CurrentTile.Pos.X + 1, SingleTon.GetCursorInstance().CurrentTile.Pos.Y]; SingleTon.GetPlayerController().Steps++; return(CheckForMonster()); } else { return(false); } case ConsoleKey.S: DrawStats = !DrawStats; if (DrawStats) { statsD.Draw(CW.GetPos().X + (MapDraw.ViewSize.X * 2) + 6, 2); return(false); } else { CW.Clear(); return(true); } case ConsoleKey.Escape: Dungeon DG = (Dungeon)SingleTon.GetMapManagerInstance().CurrentMap.MyTile; if (DG != null && DG.ParrentMap != null) { SingleTon.GetCursorInstance().CurrentTile = DG.DungeonMap.MyTile; SingleTon.GetMapManagerInstance().CurrentMap = DG.ParrentMap; PlayManager.State = PlayerState.WorldMap; } return(true); default: return(false); } }
public void Run() { State = PlayerState.WorldMap; CW.Clear(); ViewMap.DrawMap(); while (true) { switch (State) { case PlayerState.WorldMap: if (infoBoardSize < DrawInfoBox.Inputs.Count) { DIB.Draw(2, MapDraw.ViewSize.Y * 2 + 3); } if (movement.CheckMoveMent()) { ViewMap.DrawMap(); } break; case PlayerState.Dungeon: if (infoBoardSize < DrawInfoBox.Inputs.Count) { DIB.Draw(2, MapDraw.ViewSize.Y * 2 + 3); } if (movement.MovementInDungeon()) { ViewMap.DrawMap(); } break; case PlayerState.Store: break; case PlayerState.Combat: switch (movement.CombatMenuNavigation()) { case CombatMenuReturn.Menu: CD.RedrawAcionMenu(); break; case CombatMenuReturn.LogAndStatBlock: CD.ReDrawLog(); CD.ReDrawStats(); break; case CombatMenuReturn.Log: CD.ReDrawLog(); break; case CombatMenuReturn.StatAndMenu: CD.RedrawAcionMenu(); CD.ReDrawStats(); break; case CombatMenuReturn.All: CD.Draw(new Cord { X = 2, Y = 2 }); break; } break; case PlayerState.Inventory: switch (movement.InventoryNavigation()) { case InventoryMenuReturn.DrawInventoryContainer: ID.DrawInventoryContainer(); break; case InventoryMenuReturn.Everything: ID.Draw(); break; case InventoryMenuReturn.Gold: ID.DrawGold(); break; case InventoryMenuReturn.None: //why did I make this? break; case InventoryMenuReturn.TabsAndDrawInventoryContainer: ID.DrawInventoryContainer(); ID.DrawTabs(); break; } break; } } }
private void NidaleeOnDraw(EventArgs args) { if (Target != null) { Utility.DrawCircle(Target.Position, Target.BoundingRadius, Color.Red, 1, 1); } foreach (var spell in cougarList) { var circle = Config.Item("draw" + spell.Slot.ToString()).GetValue <Circle>(); if (circle.Active && Kitty && !Me.IsDead) { Utility.DrawCircle(Me.Position, spell.Range, circle.Color, 1, 1); } } foreach (var spell in humanList) { var circle = Config.Item("draw" + spell.Slot.ToString()).GetValue <Circle>(); if (circle.Active && !Kitty && !Me.IsDead) { Utility.DrawCircle(Me.Position, spell.Range, circle.Color, 1, 1); } } if (!Config.Item("drawcds").GetValue <bool>()) { return; } var wts = Drawing.WorldToScreen(Me.Position); if (!Kitty) // lets show cooldown timers for the opposite form :) { if (Me.Spellbook.CanUseSpell(SpellSlot.Q) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Null"); } else if (CQ == 0) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Ready"); } else { Drawing.DrawText(wts[0] - 80, wts[1], Color.Orange, "Q: " + CQ.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.W) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Null"); } else if (CW == 0) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Ready"); } else { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.Orange, "W: " + CW.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.E) == SpellState.NotLearned) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Null"); } else if (CE == 0) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Ready"); } else { Drawing.DrawText(wts[0], wts[1], Color.Orange, "E: " + CE.ToString("0.0")); } } else { if (Me.Spellbook.CanUseSpell(SpellSlot.Q) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Null"); } else if (HQ == 0) { Drawing.DrawText(wts[0] - 80, wts[1], Color.White, "Q: Ready"); } else { Drawing.DrawText(wts[0] - 80, wts[1], Color.Orange, "Q: " + HQ.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.W) == SpellState.NotLearned) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Null"); } else if (HW == 0) { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.White, "W: Ready"); } else { Drawing.DrawText(wts[0] - 30, wts[1] + 30, Color.Orange, "W: " + HW.ToString("0.0")); } if (Me.Spellbook.CanUseSpell(SpellSlot.E) == SpellState.NotLearned) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Null"); } else if (HE == 0) { Drawing.DrawText(wts[0], wts[1], Color.White, "E: Ready"); } else { Drawing.DrawText(wts[0], wts[1], Color.Orange, "E: " + HE.ToString("0.0")); } } }
private bool Authorization() { string inputData = ReadHttp(); if (inputData.Length > 15 && inputData.Substring(0, 14) == "GET /websocket" && Regex.IsMatch(inputData, "Connection: Upgrade") && Regex.IsMatch(inputData, "Upgrade: websocket")) { SendHttp("HTTP/1.1 101 Switching Protocols" + Environment.NewLine + "Connection: Upgrade" + Environment.NewLine + "Upgrade: websocket" + Environment.NewLine + "Sec-WebSocket-Accept: " + Convert.ToBase64String( System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes( new Regex("Sec-WebSocket-Key: (.*)").Match(inputData).Groups[1].Value.Trim() + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))) + Environment.NewLine + Environment.NewLine); useWebsocket = true; } else if (inputData == "CONNECT STANDART TCP") { useWebsocket = false; Send("CONNECTION OPEN"); } else { Console.WriteLine(DateTime.Now + " [DEBUG][TCP] " + tcpClient.Client.RemoteEndPoint + " прислал ЭТО " + inputData); SendHttp("ERROR-FORMAT"); return(false); } while (true) { inputData = Read(); CW wrap = JsonConvert.DeserializeObject <CW>(inputData); if (wrap.type != null && wrap.body != null) { if (wrap.type == "log") { CW.Login loginJSON = JsonConvert.DeserializeObject <CW.Login>(wrap.body); if (loginJSON.login != null && loginJSON.pass != null && loginJSON.login.Length >= 4 && loginJSON.pass.Length >= 4) { if (loginJSON.withpass) { string[] res = MySql_Client.CheckUser(loginJSON.login, loginJSON.pass); if (res != null) { Id = Convert.ToUInt32(res[0]); Login = res[1]; Send("LOGINED-SUCCSESS-ENTER-CHAT"); return(true); } else { Send("ERROR-LOGIN-PASSWORD"); } } else { Send("NOT-WORK-USE-WITHPASS"); } } else { Send("ERROR-DATA-CONNECTION-CLOSING"); return(false); } } else if (wrap.type == "reg") { CW.Registration regJSON = JsonConvert.DeserializeObject <CW.Registration>(wrap.body); if (regJSON.login != null && regJSON.pass != null && regJSON.email != null) { if (Regular.CheckLogin(regJSON.login)) { if (Regular.CheckPass(regJSON.pass)) { if (Regular.CheckEmail(regJSON.email)) { Id = MySql_Client.RegNewUser(regJSON.login, regJSON.pass, regJSON.email); if (Id > 0) { Login = regJSON.login; Send("REGISTR-SUCCSESS-ENTER-CHAT"); return(true); } else { Send("ERR-REGEXIST"); } } else { Send("ERR-REGEMAIL"); } } else { Send("ERR-REGPASS"); } } else { Send("ERR-REGLOGIN"); } } else { Send("ERROR-DATA-CONNECTION-CLOSING"); return(false); } } else { Console.WriteLine(inputData); Send("ERROR-DATA-CONNECTION-CLOSING"); return(false); } } else { Send("ERROR-DATA-CONNECTION-CLOSING"); return(false); } } }