示例#1
0
    // Draw up the prefab for the buyable on the screen
    void DisplayBuyable(BuyableData buyableData)
    {
        Buyable prefab = Instantiate(idlePrefab, prefabContainer);

        prefabs.Add(prefab);
        prefab.Init(buyableData);
    }
示例#2
0
 private void buyCurrentBlock()
 {
     if (GameController.waitModal == false)
     {
         Buyable block  = Board.instance().getPlayerInTurnBlock().GetComponent <Buyable>();
         Player  player = GameController.playerInTurn();
         if (player.getFund() < block.price)
         {
             if (player.calNetWorth() < block.price)
             {
                 Modal.instance().showModal("Bạn không đủ tiền mua <color=" + block.color + "><b>" + block.blockName + "</b></color>", "OK", () => { });
             }
             else
             {
                 Modal.instance().showModal("Bạn không đủ tiền mặt để mua <color=" + block.color + "><b>" + block.blockName + "</b></color>. Bạn có thể bán tài sản để mua.", "OK", () => { });
             }
         }
         else
         {
             Modal.instance().showModal("Bạn có chắc muốn mua <color=" + block.color + "><b>" + block.blockName + "</b></color> với giá <color=#aa0115><b>" + block.price + "Đ</b></color> không?", "Có", "Không",
                                        () => {
                 player.buy(block);
             },
                                        () => { }
                                        );
         }
     }
 }
示例#3
0
 // Called when the idle is upgraded to its maximum amount
 void OnMaximumUpgradeReached(Buyable b)
 {
     if (b == buyable)
     {
         upgradeButton.gameObject.SetActive(false);
     }
 }
示例#4
0
    void Start()
    {
        buyable      = GetComponent <Buyable>();
        utilities    = Utilities.Instance;
        moneyManager = MoneyManager.Instance;

        // Events to tell the Buyable script (attached) that we're interacting
        upgradeButton.onClick.AddListener(buyable.UpgradeButtonPressed);
        manualTapButton.onClick.AddListener(buyable.RunProcess);
        managerButton.onClick.AddListener(buyable.BuyManagerButtonPressed);

        // Event listeners from the Buyable script
        Buyable.onVariableChanged       += OnVariableChanged;
        Buyable.onProcessBegin          += OnProcessBegin;
        Buyable.onProcessUpdate         += OnProcessUpdate;
        Buyable.onProcessFinish         += OnProcessFinish;
        Buyable.onManagerHired          += OnManagerHired;
        Buyable.onBuyablePurchase       += OnBuyablePurchase;
        Buyable.onMaximumUpgradeReached += OnMaximumUpgradeReached;
        BuyableData.onDataLoaded        += OnBuyableDataLoaded;
        GameManager.onLoadingComplete   += OnLoadingComplete;

        // We don't require any waiting to do this
        StartUI();
    }
示例#5
0
 // Called when the process end
 void OnProcessFinish(Buyable b)
 {
     if (b == buyable)
     {
         progressFill.fillAmount = 0f;
     }
 }
示例#6
0
 // Called after a manager is hired
 void OnManagerHired(Buyable b)
 {
     if (b == buyable)
     {
         UpdateUI();
     }
 }
示例#7
0
    /* Event listeners from the Buyable delegate */

    // Called when a variable is changed
    void OnVariableChanged(Buyable b)
    {
        if (b == buyable)
        {
            UpdateUI();
        }
    }
示例#8
0
    private void sellBlockEvent(Buyable block)
    {
        if (GameController.waitModal)
        {
            return;
        }
        int amount;

        if (block.GetComponent <Buildable>() != null)
        {
            amount = block.price / 2 + block.GetComponent <Buildable>().getProperties() * block.GetComponent <Buildable>().propertyPrice / 2;
        }
        else
        {
            amount = block.price / 2;
        }
        Modal.instance().showModal("Bạn có chắc muốn bán <color=" + block.color + "><b>" + block.blockName + "</b></color> không? Bạn sẽ nhận được <color=#216C2A><b>" + amount + "Đ</b></color>.", "Có", "Không",
                                   () =>
        {
            GameController.playerInTurn().sell(block);
            closeInfo();
        },
                                   () => { }
                                   );
    }
