void AddItemToInventory(ItemRequest request)
    {
        if (!isOwner)
        {
            return;
        }
        Item shipped_item = amazon.RequestItem(request.item_name);

        if (SharedItem.isSharedItem(shipped_item))
        {
            if (!isServer)
            {
                InvokeServerRpc(RPC_AddSharedItem, request.item_name, 1, channel: INVMANG_CHANNEL);
            }
            else
            {
                string            item_name = request.item_name;
                uint              clientId  = NetworkingManager.singleton.LocalClientId;
                NetworkSharedItem netItem   = new NetworkSharedItem(item_name);
                networkInv.AddItemStack(item_name, netItem, 1);
            }
        }
        if (AbilityItem.isAbilityItem(shipped_item))
        {
            shipped_item.context   = this;
            shipped_item.menu_form = image;
            actionSlots.ability_items[shipped_item.name()] = (AbilityItem)shipped_item;
            actionSlots.ChangeAbilityItem(actionSlots.ability_items.GetStackCount(), shipped_item.name());
        }
        GameObject.Destroy(request.gameObject);
    }
Beispiel #2
0
    void AddItemToInventory(WorldItem request)
    {
        if (!IsOwner)
        {
            return;
        }
        Item shipped_item = ItemCatalogue.RequestItem(request.item_name);

        if (SharedItem.isSharedItem(shipped_item))
        {
            if (!IsServer)
            {
                InvokeServerRpc(RPC_AddSharedItemNetwork, request.NetworkId, 1, channel: INVMANG_CHANNEL);
            }
            else
            {
                RPC_AddSharedItemNetwork(request.NetworkId, 1);
            }
        }
        else if (AbilityItem.isAbilityItem(shipped_item))
        {
            shipped_item.context   = this;
            shipped_item.menu_form = Resources.Load(shipped_item.name() + "MenuForm") as Sprite;
            actionSlots.ability_items[shipped_item.name()] = (AbilityItem)shipped_item;
            actionSlots.ChangeAbilityItem(actionSlots.ability_items.GetStackCount(), shipped_item.name());
        }
    }
Beispiel #3
0
        public async Task ShareItem(string description)
        {
            try {
                StorageFile file = currentSelectedFile;
                currentSelectedFile = null;
                Dictionary <string, string> fileInfoDict = await UploadFile(file);

                if (fileInfoDict != null)
                {
                    SharedItem itemToShare = new SharedItem {
                        facebookUserID = FacebookId, description = description, url = fileInfoDict["link"], name = fileInfoDict["name"], date = System.DateTime.UtcNow
                    };
                    await sharedItemsTable.InsertAsync(itemToShare);

                    var dialog = new MessageDialog("Successfully shared item: \"" + fileInfoDict["name"] + "\".");
                    dialog.Commands.Add(new UICommand("Ok"));
                    dialog.ShowAsync();
                }
                RefreshItems();
            } catch (MobileServiceInvalidOperationException) {
                var dialog = new MessageDialog("Error when sharing item!");
                dialog.Commands.Add(new UICommand("Ok"));
                dialog.ShowAsync();
            }
        }
Beispiel #4
0
    public void EquipSharedItem(string item_name)
    {
        if (!IsOwner)
        {
            return;
        }
        Item shipped_item = ItemCatalogue.RequestItem(item_name);

        if (SharedItem.isSharedItem(shipped_item))
        {
            if (!IsServer)
            {
                InvokeServerRpc(RPC_EquipSharedItem, item_name, 1, channel: INVMANG_CHANNEL);
            }
            else
            {
                ulong             clientId = NetworkingManager.Singleton.LocalClientId;
                NetworkSharedItem netItem;
                if (NetworkSwapSharedItem(item_name, (int)clientId, out netItem, 1))
                {
                    RPC_ClientEquipSharedItem(netItem.name);
                }
            }
        }
    }
