public AuctionEntry(int timeRemaining, int highestBid, int highestBidder, int randomId = -1) { RandomId = RandomID.NextRandomId(randomId); this.timeRemaining = timeRemaining; this.highestBid = highestBid; this.highestBidder = highestBidder; }
public TwoPlayer(User inviting, User invitee, bool accepted, int randomId = -1) { RandomId = RandomID.NextRandomId(randomId); Inviting = inviting; Invitee = invitee; Accepted = accepted; PosX = Invitee.X; PosY = Invitee.Y; byte[] youHaveInvited = PacketBuilder.CreateChat(Messages.Format2PlayerYouInvited(inviting.Username), PacketBuilder.CHAT_BOTTOM_RIGHT); byte[] yourInvited = PacketBuilder.CreateChat(Messages.Format2PlayerYourInvited(invitee.Username), PacketBuilder.CHAT_BOTTOM_RIGHT); Invitee.LoggedinClient.SendPacket(youHaveInvited); Inviting.LoggedinClient.SendPacket(yourInvited); deleteTimer = new Timer(new TimerCallback(deleteTwoPlayer), null, 2 * 60 * 1000, 2 * 60 * 1000); twoPlayerGames.Add(this); update(); if (Multiroom.IsMultiRoomAt(PosX, PosY)) { this.Multiroom = Multiroom.GetMultiroom(PosX, PosY); } }
/// <summary> /// Register for any interested events. /// </summary> public override void Awake() { base.Awake(); m_ItemSetManager = m_GameObject.GetCachedComponent <ItemSetManagerBase>(); m_ItemSetManager.Initialize(false); // If the CategoryID is empty then the category hasn't been initialized. Use the first category index. if (RandomID.IsIDEmpty(m_ItemSetCategoryID) && m_ItemSetManager.CategoryItemSets.Length > 0) { m_ItemSetCategoryID = m_ItemSetManager.CategoryItemSets[0].CategoryID; } m_ItemSetCategoryIndex = m_ItemSetManager.CategoryIDToIndex(m_ItemSetCategoryID); var equipUnequipAbilities = GetAbilities <EquipUnequip>(); if (equipUnequipAbilities != null) { // The ItemSet CategoryID must match for the ToggleEquip ability to be able to use the EquipUnequip ability. for (int i = 0; i < equipUnequipAbilities.Length; ++i) { if (equipUnequipAbilities[i].ItemSetCategoryID == m_ItemSetCategoryID) { m_EquipUnequipItemAbility = equipUnequipAbilities[i]; break; } } } }
public Client(Socket socket) { ID = RandomID.Generate(); IP = ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(); Port = ((IPEndPoint)socket.RemoteEndPoint).Port; this.Socket = socket; this.Buffer = new byte[PacketStream.MaxBuffer]; this.Data = new PacketStream(); }
public HorseInstance(HorseInfo.Breed breed, int randomId = -1, string loadName = null, string loadDescription = "", int loadSpoiled = 0, string loadCategory = "KEEPER", int loadMagicUsed = 0, int loadAutoSell = 0, int leaseTimer = 0, bool loadHidden = false, int loadOwner = 0) { RandomId = RandomID.NextRandomId(randomId); owner = loadOwner; if (loadName == null) { if (breed.Type == "camel") { name = "Wild Camel"; } else if (breed.Type == "llama") { name = "Jungle Llama"; } else if (breed.Type == "zebra") { name = "Wild Zebra"; } else { name = "Wild Horse"; } } else { name = loadName; } if (GameServer.RandomNumberGenerator.Next(0, 100) > 50) { Gender = breed.GenderTypes()[1]; } else { Gender = breed.GenderTypes()[0]; } description = loadDescription; Breed = breed; Color = breed.Colors[GameServer.RandomNumberGenerator.Next(0, breed.Colors.Length)]; BasicStats = new HorseInfo.BasicStats(this, 1000, 0, 1000, 1000, 500, 200, 1000, 0); int inteligence = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Inteligence, (breed.BaseStats.Inteligence * 2)) - breed.BaseStats.Inteligence); int personality = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Personality, (breed.BaseStats.Personality * 2)) - breed.BaseStats.Personality); int height = GameServer.RandomNumberGenerator.Next(breed.BaseStats.MinHeight, breed.BaseStats.MaxHeight); AdvancedStats = new HorseInfo.AdvancedStats(this, 0, 0, 0, 0, inteligence, 0, personality, height); Equipment = new HorseInfo.HorseEquips(); autosell = loadAutoSell; category = loadCategory; spoiled = loadSpoiled; magicUsed = loadMagicUsed; leaseTime = leaseTimer; hidden = loadHidden; Leaser = 0; }
/// <summary> /// Draws the Categories editor. /// </summary> private void DrawCategories() { var categories = m_ItemCollection.Categories; if (categories == null) { // At least one category needs to exist. var category = ScriptableObject.CreateInstance <Category>(); category.ID = RandomID.Generate(); category.name = "Items"; categories = m_ItemCollection.Categories = new Category[] { category }; AssetDatabase.AddObjectToAsset(category, AssetDatabase.GetAssetPath(m_ItemCollection)); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection)); } EditorGUILayout.BeginHorizontal(); GUI.SetNextControlName("CategoryName"); m_CategoryName = EditorGUILayout.TextField("Name", m_CategoryName); GUI.enabled = !string.IsNullOrEmpty(m_CategoryName) && (m_CategoryTreeView.TreeModal as CategoryCollectionModal).IsUniqueName(m_CategoryName); if (GUILayout.Button("Add", GUILayout.Width(100)) || (Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "CategoryName")) { // Create the new Category. var category = ScriptableObject.CreateInstance <Category>(); category.name = m_CategoryName; category.ID = RandomID.Generate(); // Add the Category to the ItemCollection. Array.Resize(ref categories, categories.Length + 1); categories[categories.Length - 1] = category; m_ItemCollection.Categories = categories; AssetDatabase.AddObjectToAsset(category, m_ItemCollection); // Reset. EditorUtility.SetDirty(m_ItemCollection); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection)); m_CategoryName = string.Empty; GUI.FocusControl(""); m_CategoryTreeView.Reload(); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; GUILayout.Space(5); if (categories != null) { var guiRect = GUILayoutUtility.GetLastRect(); var height = m_MainManagerWindow.position.height - guiRect.yMax - 21; m_CategoryTreeView.searchString = m_CategorySearchField.OnGUI(new Rect(0, guiRect.yMax, m_MainManagerWindow.position.width - m_MainManagerWindow.MenuWidth - 2, 20), m_CategoryTreeView.searchString); m_CategoryTreeView.OnGUI(new Rect(0, guiRect.yMax + 20, m_MainManagerWindow.position.width - m_MainManagerWindow.MenuWidth - 1, height)); // OnGUI doesn't update the GUILayout rect so add a blank space to account for it. GUILayout.Space(height + 10); } }
private void reset() { // Delete all entries entries.Clear(); RandomId = RandomID.NextRandomId(); Mode = "TAKINGENTRIES"; if (arenaTimeout != null) { arenaTimeout.Dispose(); } arenaTimeout = null; }
/// <summary> /// Returns a new ID for the category. /// </summary> /// <returns>The new cateogry ID.</returns> public static uint GenerateID() { uint id; // The category ID is stored as a uint. Inspector fields aren't able to cast to a uint so keep generating a new ID for as long as // the value is greater than the max int value. do { id = RandomID.Generate(); } while (id > int.MaxValue); return(id); }
public Arena(int id, string type, int entryCost, int raceEvery, int slots, int timeOut) { RandomId = RandomID.NextRandomId(); Mode = "TAKINGENTRIES"; Id = id; Type = type; EntryCost = entryCost; RaceEvery = raceEvery; Slots = slots; Timeout = timeOut; arenas.Add(this); entries = new List <ArenaEntry>(); }
public Connection(Socket socket, ConnectionType conType) { if (conType == ConnectionType.Client) { ID = RandomID.Generate(); IP = ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(); Port = ((IPEndPoint)socket.RemoteEndPoint).Port; } this.Socket = socket; this.Buffer = new byte[PacketStream.MaxBuffer]; this.Data = new PacketStream(); }
//[AuthorizationFilter("User")] public IActionResult ListPool(NumJuror model) { int numberOfJurors = model.numberOfJurors; JurySQLDAO jurySQLDAO = new JurySQLDAO(); JuryPool jury = new JuryPool(); int rows = jurySQLDAO.GetRows(); RandomID randomID = new RandomID(); for (int i = 0; i < numberOfJurors; i++) { Juror juror = new Juror(); juror = jurySQLDAO.GetJuror(randomID.getRandomID(rows)); jury.Pool.Add(juror); } return(View(jury)); }
public IActionResult ListPool(int numberOfJurors) { //added temp data to ensure working code //int numberOfJurors = numJuror.numberOfJurors; JurySQLDAO jurySQLDAO = new JurySQLDAO(); numberOfJurors = 7; JuryPool jury = new JuryPool(); int rows = jurySQLDAO.GetRows(); RandomID randomID = new RandomID(); for (int i = 0; i < numberOfJurors; i++) { Juror juror = new Juror(); juror = jurySQLDAO.GetJuror(randomID.getRandomID(rows)); jury.Pool.Add(juror); } return(View(jury)); }
static void Main(string[] args) { Console.WriteLine("Please enter the number of Jurors need for this pool:"); string temp = Console.ReadLine(); int numberOfJurors; bool success = Int32.TryParse(temp, out numberOfJurors); if (success) { numberOfJurors = int.Parse(temp); JuryPool juryPool = new JuryPool(); JurySQLDAO juryDAO = new JurySQLDAO(); RandomID randomID = new RandomID(); int numberOfRows = juryDAO.GetRows(); for (int i = 0; i < numberOfJurors; i++) { Juror juror = new Juror(); juror = juryDAO.GetJuror(randomID.getRandomID(numberOfRows)); juryPool.Pool.Add(juror); } Console.WriteLine(); Console.WriteLine("Jury Pool:"); Console.WriteLine(); foreach (Juror juror in juryPool.Pool) { Console.WriteLine(juror.firstName + " " + juror.lastName); Console.WriteLine(juror.streetAddress); Console.WriteLine(juror.city + ", " + juror.state + " " + juror.zipcode); Console.WriteLine(); } } else { Console.WriteLine("Please enter a valid whole number"); } Console.ReadLine(); }
/// <summary> /// Draws the fields related to the inspector drawer. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> protected override void DrawInspectorDrawerFields(object target, Object parent) { // ItemCollection must exist for the categories to be populated. var itemSetManager = (parent as UltimateCharacterLocomotion).GetComponent <ItemSetManagerBase>(); if (itemSetManager == null) { EditorGUILayout.HelpBox("The character must have the ItemSetManager component.", MessageType.Error); return; } itemSetManager.Initialize(false); if (itemSetManager.CategoryItemSets == null || itemSetManager.CategoryItemSets.Length == 0) { return; } // Draw a popup with all of the ItemSet categories. var categoryID = InspectorUtility.GetFieldValue <uint>(target, "m_ItemSetCategoryID"); var selected = -1; var categoryNames = new string[itemSetManager.CategoryItemSets.Length]; for (int i = 0; i < categoryNames.Length; ++i) { categoryNames[i] = itemSetManager.CategoryItemSets[i].CategoryName; if (categoryID == itemSetManager.CategoryItemSets[i].CategoryID) { selected = i; } } var newSelected = EditorGUILayout.Popup("ItemSet Category", (selected != -1 ? selected : 0), categoryNames); if (selected != newSelected || RandomID.IsIDEmpty(categoryID)) { InspectorUtility.SetFieldValue(target, "m_ItemSetCategoryID", itemSetManager.CategoryItemSets[newSelected].CategoryID); GUI.changed = true; } base.DrawInspectorDrawerFields(target, parent); }
public IHttpActionResult PostStudentProfile(int num, string type) { string result = ""; DateTime timeStart = DateTime.Now; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var studentProfileList = new List <StudentProfile>(); var randomId = new RandomID(); List <string> randomIDs = randomId.getRandomIDs(num); DateTime timeIdDone = DateTime.Now; result += "generate ID costs " + Util.getSecond(timeStart, timeIdDone) + " sec, "; var randomName = new RandomName(new Random()); List <string> randomNames = randomName.RandomNames(num, 2); DateTime timeNameDone = DateTime.Now; result += "generate Name costs " + Util.getSecond(timeIdDone, timeNameDone) + " sec, "; List <string> randomGenders = Util.getRandomList(Const.Gender, num); List <string> randomBloods = Util.getRandomList(Const.Blood, num); List <decimal> randomHeights = Util.getRandomDecimalList(150, 200, 1, num); List <decimal> randomWeights = Util.getRandomDecimalList(40, 100, 1, num); DateTime timeOtherDone = DateTime.Now; result += "generate other columns costs " + Util.getSecond(timeNameDone, timeOtherDone) + " sec, "; for (int i = 0; i < num; i++) { var item = new StudentProfile { guid = Guid.NewGuid(), Id = randomIDs[i], Name = randomNames[i], Gender = randomGenders[i], Blood = randomBloods[i], Height = randomHeights[i], Weight = randomWeights[i], CreateDate = DateTime.Now }; studentProfileList.Add(item); } randomIDs.Clear(); randomIDs.TrimExcess(); randomNames.Clear(); randomNames.TrimExcess(); randomGenders.Clear(); randomGenders.TrimExcess(); randomBloods.Clear(); randomBloods.TrimExcess(); randomHeights.Clear(); randomHeights.TrimExcess(); randomWeights.Clear(); randomWeights.TrimExcess(); GC.Collect(); DateTime timeListDone = DateTime.Now; result += "put into List costs " + Util.getSecond(timeOtherDone, timeListDone) + " sec, "; bool dbResult; switch (type) { case "ADO_For": dbResult = MassInsert_ADO_For(studentProfileList); break; case "EF_AddRange": dbResult = MassInsert_EF_AddRange(studentProfileList); break; case "SqlBulkCopy": dbResult = MassInsert_SqlBulkCopy(studentProfileList); break; case "TVP": dbResult = MassInsert_TVP(studentProfileList); break; default: return(BadRequest("invalid type: " + type)); } studentProfileList.Clear(); studentProfileList.TrimExcess(); GC.Collect(); if (!dbResult) { result += "save DB has error, see detail in EventLog"; return(Ok(new { result })); } DateTime timeDbDone = DateTime.Now; result += "save to DB costs " + Util.getSecond(timeListDone, timeDbDone) + " sec, "; DateTime timeEnd = DateTime.Now; result += "total costs " + Util.getSecond(timeStart, timeEnd) + " sec."; return(Ok(new { result })); }
public MainForm() { InitializeComponent(); randomID = new RandomID(); }
/// <summary> /// Draws the ItemTypeManager. /// </summary> public override void OnGUI() { var toolbarSelection = GUILayout.Toolbar(m_DrawItemType ? 0 : 1, m_ToolbarStrings, EditorStyles.toolbarButton); m_DrawItemType = toolbarSelection == 0; GUILayout.Space(10); if (m_DrawItemType) { GUILayout.Label("Item Types", InspectorStyles.CenterBoldLabel); } else { GUILayout.Label("Categories", InspectorStyles.CenterBoldLabel); } EditorGUILayout.BeginHorizontal(); var itemCollection = EditorGUILayout.ObjectField("Item Collection", m_ItemCollection, typeof(ItemCollection), false) as ItemCollection; if (GUILayout.Button("Create", GUILayout.MaxWidth(100))) { var path = EditorUtility.SaveFilePanel("Save Item Collection", "Assets", "ItemCollection.asset", "asset"); if (path.Length != 0 && Application.dataPath.Length < path.Length) { itemCollection = ScriptableObject.CreateInstance <ItemCollection>(); var category = ScriptableObject.CreateInstance <Category>(); category.ID = RandomID.Generate(); category.name = "Items"; itemCollection.Categories = new Category[] { category }; // Save the collection. path = string.Format("Assets/{0}", path.Substring(Application.dataPath.Length + 1)); AssetDatabase.DeleteAsset(path); AssetDatabase.CreateAsset(itemCollection, path); AssetDatabase.AddObjectToAsset(category, path); AssetDatabase.ImportAsset(path); } } EditorGUILayout.EndHorizontal(); if (itemCollection != m_ItemCollection) { m_ItemCollection = itemCollection; if (m_ItemCollection != null) { EditorPrefs.SetString(ManagerUtility.LastItemCollectionGUIDString, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(itemCollection))); (m_CategoryTreeView.TreeModal as CategoryCollectionModal).ItemCollection = m_ItemCollection; (m_ItemTypeTreeView.TreeModal as ItemTypeCollectionModal).ItemCollection = m_ItemCollection; } else { EditorPrefs.SetString(ManagerUtility.LastItemCollectionGUIDString, string.Empty); (m_CategoryTreeView.TreeModal as CategoryCollectionModal).ItemCollection = null; (m_ItemTypeTreeView.TreeModal as ItemTypeCollectionModal).ItemCollection = null; } m_CategoryTreeView.Reload(); m_ItemTypeTreeView.Reload(); } // ItemCollection must be populated in order to create Categories/ItemTypes. if (m_ItemCollection == null) { EditorGUILayout.HelpBox("An ItemCollection must be selected. Use the \"Create\" button to create a new collection.", MessageType.Error); return; } if (m_DrawItemType) { DrawItemTypes(); } else { DrawCategories(); } }
/// <summary> /// Draws the identify, duplicate and delete buttons for the category. /// </summary> /// <param name="rowRect">The rect of the category row.</param> /// <param name="id">The id of the category to draw the controls of.</param> /// <returns>True if the controls changed the ItemCollection.</returns> private bool DrawControls(Rect rowRect, int id) { var duplicateRect = rowRect; duplicateRect.x = duplicateRect.width - 44; duplicateRect.width = 20; duplicateRect.y += 4; duplicateRect.height = 16; if (GUI.Button(duplicateRect, InspectorStyles.DuplicateIcon, InspectorStyles.NoPaddingButtonStyle)) { // Generate a unique name for the category. var categories = m_ItemCollection.Categories; var category = categories[id]; var index = 1; string name; do { name = category.name + " (" + index + ")"; index++; } while (!IsUniqueName(name)); var clonedCategory = ScriptableObject.CreateInstance <Category>(); clonedCategory.ID = RandomID.Generate(); clonedCategory.name = name; AssetDatabase.AddObjectToAsset(clonedCategory, m_ItemCollection); // Add the Category to the ItemCollection. Array.Resize(ref categories, categories.Length + 1); categories[categories.Length - 1] = clonedCategory; m_ItemCollection.Categories = categories; EditorUtility.SetDirty(m_ItemCollection); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection)); return(true); } var deleteRect = rowRect; deleteRect.x = deleteRect.width - 20; deleteRect.width = 18; deleteRect.y += 4; deleteRect.height = 16; GUI.enabled = m_ItemCollection.Categories.Length > 1; if (GUI.Button(deleteRect, InspectorStyles.DeleteIcon, InspectorStyles.NoPaddingButtonStyle)) { // The category can't be deleted if other ItemTypes depend on it. var canRemove = true; for (int i = 0; i < m_ItemCollection.ItemTypes.Length; ++i) { var categoryIDs = m_ItemCollection.ItemTypes[i].CategoryIDs; for (int j = 0; j < categoryIDs.Length; ++j) { if (categoryIDs[j] == m_ItemCollection.Categories[id].ID) { EditorUtility.DisplayDialog("Unable to Delete", "Unable to delete the category: the ItemType " + m_ItemCollection.ItemTypes[i].name + " uses this category", "OK"); canRemove = false; break; } } if (!canRemove) { break; } } if (canRemove) { if (m_BeforeModalChange != null) { m_BeforeModalChange(); } // Remove the category. Undo.DestroyObjectImmediate(m_ItemCollection.Categories[id]); var categories = new List <Category>(m_ItemCollection.Categories); categories.RemoveAt(id); m_ItemCollection.Categories = categories.ToArray(); EditorUtility.SetDirty(m_ItemCollection); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection)); } GUI.enabled = true; return(true); } GUI.enabled = true; return(false); }
public ItemInstance(int id, int randomId = -1, int data = 0) { RandomId = RandomID.NextRandomId(randomId); Data = data; ItemId = id; }
public Trade(User me) { RandomId = RandomID.NextRandomId(); Trader = me; }