public string GetImage(AbstractItem detailItem)
 {
     switch (detailItem.GetPanelCssClass())
     {
         case "full-panel":
             return detailItem.Image.RenderCrop("938x310");
         case "half-panel":
             return detailItem.Image.RenderCrop("480x210");
         case "third-panel":
             return detailItem.Image.RenderCrop("300x180");
         case "quarter-panel":
             return detailItem.Image.RenderCrop("220x120");
         default:
             return "";
     }
 }
Ejemplo n.º 2
0
            public void Traverse(IEnumerable <TDependency> dependencies, ItemMatch pathAnchor,
                                 bool pathAnchorIsCountMatch, AbstractPathMatch <TDependency, TItem>[] expectedPathMatches)
            {
                Dictionary <TItem, TDependency[]> incidentDependencies = _backwards
                    ? AbstractItem <TItem> .CollectIncomingDependenciesMap(dependencies)
                    : AbstractItem <TItem> .CollectOutgoingDependenciesMap(dependencies);

                _seenInnerPathStarts.Clear();
                Paths.Clear();
                Counts.Clear();
                _onPath.Clear();

                TItem[] uniqueStartItems = (pathAnchor == null
                    ? incidentDependencies.Keys
                    : incidentDependencies.Keys.Where(i => pathAnchor.Matches(i).Success)).ToArray();
                AbstractPathMatch <TDependency, TItem> endMatch;

                AbstractPathMatch <TDependency, TItem>[] innerMatches;
                int n = expectedPathMatches.Length;

                if (n == 0)
                {
                    endMatch     = null;
                    innerMatches = expectedPathMatches;
                }
                else
                {
                    endMatch     = expectedPathMatches[n - 1];
                    innerMatches = expectedPathMatches.Take(n - 1).ToArray();
                }

                foreach (var item in uniqueStartItems.OrderBy(i => i.Name))
                {
                    if (_seenInnerPathStarts.Add(item))
                    {
                        List <PathNode <TItem, TDependency> > up = Traverse(root: item,
                                                                            incidentDependencies: incidentDependencies, expectedInnerPathMatches: innerMatches,
                                                                            endMatch: endMatch, down: new DownInfo(pathAnchorIsCountMatch ? item : null));
                        if (up != null)
                        {
                            Paths.Add(item, up);
                        }
                    }
                }
            }
Ejemplo n.º 3
0
        internal MetadataDiscoveryRequest Build(AbstractItem item, MetadataDiscoveryRequestType type)
        {
            var properties = new string[] { "Perspective", "Dimension", "Hierarchy", "Level", "Property", "MeasureGroup", "DisplayFolder", "Measure", "Table", "Column" };

            IFilter filter  = null;
            var     filters = new List <IFilter>();

            foreach (var property in properties)
            {
                filter = BuildCaptionFilter(item, property);
                if (filter != null)
                {
                    filters.Add(filter);
                }
            }

            var target = GetTarget(item);

            filter = BuildCaptionFilterForCaptionProperty(item, target);
            if (filter != null)
            {
                filters.Add(filter);
            }

            var connectionString = item.GetConnectionString();

            var factory = new DiscoveryRequestFactory();
            MetadataDiscoveryRequest request = null;

            switch (type)
            {
            case MetadataDiscoveryRequestType.Direct:
                request = factory.BuildDirect(connectionString, target, filters);
                break;

            case MetadataDiscoveryRequestType.Relation:
                target  = GetTargetRelation(item);
                request = factory.BuildRelation(connectionString, target, filters);
                break;

            default:
                break;
            }
            return(request);
        }
Ejemplo n.º 4
0
        public async Task <AbstractItem> GetItemAsync(int id)
        {
            AbstractItem item = await Context.Books.FirstOrDefaultAsync(b => b.Id == id);

            if (item == null)
            {
                item = await Context.Jornals.FirstOrDefaultAsync(j => j.Id == id);
            }

            if (item == null)
            {
                return(null);
            }
            else
            {
                return(item);
            }
        }
Ejemplo n.º 5
0
        private AbstractItem ParseToItem(string data)
        {
            string[] fields = data.Split(FieldDelim);

            int idx = 0;

            int      id        = Int32.Parse(fields[idx++]);
            int      srcId     = Int32.Parse(fields[idx++]);
            DateTime addedDate = DateTime.Parse(fields[idx++]);
            string   title     = fields[idx++];
            bool     isNew     = Boolean.Parse(fields[idx++]);
            string   url       = fields[idx++];

            AbstractItem b = AbstractItem.CreateGenericItem(id, Sources.Single(x => x.ID == srcId),
                                                            title, url, isNew, addedDate);

            return(b);
        }
Ejemplo n.º 6
0
    // Raycast version of OnMouseOver
    private void MouseOverItem()
    {
        Collider2D collider = Physics2D.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition), 1 << LayerMask.NameToLayer("Items"));

        if (collider == null)
        {
            if (selectedItem != null)
            {
                selectedItem.MouseExit();
                selectedItem = null;
            }

            return;
        }

        selectedItem = collider.GetComponent <AbstractItem>();
        selectedItem.MouseOver();
    }
Ejemplo n.º 7
0
        public void ShowRoom(float sizeCell, AbstractItem objectAbstractItemBehaviour = null)
        {
            WorldPosition = new Vector2(GridX * sizeCell, GridY * sizeCell);
            roomRadius    = sizeCell / 2;

            View = GameObject.Instantiate
                   (
                PrefabsManager.LoadPrefab(PrefabsManager.PrefabsList.DefaultRoom)
                   ).GetComponent <RoomView>();

            View.InitView(WorldPosition, this);

            if (objectAbstractItemBehaviour != null)
            {
                AbstractItem = objectAbstractItemBehaviour;
                objectAbstractItemBehaviour.Show(this);
            }
        }
