Inheritance: MonoBehaviour
Exemplo n.º 1
0
    void PlayVoice(string language)
    {
        var res = AkSoundEngine.SetCurrentLanguage(language); //备注:设置语言在运行的过程中不能频繁设置,游戏运行过程中只能设置一次,暂时测试出来结果是这样

        AudioCtrl.SetVoiceVolume(20);
        AudioManager.Instance.PlayVoice("VO_OYe", AudioManager.Instance.GetEmitterGameObject(EAudioType.Voice));
    }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            AudioCtrl.playSFX(gameObject.GetComponent <AudioSource>(), gameObject.GetComponent <AudioSource>().clip, 0.9f);
            gameObject.GetComponent <SpriteRenderer>().enabled = false;

            if (collision.gameObject.transform.position.y < 0)
            {
                GameObject topExplosion = Instantiate(explosionPrefab, new Vector2(transform.position.x, transform.position.y), Quaternion.identity);
                topExplosion.GetComponent <ParticleSystem>().Play();
            }
            else
            {
                GameObject explosion = Instantiate(explosionPrefab, new Vector2(transform.position.x, transform.position.y - 1f), Quaternion.identity);
                explosion.GetComponent <ParticleSystem>().Play();
            }
            Destroy(gameObject, gameObject.GetComponent <AudioSource>().clip.length);
        }
        if (collision.tag == "Ghost")
        {
            AudioCtrl.playSFX(gameObject.GetComponent <AudioSource>(), gameObject.GetComponent <AudioSource>().clip, 1f);

            if (collision.gameObject.transform.position.y < 0)
            {
                GameObject topExplosion = Instantiate(explosionPrefab, new Vector2(transform.position.x, transform.position.y), Quaternion.identity);
                topExplosion.GetComponent <ParticleSystem>().Play();
            }
            else
            {
                GameObject explosion = Instantiate(explosionPrefab, new Vector2(transform.position.x, transform.position.y - 1f), Quaternion.identity);
                explosion.GetComponent <ParticleSystem>().Play();
            }
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 사운드 재생.
    /// </summary>
    /// <param name="audioSource"></param>
    /// <param name="audioClipInfo"></param>
    /// <param name="is3DSound"></param>
    private void PlayAudiosourceSound(AudioSource audioSource, AudioClipInfo audioClipInfo, bool is3DSound = true)
    {
        if (audioSource)
        {
            if (!SettingManager.Instance.IsOnSound(audioClipInfo.Type))
            {
                SetVolume(audioClipInfo.Type, 0);
            }

            if (audioClipInfo.Clip)
            {
                audioSource.clip = audioClipInfo.Clip;
            }
            if (audioClipInfo.Type == AudioType.BGM)
            {
                is3DSound = false;
            }
            audioSource = SetAudioSource(audioSource, isVolumeAarry[(int)audioClipInfo.Type] * audioClipInfo.VolumeRate, audioClipInfo.IsLoop, is3DSound);
            if (audioClipInfo.Type == AudioType.BGM)
            {
                audioSource.priority = priorityBGM;
            }


            AudioCtrl.Play(audioSource, audioClipInfo.Type);
        }
    }
Exemplo n.º 5
0
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        if (DataCtrl.instance.data.playMusic)
        {
            BGMusic.SetActive(true);
            btnMusic.GetComponent <Image>().sprite = imgMusicOn;
        }
        else
        {
            BGMusic.SetActive(false);
            btnMusic.GetComponent <Image>().sprite = imgMusicOff;
        }

        if (DataCtrl.instance.data.playSound)
        {
            soundOn = true;
            btnSound.GetComponent <Image>().sprite = imgSoundOn;
        }
        else
        {
            soundOn = false;
            btnSound.GetComponent <Image>().sprite = imgSoundOff;
        }
    }
Exemplo n.º 6
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 7
0
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        BGMusic.SetActive(!muteBG);
    }
Exemplo n.º 8
0
 private void Awake()
 {
     if (Ins != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Ins = this;
     }
 }
Exemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     if (bgMusicOn)
     {
         bgMusic.gameObject.SetActive(true);
     }
 }
