private void Start()
    {
        /* Using the Extension Method
         *
         * transform.Find("attackBtn").AddTooltip(() => "Attack, " + attackCooldown);
         * */

        Tooltip.AddTooltip(transform.Find("attackTooltipBtn"), "Attack damage");
        Tooltip.AddTooltip(transform.Find("speedTooltipBtn"), "Movement speed");
        Tooltip.AddTooltip(transform.Find("healthTooltipBtn"), "Health amount");

        Tooltip.AddTooltip(transform.Find("patrolBtn"), "Patrol");
        Tooltip.AddTooltip(transform.Find("defendBtn"), "Defend");

        Tooltip.AddTooltip(transform.Find("attackBtn"), () => "Attack, " + (Mathf.Round(attackCooldown * 100f) / 100f));

        transform.Find("attackBtn").GetComponent <Button_UI>().ClickFunc = () => {
            if (attackCooldown > 0)
            {
                Tooltip_Warning.ShowTooltip_Static("Cannot attack!");
            }
            else
            {
                attackCooldown = 5f;
            }
        };
    }
Exemple #2
0
    private void Awake()
    {
        instance = this;
        backgroundRectTransform = transform.Find("background").GetComponent <RectTransform>();
        tooltipText             = transform.Find("text").GetComponent <Text>();
        backgroundImage         = transform.Find("background").GetComponent <Image>();

        HideTooltip();
    }
 private void TryBuyItem(Item.ItemType itemType)
 {
     if (shopCustomer.TrySpendGoldAmount(Item.GetCost(itemType)))
     {
         // Can afford cost
         shopCustomer.BoughtItem(itemType);
     }
     else
     {
         Tooltip_Warning.ShowTooltip_Static("Cannot afford " + Item.GetCost(itemType) + "!");
     }
 }
Exemple #4
0
        public SkillButton(Transform transform, PlayerSkills playerSkills, PlayerSkills.SkillType skillType, Material skillLockedMaterial, Material skillUnlockableMaterial)
        {
            this.transform               = transform;
            this.playerSkills            = playerSkills;
            this.skillType               = skillType;
            this.skillLockedMaterial     = skillLockedMaterial;
            this.skillUnlockableMaterial = skillUnlockableMaterial;

            image           = transform.Find("image").GetComponent <Image>();
            backgroundImage = transform.Find("background").GetComponent <Image>();

            transform.GetComponent <Button_UI>().ClickFunc = () => {
                if (!playerSkills.IsSkillUnlocked(skillType))
                {
                    // Skill not yet unlocked
                    if (!playerSkills.TryUnlockSkill(skillType))
                    {
                        Tooltip_Warning.ShowTooltip_Static("Cannot unlock " + skillType + "!");
                    }
                }
            };
        }
    private LevelSystem levelSystem;                                                                                       // In relation to equipping items, the LevelSystem must work along with EquipWindow when choosing new available items after leveling up //

    private void Awake()                                                                                                   // Again, this Awake variable is meant to activate the equipping and leveling system actions of the game //
    {
        transform.Find("equipNoneBtn").GetComponent <Button_UI>().ClickFunc    = () => player.SetEquip(Player.Equip.None); // You need to set up the equipping mechanism when there is no item to equip //
        transform.Find("equipHelmet1Btn").GetComponent <Button_UI>().ClickFunc = () => {                                   // You need to set up the equipping mechanism when there is Helmet1 to be equipped during the game, at which the ClickFunc will be used to trigger equipping the item //
            if (levelSystem.GetLevelNumber() >= 4)                                                                         // If you reach the levelSystem number 4, you are eligible to equip the Helmet1 asset //
            {
                player.SetEquip(Player.Equip.Helmet_1);                                                                    // You as the player are eligible to set this item //
            }
            else                                                                                                           // If you haven't reached this level, then //
            {
                Tooltip_Warning.ShowTooltip_Static("Level Required 5!");                                                   // If you aren't suited to click the item you want to equip, a toolmenu will notify you stating 'Level Required 5!' //
            }
        };
        transform.Find("equipHelmet2Btn").GetComponent <Button_UI>().ClickFunc = () => { // You are telling the game to find Helmet2 within the game, at which you are connecting it to the mechanism that makes the item clickable enough for you to equip it, through ClickFun and GetButton //
            if (levelSystem.GetLevelNumber() >= 9)                                       // If you reach Level 10 //
            {
                player.SetEquip(Player.Equip.Helmet_2);                                  // You as the player, are eligible to equip Helmet2 //
            }
            else                                                                         // Otherwise //
            {
                Tooltip_Warning.ShowTooltip_Static("Level Required 10!");                // You order the game to give Tooltip_Warning stating 'Level Required 10!' to be eligible to equip the item in case you haven't reached level 10 //
            }
        };
        transform.Find("equipHelmet3Btn").GetComponent <Button_UI>().ClickFunc = () => {
            if (levelSystem.GetLevelNumber() >= 9)
            {
                player.SetEquip(Player.Equip.Helmet_3);
            }
            else
            {
                Tooltip_Warning.ShowTooltip_Static("Level Required 15!");
            }
        };

        Tooltip_ItemStats.AddTooltip(transform.Find("equipNoneBtn"), headSprite, "None", "Just your head, not much protectin", 1);                        // You are setting the variable Tooltip_ItemStates to AddToolTop to communicate that the headSprite isn't very effective //
        Tooltip_ItemStats.AddTooltip(transform.Find("equipHelmet1Btn"), helmet1Sprite, "Basic Helmet", "Simple protetion, better than nothing", 5);       // For the next item, which is helmet1Sprite, you are stating that it's a basic helmet using Tooltip_ItemStats.AddTooltip //
        Tooltip_ItemStats.AddTooltip(transform.Find("equipHelmet2Btn"), helmet2Sprite, "Epic Helmet", "Epic protection, looks great too!", 10);           // You are revealing for helmet2Sprite that it's an 'Epic Helmet' with 'Epic protection, looks great too!' //
        Tooltip_ItemStats.AddTooltip(transform.Find("equipHelmet3Btn"), helmet3Sprite, "Awesome Helmet", "This button just does cool stuff I guess", 15); // You are revealing for helmet2Sprite that it's an 'Epic Helmet' with 'Epic protection, looks great too!' //
    }