Beispiel #5
0
 private void ChangeSharedItemUI(SharedItem item)
 {
     if (CheckForItemBar())
     {
         item_bar.use_slot.sprite = item?.menu_form;
     }
 }
Beispiel #6
0
 public SharedItemsListElement(string date, string description, string name, string url, string userID, SharedItem sharedItem)
 {
     this.Date        = date;
     this.Description = description;
     this.Name        = name;
     this.URL         = url;
     this.UserID      = userID;
     this.SharedItem  = sharedItem;
 }
 private void RPC_ClientEquipSharedItem(string item_name)
 {
     if (item_name != "")
     {
         SharedItem shipped_item = (SharedItem)amazon.RequestItem(item_name);
         shipped_item.context   = this;
         shipped_item.menu_form = image;
         actionSlots.ChangeSharedItem(shipped_item);
     }
 }
Beispiel #8
0
 private void RPC_ClientEquipSharedItem(string item_name)
 {
     if (item_name != "")
     {
         SharedItem shipped_item = (SharedItem)ItemCatalogue.RequestItem(item_name);
         shipped_item.context   = this;
         shipped_item.menu_form = Resources.Load <Sprite>(shipped_item.name() + "MenuForm");
         actionSlots.ChangeSharedItem(shipped_item);
     }
 }
Beispiel #9
0
 private void Start()
 {
     if (paused)
     {
         PauseGame();
     }
     sharedItems = new SharedItem(0, 3);
     SpawnPlayers();
     UIManager.Instance.InstantiateResourceHud(sharedItems.Money, sharedItems.Revives);
 }
        public async Task <IActionResult> Create([Bind("ID,Name,PictureLink,Location,Address,ContactorPhone,ContactorEmail,Type,Description")] SharedItem sharedItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sharedItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sharedItem));
        }
        public void AddSharedItem(SharedItem sharedItem)
        {
            if (listSharedItems.Count == 0)
            {
                sharedItem.Id = 1;
            }
            else
            {
                sharedItem.Id = listSharedItems.Max(u => u.Id) + 1;
            }

            listSharedItems.Add(sharedItem);
        }
Beispiel #12
0
 public void ChangeSharedItem(SharedItem item)
 {
     if (shared_item != null)
     {
         shared_item.OnDestroy();
     }
     shared_item = item;
     if (shared_item != null)
     {
         shared_item.Start();
     }
     ChangeSharedItemUI(item);
 }
Beispiel #13
0
        public async Task DeleteItem(SharedItem itemToDelete)
        {
            try {
                await sharedItemsTable.DeleteAsync(itemToDelete);

                var dialog = new MessageDialog("Successfully deleted " + itemToDelete.name + ".");
                dialog.Commands.Add(new UICommand("Ok"));
                dialog.ShowAsync();
                RefreshItems();
            } catch (MobileServiceInvalidOperationException) {
                var dialog = new MessageDialog("Error when deleting item!");
                dialog.Commands.Add(new UICommand("Ok"));
                dialog.ShowAsync();
            }
        }
        public HttpResponseMessage GetGetSharedItem(int idSession, int idSharedItem)
        {
            IsSessionExist(idSession);
            IsSharedItemExist(idSession, idSharedItem);

            SharedItem sharedItem = sessionDal.GetSharedItemById(idSession, idSharedItem);


            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StreamContent(new FileStream(sharedItem.Path, FileMode.Open, FileAccess.Read));
            response.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = sharedItem.Text;

            return(response);
        }
