public void UpdateItem(string uniqueUUID, ICoreData item, bool updateUI) { for (int i = 0; i < InternalItems.Count; i++) { if (InternalItems[i].BaseData.UniqueUUID == uniqueUUID) { IStackableData iStackDataInterface = InternalItems[i].BaseData as IStackableData; if (iStackDataInterface != null) { if (iStackDataInterface.DestroyOnUse && iStackDataInterface.Quantity <= 0) { RemoveItem(InternalItems[i].BaseData.UniqueUUID, updateUI); } else { InternalItems[i] = item; EventSystem.EventMessenger.Instance.Raise(new Events.EventItemWasUpdatedOnInventory(InventoryUUID, item, updateUI)); } } else { InternalItems[i] = item; EventSystem.EventMessenger.Instance.Raise(new Events.EventItemWasUpdatedOnInventory(InventoryUUID, item, updateUI)); } } } }
public void Initialize(ICoreData data) { _icon = data.Icon; _healthable.Initialize(data.HealthableData); _armorable.Initialize(data.ArmorableData); _teamable.Initialize(_initialTeam); }
protected override void OnCoreDataLoaded(ICoreData coreData) { ThreadPool.QueueUserWorkItem(delegate { BindCoreData(coreData); }); }
public SongsControllerTests() { _logger = Substitute.For <ILogger <SongsController> >(); _songService = Substitute.For <ISong>(); _fileStorage = Substitute.For <IFileStorage>(); _coreDataService = Substitute.For <ICoreData>(); _songsController = new SongsController(_logger, _coreDataService, _fileStorage, _songService); }
public void CreateItem(ICoreData ItemData) { string _strDBName = GetDBPath(); IDbConnection _connection = new SqliteConnection(_strDBName); IDbCommand _command = _connection.CreateCommand(); string tableName = "items"; string sql = ""; _connection.Open(); if (ItemData != null) { if (ItemData.BaseData is ISerializeData) { ISerializeData itemSerializeDataInterface = ItemData.BaseData as ISerializeData; if (itemSerializeDataInterface == null) { Debug.LogError("The external DB item data does not implement the interface ISerializeData"); return; } IPropertySerializer propertiesInterface = ItemData.BaseData.Properties as IPropertySerializer; string serializedProperties = string.Empty; if (propertiesInterface != null) { serializedProperties = propertiesInterface.Serialize(); } sql = string.Format("INSERT INTO " + tableName + " (item_uuid, type, data, properties)" + " VALUES ( \"{0}\", \"{1}\", \"{2}\", \"{3}\");", ItemData.BaseData.UniqueUUID, ItemData.BaseData.Type, itemSerializeDataInterface.SerializeItemData(), serializedProperties ); _command.CommandText = sql; _command.ExecuteNonQuery(); } else { Debug.LogError("External DB item [" + ItemData.BaseData.Name + "] does not implement ISerializeData interface."); } } else { Debug.Log("The external DB item is null."); } _command.Dispose(); _command = null; _connection.Close(); _connection = null; }
public ICoreData GetItem(string uniqueUUID) { for (int i = 0; i < InternalItems.Count; i++) { ICoreData resultItem = InternalItems[i]; if (resultItem.BaseData.UniqueUUID == uniqueUUID) { return(resultItem); } } return(null); }
private void TestGetSpecificItem(ICoreData testItem) { ICoreData tmpBaseItem = TheInventory.GetItem(testItem.BaseData.UniqueUUID); if (tmpBaseItem == null) { Debug.LogError("FAILED [TestGetSpecificItem]. We should have the item in the inventory."); } else { Debug.Log("PASSED [TestGetSpecificItem]. Weapon description [" + tmpBaseItem.BaseData.Description + "] uniqueUUID [" + tmpBaseItem.BaseData.UniqueUUID + "]"); } }
public void UpdateSlotItem(ICoreData item, bool updateUI = true) { ThisUIItem.Item = item; ThisUIItem.IsActive = true; ThisUIItem.transform.SetParent(transform); UpdateSlotItemData(); if (updateUI) { ThisUIItem.UpdateUI(); } }
public SongsControllerTests(PostgresDatabaseFixture fixture) { _fixture = fixture; _logger = new Logger <SongsController>(new NullLoggerFactory()); _coreDataService = new DbCoreData(_fixture._context); _fileStorage = Substitute.For <IFileStorage>(); _songService = new DbSong(_fixture._context); _songsController = new SongsController(_logger, _coreDataService, _fileStorage, _songService); Setup.DropAllRows(_fixture._context); }
public void UpdateItem(string itemUUID, ICoreData itemDBData) { string sql = ""; string tableName = "items"; string conn = GetDBPath(); IDbConnection dbconn = (IDbConnection) new SqliteConnection(conn); dbconn.Open(); IDbCommand dbcmd = dbconn.CreateCommand(); ISerializeData itemSerializeDataInterface = null; if (itemDBData.BaseData is ISerializeData) { itemSerializeDataInterface = itemDBData.BaseData as ISerializeData; if (itemSerializeDataInterface == null) { Debug.LogError("The external DB item data does not implement the interface ISerializeData"); return; } } #region DB Structure //CREATE TABLE `items` ( // `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, // `object_id` TEXT DEFAULT '00000000-0000-0000-0000-000000000000', // `owner_id` INTEGER NOT NULL, // `object_owner_id` TEXT, // `type` TEXT NOT NULL, // `data` BLOB NOT NULL, // `position` BLOB NOT NULL, // `rotation` BLOB NOT NULL, // `timeout` INTEGER //); #endregion DB Structure // should i add player uuid on the where statment???? sql = string.Format("UPDATE \"" + tableName + "\" SET data=\"{0}\" WHERE item_uuid=\"{2}\";", itemSerializeDataInterface.SerializeItemData(), itemUUID); dbcmd.CommandText = sql; dbcmd.ExecuteNonQuery(); dbcmd.Dispose(); dbcmd = null; dbconn.Close(); dbconn = null; }
private void TestRemoveItemFromInventory(ICoreData testItem) { TheInventory.RemoveItem(testItem, false); ICoreData tmpBaseItem = TheInventory.GetItem(testItem.BaseData.UniqueUUID); if (tmpBaseItem == null) { Debug.Log("PASSED [TestRemoveItemFromInventory]. Weapon description [" + testItem.BaseData.Description + "] uniqueUUID [" + testItem.BaseData.UniqueUUID + "]"); } else { Debug.LogError("FAILED [TestRemoveItemFromInventory]. We should have the item removed from the inventory."); } }
private void TestCountAllItemsFromInventory(ICoreData itemA, ICoreData itemB) { TestAddItemToInventory(itemA); TestAddItemToInventory(itemB); if (TheInventory.ItemsCount == 2) { Debug.Log("PASSED [TestCountAllItemsFromInventory]. All items were acounted for."); } else { Debug.LogError("FAILED [TestCountAllItemsFromInventory]. We should have two items in the inventory."); } TheInventory.RemoveAllItems(); }
private void TestUpdateItemInTheInventory(ICoreData testItem) { TheInventory.UpdateItem(ItemA_ID, testItem, false); ICoreData tmpBaseItem = TheInventory.GetItem(ItemB_ID); if (tmpBaseItem == null) { Debug.LogError("FAILED [TestUpdateItemInTheInventory]. The item is missing from inventory."); } else { Debug.Log("PASSED [TestUpdateItemInTheInventory]. Weapon description [" + tmpBaseItem.BaseData.Description + "] uniqueUUID [" + tmpBaseItem.BaseData.UniqueUUID + "]"); } }
private void TestGetAllItemsFromInventory(ICoreData itemA, ICoreData itemB) { TestAddItemToInventory(itemA); TestAddItemToInventory(itemB); List <ICoreData> items = TheInventory.Items; if (items.Count == 2) { Debug.Log("PASSED [TestGetAllItemsFromInventory]. We got all the items."); } else { Debug.LogError("FAILED [TestGetAllItemsFromInventory]. We should have two items in the inventory."); } TheInventory.RemoveAllItems(); }
private void TestAddItemToInventory(ICoreData testItem) { // Test add item TheInventory.AddItem(testItem, false); // Check item name and unique uuid ICoreData tmpBaseItem = TheInventory.GetItem(testItem.BaseData.UniqueUUID); if (tmpBaseItem == null) { Debug.LogError("FAILED [TestAddItemToInventory]. We should have the item in the inventory."); } else { Debug.Log("PASSED [TestAddItemToInventory]. Weapon description [" + tmpBaseItem.BaseData.Description + "] uniqueUUID [" + tmpBaseItem.BaseData.UniqueUUID + "]"); } }
private void AddItem(ICoreData item, bool updateUI) { if (TheInventory == null) { Debug.LogWarning("The inventory is null... Is this a network ui object??"); return; } UISlot slot = TheSlotsContainer.GetSlot(); if (slot) { slot.UpdateSlotItem(item, updateUI); } else { Debug.LogError("The slot is null.. is the inventory full???"); } }
public DancersControllerTests(PostgresDatabaseFixture fixture) { _fixture = fixture; _logger = new Logger <DancersController>(new NullLoggerFactory()); _coreService = new DbCoreData(_fixture._context); _dancerService = new DancerService(_fixture._context); _badgeService = new DbBadge(_fixture._context); _fileStorage = new LocalFileStorage("."); _authorizationService = Substitute.For <IAuthorization>(); _dancersController = new DancersController( _logger, _coreService, _dancerService, _badgeService, _fileStorage, _authorizationService); Setup.DropAllRows(_fixture._context); }
public void AddItem(ICoreData item, bool updateUI) { if (CheckIfExists(item.BaseData.UniqueUUID) == false) // We dont have the item when false { if (CanAddItem) { item.Inventory = this; item.BaseData.InventoryUUID = InventoryUUID; InternalItems.Add(item); EventSystem.EventMessenger.Instance.Raise(new Events.EventItemWasAddedToInventory(InventoryUUID, item, updateUI)); } else { Debug.LogWarning("The inventory is full with [" + InventoryMaxItems + "] items."); } } else { Debug.LogError("The item with the unique uuid of [" + item.BaseData.UniqueUUID + "] is already in the inventory."); } }
private void Resume(ICoreData coreData) { this.AllSessions = coreData.Sessions; HasCoreDataLoaded = true; QueueLoadData(); }
private void BindCoreData(ICoreData coreData) { this.BusyText = "Displaying..."; QueueSafeDispatch(() => { LogInstance.LogDebug("Core data present; binding session data"); this.Items = coreData.Sessions.ToObservableCollection(); LogInstance.LogDebug("Session data set on ViewModel"); coreData.SessionsBound = true; IsDataBound = true; this.Error = ErrorItemViewModel.FromCompletion(coreData.SessionCompletedInfo); }); }
private void BindCoreData(ICoreData coreData) { if (IsInDesignMode) return; if (this.Items != null && this.Items.Any()) return; SafeDispatch(() => { // you'd think .Distinct() is what we'd use but nope var distinctRoomNames = coreData.Sessions.GroupBy(x => x.Room).Select(x => x.First().Room); this.Items = new ObservableCollection<RoomItemViewModel>(); distinctRoomNames.OrderBy(n=> n).ForEach(roomName => this.Items.Add(new RoomItemViewModel {Name = roomName})); }); }
protected override void OnCoreDataLoaded(ICoreData coreData) { if (this.IsRefreshInProgress) { this.IsRefreshInProgress = false; this.SetBusy(false); } }
protected override void OnCoreDataLoaded(ICoreData coreData) { BindCoreData(coreData); }
public EventUpdateItemOnInventory(string inventoryUUID, ICoreData item, bool updateUI = true) { this.InventoryUUID = inventoryUUID; this.Item = item; this.UpdateUI = updateUI; }
private void QueueSearch(ICoreData coreData, string qry) { SetBusy(true, "Searching..."); QueueSafeDispatch( () => { var items = new ObservableCollection<SearchItemViewModel>(); qry = qry.ToLower(); coreData.Sessions.Where(s => s.Title.ToLower().Contains(qry) || s.Abstract.ToLower().Contains(qry) || s.Technology.ToLower().Contains(qry) || s.TrackArea.ToLower().Contains(qry) || (s.Speaker != null && s.Speaker.Name.ToLower().Contains(qry)) ).ForEach(s => items.Add(SearchItemViewModel.Create(s))); coreData.Speakers.Where(sp => sp.Name.ToLower().Contains(qry) || (sp.TwitterId != null && sp.TwitterId.ToLower().Contains(qry)) || (sp.Bio != null && sp.Bio.ToLower().Contains(qry)) || (sp.Website != null && sp.Website.ToLower().Contains(qry)) || (sp.Company != null && sp.Company.ToLower().Contains(qry)) ).ForEach(sp => items.Add(SearchItemViewModel.Create(sp))); this.Items = items; SetBusy(false); }); }
protected override void OnCoreDataLoaded(ICoreData coreData) { this.HasCoreDataLoaded = true; this.AllSessions = coreData.Sessions; CheckAllFinished(); }
public EventItemWasRemovedFromInventory(string inventoryUUID, ICoreData item, bool updateUI = true) { this.InventoryUUID = inventoryUUID; this.Item = item; this.UpdateUI = updateUI; }
public void RemoveItem(ICoreData item, bool updateUI) { RemoveItem(item.BaseData.UniqueUUID, updateUI); }