示例#9
0
    IEnumerator CheckPackageBuyable(ShopData shopData)
    {
        buyable = Buyable.Buy;
        WWWForm form = new WWWForm();

        form.AddField("userID", User.Instance.userID, System.Text.Encoding.UTF8);
        form.AddField("type", 100);
        form.AddField("shopID", shopData.id, System.Text.Encoding.UTF8);
        string php    = "ShopInfo.php";
        string result = "";

        yield return(StartCoroutine(WebServerConnectManager.Instance.WWWCoroutine(php, form, x => result = x)));

        if (!string.IsNullOrEmpty(result))
        {
            if (result == "1")
            {
                buyable = Buyable.Overlap;
            }
            else if (result == "2")
            {
                buyable = Buyable.Limited;
            }
        }
    }
    public IEnumerator ClickMethod(Buyable toDisplay)
    {
        parent.Hide();
        yield return(toDisplay.Buy());

        parent.Destroy();
    }
示例#11
0
    public SolarPanel(GameObject clone)
    {
        Buyable = new Buyable { Cost = PRICE_SOLAR_PANEL };

        this.LifeTime = 20;

        this.gameObject = clone;
    }
示例#12
0
 private void DropProduct(object sender, DragEventArgs e)
 {
     if (canDrag) // only if this now paying mode
     {
         Buyable data = (Buyable)e.Data.GetData(typeof(Buyable));
         AddSingleToCart(data);
     }
 }
示例#13
0
 private void ProductGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (ProductGrid.SelectedItem != null)
     {
         Buyable b = (Buyable)ProductGrid.SelectedItem;
         DragDrop.DoDragDrop(sender as DependencyObject, b, DragDropEffects.Move);
     }
 }
示例#14
0
 public bool BuyUnit(Buyable buyable)
 {
     if (!CanBuyUnit(buyable))
     {
         return(false);
     }
     ApplyRequirements(buyable);
     return(true);
 }
示例#15
0
        public static void Run()
        {
            IRobot robot = new Robot();

            robot.Introduce("Hello");

            IRobot dancingRobot = new DancingRobot(robot);

            dancingRobot.Introduce("He yo");

            IRobot dancingAndShooting = new DancingAndShootingRobot(dancingRobot);

            dancingAndShooting.Introduce("Hey");

            Console.WriteLine(new String('-', 50));

            //2

            // Create book
            var book = new Book("Microsoft", "CLR via C# 4", 10);

            book.Display();
            Console.WriteLine(new string('-', 60));

            // Create video
            var video = new Video("Stanley Kubrick", "A Clockwork Orange", 23, 92);

            video.Display();
            Console.WriteLine(new string('-', 60));

            // Make book borroable, then borrow and display
            Console.WriteLine("Making book borrowable:");
            var borrowableBook = new Borrowable(book);

            borrowableBook.BorrowItem("Nikolay Kostov");
            borrowableBook.BorrowItem("Ivaylo Kenov");
            borrowableBook.Display();
            Console.WriteLine(new string('-', 60));

            // Make video borrowable, then borrow and display
            Console.WriteLine("Making video borrowable:");
            var borrowableVideo = new Borrowable(video);

            borrowableVideo.BorrowItem("Nikolay Kostov");
            borrowableVideo.BorrowItem("Ivaylo Kenov");
            borrowableVideo.Display();
            Console.WriteLine(new string('-', 60));

            // Make only video buyable
            Console.WriteLine("Making video buyable:");
            var buyableAndBorrowableVideo = new Buyable(borrowableVideo, 15);

            buyableAndBorrowableVideo.Display();
            Console.WriteLine(new string('-', 60));
        }
    public MicrowaveAntenna(GameObject clone)
    {
        Buyable = new Buyable
        {
            Cost = BUY_PRICE
        };

        this.LifeTime = 200;

        this.gameObject = clone;
    }
