Inheritance: MonoBehaviour
Exemple #1
0
    public void SettingClick()
    {
        ButtonSound.ButtonClickPlay();

        PrefabsTwo.LoadUI("Prefabs/setting");
        Destroy(gameObject);
    }
    /// <summary>
    /// 返回建造页面
    /// </summary>
    public void BackToBuild()
    {
        ButtonSound.ButtonClickPlay();
        GameObject go = PrefabsTwo.LoadUI("Prefabs/Lottery");

        Destroy(gameObject);
    }
Exemple #3
0
        private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector2 localPos;
                RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, canvas.worldCamera,
                                                                        out localPos);

                _particleSystem.Play();
                _rect.anchoredPosition = localPos;

                GameObject obj = EventSystem.current.currentSelectedGameObject;
                if (obj != null)
                {
                    Button btn = obj.GetComponent <Button>();
                    if (btn != null)
                    {
                        ButtonSound bs = obj.GetComponent <ButtonSound>();
                        if (bs != null)
                        {
                            //如果SoundName没有设置就不播放按钮音频
                            if (bs.SoundName != null)
                            {
                                btn.PlayButtonEffect(bs.SoundName);
                            }
                        }
                        else
                        {
                            //播放默认音频
                            btn.PlayButtonEffect();
                        }
                    }
                }
            }
        }
Exemple #4
0
        public static void AddButtonSoundToButtonInPrefab()
        {
            UnityEngine.Object[] gos = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
            string     resPath       = "";
            GameObject go            = null;

            for (int i = 0, count = gos.Length; i < count; i++)
            {
                go      = gos[i] as GameObject;
                resPath = AssetDatabase.GetAssetPath(go);
                if (resPath.EndsWith(".prefab"))
                {
                    Button[] btns = go.transform.GetComponentsInChildren <Button>(true);
                    foreach (var r in btns)
                    {
                        if (r.GetComponent <ButtonSound>() == null)
                        {
                            ButtonSound bs = r.gameObject.AddComponent <ButtonSound>();
                            bs.type = Logic.Enums.ButtonSoundType.NormalClick;
                        }
                    }
                    EditorUtility.SetDirty(go);
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }
            }
        }
    private void FadeInOutline()
    {
        // Setup the color to use for the flash
        Color       color = effectColor;
        ButtonSound sound = ButtonSound.Hover;

        // If we have an operation source then instead set the color to the intended operation type color
        if (OperationInProgress)
        {
            color = UISettings.GetOperatorColor(operationSource.MatrixParent.IntendedNextOperationType);
            sound = ButtonSound.Preview;
        }

        // Create the pop effect for hovering
        PunchSize(sound);

        // If wer still have an outline then make it invisible
        if (currentOutline)
        {
            currentOutline.Remove();
        }

        // Fade in a new outline
        currentOutline = OutlineManager.FadeInOutline(transform, effectType, color);
    }
    public void OnEndDrag(PointerEventData data)
    {
        isDragging = false;

        if (selectable.interactable)
        {
            // If we don't have the pointer then remove the current outline
            if (!hasPointer)
            {
                RemoveCurrentOutline();
            }
            // If we do have the pointer then make some other outline fade out
            else
            {
                Flash(effectColor);
            }

            // By default use the pointer up sound
            ButtonSound sound = pointerUpSound;

            // If the matrix has a valid operation then play the confirm sound instead
            if (operationSource && operationSource.MatrixParent.OperationIsValid)
            {
                sound = ButtonSound.Confirm;
            }

            // Punch the button with the pointer up sound
            PunchSize(sound);

            // If we should delegate to the selectable then do so
            TryDelegatePointerEvent("EndDrag", data);
        }
    }
