public void PauseEditorAudio()
 {
     editorAudioText.text  = "None";
     editorAudioText.color = Color.white;
     editorAudio           = editorAudios[0]; // "none" won't play when ed opens.
     WebGLComm.inst.PauseEditorAudio();
 }
 void Awake()
 {
     if (BackgroundAudio.instance == null)
     {
         BackgroundAudio.instance = this;
     }
 }
 /// <summary>
 /// 停止播放背景音乐
 /// </summary>
 public void StopBackgroundMusic()
 {
     if (BackgroundAudio.isPlaying)
     {
         BackgroundAudio.Stop();
     }
 }
Example #4
0
 // Start is called before the first frame update
 void Start()
 {
     //Set starting background
     currentBackground = "darkForest";
     // Music for the specific background
     BackgroundAudio.PlaySound("DarkForest");
     //   musicIsOff = false;
 }
Example #5
0
	public static void PlayBG(BackgroundAudio lol)
	{
		if (blAH) {

			Debug.Log ("hey i called it");
			blAH.playBackground (lol);
		}
	}
Example #6
0
    // Start is called before the first frame update

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.transform.tag == "Coin")
        {
            BackgroundAudio.PlaySound("Coin");
            coin++;
            textCoins.text = coin.ToString();
            Destroy(other.gameObject);
        }
    }
    // For playing backgorund audio in game.
    public void SetGameBackgroundAudio(string n)
    {
        foreach (BackgroundAudio env in environmentAudios)
        {
            if (n == env.name)
            {
                gameAudio = env;
//				WebGLComm.inst.PlayEnvironmentAudio(env.serverPath);
            }
        }
    }
Example #8
0
        void OnTriggerEnter2D(Collider2D collider)
        {
            var p = collider.gameObject.GetComponent <PlayerController>();

            if (p != null)
            {
                BackgroundAudio.PlaySound("Death");
                var ev = Schedule <PlayerEnteredDeathZone>();
                ev.deathzone = this;
            }
        }
 private void OnTriggerEnter2D(Collider2D collider)
 {
     //If in contact with the player, then call the bg change script
     if (collider.tag == "tag_player")
     {
         if (audioClip != null)
         {
             StartCoroutine(BackgroundAudio.ChangeTracks(audioClip));
         }
     }
 }
 // For playing audio in editor
 public void SelectEditorAudio(string n)
 {
     foreach (BackgroundAudio env in environmentAudios)
     {
         if (n == env.name)
         {
             editorAudio = env;
             WebGLComm.inst.PlayEnvironmentAudio(env.serverPath);
         }
     }
 }
Example #11
0
    void Start()
    {
        Instance = this;
        //Populates dictionary with clips from the above data structure
        foreach (NamedAudio s in stings)
        {
            stingsDict.Add(s.name, s.clip);
        }

        DontDestroyOnLoad(Instance);
        stingSource = transform.GetChild(0).GetComponent <AudioSource>();
    }
Example #12
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(this.gameObject);
 }
        /// <summary>
        /// 播放背景音乐
        /// </summary>
        /// <param name="clip">音乐剪辑</param>
        /// <param name="isLoop">是否循环</param>
        /// <param name="speed">播放速度</param>
        public void PlayBackgroundMusic(AudioClip clip, bool isLoop = true, float speed = 1)
        {
            if (BackgroundAudio.isPlaying)
            {
                BackgroundAudio.Stop();
            }

            BackgroundAudio.clip  = clip;
            BackgroundAudio.loop  = isLoop;
            BackgroundAudio.pitch = speed;
            BackgroundAudio.Play();
        }
Example #14
0
 private void Awake()
 {
     if (controller == null)
     {
         DontDestroyOnLoad(gameObject);
         controller = this;
     }
     else if (controller != this)
     {
         Destroy(gameObject);
     }
 }
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
    public void PopulateBackgroundAudiosFromBrowser(SimpleJSON.JSONClass N)
    {
        environmentAudios = new BackgroundAudio[N["tracks"].AsArray.Count];
        WebGLComm.inst.Debug("populating " + N["tracks"].AsArray.Count + " audios.");
        int i = 0;

        foreach (SimpleJSON.JSONClass item in N["tracks"].AsArray.Childs)
        {
            BackgroundAudio ea = new BackgroundAudio(item["name"], item["file"]);
            environmentAudios[i] = ea;
            i++;
        }
    }