示例#17
0
 public void buy(Buyable block)
 {
     if (block.getOwner() == null)
     {
         if (fund >= block.price)
         {
             block.setOwner(this);
             fund      -= block.price;
             needUpdate = true;
         }
     }
 }
示例#18
0
    public void Buy()
    {
        Buyable current = store[currVal];

        if (!current.purchased)
        {
            if (Player_Purchase_Pref.purch_pref.SubtractMoney(current.cost))
            {
                current.purchased = true;
            }
        }
    }
示例#19
0
 public virtual void AddElement(Buyable element)
 {
     foreach (StoreEntry e in piles)
     {
         if (e.elements.Count == 0 || e.name == element.name)
         {
             e.elements.Add(element);
             return;
         }
     }
     Debug.Log("Shop added element without pile!");
 }
示例#20
0
        private void ApplyRequirements(Buyable buyable)
        {
            foreach (BuyRequirement req in buyable.Requirements)
            {
                BasicResource res = Resources.Find(o => o.GetType() == req.RequiredResource);

                if (res == null)
                {
                    throw new KeyNotFoundException("Resource not found");
                }
                res.Amount -= req.AmountRequired;
            }
        }
示例#21
0
 public void onMortgageButtonClick(Buyable field)
 {
     if (field.isPledged())
     {
         field.repayMortgage();
         mortgageButton.GetComponentInChildren <Text>().text = "Zastaw pole";
     }
     else
     {
         field.takeMortgage();
         mortgageButton.GetComponentInChildren <Text>().text = "Wykup pole";
     }
 }
    public IEnumerator OfferPurchase(Buyable course)
    {
        playerWantsToBuy = null;
        graphics.sprite  = course.graphics;
        transform.GetChild(0).gameObject.SetActive(true);

        while (playerWantsToBuy == null)
        {
            yield return(null);
        }

        transform.GetChild(0).gameObject.SetActive(false);
    }
示例#23
0
 // Called when the process percentage is changed
 void OnProcessUpdate(Buyable b, float progress)
 {
     if (b == buyable)
     {
         if (buyable.Data.ProcessTime > 0.25f)
         {
             progressFill.fillAmount = progress;
         }
         else
         {
             progressFill.fillAmount = 1000f;
         }
     }
 }
示例#24
0
 // Called when a buyable is purchased (meaning 1 is now owned)
 void OnBuyablePurchase(Buyable b)
 {
     if (displayIndex < idles.Length && setupComplete)
     {
         if (displayMode == DisplayModes.DisplayNextAfterPurchase)
         {
             if (b.Data == idles[displayIndex])
             {
                 DisplayBuyable(idles[displayIndex]);
                 IncrementDisplayIndex();
             }
         }
     }
 }
示例#25
0
 public void RemoveElement(Buyable element)
 {
     foreach (StoreEntry e in piles)
     {
         if (e.elements.Remove(element))
         {
             if (e.elements.Count == 0)
             {
                 piles.Remove(e);
             }
             return;
         }
     }
     Debug.Log("Shop dropped nonexistant element!");
 }
示例#26
0
        public void EmphasizeBestSellers(object sender, DataGridRowEventArgs e)
        {
            LinearGradientBrush myBrush = new LinearGradientBrush();

            myBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
            myBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
            myBrush.GradientStops.Add(new GradientStop(Colors.Red, 1.0));

            Buyable b = e.Row.DataContext as Buyable;

            if (b.Prod.IsTopSeller)
            {
                e.Row.Background = myBrush;
            }
        }
