Пример #1
0
    private void ActivePlayer()
    {
        if (!isReset)
        {
            return;
        }
        if (InputController.GetInstance().TargetObj == this.gameObject && InputController.GetInstance().IsInputing)
        {
            if (generateGravity != null)
            {
                generateGravity.SetIsGravity = true;
                generateGravity.SetIsKinematic(false);
                isReset = false;
                isDie   = false;
            }
            if (particleController != null)
            {
                particleController.Play();
            }

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(3));
            }

            if (particleDoTW)
            {
                particleDoTW.gameObject.SetActive(false);
            }
        }
    }
    public void UpdatedBGMMusic(AudioClip _clip)
    {
        if (MusicMgr.GetInstance() != null)
        {
            if (MusicMgr.GetInstance().GetBGMusic != null)
            {
                if (MusicMgr.GetInstance().GetBGMusic.clip != _clip)
                {
                    MusicMgr.GetInstance().PlayBGMMusicTransition(_clip, transitionTime);
                }
            }
            else
            {
                switch (target)
                {
                case DayAndNight.Day:
                default:
                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        MusicMgr.GetInstance().LoadPlayBGMusic(GameDataController.GetInstance().musicData.GetBGMClip(0));
                    }
                    break;

                case DayAndNight.Night:
                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        MusicMgr.GetInstance().LoadPlayBGMusic(GameDataController.GetInstance().musicData.GetBGMClip(1));
                    }
                    break;
                }
            }
        }
    }
Пример #3
0
 public void ButtonMusicEvent(AudioClip _audioClip, bool isLoop = false)
 {
     if (MusicMgr.GetInstance() != null)
     {
         MusicMgr.GetInstance().PlaySound(_audioClip, isLoop, 0.3f, true);
     }
 }
Пример #4
0
    public override void ShowUI()
    {
        //RemoveListener();
        if (!gameObject.activeSelf)
        {
            gameObject.SetActive(true);
        }

        oriRaidus = raidus;
        dir       = (raidus - targetRaidus) >= 0 ? 1 : -1;

        isForward = dir == 1 ? false : true;

        if (isForward)
        {
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(1), false, 0.3f, true);
            }
        }
        else
        {
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(2), false, 0.3f, true);
            }
        }

        tempTime = 0;

        cicle = new Vector4(center.x, center.y, raidus);
        AddListener();
    }
Пример #5
0
    public void GameStart()
    {
        isButton = false;

        EventCenter.GetInstance().RemoveEventListener("PartUIToMainUI", ShowUI);
        EventCenter.GetInstance().RemoveEventListener(EventData.HideHelpUI, ShowUI);

        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
        {
            isPlayingMusic = GameDataController.GetInstance().musicData.isPlaying;
        }

        if (isPlayingMusic)
        {
            if (MusicMgr.GetInstance().GetBGMusic == null)
            {
                if (musicData)
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic(musicData.GetBGMClip(0));
                }
                else
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic("BGM");
                }
            }
            else if (MusicMgr.GetInstance().BGMusicIsPlaing == false)
            {
                MusicMgr.GetInstance().PlayBGMusic();
            }
        }
        else
        {
            if (MusicMgr.GetInstance().GetBGMusic == null)
            {
                if (musicData)
                {
                    MusicMgr.GetInstance().LoadBGMusic(musicData.GetBGMClip(0));
                }
                else
                {
                    MusicMgr.GetInstance().LoadBGMusic("BGM");
                }
            }
        }

        if (audioOpenImg != null && audioCloseImg != null)
        {
            audioOpenImg.gameObject.SetActive(isPlayingMusic);
            audioCloseImg.gameObject.SetActive(!isPlayingMusic);
        }

        //RemoveListener();
        AddListener();
    }