Example #17
0
    void Start()
    {
        restartButton = GetComponent <Button>();
        DataController  dataController  = FindObjectOfType <DataController>();
        BackgroundAudio backgroundAudio = FindObjectOfType <BackgroundAudio>();

        restartButton.onClick.AddListener(delegate {
            Destroy(GameObject.FindGameObjectWithTag("DataControllerLoad"));
            Destroy(GameObject.FindGameObjectWithTag("BackGroundAudio"));
            //Destroy(backgroundAudio);
            SceneManager.LoadScene("PersistentScene");
        });
    }
 /// <summary>
 /// 恢复播放背景音乐
 /// </summary>
 /// <param name="isGradual">是否渐进式</param>
 public void UnPauseBackgroundMusic(bool isGradual = true)
 {
     if (isGradual)
     {
         BackgroundAudio.volume = 0;
         BackgroundAudio.UnPause();
         BackgroundAudio.DOFade(BackgroundVolume, 2);
     }
     else
     {
         BackgroundAudio.UnPause();
     }
 }
 private void OnEnable()
 {
     if (_Instance == null)
     {
         _Instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         Debug.Log("Instance Already Exists");
         Destroy(this.gameObject);
     }
 }
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (_instance != null)
        {
            Destroy(gameObject);
            return;
        }
        else
        {
            _instance = this;
        }
    }
    public void NextEditorAudio()
    {
        editorAudioIndex++;
        editorAudioIndex %= editorAudios.Length;
        if (editorAudioIndex == 0)
        {
            editorAudioIndex = 1;                                // skip "none", that's only for stoping.
        }
        editorAudio = editorAudios[editorAudioIndex];
//		Debug.Log("next:"+editorAudio.name);
        WebGLComm.inst.PlayEditorAudio(editorAudio.serverPath);
        editorAudioText.text  = editorAudio.name;
        editorAudioText.color = Color.yellow;
    }
 /// <summary>
 /// 暂停播放背景音乐
 /// </summary>
 /// <param name="isGradual">是否渐进式</param>
 public void PauseBackgroundMusic(bool isGradual = true)
 {
     if (isGradual)
     {
         BackgroundAudio.DOFade(0, 2).OnComplete(() =>
         {
             BackgroundAudio.Pause();
             BackgroundAudio.volume = BackgroundVolume;
         });
     }
     else
     {
         BackgroundAudio.Pause();
     }
 }
Example #23
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        audioSource = GetComponent <AudioSource>();
        SetAudioEnabled(GameManager.Instance.SettingsManager.BackgroundMusicEnabled);
    }
    public void PlayEditorAudio()
    {
        editorAudioIndex = Random.Range(1, editorAudios.Length);
        editorAudio      = editorAudios[editorAudioIndex];
//		if (editorAudio == null){
//		}
        WebGLComm.inst.PlayEditorAudio(editorAudio.serverPath);
        editorAudioText.text = editorAudio.name;
        if (editorAudio.name == "None")
        {
            editorAudioText.color = Color.white;
        }
        else
        {
            editorAudioText.color = Color.yellow;
        }
    }
Example #25
0
 void Awake()
 {
     current = this;
 }
Example #26
0
 public void playBackground(BackgroundAudio symbol)
 {
     switch (symbol)
     {
         case BackgroundAudio.DeathStinger:
             bg.clip = bgList[0];
             bg.Play();
             break;
         case BackgroundAudio.Level1Loop:
             bg.clip = bgList[1];
             bg.Play();
             break;
         case BackgroundAudio.MainTitle:
             bg.clip = bgList[2];
             bg.Play();
             break;
         case BackgroundAudio.Victory:
             bg.clip = bgList[3];
             bg.Play();
             break;
         default:
             break;
     }
 }