Exemple #7
0
    public static void PlayButtonSound()
    {
        Debug.Log("SFX volume: " + soundEffectVolume.ToString());
        ButtonSound soundSource = GameObject.FindObjectOfType <ButtonSound>();

        soundSource.GetComponent <AudioSource>().volume = soundEffectVolume;
        soundSource.GetComponent <AudioSource>().Play();
    }
    /// <summary>
    /// 返回编队页面
    /// </summary>
    public void BackToFormation()
    {
        ButtonSound.ButtonClickPlay();
        GameObject go = PrefabsTwo.LoadUI("Prefabs/FormationMain");

        go.GetComponent <FormationMenuController>().type = type;
        Destroy(gameObject);
    }
    public void OpenToRetire()
    {
        ButtonSound.ButtonClickPlay();
        GameObject go = PrefabsTwo.LoadUI("Prefabs/RetireSelect");

        go.GetComponent <FormationSelectController>().pos = 3;
        Destroy(gameObject);
    }
Exemple #10
0
    private void DisableButtonSounds(Button button)
    {
        ButtonSound buttonSound = button.gameObject.GetComponent <ButtonSound>();

        if (buttonSound != null)
        {
            buttonSound.enabled = false;
        }
    }
 public void Change()
 {
     ButtonSound.ButtonClickPlay();
     DetailMain.SetActive(!DetailMain.activeSelf);
     FormationBottom.SetActive(!FormationBottom.activeSelf);
     DetailBottom.SetActive(!DetailBottom.activeSelf);
     type = 1 - type;
     DisPlay();
 }
Exemple #12
0
    public void PackegeOpen()
    {
        ButtonSound.ButtonClickPlay();
        GameObject go = PrefabsTwo.LoadUI("Prefabs/Packege");

        go.GetComponent <PackageController>().Choice = 1;
        go.GetComponent <PackageController>().ShowPackage();
        Destroy(gameObject);
    }
Exemple #13
0
    private void DisableSound()
    {
        ButtonSound sound = button.gameObject.GetComponent <ButtonSound>();

        if (sound != null)
        {
            sound.enabled = false;
        }
    }
Exemple #14
0
 public void OnClick()
 {
     ButtonSound.ButtonClickPlay();
     if (gameObject.name.Substring(gameObject.name.Length - 2, 1) == "F")
     {
         controller.AddFormation(1, 1);
     }
     else
     {
         controller.AddFormation(0, 1);
     }
 }
 public void StageC2lick()
 {
     ButtonSound.ButtonClickPlay();
     if (TeamModel.IsAttack())
     {
         Prefabs.SceneSwitch("BattleField3", null);
     }
     else
     {
         Prefabs.Alert("编队前后排都要有角色!", null);
     }
 }
 /// <summary>
 /// 确认更换或添加英雄
 /// </summary>
 public void OKClick()
 {
     ButtonSound.ButtonClickPlay();
     if (selectHeroInfo != null)
     {
         if (heroInfo == null)
         {
             TeamModel.Add(selectHeroInfo);
         }
         else
         {
             TeamModel.Change(heroInfo, selectHeroInfo);
         }
     }
     BackToFormation();
 }
    public void Build()
    {
        ButtonSound.ButtonClickPlay();
        string             json = PlayerPrefs.GetString("HeroData");
        List <DynamicDate> date = JsonMapper.ToObject <List <DynamicDate> >(json);

        switch (Random.Range(1, 5))
        {
        case 1:
            DynamicDate NewOne = new DynamicDate(1001, 1, 4, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1);
            date.Add(NewOne);
            break;

        case 2:
            DynamicDate NewOne1 = new DynamicDate(1002, 1, 4, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1);
            date.Add(NewOne1);
            break;

        case 3:
            DynamicDate NewOne2 = new DynamicDate(5001, 1, 3, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1);
            date.Add(NewOne2);
            break;

        case 4:
            DynamicDate NewOne3 = new DynamicDate(3001, 1, 3, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1);
            date.Add(NewOne3);
            break;

        case 5:
            DynamicDate NewOne4 = new DynamicDate(4002, 1, 3, 10, 0, 0, 0, date[date.Count - 1].PackageID + 1);
            date.Add(NewOne4);
            break;
        }


        Prefabs.Alert("Completion of Draw!", null);
        string NewDate = JsonMapper.ToJson(date);

        PlayerPrefs.SetString("HeroData", NewDate);
    }
