private void Awake()
 {
     btn_animation = GetComponent <ButtonClickAnimation>();
     button        = GetComponent <Button>();
     button.onClick.AddListener(TaskOnClick);
     button_id = System.Convert.ToByte(name.Substring(8));
 }
Пример #2
0
 private void AnimateButton(bool isDown)
 {
     ButtonClickAnimation.Stop();
     ButtonClickAnimation.SetScale(transform.localScale, (isDown ? _pressedScale : StartScale));
     ButtonClickAnimation.SetRotation(transform.eulerAngles, Vector3.forward * (isDown ? 180 : 0));
     ButtonClickAnimation.Play();
 }
        isAnimated;      // Анимируется ли текст

    private void Awake()
    {
        txt_spent_mana = transform.GetChild(3).GetComponent <Text>(); // Текст затраченной маны
        btn_animation  = GetComponent <ButtonClickAnimation>();
        audio_s        = GetComponent <AudioSource>();
        button         = GetComponent <Button>();
        button.onClick.AddListener(TaskOnClick);
    }
Пример #4
0
    private bool isOn; // Включён ли звук

    private void Awake()
    {
        audio_s       = GetComponent <AudioSource>();
        btn_animation = GetComponent <ButtonClickAnimation>();
        GetComponent <Button>().onClick.AddListener(TaskOnClick);

        if (GlobalData.GetInt("Sound") != 0)
        {
            isOn = true;
        }
    }
    private bool isOn; // Включён ли звук

    private void Awake()
    {
        audio_s = GetComponent <AudioSource>();
        GetComponent <Button>().onClick.AddListener(TaskOnClick);
        avatar                   = transform.GetChild(0).GetComponent <Image>();
        rect_transform           = avatar.GetComponent <RectTransform>();
        choosed_unit             = CheckSlot(); // Записываем юнита в текущем слоте
        btn_animation            = GetComponent <ButtonClickAnimation>();
        btn_animation.size       = 0.86f;       // Меняем размер увеличенной кнопки
        btn_animation.anim_speed = 0.14f;       // Меняем скорость анимации

        if (GlobalData.GetInt("Sound") != 0)
        {
            isOn = true;
        }
    }
    private void Awake()
    {
        outline = transform.GetChild(0).gameObject;
        avatar  = transform.GetChild(1).GetComponent <Image>();
        button  = GetComponent <Button>();
        button.onClick.AddListener(TaskOnClick);
        btn_animation            = GetComponent <ButtonClickAnimation>();
        btn_animation.size       = 0.86f; // Меняем размер увеличенной кнопки
        btn_animation.anim_speed = 0.14f; // Меняем скорость анимации
        CheckButtonCondition();

        if (name.Substring(3) == "Empty")
        {
            GetComponent <Button>().interactable = false;
            avatar.gameObject.SetActive(false);
            enabled = false;
        }
    }
Пример #7
0
    private void Awake()
    {
        outline       = transform.GetChild(0).gameObject;
        unit_avatar   = transform.GetChild(1).GetComponent <Image>();
        txt_unit_cost = transform.GetChild(2).GetComponent <Text>();
        btn_animation = GetComponent <ButtonClickAnimation>();
        audio_s       = GetComponent <AudioSource>();
        button        = GetComponent <Button>();
        button.onClick.AddListener(TaskOnClick);
        unit_name                = CheckSlot();          // Берём имя юнита в текущем "слоте"
        unit_cost                = GetCost();            // Берём его стоимость в мане
        txt_unit_cost.text       = unit_cost.ToString(); // Меняем текст стоимости юнита
        btn_animation.size       = 0.31f;                // Меняем размер увеличенной кнопки
        btn_animation.anim_speed = 0.06f;                // Меняем скорость анимации

        // Выключаем кнопку если слот пустой
        if (unit_name == "" || unit_name == null)
        {
            txt_unit_cost.text  = "";
            button.interactable = false;
            enabled             = false; // Отключаем скрипт
        }
    }
Пример #8
0
    // Записываем юнита
    public void SetUnit(string choosed_unit, GameObject outline, ButtonClickAnimation btn_animation)
    {
        // Выключаем старую обводку, если она есть
        if (this.outline != null)
        {
            this.outline.SetActive(false);
        }

        // Если новый юнит
        if (choosed_unit != ChoosedUnit)
        {
            ChoosedUnit  = choosed_unit;
            this.outline = outline;
            this.outline.SetActive(true); // Включаем новую обводку
            this.btn_animation = btn_animation;

            // Звук нажатия
            if (isOn)
            {
                audio_s.pitch = 1.19f;
                audio_s.Play();
            }
        }
        // Если выбранный юнит
        else
        {
            // Звук нажатия
            if (isOn)
            {
                audio_s.pitch = 1;
                audio_s.Play();
            }

            ChoosedUnit = null;
        }
    }