public static double GetStrength(string value) { CharSelection selection = GetSelections(value); int charCount = GetTotalCharCountForSelection(selection); double strength = Math.Pow(value.Length, charCount); return(strength); }
public static void CharSelectionCB(Packet packet) { List <CharacterSelectionEntry> characters = new List <CharacterSelectionEntry>(); int id = packet.ReadInt(); int session_id = packet.ReadInt(); for (int i = 0; i < 8; i++) { CharacterSelectionEntry entry = packet.ReadCharacterSelectionEntry(); characters.Add(entry); } Client.instance.setSessionId(session_id); SceneManager.ClearScenes(); SceneManager.TryAddSceneNoDupe(ScenePrefabs.SelectionGUI, "Game"); CharSelection.SetCharacters(characters.ToArray()); }
//On Click public void OnClick() { ResetAllButtons(); Selected = true; if (Border) { Border.color = BorderColorHighlight; } //play sfx GlobalAudioPlayer.PlaySFX(PlaySFXOnClick); //set selected player prefab CharSelection Cs = GameObject.FindObjectOfType <CharSelection>(); if (Cs) { Cs.SelectPlayer(PlayerPrefab); } }
public static CharSelection GetSelections(string value) { CharSelection selections = CharSelection.None; foreach (char curChar in value) { if (SIMPLERANDOMGENERATOR_CHARSELECTION_LOWERCASE.Contains(curChar.ToString())) { selections |= CharSelection.Lowercase; } else if (SIMPLERANDOMGENERATOR_CHARSELECTION_UPPERCASE.Contains(curChar.ToString())) { selections |= CharSelection.Uppercase; } else if (SIMPLERANDOMGENERATOR_CHARSELECTION_DIGITS.Contains(curChar.ToString())) { selections |= CharSelection.Digits; } else if (SIMPLERANDOMGENERATOR_CHARSELECTION_MINUS.Contains(curChar.ToString())) { selections |= CharSelection.Minus; } else if (SIMPLERANDOMGENERATOR_CHARSELECTION_UNDERLINE.Contains(curChar.ToString())) { selections |= CharSelection.Underline; } else if (SIMPLERANDOMGENERATOR_CHARSELECTION_SPACE.Contains(curChar.ToString())) { selections |= CharSelection.Space; } else if (SIMPLERANDOMGENERATOR_CHARSELECTION_BRACKETS.Contains(curChar.ToString())) { selections |= CharSelection.Brackets; } else if (SIMPLERANDOMGENERATOR_CHARSELECTION_OTHER.Contains(curChar.ToString())) { selections |= CharSelection.Other; } } return(selections); }
public static int GetTotalCharCountForSelection(CharSelection selection) { int totalCount = 0; if (selection.HasFlag(CharSelection.Lowercase)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_LOWERCASE.Length; } if (selection.HasFlag(CharSelection.Uppercase)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_UPPERCASE.Length; } if (selection.HasFlag(CharSelection.Digits)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_DIGITS.Length; } if (selection.HasFlag(CharSelection.Minus)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_MINUS.Length; } if (selection.HasFlag(CharSelection.Underline)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_UNDERLINE.Length; } if (selection.HasFlag(CharSelection.Space)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_SPACE.Length; } if (selection.HasFlag(CharSelection.Brackets)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_BRACKETS.Length; } if (selection.HasFlag(CharSelection.Other)) { totalCount += SIMPLERANDOMGENERATOR_CHARSELECTION_OTHER.Length; } return(totalCount); }
public override void _Ready() { instance = this; playBtn = GetTree().Root.FindNode("PlayBtn", true, false) as Button; playBtn.Disabled = true; Node parent = GetTree().Root.FindNode("CharContainer", true, false); if (parent != null) { for (int i = 0; i < Characters.Count; i++) { CharSlot newCharslot = s_charslot.Instance() as CharSlot; newCharslot.GetNode <Label>("NameLabel").Text = Characters[i].getName(); newCharslot.AssignAttr(Characters[i]); parent.AddChild(newCharslot, true); } } else { GD.PrintErr("Failed to find the character container ndoe when creating character list."); } }
public void OnClick() { ResetAllButtons(); Selected = true; if (Border) { Border.color = BorderColorHighlight; } //播放点击音效 GlobalAudioPlayer.PlaySFX(PlaySFXOnClick); //设置两个角色的预制体 CharSelection Cs = GameObject.FindObjectOfType <CharSelection>(); if (Cs) { Cs.SelectPlayer(PlayerPrefab); } //为此玩家设置平视显示器图标 GlobalPlayerData.PlayerHUDProtrait = HUDPortrait; }
public void onSelect() { CharSelection.selectedPid = this.slot.getPid(); CharSelection.UpdatePlayerButtonStatus(); }
public static String QuickGetRandomString( CharSelection selection, Int32 length, bool atLeastOneOfEachGroup) { string random = String.Empty; StringBuilder chars = new StringBuilder(); if (selection.HasFlag(CharSelection.Lowercase)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_LOWERCASE); } if (selection.HasFlag(CharSelection.Uppercase)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_UPPERCASE); } if (selection.HasFlag(CharSelection.Digits)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_DIGITS); } if (selection.HasFlag(CharSelection.Minus)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_MINUS); } if (selection.HasFlag(CharSelection.Underline)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_UNDERLINE); } if (selection.HasFlag(CharSelection.Space)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_SPACE); } if (selection.HasFlag(CharSelection.Brackets)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_BRACKETS); } if (selection.HasFlag(CharSelection.Other)) { chars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_OTHER); } random = SimpleRandomGenerator.QuickGetRandomString(chars.ToString(), length); int groupCount = 0; groupCount += (selection.HasFlag(CharSelection.Lowercase)) ? 1 : 0; groupCount += (selection.HasFlag(CharSelection.Uppercase)) ? 1 : 0; groupCount += (selection.HasFlag(CharSelection.Digits)) ? 1 : 0; groupCount += (selection.HasFlag(CharSelection.Minus | CharSelection.Underline | CharSelection.Space | CharSelection.Brackets | CharSelection.Other)) ? 1 : 0; if (atLeastOneOfEachGroup && length >= groupCount) { StringBuilder specialChars = new StringBuilder(); if (selection.HasFlag(CharSelection.Minus)) { specialChars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_MINUS); } if (selection.HasFlag(CharSelection.Underline)) { specialChars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_UNDERLINE); } if (selection.HasFlag(CharSelection.Space)) { specialChars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_SPACE); } if (selection.HasFlag(CharSelection.Brackets)) { specialChars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_BRACKETS); } if (selection.HasFlag(CharSelection.Other)) { specialChars.Append(SIMPLERANDOMGENERATOR_CHARSELECTION_OTHER); } bool fixing = true; while (fixing) { fixing = false; if (selection.HasFlag(CharSelection.Lowercase)) { if (!StringContainsOneOf(random, SIMPLERANDOMGENERATOR_CHARSELECTION_LOWERCASE)) { fixing = true; string single = SimpleRandomGenerator.QuickGetRandomString(SIMPLERANDOMGENERATOR_CHARSELECTION_LOWERCASE, 1); int index = SimpleRandomGenerator.QuickGetRandomInt(1, random.Length) - 1; random = random.Remove(index, 1); random = random.Insert(index, single); } } if (selection.HasFlag(CharSelection.Uppercase)) { if (!StringContainsOneOf(random, SIMPLERANDOMGENERATOR_CHARSELECTION_UPPERCASE)) { fixing = true; string single = SimpleRandomGenerator.QuickGetRandomString(SIMPLERANDOMGENERATOR_CHARSELECTION_UPPERCASE, 1); int index = SimpleRandomGenerator.QuickGetRandomInt(1, random.Length) - 1; random = random.Remove(index, 1); random = random.Insert(index, single); } } if (selection.HasFlag(CharSelection.Digits)) { if (!StringContainsOneOf(random, SIMPLERANDOMGENERATOR_CHARSELECTION_DIGITS)) { fixing = true; string single = SimpleRandomGenerator.QuickGetRandomString(SIMPLERANDOMGENERATOR_CHARSELECTION_DIGITS, 1); int index = SimpleRandomGenerator.QuickGetRandomInt(1, random.Length) - 1; random = random.Remove(index, 1); random = random.Insert(index, single); } } if (specialChars.Length > 0) { if (!StringContainsOneOf(random, specialChars.ToString())) { fixing = true; string single = SimpleRandomGenerator.QuickGetRandomString(specialChars.ToString(), 1); int index = SimpleRandomGenerator.QuickGetRandomInt(1, random.Length) - 1; random = random.Remove(index, 1); random = random.Insert(index, single); } } } } return(random); }