Пример #6
0
    public void UpdatedMusicUI()
    {
        if (bgMusic == null)
        {
            bgMusic = MusicMgr.GetInstance().GetBGMusic;
        }

        if (bgMusic == null || linerender == null)
        {
            return;
        }

        //音乐采样
        bgMusic.GetSpectrumData(spectrum, 0, FFTWindow.BlackmanHarris);


        int j = 1;

        while (j < numSamples + 1)
        {
            float newData = (spectrum[j - 1] * 1.0f * 1);
            //对更新数据进行延迟处理
            if (newData > spactrumDataDelay[j - 1])
            {
                spactrumDataDelay[j - 1] += (delay * Time.deltaTime);
                if (spactrumDataDelay[j - 1] > newData)
                {
                    spactrumDataDelay[j - 1] = newData;
                }
            }
            else
            {
                spactrumDataDelay[j - 1] -= (delay * Time.deltaTime);
                if (spactrumDataDelay[j - 1] < 0f)
                {
                    spactrumDataDelay[j - 1] = 0f;
                }
            }
            j++;
        }


        for (int i = 0, cnt = LINERENDER_POINT_CNT; i < cnt; ++i)
        {
            var v     = spactrumDataDelay[i];
            var tempX = ((i - LINERENDER_POINT_CNT / 2) * 0.2f) * multiplyerLenth;

            tempX -= ((0) - LINERENDER_POINT_CNT / 2) * 0.2f * multiplyerLenth;

            linerender.SetPosition(i, new Vector3(tempX, i == 0 ? 0 : v * 20 * multiplyerHeight * 10, 0));
        }
    }
Пример #7
0
    public void BallonHitGameUpdate()
    {
        if (curTimes == times && !canHit)
        {
            Invoke("GameEnd", 5.0f);
        }
        else
        {
            //timer += Time.deltaTime;
            if (canRiseNewBallons)
            {
                canRiseNewBallons = false;
                Debug.Log("create ballon");
                curTimes++;
                timesText.text = ("Times:" + curTimes) as string;
                //创建气球
                for (int i = 0; i < 4; i++)
                {
                    ballonsList[i] = Instantiate(ballonPrefab, new Vector3(((rightBorder - leftBorder) / 4) * (i + 1) + leftBorder, lowBorder, 0), Quaternion.identity);
                }
                //ballonsList[0] = Instantiate(ballonPrefab, new Vector3(((rightBorder - leftBorder) / 4) * 1 + leftBorder, lowBorder, 0), Quaternion.identity);

                //分配气球上的单词
                curWordString = choseWordList[Random.Range(0, choseWordList.Count)];

                rightBallonIndex = Random.Range(0, 3);
                //Debug.Log("right index:" + rightBallonIndex);
                MusicMgr.GetInstance().SpeakVoice(curWordString);

                //curWordString = tempWords[rightBallonIndex];
                //Debug.Log("curWord:"+curWordString);
                ballonsList[rightBallonIndex].GetComponent <Ballon>().wordString = curWordString;
                for (int i = 0; i < 4; i++)
                {
                    if (i != rightBallonIndex)
                    {
                        otherWordString = choseWordList[Random.Range(0, choseWordList.Count)];
                        while (otherWordString == curWordString)
                        {
                            otherWordString = choseWordList[Random.Range(0, choseWordList.Count)];
                        }
                        //Debug.Log(i+"Word:" + tempWords[i]);
                        ballonsList[i].GetComponent <Ballon>().wordString = otherWordString;
                        //Debug.Log(i + "ballon:" + tempWords[i]);
                    }
                }
            }
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (gameData != null)
        {
            sOpNum = gameData.tempOpNum;
        }

        if (sOpNum < 0)
        {
            return;
        }

        if (Physics.CheckBox(transform.position, Vector3.one / 2, transform.rotation, layer))
        {
            if (sOpNum > 0)
            {
                sOpNum--;
                if (gameData != null && gameData.tempOpNum != sOpNum)
                {
                    gameData.tempOpNum = sOpNum;
                }
            }
            else if (sOpNum == 0)
            {
                sOpNum--;
                if (gameData != null && gameData.tempOpNum != sOpNum)
                {
                    gameData.tempOpNum = sOpNum;
                }
                GameEnd();
            }


            if (gameEndEvent != null)
            {
                gameEndEvent?.Invoke(null);
            }

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(6));
            }

            this.gameObject.SetActive(false);
        }
    }