Ejemplo n.º 8
0
 private bool IsItemAlreadyAdded(AbstractItem item, bool isUser = true) //Check if user/store already have that item
 {
     if (isUser)
     {
         if (userItemsList.Exists(i => i.Name.Equals(item.Name)))
         {
             return(true);
         }
     }
     else
     {
         if (storeItemsList.Exists(i => i.Name.Equals(item.Name)))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
        public void SetContent(AbstractItem item, bool isReading)
        {
            _item = item;

            if (item.BorrowedCopies >= item.CopyNumber && !isReading)
            {
                noFreeCopiesTxtBlk.Visibility = Visibility.Visible;
                borrowBtn.IsEnabled           = false;
            }
            string category;

            if (item is Book)
            {
                categoryCombobox.ItemsSource  = Enum.GetValues(typeof(Book.BookCategory));
                categoryCombobox.SelectedItem = ((Book)item).Category;
                category = ((Book)item).Category.ToString();
                defaultCoverImage.Source = defaultBookImage.Source;
                deleteBtn.Content        = "Delete book";
            }
            else
            {
                categoryCombobox.ItemsSource  = Enum.GetValues(typeof(Journal.JournalCategory));
                categoryCombobox.SelectedItem = ((Journal)item).Category;
                category = ((Journal)item).Category.ToString();
                defaultCoverImage.Source = defaultMagazineImage.Source;
                deleteBtn.Content        = "Delete magazine";
            }

            if (item.CoverImage != null)
            {
                coverImageTxtBox.Text = item.CoverImage;
            }

            GuidTxtBlk.Text             = item.Guid.ToString();
            subCategoryTxtBox.Text      = item.SubCategory;
            datePicker.MinYear          = new DateTime(100, 1, 1);
            datePicker.MaxYear          = DateTime.Today;
            datePicker.Date             = (DateTimeOffset)item.Date;
            copyNumberTxtBox.Text       = item.CopyNumber.ToString();
            itemNameTxtBox.Text         = item.ItemName;
            borrowedСopiesTxtBlock.Text = item.BorrowedCopies.ToString();

            SetReading(isReading);
        }
Ejemplo n.º 10
0
        private void searchBtn_Click(object sender, RoutedEventArgs e)
        {
            //Is Book
            //       if (typeCombobox.SelectedIndex == 0)
            {
                _item = new Book(itemNameTxtBox.Text, new Guid(),
                                 (Book.BookCategory)categoryCombobox.SelectedItem, subCategoryTxtBox.Text);
                if (categoryCheckBox.IsChecked == false)
                {
                    ((Book)_item).Category = null;
                }
            }
            //  //Is Magazine
            ////  else
            //  {
            //      _item = new Journal(itemNameTxtBox.Text, new Guid(),
            //          (Journal.JournalCategory)categoryCombobox.SelectedItem, subCategoryTxtBox.Text);
            //      if (categoryCheckBox.IsChecked == false)
            //          ((Journal)_item).Category = null;
            //  }

            if (dateCheckBox.IsChecked == true)
            {
                _item.Date = datePicker.Date;
            }
            else
            {
                _item.Date = null;
            }

            if (itemNameTxtBox.Text == string.Empty || itemNameCheckBox.IsChecked == false)
            {
                _item.ItemName = null;
            }

            Frame.Navigate(typeof(ItemListPage));


            if (Submit != null)
            {
                Submit(this, new ItemEventArgs(_item));
            }
        }
Ejemplo n.º 11
0
        // Add item (return copies-id of new-added item for save/print and use it later for identify each hard-copy)
        public Respone <IEnumerable <Guid> > AddItem(AbstractItem newItem)
        {
            Respone <IEnumerable <Guid> > feedback = new Respone <IEnumerable <Guid> >();

            // check if current user can add items
            if (_users.CurrentUser != null && _users.CurrentUser.Access == UserType.Reader)
            {
                feedback.IsWorking     = false;
                feedback.Message       = "Readers can't add new items";
                feedback.WrongDataType = WrongData.UserType;
                return(feedback);
            }

            // this item is already exist
            AbstractItem temp;

            if (_itemsById.TryGetValue(newItem.ID, out temp))
            {
                feedback.IsWorking     = false;
                feedback.Message       = "Item is already exist";
                feedback.WrongDataType = WrongData.ItemId;
                return(feedback);
            }
            // add book
            else
            {
                if (_itemsById.ContainsKey(newItem.ID))
                {
                    _itemsById[newItem.ID] = newItem;
                }
                else
                {
                    _itemsById.Add(newItem.ID, newItem);
                }
                _itemsByTitle.Add(newItem);
                ReSort();

                feedback.IsWorking = true;
                feedback.Data      = newItem.AviableCopiesID;

                return(feedback);
            }
        }
        //Remove item from cart
        private void removeItem_Click(object sender, RoutedEventArgs e)
        {
            if (rentedList.SelectedIndex > -1)
            {
                AbstractItem temp = rentedList.Items.ElementAt(rentedList.SelectedIndex) as AbstractItem;
                InterfaceManager.ActualUser.Total -= (temp.Price * (100 - (double)temp.Discount) / 100) * CostForRent;

                rentedList.Items.RemoveAt(rentedList.SelectedIndex);
            }

            if (buyedList.SelectedIndex > -1)
            {
                AbstractItem temp = buyedList.Items.ElementAt(buyedList.SelectedIndex) as AbstractItem;
                InterfaceManager.ActualUser.Total -= (temp.Price * (100 - (double)temp.Discount) / 100);

                buyedList.Items.RemoveAt(buyedList.SelectedIndex);
            }
            tBTotal.Text = string.Format("{0:$#0.##}", InterfaceManager.ActualUser.Total);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Renders item as a path.
 ///
 /// Item will be rendered in the top left corner (with dimensions (1/3)*blockSize x (1/3)*blockSize) of of the block.
 /// </summary>
 /// <param name="item">Item to be rendered.</param>
 /// <param name="x">Top left corner x-coordinate of map block.</param>
 /// <param name="y">Top left corner y-coordinate of map block.</param>
 /// <param name="blockSize">Height and width of the block.</param>
 /// <returns>Item rendered as path.</returns>
 private Path RenderItem(AbstractItem item, double x, double y, double blockSize)
 {
     if (item is AbstractArmor)
     {
         return(RenderArmor((AbstractArmor)item, x, y, blockSize));
     }
     else if (item is AbstractWeapon)
     {
         return(RenderWeapon((AbstractWeapon)item, x, y, blockSize));
     }
     else if (item is AbstractInventoryItem)
     {
         return(RenderItem((AbstractInventoryItem)item, x, y, blockSize));
     }
     else
     {
         return(new Path());
     }
 }
        public bool ReturnItem(AbstractItem abstractItem, User user)
        {
            var getItem = _abstractItemRepository.GetById(abstractItem.Id);

            if (getItem.RentedQuantity <= 0)
            {
                return(false);
            }

            if (getItem == null)
            {
                return(false);
            }

            var getCustomerRentals = _custRentModelRepository.GetAll();

            var currentUser = getCustomerRentals.FirstOrDefault(current => current.UserId == user.Id && current.AbstractItemId == abstractItem.Id);

            if (currentUser != null)
            {
                if (currentUser.IsItemReturned)
                {
                    return(false);
                }

                currentUser.DateItemReturned = DateTime.Now;

                getItem.RentedQuantity--;

                currentUser.IsItemReturned = true;

                _custRentModelRepository.Update(currentUser);

                _custRentModelRepository.Save();

                _abstractItemRepository.Update(getItem);

                _abstractItemRepository.Save();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 15
0
    public void InvokeItemPickup(Collider collider)
    {
        AbstractItem itemToPickup = collider.gameObject.GetComponent <AbstractItem>();

        if (itemToPickup == null)
        {
            return;
        }

        Debug.DrawLine(transform.position, collider.transform.position, Color.yellow);

        if ((transform.position - collider.transform.position).sqrMagnitude < 1.25f)
        {
            if (OnItemPickup != null)
            {
                OnItemPickup.Invoke(itemToPickup);
                collider.gameObject.SetActive(false);
            }
        }
    }
Ejemplo n.º 16
0
    private void AddItemToInventory(int playerNumber, string itemAssembly, ItemType itemType)
    {
        //set the player to be the local player
        Player player = m_LocalPlayer;

        //check to make sure the player number corresponds to the local player otherwise assign player to be equal to the otherPlayer
        if (player.PlayerNumber != playerNumber)
        {
            player = m_OtherPlayer;
        }

        //get the item that the player just picked up as an object
        AbstractItem itemInstance = null;

        if (itemType == ItemType.PickUp)
        {
            itemInstance = m_PickUpItemsInGame[itemAssembly];
        }

        else
        {
            itemInstance = m_ItemsInGame[itemAssembly];
        }

        //figure out what type the item is so that we can put it into the correct location in the player's journal
        if ((itemInstance as AbstractItem).ItemType == ItemType.Passive)
        {
            player.Journal.AddPassiveItemToJournal(itemInstance as AbstractPassive);
        }
        //if the item is an pick up item then don't add it to the journal just activate the effect
        else if ((itemInstance as AbstractItem).ItemType == ItemType.PickUp)
        {
            (itemInstance as AbstractItem).ActivateItem(player);
        }
        //if the item is an active item then we need to add it to the journal but also remove the old item and place it back into the world
        else
        {
            //TODO: place the old active item back into the world. Make this function return the old active item
            player.Journal.AquireNewActiveItem(itemInstance as AbstractItem);
        }
    }
Ejemplo n.º 17
0
    // Pick up
    public void PickupItem()
    {
        // Search for nearby items
        Collider2D[] items = Physics2D.OverlapCircleAll(transform.position, 10, 1 << LayerMask.NameToLayer("Items"));

        // No items
        if (items.Length == 0)
        {
            return;
        }

        AbstractItem closestItem     = null;
        float        closestDistance = -1;

        // Find eligible item
        foreach (var item in items)
        {
            float distance = Vector2.Distance(transform.position, item.transform.position);

            if (distance > pickUpRange)
            {
                continue;
            }

            if (closestDistance == -1 || closestDistance < distance)
            {
                closestDistance = distance;
                closestItem     = item.GetComponent <AbstractItem>();
            }
        }

        if (closestItem == null)
        {
            return;
        }

        if (closestItem.ItemType == ItemType.Weapon)
        {
            EquipItem((AbstractWeapon)closestItem);
        }
    }
Ejemplo n.º 18
0
        protected virtual IEnumerable <CaptionFilter> BuildFilters(AbstractItem item)
        {
            if (item is IPerspectiveFilter)
            {
                yield return(new CaptionFilter(Target.Perspectives, ((IPerspectiveFilter)item).Perspective));
            }
            if (item is IDimensionFilter)
            {
                yield return(new CaptionFilter(Target.Dimensions, ((IDimensionFilter)item).Dimension));
            }
            if (item is IHierarchyFilter)
            {
                yield return(new CaptionFilter(Target.Hierarchies, ((IHierarchyFilter)item).Hierarchy));
            }
            if (item is ILevelFilter)
            {
                yield return(new CaptionFilter(Target.Levels, ((ILevelFilter)item).Level));
            }
            if (item is IMeasureGroupFilter && !(string.IsNullOrEmpty(((IMeasureGroupFilter)item).MeasureGroup)))
            {
                yield return(new CaptionFilter(Target.MeasureGroups, ((IMeasureGroupFilter)item).MeasureGroup));
            }
            if (item is IDisplayFolderFilter && !(string.IsNullOrEmpty(((IDisplayFolderFilter)item).DisplayFolder)))
            {
                yield return(new CaptionFilter(Target.DisplayFolders, ((IDisplayFolderFilter)item).DisplayFolder));
            }

            //if (item is ISchemaFilter)
            //    yield return new CaptionFilter(Target.Schemas, ((ISchemaFilter)item).Schema);
            if (item is ITableFilter)
            {
                yield return(new CaptionFilter(Target.Tables, ((ITableFilter)item).Table));
            }

            var itselfTarget = BuildTarget(item);

            if (!string.IsNullOrEmpty(item.Caption))
            {
                yield return(new CaptionFilter(itselfTarget, item.Caption));
            }
        }
Ejemplo n.º 19
0
        public void ApplyItemDef(ShopItemStats stats, AbstractItem item)
        {
            item.UIDef.GetShopData(out Sprite sprite, out string nameKey, out string descKey);

            // Apply all the stored values
            stats.playerDataBoolName     = GetShopBool(item);
            stats.nameConvo              = nameKey;
            stats.descConvo              = descKey;
            stats.requiredPlayerDataBool = requiredPlayerDataBool;
            stats.removalPlayerDataBool  = string.Empty;
            stats.dungDiscount           = dungDiscount;
            if (item is Items.CharmItem charm && int.TryParse(charm.fieldName.Split('_').Last(), out int charmNum))
            {
                stats.notchCostBool = $"charmCost_{charmNum}";
            }
            if (item is Items.EquippedCharmItem echarm)
            {
                stats.notchCostBool = $"charmCost_{echarm.charmNum}";
            }
            int index = items.IndexOf(item);

            if (index >= 0 && index < costs.Count)
            {
                stats.cost = costs[index];
            }
            else
            {
                stats.cost = 1;
            }

            // Need to set all these to make sure the item doesn't break in one of various ways
            stats.priceConvo     = string.Empty;
            stats.specialType    = 0;
            stats.charmsRequired = 0;
            stats.relic          = false;
            stats.relicNumber    = 0;
            stats.relicPDInt     = string.Empty;

            // Apply the sprite for the UI
            stats.transform.Find("Item Sprite").gameObject.GetComponent <SpriteRenderer>().sprite = sprite;
        }
Ejemplo n.º 20
0
        public async Task <AbstractItem> DeleteItemAsync(Guid guid)
        {
            AbstractItem item = await Context.Books.FirstOrDefaultAsync(b => b.ISBN == guid);

            if (item == null)
            {
                item = await Context.Jornals.FirstOrDefaultAsync(j => j.ISBN == guid);
            }
            if (item != null)
            {
                item.IsActive = false;
                await Context.SaveChangesAsync();

                return(item);
            }

            else
            {
                return(null);
            }
        }
Ejemplo n.º 21
0
 public bool CreateItem(AbstractItem item, bool isUser = true) //Create new item to its proper list
 {
     if (isUser == true)
     {
         if (!IsItemAlreadyAdded(item))
         {
             userItemsList.Add(item);
             SerializeJsonFile(userItemsList, "UserItems.json");
             return(true);
         }
     }
     else
     {
         if (!IsItemAlreadyAdded(item, false))
         {
             storeItemsList.Add(item);
             SerializeJsonFile(storeItemsList, "StoreItems.json");
             return(true);
         }
     }
     return(false);
 }
        private void Search_Item(object sender, RoutedEventArgs e)
        {
            //we check 2 thing's the name and the edition they qunic, and if they valid we can to the add and remove
            BookLib.ItemCollection collection = libraryManager.GetItemCollection();
            item  = collection[double.Parse(EditionTxt.Text)];
            item2 = collection[NameTxtt.Text];
            if (item == item2 && item != null)
            {
                ItemNameblock.Text = "Item was Found";
                addbt.IsEnabled    = true;
                removebt.IsEnabled = true;
            }

            else
            {
                ItemNameblock.Text = "Item was Not Found";
                item            = null;
                item2           = null;
                EditionTxt.Text = "";
                NameTxtt.Text   = "";
            }
        }
Ejemplo n.º 23
0
        private async void ReturnItem_BTN_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (data.AbstractItems.FindByName(Name_LIstView.SelectedItem.ToString()) is Book)
                {
                    CurrentItem = (Book)data.AbstractItems.FindByName(Name_LIstView.SelectedItem.ToString());
                }

                else
                {
                    CurrentItem = (Journal)data.AbstractItems.FindByName(Name_LIstView.SelectedItem.ToString());
                }
                data.AbstractItems.UserReturnItem(CurrentItem, data.CurrentUser);
                FillLists();
            }

            catch (NullReferenceException)
            {
                await new MessageDialog("You must choose an item to remove before trying to return it!").ShowAsync();
            }
        }
Ejemplo n.º 24
0
            public FindCycleDepsPathFinder([NotNull, ItemNotNull] IEnumerable <TDependency> dependencies,
                                           [CanBeNull] ItemMatch cycleAnchorsMatch, bool ignoreSelfCycles, int maxCycleLength,
                                           [NotNull] Action <int, Stack <TDependency>, string> recordNewCycleToRoot,
                                           [NotNull, ItemCanBeNull] AbstractPathMatch <TDependency, TItem>[] expectedPathMatches, Action checkAbort) : base(checkAbort)
            {
                Dictionary <TItem, TDependency[]> outgoing = AbstractItem <TItem> .CollectOutgoingDependenciesMap(dependencies);

                _maxCycleLength       = maxCycleLength;
                _ignoreSelfCycles     = ignoreSelfCycles;
                _recordNewCycleToRoot = recordNewCycleToRoot;

                IEnumerable <TItem> roots = outgoing.Keys.Where(i => ItemMatch.IsMatch(cycleAnchorsMatch, i));

                _addIndexToMarkerFormat = "D" + ("" + roots.Count() / 2).Length;

                foreach (var root in roots.OrderBy(i => i.Name))
                {
                    _root = root;
                    _visited2RestLength = new Dictionary <TItem, int>();
                    Traverse(root, outgoing, expectedPathMatches, endMatch: null, down: Ignore.Om);
                }
            }
Ejemplo n.º 25
0
    public void EquipItem(GameObject itemId)
    {
        if (itemId != null && itemId.GetComponent <AbstractItem>().itemType == "Equipttable")
        {
            AbstractItem itemscpt = itemId.GetComponent <AbstractItem>();

            if (!itemscpt.equipped && equippedSlots.Any(x => x.GetComponent <SlotInfo>().item == null))
            {
                if (itemId.GetComponent <AbstractItem>()._armorType == (int)AbstractItem.armorType.Head)
                {
                    itemId.transform.position = GameObject.FindGameObjectWithTag("Player").transform.position + new Vector3(0, 0.65f, 0);
                }
                else if (itemId.GetComponent <AbstractItem>()._armorType == (int)AbstractItem.armorType.Body)
                {
                    itemId.transform.position = GameObject.FindGameObjectWithTag("Player").transform.position + new Vector3(0, 0, 0);
                }


                itemscpt.equipped = true;
                itemscpt.EnableItemEffect();
                itemId.transform.SetParent(GameObject.FindGameObjectWithTag("EquippedItems").gameObject.transform);

                //Debug.Log("EQUIPPED: " + itemId.name);
            }
            else if (itemscpt.equipped)
            {
                itemId.transform.position = GameObject.FindGameObjectWithTag("ItemsFolder").transform.position;
                itemscpt.equipped         = false;
                itemscpt.DisableItemEffect();
                itemId.transform.SetParent(GameObject.FindGameObjectWithTag("ItemsFolder").gameObject.transform);

                //Debug.Log("UNEQUIPPED: " + itemId.name);
            }

            //Items.RemoveAt(itemId);
        }

        SlotsUpdate();
    }
Ejemplo n.º 26
0
 private void rentItem_Click(object sender, RoutedEventArgs e)
 {
     if (listBox.SelectedItem != null) //if user choosed item from listBox
     {
         AbstractItem itemForRent = MainPage.Items[itemsOfSearch[listBox.SelectedIndex].ISBN];
         if (MainPage.Items.RentItem(itemForRent))
         {
             RentItem rent = new RentItem(itemForRent);
             _user.UpdateRent(rent);
             MessageSuccessRent();
             ClearPreviousSearch();
         }
         else //item is not available for rengt
         {
             MessageNotAvailableForRent();
         }
     }
     else
     {
         MessageNotChooseItems();
     }
 }
Ejemplo n.º 27
0
 // Check if item exist and go to create new item or stay in this page and continue add copies
 private void addItemBtn_Click(object sender, RoutedEventArgs e)
 {
     if (!int.TryParse(idTbx.Text, out _id))
     {
         errorTbl.Text = "For enter ID use digits only";
     }
     else if (UsersManager.GetInstanse.CurrentUser.Access == UserType.Reader)
     {
         errorTbl.Text = "Readers can't add items";
     }
     else
     {
         if (_items.Exist(_id))
         {
             _foundedItem = _items.GetItem(_id);
             ShowAddCopiesControllers();
         }
         else
         {
             this.Frame.Navigate(typeof(AddEditItem), _id);
         }
     }
 }
Ejemplo n.º 28
0
        private void CheckItem(AbstractItem expected, AbstractItem actual)
        {
            Assert.IsNotNull(actual, "Actual item is null");
            Assert.AreEqual(expected.Name, actual.Name, "Wrong creature name!");
            Assert.AreEqual(expected.UniqueId, actual.UniqueId, "Wrong creature uid!");
            if (actual is AbstractWeapon)
            {
                Assert.IsTrue(expected is AbstractWeapon, "Actual item is not a weapon!");
                Assert.AreEqual(((AbstractWeapon)expected).Damage, ((AbstractWeapon)actual).Damage, "Actual item does not have correct damage!");
            }

            else if (actual is AbstractArmor)
            {
                Assert.IsTrue(expected is AbstractArmor, "Actual item is not an armor!");
                Assert.AreEqual(((AbstractArmor)expected).Defense, ((AbstractArmor)actual).Defense, "Actual item does not have correct deffense!");
            }

            else if (actual is AbstractInventoryItem)
            {
                Assert.IsTrue(expected is AbstractInventoryItem, "Actual item is not an inventory item!");
                Assert.AreEqual(((AbstractInventoryItem)expected).ItemValue, ((AbstractInventoryItem)actual).ItemValue, "Actual item does not have correct item value!");
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Updated general item data
        /// </summary>
        /// <param name="id"></param>
        /// <param name="updatedItem"></param>
        /// <returns></returns>
        public async Task UpdateAbstractItem(int id, AbstractItem updatedItem)
        {
            string updateQuery = "UPDATE AbstractItems " +
                                 $"Set Name = @name , Writer = @writer , PrintDate = @printDate , Publisher = @publisher , " +
                                 $"IDOfGenre = @genreID , Discount = @discount , Quantity = @quantity , Price = @price " +
                                 $"WHERE ItemID = @id";

            try
            {
                SqliteCommand command = new SqliteCommand(updateQuery);
                command.Parameters.AddWithValue("@name", updatedItem.Name);
                command.Parameters.AddWithValue("@writer", updatedItem.Writer);
                command.Parameters.AddWithValue("@printDate", updatedItem.PrintDate);
                command.Parameters.AddWithValue("@publisher", updatedItem.Publisher);
                command.Parameters.AddWithValue("@genreID", updatedItem.Genre.ID);
                command.Parameters.AddWithValue("@discount", updatedItem.Discount);
                command.Parameters.AddWithValue("@quantity", updatedItem.Quantity);
                command.Parameters.AddWithValue("@price", updatedItem.Price);
                command.Parameters.AddWithValue("@id", id);
                SqlFileAccess.SqlPerformQuery(command);
            }
            catch (Exception e)
            {
                if (e is SqliteException || e is ArgumentOutOfRangeException)
                {
                    await SaveToLogFile(e.ToString());

                    throw new GeneralItemException("Cant get Update Abstract Item");
                }
                else
                {
                    await SaveToLogFile(e.ToString());

                    throw new DALException("Unknown Error");
                }
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Its the function that work on the items thad choose from the list
        /// </summary>
        /// <param name="SelectedIndex">selected item from the list</param>
        /// <param name="Client"></param>
        /// <param name="method">Its a string thad you send id its "delete" or "edit"</param>
        /// <returns></returns>
        public static async Task <bool> SelectetItemHandler(AbstractItem SelectedIndex, HttpClient Client, string method)
        {
            try
            {
                if (SelectedIndex == null || String.IsNullOrEmpty(SelectedIndex.Title))
                {
                    throw new Exception($"You need select item before {method}!");
                }


                var json = JsonConvert.SerializeObject(SelectedIndex);

                HttpResponseMessage response = new HttpResponseMessage();
                if (method == "delete")
                {
                    response = await SelecteditemPutAsync(Client, SelectedIndex.ISBN, json, "delete");
                }
                if (method == "buy")
                {
                    response = await SelecteditemPutAsync(Client, SelectedIndex.ISBN, json, "buy");
                }
                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                return(false);
            }
        }
Ejemplo n.º 31
0
    void SpawnObjects(ref List <Vector3> possibleLocations)
    {
        List <AbstractItem> possibleItems = GameManager.Instance.GetItemList();

        int randomIndex = Random.Range(0, possibleItems.Count);
        int spawnRate   = _itemScriptableObject._spawnRate;

        bool shouldSpawn = Random.Range(0, 100) < spawnRate;

        if (shouldSpawn)
        {
            Vector3 position =
                possibleLocations[Random.Range(0, possibleLocations.Count)];
            possibleLocations.Remove(position);
            position.y = 0;

            AbstractItem itemToSpawn = possibleItems[randomIndex];
            GameObject   item        = Instantiate(itemToSpawn.gameObject, position,
                                                   Quaternion.identity);
            itemToSpawn.sprite    = itemToSpawn.gameObject.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite;
            item.transform.parent = transform;
            GameManager.Instance.AddSpawnedItem(item, itemToSpawn);
        }
    }
Ejemplo n.º 32
0
 public Note(string name, long unid, bool showAnnotation, AbstractItem attachedItem, string text)
     : base(name, unid, showAnnotation)
 {
     this.attachedItem = attachedItem;
        this.text = text;
 }
Ejemplo n.º 33
0
 protected Decorator(AbstractItem item)
 {
     this.AbstractItem = item;
 }
Ejemplo n.º 34
0
        /// <summary>
        /// Generate an <see cref="AbstractItem"/> of the specified kind starting from a specified correct item.
        /// The every element of <see cref="E_ItemType"/> is associated an index of the <see cref="attPopulationMatrix"/> 
        /// so that the vector corresponding to the passed index is used in creating the new <see cref="AbstractItem"/> 
        /// </summary>
        /// <param name="CorrectItem">The <see cref="AbstractItem"/> which is considered as correct</param>
        /// <param name="ItemTypeToGenerate">The <see cref="E_ItemType"/> which must be generated</param>
        /// <returns></returns>
        private AbstractItem InvertByItemType(AbstractItem CorrectItem, E_ItemType ItemTypeToGenerate)
        {
            ItemGraficalProperty wvIgp;
            AbstractItem wvInvertedAbstractItem = new AbstractItem(ItemTypeToGenerate, CorrectItem.ItemKind);
            bool[] wvVctor = attPopulationMatrix[(int)ItemTypeToGenerate];

            for(int i = 0;  i<CorrectItem.PropertiesCount; i++)
            {

                ItemGraficalProperty wvProperty = new ItemGraficalProperty();
                wvIgp = CorrectItem.ItemProperties[i];
                if(wvVctor[i])
                {
                    wvProperty.SetContent(wvIgp.PropertyKind, wvIgp.Content);
                }
                else
                {

                    wvProperty.SetContent(InvertProperty(wvIgp));

                }

                wvInvertedAbstractItem.AddProperty(wvProperty);
            }

            return wvInvertedAbstractItem;
        }
Ejemplo n.º 35
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Path))
            { //Do not build the second level for blog section.
                if (ContextItem == null)
                {
                    ContextItem = Sitecore.Context.Database.GetItem( Path );
                }
            }

            if (ContextItem != null)
            {
                //Retrieve CSS class
                CssClass = new AbstractItem(contextItem.InnerItem).GetPanelCssClass();

                if (!String.IsNullOrEmpty(RootUrl))
                {
                    contextItem.Url = String.Format( "{0}?section={1}",RootUrl,contextItem.Name );
                }

                //if (ContextItem.InnerItem.HasChildren)
                //{
                //    List<PageSummaryItem> secondLevel = ContextItem.InnerItem.Children.ToList().ConvertAll( x => new PageSummaryItem(x) );
                //    secondLevel.RemoveAll(x => x.Hidefrommenu.Checked); //Remove all hidden items

                //    if (secondLevel.Count > 0)
                //    {
                //        secondLevel.First().IsFirst = true;
                //        secondLevel.Last().IsLast = true;

                //        if (!String.IsNullOrEmpty(RootUrl)) //Set the jump links
                //        {
                //            foreach (PageSummaryItem child in secondLevel)
                //            {
                //                child.Url = String.Format("{0}#{1}", contextItem.Url, child.Name);
                //            }
                //        }

                //        ChildLinks.DataSource = secondLevel;
                //        ChildLinks.DataBind();
                //    }
                //}
            }
        }
Ejemplo n.º 36
0
        //
        /// <summary>
        /// returns an item given a clue ad an item kind
        /// </summary>
        /// <param name="c">a clue object</param>
        /// <param name="itemKind">an itemkind</param>
        /// <returns> an Item object that contains, in order : 
        ///         1. Item code
        ///         2. Barcode
        ///         3. Item Name
        ///         4. Item Price
        ///         5. Item Description
        ///         6. Item Reparto
        ///         7. Texture file name
        ///         8. Image file name
        ///         9. item kind
        /// </returns>
        public Item GetItemFromAbstractItem(AbstractItem Item)
        {
            try
            {
                DBConnection.Open();
            }
            catch
            {
                DBConnection.Close();
                DBConnection.Open();
            }

            // note : we want items of which we have more than 10 available
            string query = "SELECT TOP 1 I.ID, I.Barcode, II.ItemName, II.Price, II.Description, II.Reparto, T.FileName, I.Image";
            query += " FROM Item AS I ,Texture AS T, ItemKind AS IK, TextureKind AS TK, ItemInfo AS II, Color AS C";
            query += " WHERE II.ItemKind = IK.ID AND I.ItemInfo = II.ID AND I.Texture = T.ID AND T.TextureKind = TK.ID AND T.MainColor = C.ID";
            query += " AND I.Available > 10 AND IK.ItemKind = @p5";

            string order = " ORDER BY Rnd(-(10000*I.ID)*Time())";

            string whereLong = " AND II.Long = @p1";
            string whereLight = " AND T.Light = @p2";
            string whereTexture = " AND TK.TextureKind = @p3";
            string whereColor = " AND C.Color = @p4";

            // parameter @p1 - shape
            if(Item.CheckPropertyByKind(E_PropertiesKind.SHAPE))
            {
                if (Item.GetProperty(E_PropertiesKind.SHAPE) == E_Shape.LONG.ToString())
                {
                    whereLong = whereLong.Replace("@p1", true.ToString());
                }
                else
                {
                    whereLong = whereLong.Replace("@p1", false.ToString());
                }
                query += whereLong;
            }

            // parameter @p2 - gradiation
            if (Item.CheckPropertyByKind(E_PropertiesKind.GRADIATION))
            {
                if (Item.GetProperty(E_PropertiesKind.GRADIATION) == E_Gradiation.LIGHT.ToString())
                {
                    whereLight = whereLight.Replace("@p2", true.ToString());
                }
                else
                {
                    whereLight = whereLight.Replace("@p2", false.ToString());
                }
                query += whereLight;
            }

            // parameter @p3 - texture kind
            if (Item.CheckPropertyByKind(E_PropertiesKind.TEXTURE))
            {
                whereTexture = whereTexture.Replace("@p3", "\'" + Item.GetProperty(E_PropertiesKind.TEXTURE).ToLower() + "\'");
                query += whereTexture;
            }

            // parameter @p4 - main color
            if (Item.CheckPropertyByKind(E_PropertiesKind.COLOR))
            {
                whereColor = whereColor.Replace("@p4", "\'" + Item.GetProperty(E_PropertiesKind.COLOR).ToLower() + "\'");
                query += whereColor;
            }

            // parameter @p5 - item kind
            query = query.Replace("@p5", "\'" + Item.ItemKind.ToString().ToLower() + "\'");

            query += order;

            OleDbCommand command = new OleDbCommand(query, DBConnection);

            OleDbDataReader result = command.ExecuteReader();

            result.Read();

            int codice = result.GetInt32(0);
            string barcode = result.GetString(1);
            string name = result.GetString(2);
            double price = result.GetDouble(3);
            string descr = result.GetString(4);
            string rep = result.GetString(5);
            string texture = result.GetString(6);
            string image = result.GetString(7);

            Item i = new Item(codice, barcode, name, price, descr, rep, texture, image, Item);

            DBConnection.Close();

            return i;
        }
Ejemplo n.º 37
0
        /// <summary>
        /// Generate an <see cref="AbstractItem"/> that is correct for the game solution
        /// </summary>
        /// <param name="ItemKind"></param>
        /// <returns></returns>
        private AbstractItem GenerateCorrectAbstractItem(E_ItemKind ItemKind)
        {
            int wvRandom;
            E_Gradiation wvGradiation;
            E_Shape wvShape;
            E_Color wvColor;
            E_Texture wvTexture;

            AbstractItem wvAbstractItem = new AbstractItem(E_ItemType.A, ItemKind);
            ItemGraficalProperty wvProperty = new ItemGraficalProperty();
            List <E_PropertiesKind> wvPropertiesKind = new List<E_PropertiesKind>();

            wvRandom = attRandom.Next((int)E_PropertiesKind._NULL + 1 ,(int)E_PropertiesKind._END);

            if (ItemKind == E_ItemKind.HAT)//Because in our DB only HATS have the E_PropertyKind.SHAPE implemented
            {
                for (int i = (int)E_PropertiesKind._NULL + 1; i < (int)E_PropertiesKind._END ; i++)
                {
                    if (i != wvRandom)
                        wvPropertiesKind.Add((E_PropertiesKind)i);
                }
            }
            else
            {
                for (int i = (int)E_PropertiesKind._NULL + 1; i < (int)E_PropertiesKind._END; i++)
                {
                    if (i != (int)E_PropertiesKind.SHAPE)
                        wvPropertiesKind.Add((E_PropertiesKind)i);
                }
            }

            wvGradiation = E_Gradiation._NULL;
            foreach (E_PropertiesKind pk in wvPropertiesKind)
            {
                wvProperty = new ItemGraficalProperty();
                switch (pk)
                {
                    case E_PropertiesKind.COLOR:

                        #region Color from Gradiation
                        List<E_Color> wvColors = new List<E_Color>();
                        if(wvGradiation == E_Gradiation._NULL)//This because is no possible to have WHITE items with DARK graiation or DARK item with LIGHT gradaition
                        {
                            for (int i = (int)E_Color._NULL + 1; i < (int)E_Color._END; i++)
                            {
                                wvColors.Add((E_Color)i);
                            }
                        }
                        else
                        {
                            for (int i = (int)E_Color._NULL + 1; i < (int)E_Color._END; i++)
                            {
                                if ((E_Color)i != E_Color.BLACK && (E_Color)i != E_Color.WHITE)
                                    wvColors.Add((E_Color)i);
                            }
                        }
                        wvRandom = attRandom.Next(wvColors.Count);
                        wvColor = wvColors[wvRandom];
                        #endregion

                        wvProperty.SetContent(pk, wvColor);
                        break;
                    case E_PropertiesKind.GRADIATION:
                        wvRandom = attRandom.Next(1 + (int)E_Gradiation._NULL, (int)E_Gradiation._END);
                        wvGradiation = (E_Gradiation)wvRandom;
                        wvProperty.SetContent(pk, wvGradiation);
                        break;
                    case E_PropertiesKind.SHAPE:
                        wvRandom = attRandom.Next(1 + (int)E_Shape._NULL, (int)E_Shape._END);
                        wvShape = (E_Shape)wvRandom;
                        wvProperty.SetContent(pk, wvShape);
                        break;
                    default: //TEXTURE
                        wvRandom = attRandom.Next(1 + (int)E_Texture._NULL, (int)E_Texture._END);
                        wvTexture = (E_Texture)wvRandom;
                        wvProperty.SetContent(pk, wvTexture);
                        break;

                }
                wvAbstractItem.AddProperty(wvProperty);
            }

            return wvAbstractItem;
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Generate a populated <see cref="Room"/> 
        /// </summary>
        /// <param name="Name">The name of the room to be generated</param>
        /// <param name="CorrectItem">The correct <see cref="Item"/> to be conteined in the room</param>
        /// <returns></returns>
        private Room GenerateRoom(E_RoomsName Name, Item CorrectItem)
        {
            Room wvRoom = null;
            List<Item> wvItems = new List<Item>();
            wvItems.Add(CorrectItem);

            for (int i = (int)E_ItemType.A + 1; i<= (int)E_ItemType.F; i++)
            {
                AbstractItem wvAbstractItem = new AbstractItem((E_ItemType)i, CorrectItem.ItemKind);

                wvAbstractItem = InvertByItemType(CorrectItem, (E_ItemType)i);

                wvItems.Add(attDataBase.GetItemFromAbstractItem(wvAbstractItem));

            }

            wvRoom = new Room(Name, wvItems);
            return wvRoom;
        }
Ejemplo n.º 39
0
 public Note(AbstractItemData itemData, AbstractItem attachedItem, string text)
     : this(itemData.name, itemData.unid, itemData.showAnnotation, attachedItem, text)
 {
 }
Ejemplo n.º 40
0
        private void OnItemCollected(AbstractItem item, Player collectedBy)
        {
            // Check what was collected
            Console.WriteLine("Found item of type:" + item.GetType());
            if (item is GunItem)
            {
                EvolutionManager.Instance.HasGun = true;
                // Update the player
                EvolutionManager.Instance.SetupPlayer(player);
                player.LoadContent();

            }
            else if (item is LegsItem)
            {
                // Set legs to true
                EvolutionManager.Instance.HasLegs = true;
                // Update the player
                EvolutionManager.Instance.SetupPlayer(player);
                player.LoadContent();
            }

            item.OnCollected(collectedBy);
        }
Ejemplo n.º 41
0
        public Game GetGameForProf()
        {
            string wvPlayerID = "15-01-2016-10-50-42_alberto";
            string wvPlayerName = "alberto";

            ItemGraficalProperty wvProperty = new ItemGraficalProperty();
            Solution wvSolution = new Solution();
            List<Room> wvRooms = new List<Room>();
            List<Item> wvItems;

            AbstractItem wvAbstract;

            wvRooms.Add(new Room(E_RoomsName.START_ROOM));

            #region Room = LIVINGROOM
            wvItems = new List<Item>();

            #region A -> ID 19
            wvAbstract = new AbstractItem(E_ItemType.A, E_ItemKind.TROUSERS);
            wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.BLUE);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.SCOTTISH);
            wvAbstract.AddProperty(wvProperty);

            wvItems.Add(GetItem(wvAbstract, E_Items.AOne));
            wvSolution.AddItem(wvAbstract);
            #endregion

            #region B One -> 18
            wvAbstract = new AbstractItem(E_ItemType.B, E_ItemKind.TROUSERS);
            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.BLUE);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.PLAINCOLOR);
            wvAbstract.AddProperty(wvProperty);

            wvItems.Add(GetItem(wvAbstract, E_Items.BOne));
            #endregion

            wvRooms.Add(new Room(E_RoomsName.LIVINGROOM, wvItems));
            #endregion

            #region Room = KITCHEN
            wvItems = new List<Item>();

            #region A Two -> 71
            wvAbstract = new AbstractItem(E_ItemType.A, E_ItemKind.HAT);
            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.GREEN);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.DARK);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.STRIPES);
            wvAbstract.AddProperty(wvProperty);

            wvSolution.AddItem(wvAbstract);
            wvItems.Add(GetItem(wvAbstract, E_Items.ATwo));
            #endregion

            #region B Two  -> 68
            wvAbstract = new AbstractItem(E_ItemType.B, E_ItemKind.HAT);
            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.GREEN);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.DARK);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.POIS);
            wvAbstract.AddProperty(wvProperty);

            wvItems.Add(GetItem(wvAbstract, E_Items.BTwo));
            #endregion

            wvRooms.Add(new Room(E_RoomsName.KITCHEN, wvItems));
            #endregion

            #region Room = BEDROOM
            wvItems = new List<Item>();

            #region A Three  -> 127
            wvAbstract = new AbstractItem(E_ItemType.A, E_ItemKind.T_SHIRT);
            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.PURPLE);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.POIS);
            wvAbstract.AddProperty(wvProperty);

            wvSolution.AddItem(wvAbstract);
            wvItems.Add(GetItem(wvAbstract, E_Items.AThree));
            #endregion

            #region B Three -> 121
            wvAbstract = new AbstractItem(E_ItemType.B, E_ItemKind.T_SHIRT);
            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.PURPLE);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT);
            wvAbstract.AddProperty(wvProperty);

            wvProperty = new ItemGraficalProperty();
            wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.FLOWERS);
            wvAbstract.AddProperty(wvProperty);

            wvItems.Add(GetItem(wvAbstract, E_Items.BThree));
            #endregion

            wvRooms.Add(new Room(E_RoomsName.BEDROOM, wvItems));
            #endregion

            //return null;
            return new Game(wvPlayerID, wvPlayerName, wvRooms, wvSolution);
        }
