private async Task <TimeSpan> LoadFromExternalDatabase() { var table = await _externalDb.FetchAllMembers(Settings.UserName); _logger.LogInfo("Found " + table.Count + " members in databse"); foreach (var member in table) { Members.Add(member.ProfileId, member); switch (member.Status) { case IEMember.MEMBER_NEW: NewItems.Add(member); break; case IEMember.MEMBER_REJECTED: RejectedItems.Add(member); break; default: ActiveItems.Add(member); break; } } NewItems.Sort(); RejectedItems.Sort(); ActiveItems.Sort(); TimeScheduler.GetTimeScheduler().AddTask(DS_TASK_NAME, TimeSpan.FromSeconds(INITIAL_DELAY), () => OnTimedEvent()); return(TimeScheduler.STOP_TIMER); // This stops us being re-scheduled }
public void GetNews() { int r = Random.Range(0, lstNews.Count); valueNews = (int)(GameManager.Instance.SRD * Random.Range(0.05f, 0.1f) * 100); NewChoosed = lstNews[r]; Debug.Log("<color=yellow>News: </color>" + NewChoosed.content + " " + valueNews + "%"); }
public void CancelNew(int itemIndex) { if (itemIndex >= 0 && itemIndex < List.Count) { NewItems.Remove(List[itemIndex]); } BindingListImpl.CancelNew(itemIndex); }
public List <LuxScanItem> Convert() { foreach (var item in RawLines) { if (item.StartsWith("Item") || IsUsableItem(item)) { _logger.Debug("Converter létrehozása"); _converter = new IDConverter(item); _logger.Debug("ID megszerzése"); var id = _converter.GetID(); _logger.Debug($"Az LuxScanItem megszerzése a {id}-hoz"); var luxscanItem = RawItems.Where(r => r.ID == id).FirstOrDefault(); _logger.Debug($"Az Itemtípus megszerzése a {id}-hoz"); var itemType = GetItemType(item); switch (itemType) { case "Item": if (IsActiveItem(item)) { _logger.Debug($"Az {id} aktív"); var kilokoGetter = new KilokoGetter(item); _logger.Debug($"Az Kilőkők megszerzése a {id}-hoz"); var kilokoNum = kilokoGetter.GetKilokoNum(); var kiloko = KilokoGetter.GetKilokoFromCodeTable(kilokoNum); _logger.Debug($"Az új LuxScanItem hozzáadása"); RawItems.Add(new LuxScanItem(id, kiloko)); } break; case "ItemName": var rawItem = RawItems.Where(r => r.ID == id).FirstOrDefault(); if (rawItem != default) { _logger.Debug($"Az új cikk hozzáadása az {id}-hoz"); rawItem.AddItem(item.Split('=')[1]); } break; } } } NewItems?.Invoke(this, RawItems); return(RawItems); }
/// <summary> /// Recycles this instance of the <see cref="CollectionChangedEventArgs{T}"/> class. /// </summary> /// <remarks> /// <para> /// This method resets this instance and returns it to a resource pool if resource pooling is /// enabled (see <see cref="ResourcePool.Enabled">ResourcePool.Enabled</see>). /// </para> /// </remarks> public void Recycle() { Action = CollectionChangedAction.Add; NewItemsIndex = -1; NewItems.Clear(); OldItemsIndex = -1; OldItems.Clear(); Pool.Recycle(this); }
public override int GetHashCode() { unchecked { var hashCode = (int)Action; hashCode = (hashCode * 397) ^ (NewItems != null ? NewItems.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OldItems != null ? OldItems.GetHashCode() : 0); hashCode = (hashCode * 397) ^ NewStartingIndex; hashCode = (hashCode * 397) ^ OldStartingIndex; return(hashCode); } }
void AddInternal(object value) { if (IsTrackingChanges) { if (DelItems.Contains(value)) { DelItems.Remove(value); } else { NewItems.Add(value); } } OnAdd(value); }
private void RemoveInternal(object value) { if (IsTrackingChanges) { if (NewItems.Contains(value)) { NewItems.Remove(value); } else { DelItems.Add(value); } } OnRemove(value); }
/* * This method is used to search for users who are currently logged in */ private async Task <bool> DoMatchFinder(bool byLogin) { List <IEProfile> profiles; bool newMemberFound = false; if (byLogin) { profiles = await _session.OnLine(Settings.SearchForFemales, Settings.MinAge, Settings.MinAge, Settings.Regions, Settings.FetchCount); } else { profiles = await _session.MatchFinder(Settings.SearchForFemales, Settings.MinAge, Settings.MaxAge, Settings.Regions, Settings.FetchCount); } if (profiles != null) { foreach (var profile in profiles) { // Do we know this profile already? IEMember member = GetMember(profile.ProfileId); if (member == null) { // We should add them.... member = new IEMember() { ProfileId = profile.ProfileId, Region = profile.Location, Status = IEMember.MEMBER_NEW }; NewItems.Add(member); NewItems.Sort(); newMemberFound = true; } member.Username = profile.Name; member.Age = profile.Age; member.ThumbnailUrl = profile.ThumbnailUrl; member.PartialSummary = profile.PartialSummary; SaveMember(member); } if (newMemberFound && OnNewMembersFound != null) { OnNewMembersFound(); } } return(newMemberFound); }
private void AddItemPricing() { //ItemPricing dummy = new ItemPricing(0, ItemId, Types.Days.Any, 0f, null, null, null, false); //ItemPricing newItem = ItemPricing.Add(ItemId, Types.Days.Any, 0f, null, null, null, false); ItemPricingModel newItem = new ItemPricingModel(ItemId, Days.Any, null, null, 0f); AddItemPricingToListBox(newItem); NewItems.Add(newItem); foreach (FormattedListBoxItem item in listBox1.Items) { item.IsSelected = Equals(item, listBox1.SelectedItem); } listBox1.ScrollIntoView(listBox1.SelectedItem); InitializeFields(newItem); SetReadOnly(false); buttonRemove.IsEnabled = true; DoChangedValueEvent(); //InitializeListBox(); }
private void RemoveItemPricing() { if (listBox1.SelectedItem != null) { int index = listBox1.SelectedIndex; FormattedListBoxItem pricing = (FormattedListBoxItem)listBox1.SelectedItem; ItemPricingModel model = (ItemPricingModel)pricing.ReferenceObject; if (model.Id == 0) { NewItems.Remove(model); } else { RemovedItems.Add(model); } listBox1.Items.Remove(pricing); ClearFields(); DoChangedValueEvent(); InitializeListBox(index); } }
public void ChangeMemberStatus(IEMember member, int newStatus) { switch (member.Status) { case IEMember.MEMBER_NEW: NewItems.Remove(member); break; case IEMember.MEMBER_REJECTED: RejectedItems.Remove(member); break; default: ActiveItems.Remove(member); break; } member.Status = newStatus; switch (member.Status) { case IEMember.MEMBER_NEW: NewItems.Add(member); break; case IEMember.MEMBER_REJECTED: RejectedItems.Add(member); break; default: ActiveItems.Add(member); break; } NewItems.Sort(); RejectedItems.Sort(); ActiveItems.Sort(); SaveMember(member); }
public override string ToString() { try { StringBuilder builder = new StringBuilder(); builder.AppendLine(String.Format("Event Type:{0}", Action)); builder.AppendLine(String.Format("New Items Count:{0}", NewItems.Count())); foreach (var item in NewItems) { builder.AppendLine(item.ToString()); } builder.AppendLine(String.Format("Old Items Count:{0}", OldItems.Count())); foreach (var item in OldItems) { builder.AppendLine(item.ToString()); } return(builder.ToString()); } catch { return(base.ToString()); } }
/// <summary> /// Tries to remove the item from new items /// </summary> /// <param name="index">The item index.</param> /// <param name="item">The item.</param> /// <returns><c>true</c> if removed, otherwise <c>false</c>.</returns> /// <remarks>This code is only need by <c>FastBindingList{T}</c>.</remarks> public bool?TryRemoveItemFromNewItems(int index, T item) { if (Mode == SuspensionMode.None || Mode == SuspensionMode.Mixed) { var newIdx = NewItems.LastIndexOf(item); if (newIdx > -1 && NewItemIndices[newIdx] == index) { NewItems.RemoveAt(newIdx); NewItemIndices.RemoveAt(newIdx); for (var i = 0; i < NewItemIndices.Count; i++) { if (NewItemIndices[i] >= index) { NewItemIndices[i]--; } } return(true); } } return(false); }
public override string ToString() { return(String.Format("{0}: +[{1}], -[{2}]", Action, NewItems.StringJoin(), OldItems.StringJoin())); }
public void RegisterNew(object entity) { //_innerUnitOfWork.RegisterNew(entity); NewItems.Add(entity); }
private void ClearChanges() { NewItems.Clear(); DirtyItems.Clear(); DeletedItems.Clear(); }
public override void Update() { base.Update(); if (SelectedLevel == -1) { // Delay after klick on level to entering it delay--; if (delay == 0) { SelectedLevel = levelToBeSelected; levelToBeSelected = -1; Levels[SelectedLevel].Initialize(ThePlayer); numberOfJumps++; bossLerpPosition += new Vector2(100, 0); } // Boss bossPosition = new Vector2(MathHelper.Lerp(bossPosition.X, bossLerpPosition.X, 0.01f), bossPosition.Y); bossAnimationTimer++; if (bossAnimationTimer > 5) { bossAnimationTimer = 0; if (bossAnimationFrame < 3) { bossAnimationFrame++; } else { bossAnimationFrame = 0; } } // SpaceObjects foreach (GameObject spaceObject in SpaceObjects) { spaceObject.Update(); } for (int i = SpaceObjects.Count() - 1; i >= 0; i--) { if (SpaceObjects[i].Dead) { SpaceObjects.RemoveAt(i); } } if (!ThePlayer.Dead) { NewItems.Update(); NewRank.Update(); // Boss if (Globals.Distance(bossPosition, Levels[playerPosition].EnterLevel.Position) < 300 && delay < 0 && !Levels[Levels.Count() - 1].Complete) { levelToBeSelected = Levels.Count() - 1; delay = 65; } Inventory.Update(); if (Inventory.Press()) { SceneManager.ChangeScene(SceneManager.inventoryScene); NewItems.Flash = -1; } Menu.Update(); if (Menu.Press()) { SceneManager.ChangeScene(SceneManager.menuScene); SoundManager.ChangeMusic(SoundManager.menu); } Rank.Update(); if (Rank.Press()) { SceneManager.ChangeScene(SceneManager.rankScene); NewRank.Flash = -1; } MapInfo.Update(); } else { playerDeath--; if (playerDeath == 30) { SoundManager.explosion.Play(); } if (playerDeath == 0) { SceneManager.ChangeScene(SceneManager.gameOverScene); } } for (int i = 0; i < Levels.Count() - 1; i++) { Levels[i].UpdateMap(); if (!ThePlayer.Dead) { if (nearestLevels.Any(item => item == Levels[i]) && Levels[i].EnterLevel.Pressed() && delay < 0) { if (!Levels[i].Complete) { levelToBeSelected = i; delay = 65; } PlayerMove(i); } } } } else { Levels[SelectedLevel].Update(); } }
public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); if (SelectedLevel == -1) { // Space objects foreach (GameObject spaceObject in SpaceObjects) { spaceObject.Draw(spriteBatch); } if (NewItems.Flash > 0) { NewItems.Flash++; NewItems.Draw(spriteBatch); } if (NewRank.Flash > 0) { NewRank.Flash++; NewRank.Draw(spriteBatch); } Inventory.Draw(spriteBatch); Menu.Draw(spriteBatch); Rank.Draw(spriteBatch); MapInfo.Draw(spriteBatch); // Boss if (!Levels[Levels.Count() - 1].Complete) { spriteBatch.Draw(TextureManager.boss, bossPosition, null, Color.White, 0f, new Vector2(TextureManager.boss.Width / 2, TextureManager.boss.Height / 2), 0.6f, SpriteEffects.None, 0.2f); spriteBatch.Draw(TextureManager.bossEngineAnimation, bossPosition, new Rectangle(163 * bossAnimationFrame, 0, 163, 139), Color.White, 0f, new Vector2(TextureManager.boss.Width / 2, TextureManager.boss.Height / 2), 0.6f, SpriteEffects.None, 0.1f); for (int i = 0; i < 1000; i++) { spriteBatch.Draw(TextureManager.pixel, new Rectangle((int)(bossPosition.X + Math.Cos(((float)i / 1000f) * Math.PI * 2) * 300), (int)(bossPosition.Y + Math.Sin(((float)i / 1000f) * Math.PI * 2) * 300), 3, 3), Color.Red); } } // Draw lines to close stars foreach (Level level in nearestLevels) { Vector2 linePosition = level.EnterLevel.Position - Levels[playerPosition].EnterLevel.Position; float distance = Globals.Distance(Levels[playerPosition].EnterLevel.Position, level.EnterLevel.Position) / 4; for (float i = 0; i < distance; i++) { spriteBatch.Draw(TextureManager.pixel, new Rectangle((int)(Levels[playerPosition].EnterLevel.Position.X + linePosition.X * (i / distance)), (int)(Levels[playerPosition].EnterLevel.Position.Y + linePosition.Y * (i / distance)), 1, 1), Color.White); } } for (int i = 0; i < Levels.Count() - 1; i++) { Levels[i].DrawMap(spriteBatch); } } else { Levels[SelectedLevel].Draw(spriteBatch); } }
/// <summary> /// Update the container buffer and item snapshots. Old (removed) items will be added to /// <see cref="OldItems"/> and new items to <see cref="NewItems"/>. /// </summary> public void Update() { _container.TakeSnapshot(); _previousSegments = _currentSegments; if (_previousData.Length != _currentData.Length) { Array.Resize(ref _previousData, _currentData.Length); } Buffer.BlockCopy(_currentData, 0, _previousData, 0, _currentData.Length); _currentSegments = _container.GetAllocatedBytes(ref _currentData); if (_currentData.Length != _previousData.Length) // buffer was resized (and replaced), update underlying buffer for all items { for (int i = 0; i < _items.Length; i++) { if (_items[i] == null) { continue; } _items[i].SetSnapshot(_currentData, i * _container.ItemSize, _container.ItemSize); } } if (_previousMapping.Length != _currentMapping.Length) { Array.Resize(ref _previousMapping, _currentMapping.Length); } Buffer.BlockCopy(_currentMapping, 0, _previousMapping, 0, _currentMapping.Length * sizeof(int)); var count = _currentData.Length / _container.ItemSize; var mr = new BufferMemoryReader(_currentData); if (_currentMapping.Length != count) { Array.Resize(ref _currentMapping, count); } for (int i = 0; i <= _container.MaxIndex; i++) { _currentMapping[i] = mr.Read <int>(i * _container.ItemSize); } for (int i = _container.MaxIndex + 1; i < count; i++) { _currentMapping[i] = -1; } NewItems.Clear(); OldItems.Clear(); if (_items.Length != _container.Capacity) { Array.Resize(ref _items, _container.Capacity); } // Compare against previous where there is a value. for (int i = 0; i < Math.Min(_previousMapping.Length, _currentMapping.Length); i++) { if (_currentMapping[i] != _previousMapping[i]) { if (_previousMapping[i] != -1) { var item = CreatePreviousItem(i); OnItemRemoved(i, item); OldItems.Add(item); } if (_currentMapping[i] != -1 && _currentMapping[i] != 0) // NB: New item starts with ID 0 { var item = CreateCurrentItem(i); OnItemAdded(i, item); NewItems.Add(item); } } } // Check expanded area. for (int i = _previousMapping.Length; i < _currentMapping.Length; i++) { if (_currentMapping[i] != -1) { var item = CreateCurrentItem(i); OnItemAdded(i, item); NewItems.Add(item); } } // Check reduced area. for (int i = _currentMapping.Length; i < _previousMapping.Length; i++) { if (_previousMapping[i] != -1) { var item = CreatePreviousItem(i); OnItemRemoved(i, item); OldItems.Add(item); } } }