Esempio n. 1
0
        private void SaveData()
        {
            var storage = new LocationStorage();

            storage.SaveLocations(new AppSettings()
            {
                Locations = Locations.Select(it => it.Location).ToList()
            });
        }
Esempio n. 2
0
 private void AddToPack(LocationStorage ls)
 {
     if (m_Owner.Backpack != null)
     {
         m_Owner.Backpack.DropItem(ls.ItemStored);
         ls.ItemStored.Location = ls.Location;
     }
     else if (m_Owner.Backpack != null)
     {
         m_Owner.AddToBackpack(ls.ItemStored);
     }
 }
Esempio n. 3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            m_Owner         = reader.ReadMobile();
            m_EquippedItems = reader.ReadStrongItemList();

            m_BackpackContent = new List <LocationStorage>();
            int BackpackContentAmount = reader.ReadInt();

            for (int i = 0; i < BackpackContentAmount; ++i)
            {
                m_BackpackContent.Add(LocationStorage.Deserialize(reader));
            }
        }
Esempio n. 4
0
 private void LoadData()
 {
     try
     {
         var storage  = new LocationStorage();
         var settings = storage.ReadLocations();
         foreach (var location in settings.Locations)
         {
             Locations.Add(new LocationViewModel(location));
         }
     }
     catch (Exception e)
     {
         Operation = e.Message;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Adds a new location to a player
        /// </summary>
        /// <param name="player"></param>
        public void AddNewLocation(GamePlayer player)
        {
            BusinessLocation location = new BusinessLocation();
            LocationStorage storage = new LocationStorage();
            storage.Items = new Dictionary<BuildableItemEnum, ItemQuantity>();
            location.Storage = storage;
            player.Locations.Add(location);

            AddItem(player,
                0, new ItemQuantity 
                { 
                    ItemCode = BuildableItemEnum.Dry_Goods_Delivery_Truck, 
                    UnStoredQuantity = 1, 
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Vegetable_Farm_Delivery_Truck,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Restaurant_Storage,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Dirty_Table,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Dirty_Dishes,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });

            AddItem(player,
                0, new ItemQuantity
                {
                    ItemCode = BuildableItemEnum.Dirty_Floor,
                    UnStoredQuantity = 1,
                    StoredQuantity = 0,
                    Level = 0
                });
        }
 public LocationsController()
 {
     _storage = new LocationStorage();
 }
        public static LocationStorageVM SetSubData(LocationStorage data, Guid aid)
        {
            var model = LocationStorageVM.MToVM(data);

            return(model);
        }
Esempio n. 8
0
        public void SaveImage(HttpPostedFileBase image, string accountId)
        {
            string defaultPath = "/Content/Images/User Profile Photo/";

            AccountAsset oldAsset = ent.AccountAssets.Where(m => m.AccountId == accountId).FirstOrDefault();

            if (oldAsset != null)
            {
                LocationStorage oldLocationStorage = oldAsset.LocationStorage;

                string oldImageAddress = oldLocationStorage.Address;

                File.Delete(HostingEnvironment.MapPath(oldImageAddress));

                ent.AccountAssets.Remove(oldAsset);
                ent.SaveChanges();

                ent.LocationStorages.Remove(oldLocationStorage);
                ent.SaveChanges();
            }

            string fileName, fileExtension = "";

            fileName      = Path.GetFileNameWithoutExtension(image.FileName);
            fileExtension = Path.GetExtension(image.FileName);

            fileName += accountId;

            if (IsExisting(defaultPath, fileName, fileExtension))
            {
                fileName += new Random().Next(101);
            }

            // variable imgPath would be stored, contains the actual location of the image.
            string imgPath = defaultPath + fileName;

            //fileName = Path.Combine(Server.MapPath((defaultPath)), fileName);
            string filePath = HostingEnvironment.MapPath(defaultPath + fileName + fileExtension);

            image.SaveAs(filePath);

            // inserts first to the storage to get the fileId
            LocationStorage storage = new LocationStorage()
            {
                LocationStorageId = KeyGenerator.GenerateId(fileName + accountId),
                Name    = fileName,
                Address = defaultPath + fileName + fileExtension
            };

            ent.LocationStorages.Add(storage);
            ent.SaveChanges();

            AccountAsset asset = new AccountAsset()
            {
                AccountAssetId    = KeyGenerator.GenerateId(fileName),
                AccountId         = accountId,
                LocationStorageId = storage.LocationStorageId
            };

            ent.AccountAssets.Add(asset);
            ent.SaveChanges();
        }
		private void AddToPack( LocationStorage ls )
		{
			if( m_Owner.Backpack != null )
			{
				m_Owner.Backpack.DropItem( ls.ItemStored );
				ls.ItemStored.Location = ls.Location;
			}
			else if( m_Owner.Backpack != null )
				m_Owner.AddToBackpack( ls.ItemStored );
		}