Ejemplo n.º 42
0
        private Item GetItem(AbstractItem AI, E_Items ID)
        {
            string wvBaseQuery = "SELECT TOP 1 I.ID, I.Barcode, II.ItemName, II.Price, II.Description, II.Reparto, T.FileName, I.Image";
            wvBaseQuery += " FROM Item AS I ,Texture AS T, ItemKind AS IK, TextureKind AS TK, ItemInfo AS II, Color AS C";
            wvBaseQuery += " WHERE II.ItemKind = IK.ID AND I.ItemInfo = II.ID AND I.Texture = T.ID AND T.TextureKind = TK.ID AND T.MainColor = C.ID";
            wvBaseQuery += " AND I.ID=";

            string query = wvBaseQuery + (int)ID;

            DBConnection.Open();
            OleDbCommand command = new OleDbCommand(query, DBConnection);

            OleDbDataReader result = command.ExecuteReader();

            result.Read();

            int codice = result.GetInt32(0);
            string barcode = result.GetString(1);
            string name = result.GetString(2);
            double price = result.GetDouble(3);
            string descr = result.GetString(4);
            string rep = result.GetString(5);
            string texture = result.GetString(6);
            string image = result.GetString(7);

            DBConnection.Close();
            Item i = new Item(codice, barcode, name, price, descr, rep, texture, image, AI);

            return i;
        }