Beispiel #15
0
        public IActionResult GetNews(string tags)
        {
            List <News> model = null;

            if (!string.IsNullOrWhiteSpace(tags))
            {
                var tagsArray = Array.ConvertAll <string, int>(tags.Split(","), int.Parse);

                model = _db.NewsAndTags.Where(x => tagsArray.Contains(x.TagId)).
                        Include(x => x.News).Include(x => x.News.NewsImages).Select(x => x.News)
                        .ToList();
            }
            else
            {
                model = _db.Newses.Include(i => i.NewsImages).ToList();
            }
            return(SharedItem.JsonContent(model));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Address,ContactorPhone,ContactorEmail,Type,Description")] SharedItem sharedItem)
        {
            if (id != sharedItem.ID)
            {
                return(NotFound());
            }

            var oldItem = _context.SharedItems.Single(i => i.ID == id);

            if (oldItem == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    oldItem.Name           = sharedItem.Name;
                    oldItem.Type           = sharedItem.Type;
                    oldItem.Description    = sharedItem.Description;
                    oldItem.ContactorEmail = sharedItem.ContactorEmail;
                    oldItem.ContactorPhone = sharedItem.ContactorPhone;
                    oldItem.Address        = sharedItem.Address;

                    _context.Update(oldItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SharedItemExists(sharedItem.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(ManageItems)));
            }
            return(View(sharedItem));
        }
Beispiel #17
0
    public void UnequipSharedItem(string item_name)
    {
        if (!IsOwner)
        {
            return;
        }
        Item shipped_item = ItemCatalogue.RequestItem(item_name);

        if (SharedItem.isSharedItem(shipped_item))
        {
            if (!IsServer)
            {
                InvokeServerRpc(RPC_UnequipSharedItem, item_name, 1, channel: INVMANG_CHANNEL);
            }
            else
            {
                ulong clientId = NetworkingManager.Singleton.LocalClientId;
                bool  success  = networkInv.RevokeItem(item_name, (int)clientId, 1);
                RPC_ClientUnequipSharedItem(success ? item_name : "");
            }
        }
    }
Beispiel #18
0
    public void Init(GameObject model)
    {
        GameObject m = Instantiate(model, transform);

        m.name          = "Model";
        animator        = GetComponentInChildren <Animator>();
        hand            = transform.Find("Hand");
        projectileSpawn = hand.GetChild(0).transform;
        agent           = GetComponent <NavMeshAgent>();

        bodyColor = m.GetComponent <SpriteRenderer>().color;


        item = GameManager.Instance.sharedItems;


        InitAbilities();
        if (ability != null)
        {
            SelectAbility(0);
        }
    }
        // look up shared content
        protected override string GetContent(string key, string[] parameters)
        {
            if (String.IsNullOrEmpty(key) || _settings == null)
            {
                return(base.GetContent(key, parameters));
            }

            bool       isFound = false;
            string     value   = String.Empty;
            SharedItem item    = null;

            if (_sharedContent != null && _sharedContent.Count > 0)
            {
                item = _sharedContent[key];
                if (item != null)
                {
                    isFound = true;
                    value   = item.Value;
                }
            }

            // 2. Consider the shared contents from the groups...
            if (item == null)
            {
                BuildEngineSettings engineSettings =
                    _settings.EngineSettings[_engineType];

                if (engineSettings != null)
                {
                    SharedContent shared = engineSettings.SharedContent;
                    if (shared != null && shared.Count != 0)
                    {
                        item = shared[key];
                        if (item != null)
                        {
                            isFound = true;
                            value   = item.Value;
                        }
                    }
                }
            }

            // 3. If not found, consider a common/default contents....
            if (item == null)
            {
                SharedContent shared = _settings.SharedContent;
                if (shared != null && shared.Count != 0)
                {
                    item = shared[key];
                    if (item != null)
                    {
                        isFound = true;
                        value   = item.Value;
                    }
                }
            }

            if (isFound)
            {
                if (parameters != null && parameters.Length != 0)
                {
                    try
                    {
                        value = String.Format(value, parameters);
                    }
                    catch
                    {
                        LogMessage(BuildLoggerLevel.Error, String.Format(
                                       "The shared content item '{0}' could not be formatted with {1} parameters.",
                                       key, parameters.Length));
                    }
                }

                return(value);
            }

            return(base.GetContent(key, parameters));
        }
Beispiel #20
0
        public static void Initialize(ApplicationDbContext context)
        {
            context.Database.EnsureCreated();
            // Look for any students.
            if (context.Categories != null && context.Categories.Any())
            {
                return; // DB has been seeded
            }

            // Categories
            var categories = new Category[]
            {
                new Category()
                {
                    Name = "Furniture", Description = "Furnitures, like table, bed, sofa."
                },
                new Category()
                {
                    Name = "Appliance", Description = "Appliances"
                },
                new Category()
                {
                    Name = "Books", Description = "Books"
                },
                new Category()
                {
                    Name = "Digital devices", Description = "Computer, cell phone"
                },
                new Category()
                {
                    Name = "Toys", Description = "Toys"
                },
                new Category()
                {
                    Name = "Pet", Description = "PET"
                },
                new Category()
                {
                    Name = "Others", Description = "Any other things"
                },
            };

            foreach (var c in categories)
            {
                context.Categories.Add(c);
            }
            context.SaveChanges();

            // SharedItems

            var items = new SharedItem[]
            {
                // Furniture
                new SharedItem()
                {
                    Name = "Table", Description = "A used table, almost brand new.", PictureLink = "/images/sample/table.jpg", Category = categories[0], Location = "{lat: -34.397, lng: 150.644}", Address = " 110 St Heliers, Auckland", ContactorEmail = "*****@*****.**", ContactorPhone = "022 800 800", Type = "Table", PostTime = new DateTime(2018, 9, 27)
                },
                new SharedItem()
                {
                    Name = "Bed", Description = "A used bed, king-size.", PictureLink = "/images/sample/bed.jpg", Category = categories[0], Location = "{lat: -34.397, lng: 150.644}", Address = " 110 St Heliers, Auckland", ContactorEmail = "*****@*****.**", ContactorPhone = "022 800 810", Type = "Bed", PostTime = new DateTime(2018, 9, 30)
                },
                new SharedItem()
                {
                    Name = "Chair", Description = "A used table, almost brand new.", PictureLink = "/images/sample/chair.jpg", Category = categories[0], Location = "{lat: -34.297, lng: 150.644}", Address = " 110 St Lukes, Auckland", ContactorEmail = "*****@*****.**", ContactorPhone = "022 800 820", Type = "Sofa", PostTime = new DateTime(2018, 10, 1)
                },

                // Appliance
                new SharedItem()
                {
                    Name = "TV", Description = "A almost new TV(Philips).", PictureLink = "/images/sample/TV.jpg", Category = categories[1], Location = "{lat: -34.397, lng: 150.614}", Address = " 1 St Heliers, Auckland", ContactorEmail = "*****@*****.**", ContactorPhone = "021 100 800", Type = "TV", PostTime = new DateTime(2018, 10, 10)
                },
                new SharedItem()
                {
                    Name = "iPhone", Description = "A brand new one.", PictureLink = "/images/sample/iphone.jpg", Category = categories[1], Location = "{lat: -34.397, lng: 150.624}", Address = " 2 St Heliers, Auckland", ContactorEmail = "*****@*****.**", ContactorPhone = "022 200 810", Type = "CellPhone", PostTime = new DateTime(2018, 10, 16)
                },
                new SharedItem()
                {
                    Name = "Washing machine", Description = "Need to be reparied.", PictureLink = "/images/sample/washingmachine.jpg", Category = categories[1], Location = "{lat: -34.297, lng: 150.634}", Address = " 3 St Lukes, Auckland", ContactorEmail = "*****@*****.**", ContactorPhone = "022 200 820", Type = "Washing machine", PostTime = new DateTime(2018, 10, 17)
                },
            };

            foreach (var i in items)
            {
                context.SharedItems.Add(i);
            }

            context.SaveChanges();
        }
Beispiel #21
0
 public void DropItem()
 {
     shared_item = null;
 }