Exemplo n.º 10
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        if (bgMusicOn)
        {
            BGMusic.SetActive(true);
        }
    }
Exemplo n.º 12
0
 void FindBGMusic()
 {
     if (audioCtrl == null)
     {
         GameObject g = GameObject.Find("BGMusic");
         if (g != null)
         {
             if (g.GetComponent <AudioCtrl>() != null)
             {
                 audioCtrl = g.GetComponent <AudioCtrl>();
             }
         }
     }
 }
Exemplo n.º 13
0
    public static void Play(AudioSource audioSource, AudioType audioType)
    {
        if (!audioSource.isActiveAndEnabled)
        {
            return;
        }

        AudioCtrl audioCtrl = audioSource.gameObject.GetComponent <AudioCtrl>();

        if (audioCtrl == null)
        {
            audioCtrl = audioSource.gameObject.AddComponent <AudioCtrl>();
        }

        audioCtrl.PlaySetting(audioSource, audioType);
        audioSource.Play();
        audioSource.mute = SoundManager.Instance.GetIsMute(audioType);
    }
Exemplo n.º 14
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        lowPitchRange  = 0.25f;
        highPitchRange = 1.75f;

        baseAudio = new AudioCtrl();
        midAudio  = new AudioCtrl();
        highAudio = new AudioCtrl();

        FormAudio(false);
    }
Exemplo n.º 15
0
 void Awake()
 {
     _audioCtrl=AudioCtrl.Instance;
     //_audioCtrl._globalVolume=this._globalVolume;
     //_audioCtrl._vfxVolume=this._vfxVolume;
 }
Exemplo n.º 16
0
    //public int iMusic;

    void Awake()
    {
        pthis = this;
        DontDestroyOnLoad(gameObject);
    }
Exemplo n.º 17
0
    // Update is called once per frame
    void Update()
    {
        if (isOutsideMap())
        {
            if (DataHolder.Instance != null && !scoreSet)
            {
                string id                = DataHolder.Instance.ID;
                string mapSeed           = GameObject.FindGameObjectWithTag("mapHandler").GetComponent <MapGenerator>().staticMap;
                string playthroughString = xmlElements.ToString();
                DBHandler.Instance.StartCoroutine(DBHandler.Instance.SetScore(id, (int)Time.timeSinceLevelLoad, mapSeed, playthroughString));
                scoreSet = true;
            }
            Time.timeScale = 0;
        }

        //Debug.DrawRay(new Vector2(transform.localPosition.x, transform.localPosition.y + yOffset + 0.2f), transform.right + lDir * 3f, Color.green);
        //Debug.DrawRay(new Vector2(transform.localPosition.x, transform.localPosition.y - yOffset - 0.2f), transform.right + RDir * 3f, Color.green);
        //Debug.DrawRay(new Vector2(transform.position.x + GetComponent<BoxCollider2D>().bounds.extents.x + 0.2f, transform.position.y), transform.right, Color.green);

        rightCol = new Vector2(transform.position.x + xOffset, transform.position.y - 0.1f);
        upCol    = new Vector2(transform.position.x, transform.position.y + yOffset + 0.2f);
        downCol  = new Vector2(transform.position.x, transform.position.y - yOffset - 0.2f);


        if (Physics2D.Raycast(rightCol, Vector2.right, 0f) && Physics2D.Raycast(upCol, transform.right + lDir * 3f, 1f) && Physics2D.Raycast(downCol, transform.right + RDir * 3f, 1f))
        {
            //Debug.Log("Allahuakbar");
            gameObject.transform.Translate((Vector2.left * Time.deltaTime) * 20f);
        }

        if (Physics2D.Raycast(upCol, Vector2.up, 0.2f))
        {
            if (!landed && !gravityOn)
            {
                AudioCtrl.playSFX(gameObject.GetComponent <AudioSource>(), gameObject.GetComponent <AudioSource>().clip, 0.3f);
                landed    = true;
                canSwitch = true;
            }
        }
        //|| Physics2D.Raycast(upCol, Vector2.up, 0.1f)
        if (Physics2D.Raycast(downCol, Vector2.down, 0.2f))
        {
            if (!landed && gravityOn)
            {
                AudioCtrl.playSFX(gameObject.GetComponent <AudioSource>(), gameObject.GetComponent <AudioSource>().clip, 0.3f);
                landed    = true;
                canSwitch = true;
            }
        }

        if (Input.GetKeyDown("space") && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() || Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            if (canSwitch)
            {
                GetComponent <Rigidbody2D>().velocity      = Vector2.zero;
                GetComponent <Rigidbody2D>().gravityScale *= -1;
                //Debug.Log("Landed: " +landed);
                gravityOn = !gravityOn;
                playerSpriteRend.flipY = !playerSpriteRend.flipY;
                playthrough.Add(Time.timeSinceLevelLoad.ToString("0.00"));
                xmlElements = new XElement("times", playthrough.Select(i => new XElement("ts", i)));
                landed      = false;
                canSwitch   = false;
            }
        }
    }