Example #27
0
        protected override void Update()
        {
            // Initial background music
            if (musicIsOff)
            {
                BackgroundAudio.PlaySound("MainTheme");
                musicIsOff = false;
            }

            if (controlEnabled)
            {
                //move.x = Input.GetAxis("Horizontal"); //this was the previous arrow key input
                move.x = playerSpeed; //set player speed

                //As long as the speed is under max, increase slowly
                if (playerSpeed > maxSpeed)
                {
                    playerSpeed -= decreaseSpeed;
                }


                /*
                 * if (coinNum == 1)
                 * {
                 *  //Reset all backgrounds away
                 *  background1.transform.position = new Vector3(background1.transform.position.x, -100, background1.transform.position.z);
                 *  background2.transform.position = new Vector3(background2.transform.position.x, -100, background2.transform.position.z);
                 *  background3.transform.position = new Vector3(background3.transform.position.x, -100, background3.transform.position.z);
                 *  background4.transform.position = new Vector3(background4.transform.position.x, -100, background4.transform.position.z);
                 *
                 *  //Move the one we want
                 *  background1.transform.position = new Vector3(background1.transform.position.x, 0, background1.transform.position.z);
                 *
                 *  // Music for the specific background
                 *  BackgroundAudio.PlaySound("DarkForest");
                 * }
                 * if (Input.GetKey("1"))
                 * {
                 *  //Reset all backgrounds away
                 *  background1.transform.position = new Vector3(background1.transform.position.x, -100, background1.transform.position.z);
                 *  background2.transform.position = new Vector3(background2.transform.position.x, -100, background2.transform.position.z);
                 *  background3.transform.position = new Vector3(background3.transform.position.x, -100, background3.transform.position.z);
                 *  background4.transform.position = new Vector3(background4.transform.position.x, -100, background4.transform.position.z);
                 *
                 *  //Move the one we want
                 *  background1.transform.position = new Vector3(background1.transform.position.x, 0, background1.transform.position.z);
                 *
                 *  // Music for the specific background
                 *  BackgroundAudio.PlaySound("DarkForest");
                 * }
                 * if (Input.GetKey("2"))
                 * {
                 *  //Reset all backgrounds away
                 *  background1.transform.position = new Vector3(background1.transform.position.x, -100, background1.transform.position.z);
                 *  background2.transform.position = new Vector3(background2.transform.position.x, -100, background2.transform.position.z);
                 *  background3.transform.position = new Vector3(background3.transform.position.x, -100, background3.transform.position.z);
                 *  background4.transform.position = new Vector3(background4.transform.position.x, -100, background4.transform.position.z);
                 *
                 *  //Move the one we want
                 *  background2.transform.position = new Vector3(background2.transform.position.x, 0, background2.transform.position.z);
                 *
                 *  // Music for the specific background
                 *  BackgroundAudio.PlaySound("RockyHills");
                 * }
                 * if (Input.GetKey("3"))
                 * {
                 *  //Reset all backgrounds away
                 *  background1.transform.position = new Vector3(background1.transform.position.x, -100, background1.transform.position.z);
                 *  background2.transform.position = new Vector3(background2.transform.position.x, -100, background2.transform.position.z);
                 *  background3.transform.position = new Vector3(background3.transform.position.x, -100, background3.transform.position.z);
                 *  background4.transform.position = new Vector3(background4.transform.position.x, -100, background4.transform.position.z);
                 *
                 *  //Move the one we want
                 *  background3.transform.position = new Vector3(background3.transform.position.x, 0, background3.transform.position.z);
                 *
                 *  // Music for the specific background
                 *  BackgroundAudio.PlaySound("PeacefulMountains");
                 * }
                 * if (Input.GetKey("4"))
                 * {
                 *  //Reset all backgrounds away
                 *  background1.transform.position = new Vector3(background1.transform.position.x, -100, background1.transform.position.z);
                 *  background2.transform.position = new Vector3(background2.transform.position.x, -100, background2.transform.position.z);
                 *  background3.transform.position = new Vector3(background3.transform.position.x, -100, background3.transform.position.z);
                 *  background4.transform.position = new Vector3(background4.transform.position.x, -100, background4.transform.position.z);
                 *
                 *  //Move the one we want
                 *  background4.transform.position = new Vector3(background4.transform.position.x, 0, background4.transform.position.z);
                 *
                 *  // Music for the specific background
                 *  BackgroundAudio.PlaySound("Waterfalls");
                 * }
                 */

                if (jumpState == JumpState.Grounded && Input.GetButtonDown("Jump"))
                {
                    jumpState = JumpState.PrepareToJump;
                }
                else if (Input.GetButtonUp("Jump"))
                {
                    stopJump = true;
                    Schedule <PlayerStopJump>().player = this;
                }
            }
            else
            {
                move.x = 0;
            }
            UpdateJumpState();
            base.Update();
        }
Example #28
0
 // Use this for initialization
 void Start()
 {
     bg = GameObject.FindGameObjectWithTag("BgMusic").GetComponent <BackgroundAudio>();
 }