Пример #9
0
    public void DownColliderEvent()
    {
        if (Physics.CheckSphere(transform.position, transform.lossyScale.x / 1.5f, 1 << 0))
        {
            if (!isDowning)
            {
                isDowning = true;

                if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                {
                    MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(4));
                }
            }
        }
        else
        {
            isDowning = false;
        }
    }
Пример #10
0
    private void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 100, 100), "PlayBkMusic"))
        {
            MusicMgr.GetInstance().PlayBkMusic("yhx");
        }

        if (GUI.Button(new Rect(0, 100, 100, 100), "StopBkMusic"))
        {
            MusicMgr.GetInstance().StopBkMusic();
        }

        if (GUI.Button(new Rect(0, 200, 100, 100), "PauseBkMusic"))
        {
            MusicMgr.GetInstance().PauseBkMusic();
        }

        v = GUI.HorizontalSlider(new Rect(0, 300, 100, 30), v, 0.0F, 1.0F);
        MusicMgr.GetInstance().SetBkVolume(v);
    }
Пример #11
0
    public void Init()
    {
        RemoveListener();
        //if (MusicMgr.GetInstance().GetBGMusic == null)
        //{
        //    MusicMgr.GetInstance().LoadBGMusic(bgmName);
        //}
        bgMusic = MusicMgr.GetInstance().GetBGMusic;
        // MusicMgr.GetInstance().StopBGMusic();

        spectrum          = new float[numSamples];
        spactrumDataDelay = new float[numSamples];

        if (linerender == null)
        {
            linerender = GetComponent <LineRenderer>();
            linerender.positionCount = LINERENDER_POINT_CNT;
            linerender.startWidth    = 0.02f;
            linerender.endWidth      = 0.02f;
        }
    }
Пример #12
0
    public void DownPlayerEvnet()
    {
        if (player == null)
        {
            return;
        }

        if (!isDie && player.transform.position.y < -5.5f)
        {
            isDie = true;
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(5));
            }
        }

        if (player.transform.position.y < -8)
        {
            ResetPlayer();
        }
    }
Пример #13
0
    private void MusicButtonEvent()
    {
        if (!isButton)
        {
            isButton = true;

            if (musicImag != null && musicOn != null && musicOff != null)
            {
                if (MusicMgr.GetInstance() != null)
                {
                    if (MusicMgr.GetInstance().BGMusicIsPlaing)
                    {
                        MusicMgr.GetInstance().PauseBGMusic();
                        musicImag.sprite = musicOff;
                        isMusic          = false;
                    }
                    else
                    {
                        //Debug.Log("MusicButtonEvent");
                        MusicMgr.GetInstance().UnPauseBGMusic();
                        musicImag.sprite = musicOn;
                        isMusic          = true;
                    }

                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
                        GameDataController.GetInstance().musicData.isPlaying = isMusic;
                    }
                }
            }


            isButton = false;
        }
    }
Пример #14
0
    protected override void ResetPlayer()
    {
        if (player == null)
        {
            return;
        }

        if (generateGravity != null)
        {
            if (particleDoTW)
            {
                particleDoTW.gameObject.SetActive(true);
            }
            StopPlayer();
            EventCenter.GetInstance().EventTrigger(EventData.playerReset);

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().StopSound(GameDataController.GetInstance().musicData.GetSEClip(5));
            }

            isReset = true;
        }
    }
Пример #15
0
 void Start()
 {
     MusicMgr.GetInstance().SetBKObject(this.GetComponent <AudioSource>());
     MusicMgr.GetInstance().PlayBkMusic();
 }