Exemplo n.º 18
0
 void Awake()
 {
     _audioCtrl = AudioCtrl.Instance;
     //_audioCtrl._globalVolume=this._globalVolume;
     //_audioCtrl._vfxVolume=this._vfxVolume;
 }
Exemplo n.º 19
0
    // Update is called once per frame
    void Update()
    {
        if (isOutsideMap())
        {
            if (DataHolder.Instance != null && !scoreSet)
            {
                if (!DataHolder.Instance.Offline)
                {
                    string id                = DataHolder.Instance.ID;
                    string mapSeed           = GameObject.FindGameObjectWithTag("mapHandler").GetComponent <MapGenerator>().staticMap;
                    string playthroughString = xmlElements.ToString();
                    DBHandler.Instance.StartCoroutine(DBHandler.Instance.SetScore(id, (int)Time.timeSinceLevelLoad, mapSeed, playthroughString));
                    scoreSet = true;
                    AudioCtrl.vibrate();
                }
                Time.timeScale = 0;
            }
            GameObject.FindGameObjectWithTag("MenuController").GetComponent <MenuController>().GameOver = true;
        }

        rightCol = new Vector2(transform.position.x + xOffset, transform.position.y - 0.1f);
        upCol    = new Vector2(transform.position.x, transform.position.y + yOffset + 0.2f);
        downCol  = new Vector2(transform.position.x, transform.position.y - yOffset - 0.2f);


        if (Physics2D.Raycast(rightCol, Vector2.right, 0f) && Physics2D.Raycast(upCol, transform.right + lDir * 3f, 1f) && Physics2D.Raycast(downCol, transform.right + RDir * 3f, 1f))
        {
            gameObject.transform.Translate((Vector2.left * Time.deltaTime) * 20f);
        }

        if (Physics2D.Raycast(upCol, Vector2.up, 0.1f))
        {
            if (!landed && !gravityOn)
            {
                AudioCtrl.playSFX(gameObject.GetComponent <AudioSource>(), gameObject.GetComponent <AudioSource>().clip, 0.3f);
                landed    = true;
                canSwitch = true;
            }
        }
        if (Physics2D.Raycast(downCol, Vector2.down, 0.1f))
        {
            if (!landed && gravityOn)
            {
                AudioCtrl.playSFX(gameObject.GetComponent <AudioSource>(), gameObject.GetComponent <AudioSource>().clip, 0.3f);
                landed    = true;
                canSwitch = true;
            }
        }

        if (Input.GetKeyDown("space") && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject() || Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            if (chargeCount > 0 || canSwitch)
            {
                if (!canSwitch)
                {
                    if (chargeCount > 0)
                    {
                        chargeCount--;
                        chargeCounter.text = chargeCount.ToString();
                    }
                }
                GetComponent <Rigidbody2D>().velocity      = Vector2.zero;
                GetComponent <Rigidbody2D>().gravityScale *= -1;
                gravityOn = !gravityOn;
                playerSpriteRend.flipY = !playerSpriteRend.flipY;

                playthrough.Add(Time.timeSinceLevelLoad.ToString("0.00") + "@" + transform.position.x + "|" + transform.position.y);
                xmlElements = new XElement("times", playthrough.Select(i => new XElement("ts", i)));

                landed    = false;
                canSwitch = false;
            }
        }
    }