Пример #1
0
        private void BuyShipEvent(object sender, EventArgs e)
        {
            Texture2D shipTexture = UIManager.GetObject <Image>("Ship Image").Texture;

            PurchaseShipsScreen.GameplayScreen.Show();

            PurchaseItemUI purchaseShipUI = new PurchaseItemUI(shipTexture, PlayerShipData, "Ship", ScreenManager.GameMouse.InGameMouse);

            purchaseShipUI.MouseOverObject += CheckForShipPlacementEvent;
            PurchaseShipsScreen.GameplayScreen.AddInGameUIObject(purchaseShipUI, "Purchase Ship UI", false);
            purchaseShipUI.Initialize();

            PurchaseShipsScreen.GameplayScreen.ScreenManager.RemoveScreen(PurchaseShipsScreen);
        }
Пример #2
0
        private void CheckForShipPlacementEvent(object sender, EventArgs e)
        {
            PurchaseItemUI purchaseShipUI = sender as PurchaseItemUI;

            if (purchaseShipUI != null)
            {
                if (ScreenManager.GameMouse.IsLeftClicked)
                {
                    PurchaseShipsScreen.GameplayScreen.AddAlliedShip(new PlayerShip(ScreenManager.GameMouse.LastLeftClickedPosition, AssetManager.GetKeyFromData(purchaseShipUI.DataAssetOfObject), UnderSiegeGameplayScreen.SceneRoot), "Ally " + MathUtils.GetUniqueTagNumber(), true);
                    Session.Money -= (purchaseShipUI.DataAssetOfObject as PlayerShipData).Price;
                    ResetPurchaseObjectUI();
                }
                else if (InputHandler.KeyPressed(Keys.Escape))
                {
                    ResetPurchaseObjectUI();
                }
            }
        }