//------------------------------------------------------------------------------------------------------------------------ // ShopView() //------------------------------------------------------------------------------------------------------------------------ public ShopView(ShopController pShopController, Actor pCustomer) : base(340, 340) { _shopController = pShopController; _commandManager = ServiceLocator.Instance.GetService <CommandManager>(); _items = new List <Item>(); _customer = pCustomer; x = (game.width - width) / 2; y = (game.height - height) / 2; //----------------------------- Create Commands --------------------------------// var moveSelectionLeft = new MoveSelectionCommand(_shopController, this, -1, 0); var moveSelectionRight = new MoveSelectionCommand(_shopController, this, 1, 0); var moveSelectionUp = new MoveSelectionCommand(_shopController, this, 0, -1); var moveSelectionDown = new MoveSelectionCommand(_shopController, this, 0, 1); var buyItem = new BuyItemCommand(_shopController, _customer); //-------------------------- Add Commands to list ------------------------------// _keyCommands = new List <KeyCommand>() { new KeyCommand((int)Key.LEFT, moveSelectionLeft), new KeyCommand((int)Key.RIGHT, moveSelectionRight), new KeyCommand((int)Key.UP, moveSelectionUp), new KeyCommand((int)Key.DOWN, moveSelectionDown), new KeyCommand((int)Key.SPACE, buyItem), }; }
public WishlistViewModel(Wishlist w) { Runtime = RuntimeInfo.Instance; activeUser = Runtime.LoggedInUser; selectedWishlist = w; removeItemCommand = new RemoveWishlistItemCommand(this); buyItemCommand = new BuyItemCommand(this); }
public WishlistViewModel(Wishlist w) { Runtime = RuntimeInfo.Instance; activeUser = Runtime.LoggedInUser; Runtime.SetupSelectedWishlist(w); selectedWishlist = Runtime.AppController.SelectedWishlist; removeItemCommand = new RemoveWishlistItemCommand(this); buyItemCommand = new BuyItemCommand(this); }
public async Task ExecutePipeline_SingleStepInPipeline_CallsStep() { var command = new BuyItemCommand(); var updateStockStep = new UpdateStockStep(); var builder = new BuyItemPipelineBuilder(updateStockStep); var pipeline = builder.CreatePipeline(command); await pipeline.ExecuteAsync(); Assert.IsTrue(updateStockStep.WasCalled); }
public void CreatePipeline_StepWithSingleDependencyNotRegistered_ThrowException() { var serviceProvider = new ServiceCollection() // CustomService dependency missing .AddTransient <StepWithSingleDependency>() .BuildServiceProvider(); var command = new BuyItemCommand(); var builder = new BuyItemSingleStepPipelineBuilder(serviceProvider); Assert.Throws <InvalidOperationException>(() => builder.CreatePipeline(command)); }
public void CreatePipeline_StepWithSingleDependency_ResolvesStepWithServiceProvider() { var serviceProvider = new ServiceCollection() .AddTransient <ICustomService, CustomService>() .AddTransient <StepWithSingleDependency>() .BuildServiceProvider(); var command = new BuyItemCommand(); var builder = new BuyItemSingleStepPipelineBuilder(serviceProvider); var pipeline = builder.CreatePipeline(command); Assert.IsNotNull(pipeline); }
public async Task ExecutePipeline_MultipleStepsInPipeline_CallsEveryStep() { var command = new BuyItemCommand(); var updateStockStep = new UpdateStockStep(); var chargeCreditCardStep = new ChargeCreditCard(); var steps = new IStep <BuyItemCommand>[] { updateStockStep, chargeCreditCardStep }; var builder = new BuyItemPipelineBuilder(steps); var pipeline = builder.CreatePipeline(command); await pipeline.ExecuteAsync(); Assert.IsTrue(updateStockStep.WasCalled); Assert.IsTrue(chargeCreditCardStep.WasCalled); }
public void Click() { if (!isdragged) { Debug.Log("name:" + item.ItemName + " Clicked!"); // ConstructionItem newitem= Instantiate(item,new Vector3(0,0,0),new Quaternion()); // newitem.name="Item_"+levelManager.items.Count; // newitem.levelManager=levelManager; Vector3 objpos = Camera.main.ScreenToWorldPoint(Input.mousePosition); objpos.z = 0; if (LevelManager.Instance.money >= item.Price) { Debug.Log("Money:" + LevelManager.Instance.money.ToString() + ", and the item cost:" + item.Price.ToString()); var BuyCommand = new BuyItemCommand(item, levelManager, objpos); levelManager.commandProcessor.ExecuteCommand(BuyCommand); } } }
public void BuyItem(WebRequestData args, Action <CommandResult> Callback) { if (args is BuyItemRequestData localArgs) { CommandArgs commandArgs = new BuyItemCommandArgs { Callback = Callback, ItemID = localArgs.ItemID, Price = localArgs.Price, CurrencyType = localArgs.CurrencyType }; BuyItemCommand command = CommandFactory .Instance .CreateCommand <BuyItemCommand>(commandArgs); command.Execute(); } else { // Make more verbose exceptions throw new ArgumentException("Incorrect args data type;"); } }
public void OnEndDrag(PointerEventData data) { Debug.Log("UI ELEMENTS:" + data.hovered.Count); Icon.transform.SetParent(originalParent.transform, true); Icon.transform.localPosition = Vector3.zero; isdragged = false; Debug.Log("EndDrag, Image at:" + Icon.transform.position + " Mouse at:" + Input.mousePosition); if (!IsMouseOverUi()) { Debug.Log("CREATING ITME!!!"); Vector3 objpos = Camera.main.ScreenToWorldPoint(Input.mousePosition); objpos.z = 0; if (LevelManager.Instance.money >= item.Price) { var BuyCommand = new BuyItemCommand(item, levelManager, objpos); levelManager.commandProcessor.ExecuteCommand(BuyCommand); } } else { Debug.Log("Mouse is over ui");// THIS HAPPENS } }
public BuyItemPipeline(BuyItemCommand command, IStep <BuyItemCommand>[] steps) { Command = command; Steps = steps; }