Example #29
0
    // Update is called once per frame
    void Update()
    {
        // Initial background music
        if (musicIsOff)
        {
            //BackgroundAudio.PlaySound("MainTheme");
            //musicIsOff = false;
        }

        //Change backgrounds according to coin number
        GameObject    thePlayer  = GameObject.Find("Player");
        CoinCollision coinScript = thePlayer.GetComponent <CoinCollision>();
        int           coinNum    = (int)coinScript.coin; //Get number of coins from the coin script

        //Check number of coins
        if (coinNum == 10)
        {
            //Change to rockyHills
            if (currentBackground != "rockyHills")
            {
                currentBackground = "rockyHills";

                //Animate
                //out with current background
                FadeOut = darkForest.GetComponent <Animator>();
                FadeOut.SetTrigger("FadeOut");
                //in with new background
                FadeIn = rockyHills.GetComponent <Animator>();
                FadeIn.SetTrigger("FadeIn");

                //Reset all backgrounds away

                /*
                 * darkForest.transform.position = new Vector3(darkForest.transform.position.x, -100, darkForest.transform.position.z);
                 * peacefulMountains.transform.position = new Vector3(peacefulMountains.transform.position.x, -100, peacefulMountains.transform.position.z);
                 * rockyHills.transform.position = new Vector3(rockyHills.transform.position.x, -100, rockyHills.transform.position.z);
                 * waterfalls.transform.position = new Vector3(waterfalls.transform.position.x, -100, waterfalls.transform.position.z);
                 */
                //Move the one we want
                rockyHills.transform.position = new Vector3(rockyHills.transform.position.x, -1, rockyHills.transform.position.z);

                // Music for the specific background
                BackgroundAudio.PlaySound("RockyHills");

                //Change dialogue
                GameObject D            = GameObject.Find("DialogueManager");
                Dialog     dialogScript = D.GetComponent <Dialog>();
                StartCoroutine(DialogCoroutine());
            }
        }
        else if (coinNum == 20)
        {
            //Change to peacefulMountains
            if (currentBackground != "peacefulMountains")
            {
                //Animate
                //out with current background
                FadeOut = rockyHills.GetComponent <Animator>();
                FadeOut.SetTrigger("FadeOut");
                //in with new background
                FadeIn = peacefulMountains.GetComponent <Animator>();
                FadeIn.SetTrigger("FadeIn");

                currentBackground = "peacefulMountains";
                //Reset all backgrounds away

                /*
                 * darkForest.transform.position = new Vector3(darkForest.transform.position.x, -100, darkForest.transform.position.z);
                 * peacefulMountains.transform.position = new Vector3(peacefulMountains.transform.position.x, -100, peacefulMountains.transform.position.z);
                 * rockyHills.transform.position = new Vector3(rockyHills.transform.position.x, -100, rockyHills.transform.position.z);
                 * waterfalls.transform.position = new Vector3(waterfalls.transform.position.x, -100, waterfalls.transform.position.z);
                 */
                //load new
                FadeIn = peacefulMountains.GetComponent <Animator>();
                FadeIn.SetTrigger("FadeIn");
                //Move the one we want
                peacefulMountains.transform.position = new Vector3(peacefulMountains.transform.position.x, -1, peacefulMountains.transform.position.z);

                // Music for the specific background
                BackgroundAudio.PlaySound("PeacefulMountains");

                //Change dialogue
                GameObject D            = GameObject.Find("DialogueManager");
                Dialog     dialogScript = D.GetComponent <Dialog>();
                StartCoroutine(DialogCoroutine());
            }
        }
        else if (coinNum == 35)
        {
            //Change to waterfalls
            if (currentBackground != "waterfalls")
            {
                //Animate
                //out with current background
                FadeOut = peacefulMountains.GetComponent <Animator>();
                FadeOut.SetTrigger("FadeOut");
                //in with new background
                FadeIn = waterfalls.GetComponent <Animator>();
                FadeIn.SetTrigger("FadeIn");

                currentBackground = "waterfalls";
                //Reset all backgrounds away

                /*
                 * darkForest.transform.position = new Vector3(darkForest.transform.position.x, -100, darkForest.transform.position.z);
                 * peacefulMountains.transform.position = new Vector3(peacefulMountains.transform.position.x, -100, peacefulMountains.transform.position.z);
                 * rockyHills.transform.position = new Vector3(rockyHills.transform.position.x, -100, rockyHills.transform.position.z);
                 * waterfalls.transform.position = new Vector3(waterfalls.transform.position.x, -100, waterfalls.transform.position.z);
                 */
                //Move the one we want
                waterfalls.transform.position = new Vector3(waterfalls.transform.position.x, -1, waterfalls.transform.position.z);

                // Music for the specific background
                BackgroundAudio.PlaySound("Waterfalls");

                //Change dialogue
                GameObject D            = GameObject.Find("DialogueManager");
                Dialog     dialogScript = D.GetComponent <Dialog>();
                dialogScript.NextSentence();
            }
        }
    }