public void Show(BuyEvent buyEvent) { if (buyEvent == null) { return; } getBuyEvent = buyEvent; this.gameObject.SetActive(true); if (yesButton != null) { yesButton.gameObject.SetActive(true); } if (cancelButton != null) { cancelButton.gameObject.SetActive(true); } string _compareType = buyEvent.GetType().ToString(); // Debug.Log (_compareType); foreach (var buyUI in buyGroup) { // Debug.Log ("buyUI:" + buyUI.tag); if (buyUI.CompareTag("BuyType/" + _compareType)) { buyUI.gameObject.SetActive(true); selectBuyGroup = buyUI; break; } } }
public virtual void TryBuyWithMoney(BuyEvent successBuyCB = null, BuyEvent failedBuyCB = null) { if (successBuyCB != null) { successBuyCB(); } }
public void AddEventTest() { DataRepository dataRepository = new DataRepository(new AutoFillFull()); Assert.AreEqual(dataRepository.GetAllEvents().Count, 3); Product product = new Product { Id = Guid.NewGuid(), Name = "TestName", Description = "TestDescription" }; Client client = new Client { Id = Guid.NewGuid(), Birthday = new DateTime(), Email = "*****@*****.**", LastName = "LastName", Name = "Name" }; Event buyEvent = new BuyEvent(Guid.NewGuid(), client, new ItemStatus(product, 10f, 10f, 10), "example"); dataRepository.AddEvent(buyEvent); Assert.AreEqual(dataRepository.GetAllEvents().Count, 4); Assert.IsTrue(dataRepository.GetAllEvents().Contains(buyEvent)); Assert.ThrowsException <ArgumentException>(() => dataRepository.AddEvent(buyEvent)); }
private void Awake() { OnBuyClick = new BuyEvent(); _animator = GetComponent <Animator>(); Button button = transform.Find("Buy").GetComponent <Button>(); button.onClick.AddListener(OnClickResender); _cost = int.Parse(button.transform.GetChild(0).GetComponent <Text>().text); //check if player already have max count of item or max count not restricted int PurchasedCount = PlayerDataController.Instance.HasItem(ItemId); string countText; if (PurchaseCountAvailable == -1) { countText = $"{PurchasedCount}"; } else if (PurchaseCountAvailable == 0) { countText = ""; } else { countText = $"{PurchasedCount} / {PurchaseCountAvailable}"; } transform.Find("Count").GetComponent <Text>().text = countText; if (PurchasedCount == PurchaseCountAvailable) { button.interactable = false; } }
public void AutoFill(DataContext dataContext) { List <Client> clients = dataContext.Clients; Dictionary <Guid, Product> products = dataContext.Products; ObservableCollection <Event> events = dataContext.Events; List <Status> statuses = dataContext.Statuses; Client client1 = new Client { Id = Guid.NewGuid(), Name = Rand.GetRandString(), LastName = Rand.GetRandString(), Birthday = new DateTime(1000, 1, 1), Email = Rand.GetRandString() + "@example.com" }; Client client2 = new Client { Id = Guid.NewGuid(), Name = Rand.GetRandString(), LastName = Rand.GetRandString(), Birthday = new DateTime(2000, 2, 2), Email = Rand.GetRandString() + "@example.com" }; Product product1 = new Product { Id = Guid.NewGuid(), Name = Rand.GetRandString(), Description = Rand.GetRandString() }; Product product2 = new Product { Id = Guid.NewGuid(), Name = Rand.GetRandString(), Description = Rand.GetRandString() }; ItemStatus itemStatus = new ItemStatus(product1, 1.1f, 1.1f, 1); ItemStatus itemStatus1 = new ItemStatus(product2, 1.1f, 1.1f, 1); ItemStatus itemStatus2 = new ItemStatus(product1, 11.1f, 11.1f, 11); ItemStatus itemStatus3 = new ItemStatus(product2, 11.1f, 11.1f, 11); Event event1 = new BuyEvent(new Guid(), client1, itemStatus, "buy example"); Event event2 = new SellEvent(new Guid(), client2, itemStatus1, "sell example"); products.Add(product1.Id, product1); products.Add(product2.Id, product2); clients.Add(client1); clients.Add(client2); events.Add(event1); events.Add(event2); statuses.Add(itemStatus2); statuses.Add(itemStatus3); }
public void ShowBuyUI(BuyEvent buyEvent) { if (buyUI == null) { return; } buyUI.Show(buyEvent); }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { Debug.Log("Receipt: " + args.purchasedProduct.receipt); if (_storeController.products.WithID(args.purchasedProduct.definition.id) != null) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); BuyEvent.OnBuy(args.purchasedProduct.receipt, args.purchasedProduct.metadata.isoCurrencyCode, args.purchasedProduct.metadata.localizedPrice); return(PurchaseProcessingResult.Pending); } else { Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); // неопределён продукт, не понятно что это } return(PurchaseProcessingResult.Complete); }
void AddEvent(Client client, Status status, string description, Type type) { Event eventToAdd; if (type == typeof(DestroyEvent)) { eventToAdd = new DestroyEvent(new Guid(), client, status, description); _dataRepository.AddEvent(eventToAdd); } else if (type == typeof(SellEvent)) { eventToAdd = new SellEvent(new Guid(), client, status, description); _dataRepository.AddEvent(eventToAdd); } else if (type == typeof(BuyEvent)) { eventToAdd = new BuyEvent(new Guid(), client, status, description); _dataRepository.AddEvent(eventToAdd); } }
public async Task <bool> Buyout([FromBody] UserDto dto) { var isBuyed = true; var buyTransport = new BuyTransport(_db); var buyHotel = new BuyHotel(_db); var buyEvent = new BuyEvent(_db); var responseFromTransportService = await buyTransport.BuyTransportAsync(dto.UserId); var responseFromHotelService = await buyHotel.BuyHotelAsync(dto.UserId); var responseFromEventService = await buyEvent.BuyEventAsync(dto.UserId); if (!responseFromTransportService || !responseFromHotelService || !responseFromEventService) { isBuyed = false; } return(isBuyed); }
void IAutoFiller.AutoFill(DataContext dataContext) { List <Client> clients = dataContext.Clients; Dictionary <Guid, Product> products = dataContext.Products; ObservableCollection <Event> events = dataContext.Events; List <Status> statuses = dataContext.Statuses; Client client1 = new Client { Id = Guid.NewGuid(), Name = "Name1", LastName = "LastName1", Birthday = new DateTime(1000, 1, 1), Email = "*****@*****.**" }; Client client2 = new Client { Id = Guid.NewGuid(), Name = "Name2", LastName = "LastName2", Birthday = new DateTime(2000, 2, 2), Email = "*****@*****.**" }; Product product1 = new Product { Id = Guid.NewGuid(), Name = "Product1", Description = "Description1" }; Product product2 = new Product { Id = Guid.NewGuid(), Name = "Product2", Description = "Description2" }; ItemStatus itemStatus = new ItemStatus(product1, 1.1f, 1.1f, 1); ItemStatus itemStatus1 = new ItemStatus(product2, 1.1f, 1.1f, 1); ItemStatus itemStatus2 = new ItemStatus(product1, 11.1f, 11.1f, 11); ItemStatus itemStatus3 = new ItemStatus(product2, 11.1f, 11.1f, 11); Event event1 = new DestroyEvent(Guid.NewGuid(), client1, itemStatus, "example destroy"); Event event2 = new BuyEvent(Guid.NewGuid(), client1, itemStatus1, "example buy"); Event event3 = new SellEvent(Guid.NewGuid(), client2, itemStatus1, "example sell"); products.Add(product1.Id, product1); products.Add(product2.Id, product2); clients.Add(client1); clients.Add(client2); events.Add(event1); events.Add(event2); events.Add(event3); statuses.Add(itemStatus2); statuses.Add(itemStatus3); }