示例#27
0
 public Buyable GetBuyable()
 {
     if (_buyable != null)
     {
         return(_buyable);
     }
     foreach (var component in buyableBlueprintPrefab.GetComponents <MonoBehaviour>())
     {
         if (component is Buyable)
         {
             _buyable = (Buyable)component;
         }
     }
     return(_buyable);
 }
示例#28
0
 private float[] calculateWeights()
 {
     float[] weights = new float[elements.Length];
     for (int i = 0; i < elements.Length; ++i)
     {
         weights[i] = Buyable.GetRarityWeight(elements[i].rarity);
         foreach (Modifier mod in modifiers)
         {
             if (mod.chooser(elements[i]))
             {
                 weights[i] *= mod.modifier;
             }
         }
     }
     return(weights);
 }
 public void Initialize(Buyable toDisplay)
 {
     if (image != null)
     {
         image.sprite = toDisplay.image;
     }
     if (title != null)
     {
         title.text = toDisplay.name;
     }
     if (clickBehaviour != null)
     {
         clickBehaviour.onClick      = (() => StartCoroutine(ClickMethod(toDisplay)));
         clickBehaviour.onRightClick = () => ZoomDisplay.instance.Show(toDisplay);
     }
 }
示例#30
0
    void Start()
    {
        buyable      = GetComponent <Buyable>();
        utilities    = Utilities.Instance;
        moneyManager = MoneyManager.Instance;

        // Event listeners from the Buyable script
        Buyable.onVariableChanged       += OnVariableChanged;
        Buyable.onProcessBegin          += OnProcessBegin;
        Buyable.onProcessUpdate         += OnProcessUpdate;
        Buyable.onProcessFinish         += OnProcessFinish;
        Buyable.onManagerHired          += OnManagerHired;
        Buyable.onBuyablePurchase       += OnBuyablePurchase;
        Buyable.onMaximumUpgradeReached += OnMaximumUpgradeReached;
        BuyableData.onDataLoaded        += OnBuyableDataLoaded;
        GameManager.onLoadingComplete   += OnLoadingComplete;
    }
示例#31
0
    public void SelectBuilding(Building b)
    {
        if (selectedBuilding == b)
        {
            b = null;
        }

        if (b != null)
        {
            Buyable buyable = b.GetBuyable();
            if (buyable is Object)
            {
                buyable = (Buyable)Instantiate((Object)buyable, transform);
                if (!buyable.IsPurchasable())
                {
                    b = null;
                }
                Destroy((Object)buyable);
            }
        }

        Destroy(selectedBlueprint);
        selectedBuilding  = null;
        selectedBlueprint = null;

        if (b == null)
        {
            return;
        }

        GameObject newBlueprint = b.buyableBlueprintPrefab;

        selectedBuilding  = b;
        selectedBlueprint = Instantiate(selectedBuilding.buyableBlueprintPrefab);
        GameObject highlight = Instantiate(selectedBlueprintHighlightPrefab);

        highlight.transform.parent = selectedBlueprint.transform;
        highlight.transform.name   = "Highlight";
        var srs = highlight.GetComponentsInChildren <SpriteRenderer>();

        for (int i = 0; i < srs.Length; i++)
        {
            srs[i].sortingOrder -= 10;
        }
        UpdateSelectedBlueprintVisuals();
    }
示例#32
0
    private void displayMortageButton(Buyable field)
    {
        var owner = field.getCurrentOwner();

        if (owner != GameController.instance.getCurrentPlayer())
        {
            return;
        }

        var textOnMortageButton = mortgageButton.GetComponentInChildren <Text>();

        textOnMortageButton.text = field.isPledged() ? "Wykup pole" : "Zastaw pole";
        mortgageButton.GetComponent <LeanButton>().OnClick.RemoveAllListeners();
        mortgageButton.GetComponent <LeanButton>().OnClick.AddListener(
            new UnityAction(() => onMortgageButtonClick(field)));
        mortgageButton.SetActive(true);
    }
示例#33
0
 public Buildable()
 {
     Buyable = new Buyable();
 }