Example #1
0
    void Buy()
    {
        Hex h = cursor.GetSelectedHex();

        if (usableBees >= h.beeCost && pollen >= h.pollenCost && !h.isActive && b.isHexPurchasable(h))
        {
            h.ActivateHex();
            h.PurchaseHex();
            if (h.upgrade != default(Upgrade))
            {
                PerformUpgrade(h.upgrade);
            }
            b.AddPurchasableHexesAdjacentTo(b.GetIndexOfHex(h));

            GameObject bee = h.transform.GetChild(0).gameObject;
            bee.GetComponent <Animator> ().SetBool("IsPurchased", true);
            bee.GetComponent <SpriteRenderer> ().color = h.GetComponent <SpriteRenderer> ().color;

            bees           += h.beeReward;
            usableBees     -= h.beeCost;
            pollen         -= h.pollenCost;
            beeText.text    = usableBees + " / " + bees;
            pollenText.text = "" + pollen;

            if (h.transform == b.rocketHex.transform)               //HACK HACK HACK
            //The user bought the endgame tile.
            {
                level.startTakeoffCutscene();
            }

            //we bought something so let's reload the text so we can show its description now
            cursor.LoadShitFromSelectedHex();
        }
    }