private static void ProcessingRewardPools() { var RewardItemPoolsAssets = Program.Original .XPathSelectElements($"//Asset[Template='RewardPool']") .Concat(Program.Original.XPathSelectElements($"//Asset[Template='RewardItemPool']")) .ToList(); var xRewardPools = new XElement("RewardPools"); foreach (var RewardPool in RewardItemPoolsAssets) { var xPool = new XElement("Pool"); xRewardPools.Add(xPool); xPool.Add(new XAttribute("ID", RewardPool.XPathSelectElement("Values/Standard/GUID").Value)); if (RewardPool.XPathSelectElement("Values/RewardPool/ItemsPool")?.HasElements ?? false) { var xItems = new XElement("Items"); xPool.Add(xItems); foreach (var item in RewardPool.XPathSelectElements("Values/RewardPool/ItemsPool/Item")) { var itemId = item.XPathSelectElement("ItemLink")?.Value ?? item.XPathSelectElement("ItemGroup")?.Value; if (itemId != null) { var xItem = new XElement("Item"); xItems.Add(xItem); xItem.Add(new XAttribute("ID", itemId)); xItem.Add(new XAttribute("Weight", item.XPathSelectElement("Weight")?.Value ?? "100")); } } } } var document = new XDocument(xRewardPools); document.Save($@"{Program.PathRoot}\Modified\Assets_RewardPools.xml"); document.Save($@"{Program.PathViewer}\Resources\Assets\RewardPools.xml"); }
public async Task <IActionResult> Create([Bind("ProductID,PoolQuantity,ProductName")] AdminRewardPoolViewModel model) { Product product = _context.Product.Where(p => p.ProductName.ToLower() == model.ProductName.ToLower()).FirstOrDefault(); if (product == null) { ModelState.AddModelError("", "Unable to Find Product"); } else if (product.ProductStock < model.PoolQuantity) { ModelState.AddModelError("", "Not Enough Stock to Reserve for Reward, Current Stock: " + product.ProductStock); } if (ModelState.IsValid) { product.ProductStock -= model.PoolQuantity; _context.Update(product); RewardPool rewardPool = new RewardPool() { PoolQuantity = model.PoolQuantity, ProductID = product.ProductID, RewardPoolStatus = RewardPoolStatus.Ongoing }; _context.Add(rewardPool); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(RedirectToAction("Create")); }
public async Task <IActionResult> DeleteConfirmed(int rewardID) { RewardPool reward = _context.RewardPool.Where(rp => rp.RewardPoolID == rewardID).FirstOrDefault(); if (_rewardsContext == null) { _rewardsContext = await _context.RewardPool.Include(rp => rp.Product) .ThenInclude(p => p.Category) .Where(rp => rp.RewardPoolStatus != RewardPoolStatus.Deleted).ToListAsync(); } else { reward.RewardPoolStatus = RewardPoolStatus.Deleted; int tempQuantityToRelease = reward.PoolQuantity; reward.PoolQuantity = 0; _context.Update(reward); Product product = _context.Product.Where(p => p.ProductID == reward.ProductID).FirstOrDefault(); if (product != null) { product.ProductStock += tempQuantityToRelease; _context.Update(product); } _context.SaveChanges(); _rewardsContext.RemoveAll(rp => rp.RewardPoolID == rewardID); } int currentPage = _currentRange / ITEMS_PER_PAGE; if (_rewardsContext.Count() > ITEMS_PER_PAGE) { int pageCount = ((_rewardsContext.Count() - 1) / ITEMS_PER_PAGE) + 1; ViewData["PaginationCount"] = pageCount; if (currentPage > pageCount) { currentPage = pageCount - 1; } } else { currentPage = 0; } ViewData["SetActivePage"] = currentPage; return(PartialView("_AdminRewardTableModelPartial", _rewardsContext.Skip(_currentRange).Take(ITEMS_PER_PAGE).ToList())); }
// Use this for initialization void Start() { #region Get all refernces if (_isBoss) { BossHealthObject = GameObject.Find("BossHealthBar"); BossHealthBar = BossHealthObject.GetComponent <Slider>(); BossText = GameObject.Find("BossNameText").GetComponent <Text>(); } HitBox = GameObject.Find("HitArea").GetComponent <BoxCollider>(); barScript = GameObject.Find("Captain").GetComponent <BarController>(); audioS = GameObject.Find("SFX").GetComponent <AudioSource>(); CameraShake = GameObject.Find("CameraShaker"); rewardPool = GameObject.Find("Reward Pool").GetComponent <RewardPool>(); #endregion StartCoroutine(InitCoroutine()); flash.SetActive(false); }
private static void ProcessingRewardPools() { ConsoleWriteHeadline("Processing Reward Pools"); var xRewardPools = new XElement("RP"); //RewardPool and RewardItemPool var RewardItemPoolsAssets = Assets.Original .XPathSelectElements($"//Asset[Template='RewardPool']") .Concat(Assets.Original.XPathSelectElements($"//Asset[Template='RewardItemPool']")) .ToList(); foreach (var RewardPool in RewardItemPoolsAssets) { var xPool = new XElement("P"); xRewardPools.Add(xPool); xPool.Add(new XAttribute("ID", RewardPool.XPathSelectElement("Values/Standard/GUID").Value)); xPool.Add(new XAttribute("N", RewardPool.XPathSelectElement("Values/Standard/Name").Value)); if (RewardPool.XPathSelectElement("Values/RewardPool/ItemsPool")?.HasElements ?? false) { var xItems = new XElement("IL"); xPool.Add(xItems); foreach (var item in RewardPool.XPathSelectElements("Values/RewardPool/ItemsPool/Item")) { var itemId = item.XPathSelectElement("ItemLink")?.Value ?? item.XPathSelectElement("ItemGroup")?.Value; if (itemId != null) { var xItem = new XElement("I"); xItems.Add(xItem); xItem.Add(new XAttribute("ID", itemId)); xItem.Add(new XAttribute("W", item.XPathSelectElement("Weight")?.Value ?? "1")); } } } } //ResourcePool var ResourcePoolAssets = Assets.Original .XPathSelectElements($"//Asset[Template='ResourcePool']") .ToList(); foreach (var ResourcePool in ResourcePoolAssets) { var xPool = new XElement("P"); xRewardPools.Add(xPool); xPool.Add(new XAttribute("ID", ResourcePool.XPathSelectElement("Values/Standard/GUID").Value)); xPool.Add(new XAttribute("N", ResourcePool.XPathSelectElement("Values/Standard/Name").Value)); if (ResourcePool.XPathSelectElement("Values/ResourceRewardPool/PossibleRewards")?.HasElements ?? false) { var xItems = new XElement("I"); xPool.Add(xItems); foreach (var item in ResourcePool.XPathSelectElements("Values/ResourceRewardPool/PossibleRewards/Item")) { var itemId = item.XPathSelectElement("Resource")?.Value; if (itemId != null) { var xItem = new XElement("I"); xItems.Add(xItem); xItem.Add(new XAttribute("ID", itemId)); xItem.Add(new XAttribute("W", item.XPathSelectElement("Weight")?.Value ?? "100")); } } } } //AssetGroups var AssetGroups = Assets.Original .Descendants("Groups") .Where(g => g.Element("GUID") != null) .Concat(Assets.Original .Descendants("Group") .Where(g => g.Element("GUID") != null)) .ToList(); foreach (var AssetGroup in AssetGroups) { var childAssets = AssetGroup.Descendants("Asset").Where(a => a.XPathSelectElement("Values/Item") != null || a.XPathSelectElement("Values/Product") != null); if (childAssets.Any()) { var xPool = new XElement("P"); xRewardPools.Add(xPool); xPool.Add(new XAttribute("ID", AssetGroup.Element("GUID").Value)); var xItems = new XElement("I"); xPool.Add(xItems); foreach (var item in childAssets) { var itemId = item.XPathSelectElement("Values/Standard/GUID")?.Value; if (itemId != null) { var xItem = new XElement("I"); xItems.Add(xItem); xItem.Add(new XAttribute("ID", itemId)); xItem.Add(new XAttribute("W", item.XPathSelectElement("Weight")?.Value ?? "100")); } } } } var document = new XDocument(xRewardPools); document.Save($@"{Program.PathRoot}\Modified\Assets_RewardPools.xml"); document.SaveIndent($@"{Program.PathViewer}\Resources\Assets\RewardPools.xml"); }
void Start() { rewardPool = GameObject.Find("Reward Pool").GetComponent <RewardPool>(); audioS = GameObject.Find("SFX").GetComponent <AudioSource>(); }