Exemple #18
0
    public static void Alert(string message, UnityAction okCallback)
    {
        GameObject page = LoadUI("Prefabs/inform");

        //page.transform.Find("infotext").GetComponent<Text>().text = message;
        page.transform.Find("infotext").GetComponent <TextMeshProUGUI>().text = message;

        //使用Lambda表达式,先销毁自身对象,再调用传递过来的回调函数
        page.transform.Find("exit").GetComponent <Button>().onClick.AddListener(() =>
        {
            ButtonSound.ButtonClickPlay();
            GameObject.Destroy(page);

            if (okCallback != null)
            {
                okCallback();
            }
        });

        page.transform.Find("confirm").GetComponent <Button>().onClick.AddListener(() =>
        {
            ButtonSound.ButtonClickPlay();
            GameObject.Destroy(page);

            if (okCallback != null)
            {
                okCallback();
            }
        });

        /*
         * Lambda表达式
         *
         * (aa, bb) =>
         * {
         *  int i = 0;
         * }
         */
    }
Exemple #19
0
    // Start is called before the first frame update
    void Start()
    {
        _rb   = GetComponent <Rigidbody2D>();
        _anim = GetComponent <Animator>();
        _c2D  = GetComponent <CapsuleCollider2D>();
        if (_c2D == null)
        {
            Debug.Log("Collider is NULL");
        }

        _buttonSound = FindObjectOfType <ButtonSound>();
        if (_buttonSound == null)
        {
            Debug.Log("Button sound NULL");
        }

        _water        = GameObject.Find("Water").GetComponent <Collider2D>();
        _eventManager = EventManager.Instance != null ? EventManager.Instance : FindObjectOfType <EventManager>();
        if (_eventManager == null)
        {
            Debug.Log("Event Manager is null");
        }
    }
Exemple #20
0
 void Start()
 {
     worked = GetComponent <Iniciar>();
     bs     = GetComponent <ButtonSound>();
 }
Exemple #21
0
 public void BulidOpen()
 {
     ButtonSound.ButtonClickPlay();
     PrefabsTwo.LoadUI("Prefabs/Lottery");
     Destroy(gameObject);
 }
Exemple #22
0
 public void Chuanwu()
 {
     ButtonSound.ButtonClickPlay();
     PrefabsTwo.LoadUI("Prefabs/chuanwu");
     Destroy(gameObject);
 }
 public void BackToMain()
 {
     ButtonSound.ButtonClickPlay();
     PrefabsTwo.LoadUI("MainMenu");
     Destroy(gameObject);
 }
 public void ButtonClick()
 {
     ButtonSound.ButtonClickPlay();
 }
Exemple #25
0
 public void Info()
 {
     ButtonSound.ButtonClickPlay();
     Info_DisPlay(Date);
 }
Exemple #26
0
 public void Equip_DisPlay()
 {
     ButtonSound.ButtonClickPlay();
     this.GetComponent <PlayerInfoEquipView>().DisPlay(Date);
 }
Exemple #27
0
 public void MissionOpen()
 {
     ButtonSound.ButtonClickPlay();
     PrefabsTwo.LoadUI("Prefabs/Mission");
     Destroy(gameObject);
 }
Exemple #28
0
 public void AttackClick()
 {
     ButtonSound.ButtonClickPlay();
     PrefabsTwo.LoadUI("Prefabs/Fight");
     Destroy(gameObject);
 }
Exemple #29
0
 public void Formation()
 {
     ButtonSound.ButtonClickPlay();
     PrefabsTwo.LoadUI("Prefabs/FormationMain");
     Destroy(gameObject);
 }
Exemple #30
0
 // Use this for initialization
 void Awake()
 {
     source   = GetComponent <AudioSource> ();
     instance = this;
     DontDestroyOnLoad(gameObject);
 }