Пример #16
0
    public void AudioButtonEvent()
    {
        if (musicData != null)
        {
            ButtonMusicEvent(musicData.GetSEClip(0));
        }

        if (isButton)
        {
            return;
        }

        isButton = true;

        if (isPlayingMusic)
        {
            if (audioOpenImg != null && audioCloseImg != null)
            {
                if (audioOpenImg.gameObject.activeSelf)
                {
                    audioOpenImg.gameObject.SetActive(false);
                }

                if (!audioCloseImg.gameObject.activeSelf)
                {
                    audioCloseImg.gameObject.SetActive(true);
                }
            }

            MusicMgr.GetInstance().PauseBGMusic();

            isPlayingMusic = false;
            isButton       = false;
        }
        else
        {
            if (audioOpenImg != null && audioCloseImg != null)
            {
                if (!audioOpenImg.gameObject.activeSelf)
                {
                    audioOpenImg.gameObject.SetActive(true);
                }

                if (audioCloseImg.gameObject.activeSelf)
                {
                    audioCloseImg.gameObject.SetActive(false);
                }
            }

            if (MusicMgr.GetInstance().GetBGMusic != null)
            {
                if (MusicMgr.GetInstance().GetBGMusic.isPlaying == false)
                {
                    MusicMgr.GetInstance().UnPauseBGMusic();
                }
            }
            else
            {
                if (musicData)
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic(musicData.GetBGMClip(0));
                }
                else
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic("BGM");
                }
            }
            isPlayingMusic = true;
            isButton       = false;
        }

        if (musicData != null)
        {
            musicData.isPlaying = isPlayingMusic;
        }
    }
Пример #17
0
 // Start is called before the first frame update
 void Start()
 {
     MusicMgr.GetInstance().PlaySoundMusic("通关", false);
 }
Пример #18
0
    public override void Init()
    {
        if (MusicMgr.GetInstance().GetBGMusic == null)
        {
            if (musicData)
            {
                MusicMgr.GetInstance().LoadBGMusic(musicData.GetBGMClip(0));
            }
            else
            {
                MusicMgr.GetInstance().LoadBGMusic("BGM");
            }
        }

        EventCenter.GetInstance().RemoveEventListener("PartUIToMainUI", ShowUI);
        base.Init();

        helpBtn   = GetControl <Button>(helpButtonName);
        listBtn   = GetControl <Button>(listButtonName);
        audioBtn  = GetControl <Button>(audioButtonName);
        studioBtn = GetControl <Button>(studioButtonName);
        homeBtn   = GetControl <Button>(homeButtonName);

        audioOpenImg  = GetControl <Image>("AudioImageOpen");
        audioCloseImg = GetControl <Image>("AudioImageClose");

        if (helpBtn)
        {
            helpBtn.onClick.RemoveAllListeners();
        }
        if (listBtn)
        {
            listBtn.onClick.RemoveAllListeners();
        }
        if (audioBtn)
        {
            audioBtn.onClick.RemoveAllListeners();
        }
        if (studioBtn)
        {
            studioBtn.onClick.RemoveAllListeners();
        }
        if (homeBtn)
        {
            homeBtn.onClick.RemoveAllListeners();
        }

        if (musicData != null)
        {
            isPlayingMusic = musicData.isPlaying;
        }

        if (audioOpenImg != null && audioCloseImg != null)
        {
            if (isPlayingMusic)
            {
                if (!audioOpenImg.gameObject.activeSelf)
                {
                    audioOpenImg.gameObject.SetActive(isPlayingMusic);
                }

                if (audioCloseImg.gameObject.activeSelf)
                {
                    audioCloseImg.gameObject.SetActive(!isPlayingMusic);
                }
            }
            else
            {
                if (audioOpenImg.gameObject.activeSelf)
                {
                    audioOpenImg.gameObject.SetActive(!isPlayingMusic);
                }

                if (!audioCloseImg.gameObject.activeSelf)
                {
                    audioCloseImg.gameObject.SetActive(isPlayingMusic);
                }
            }
        }


        isButton = true;
        EventCenter.GetInstance().AddEventListener("PartUIToMainUI", ShowUI);
    }
Пример #19
0
 //静音
 public void AudioStopper()
 {
     MusicMgr.GetInstance().PauseBKMusic();
 }
Пример #20
0
 //重新播放音效
 public void AudioBeginner()
 {
     MusicMgr.GetInstance().PlayBkMusic();
 }
Пример #21
0
    // 音量大小控制
    public void AudioControll(Slider slider)
    {
        float value = slider.value;

        MusicMgr.GetInstance().ChangeBKValue(value);
    }