Exemple #1
0
    bool init() // █ инициализация HUD-а и подгонка его элементов под особенности текущего экрана
    {
        left           = transform.FindChild("Left");
        right          = transform.FindChild("Right");
        top            = transform.FindChild("Top");
        bottom         = transform.FindChild("Bottom");
        halfLeftWidth  = getWidth(left) * 0.005f;
        halfRightWidth = getWidth(right) * 0.005f;

        Vector2 sizeLeft   = getHUD_elementSize(left);
        Vector2 sizeBottom = getHUD_elementSize(bottom);
        Vector2 sizeRight  = getHUD_elementSize(right);
        Vector2 sizeTop    = getHUD_elementSize(top);

        calculateScales();

        moneyBtn    = GameObject.Find("moneyBtn").GetComponent <PushDownButton>();
        expBtn      = GameObject.Find("expBtn").GetComponent <PushDownButton>();
        buyBallBtn  = GameObject.Find("buyBallBtn").GetComponent <PushDownButton>();
        bonusesBtn  = GameObject.Find("bonusesBtn").GetComponent <PushDownButton>();
        rubinsBtn   = GameObject.Find("rubinsBtn").GetComponent <PushDownButton>();
        backBtn     = GameObject.Find("backBtn").GetComponent <BaseController>();
        settingsBtn = GameObject.Find("settingsBtn").GetComponent <BaseController>();
        // █ подключение кнопок на обработку их событий в классе MAIN.
        buyBallBtn.subscribeOnControllEvents(main.onButtonClick);
        expBtn.subscribeOnControllEvents(main.onButtonClick);
        moneyBtn.subscribeOnControllEvents(main.onButtonClick);
        bonusesBtn.subscribeOnControllEvents(main.onButtonClick);
        rubinsBtn.subscribeOnControllEvents(main.onButtonClick);
        backBtn.subscribeOnControllEvents(main.onButtonClick);
        settingsBtn.subscribeOnControllEvents(main.onButtonClick);
        // █ инициализация игровых сердств
        main.updateMyRubins();
        main.updateMyMoney();

        isInit = true;
        hud    = this;
        return(isInit);
    }