public static void Play(this Sfx sfx, bool checkInterrupt = false)
 {
     if (SoundManager.instance != null)
     {
         SoundManager.instance.PlaySfx(sfx, false, checkInterrupt);
     }
 }
示例#2
0
        public void Reproduzir(Sfx sons = Sfx.Nenhum)
        {
            Console.Beep((int)sons, 200);

            //Use esse para reproduzir um arquivo wav
            //WinApi.MciSendString("play myaudio", "", 0, IntPtr.Zero);
        }
示例#3
0
    void Eat(GameObject food)
    {
        if (!dead)
        {
            if (OnEat != null)
            {
                OnEat();
            }
            Sfx.Play(eatSfx[Random.Range(0, eatSfx.Length)], .75f);
            Destroy(food);
            //GrowSnake();
            for (int i = 0; i < numToGrowByPerFood; i++)
            {
                if (visIndex < maxLength)
                {
                    snake[visIndex].SetVisible(true);
                    growingParts.Add(snake[visIndex].t);
                    snake[visIndex].t.localScale = Vector3.zero;
                    snake[visIndex].t.GetComponent <CircleCollider2D>().enabled = false;
                }
                visIndex++;
            }

            numEaten++;
        }
    }
 public static void PlaySfx(this MonoBehaviour monoBehaviour, Sfx sfx)
 {
     if (SoundManager.instance != null)
     {
         SoundManager.instance.PlaySfx(sfx);
     }
 }
示例#5
0
 public void MouseEnter()
 {
     if (!Disabled)
     {
         Sfx.Play(Sfx.ID.BUTTON_MOUSEOVER);
     }
 }
示例#6
0
    public void StopPlay(string name)
    {
        Sfx   s = Array.Find(sounds, sound => sound.name == name);
        Music m = Array.Find(music, music => music.name == name);


        if (m == null && s == null)
        {
            Debug.Log("Sound" + name + "Not Found");
            return;
        }
        else if (m == null && s != null)
        {
            if (s.clipsArray.Length > 0)
            {
                s.source.clip = (s.RandomCliptoPlay());
                s.source.Stop();
            }
            else
            {
                if (s != null)
                {
                    s.source.Stop();
                }
            }
        }
        else if (m != null && s == null)
        {
            if (m != null)
            {
                m.source.Stop();
            }
        }
    }
示例#7
0
        private void Move(Vector2 dir)
        {
            if (_dead)
            {
                return;
            }

            if (Mathf.Abs(dir.x) > 0)
            {
                _dir = Mathf.Sign(dir.x);
                SetSide();
            }

//            if(transform.eulerAngles.magnitude > 0)
//                transform.eulerAngles = Vector3.zero;

            _charged = Time.time - _shootHoldingTime >= ChargeTime && _shootHolding;

            _physics.Move(dir, Speed);
            _animation.Charged(_charged);
            Sfx.Charged(_charged);
            _animation.SetSpeed(_physics.Speed());
            Sfx.SetSpeed(_physics.Speed());
            _animation.SetSliding(_physics.Sliding);
            Sfx.SetSliding(_physics.Sliding);
            _animation.Dash(_physics.Dashing);
            Sfx.Dash(_physics.Dashing);

            if (transform.position.y < YKill)
            {
                OnDie();
            }
        }
示例#8
0
 public static void PlaySfx(Sfx sfx)
 {
     if (instance != null)
     {
         instance.PlaySfx(sfx.ToString() + sfxSuffix);
     }
 }
示例#9
0
    IEnumerator RestartSequence(float delay)
    {
        Sfx.Play(restartAudio);
        numRestarts++;
        FindObjectOfType <Stan>().OnTaskFail();
        yield return(new WaitForSeconds(delay));

        float p            = 0;
        bool  hasResetGame = false;

        while (p < 1)
        {
            p += Time.deltaTime * .75f;
            // float brightnessPercent = Mathf.Clamp01(restartBrightnessCurve.Evaluate(p));
            float brightnessPercent = Mathf.Clamp01(-(p * 2 - 1) * (p * 2 - 1) + 1);
            //print(p+"  " + brightnessPercent);
            monitor.material.SetColor("_EmissionColor", Color.white * brightnessPercent * 3);
            //screenOverlayMat.color = new Color(1, 1, 1, p);
            screenOverlay.material.color = new Color(1, 1, 1, brightnessPercent);
            if (p >= .5f && !hasResetGame)
            {
                Destroy(currentTask.gameObject);
                hasResetGame = true;
            }
            yield return(null);
        }
        screenOverlay.material.color = Color.clear;

        OnRestartComplete();
    }
示例#10
0
    public void removeTile(Vector3Int tileCoords, Tile tile, RaycastHit hit)
    {
        //Remove tile.
        bool removingBottom = tileCoords.z == 0;
        bool removingTop    = tileCoords.z == tiles.GetLength(2) - 1;
        bool isTileAbove    = false;

        if (!removingTop)
        {
            isTileAbove = tiles[tileCoords.x, tileCoords.y, (tileCoords.z + 1)] != null;
        }

        //You can't remove the bottom one, or if there's a tile above you
        if (!removingBottom && (removingTop || !isTileAbove))
        {
            //refactor idea: 2d array of stacks
            tiles[tileCoords.x, tileCoords.y, (tileCoords.z)] = null;
            Destroy(hit.collider.gameObject);
        }
        else
        {
            //give the user some feedback that this is a badness
            Sfx.playSound("Bad noise");
            tile.vibrateUnhappily();
        }
    }
示例#11
0
    public void RunFireEffects()
    {
        ActualAssert(ParentPlayer != null);

        if (CurrentWeapon.Kind == WeaponKind.PISTOL)
        {
            Sfx.PlaySfx(SfxCatagory.PISTOL_FIRE, 0, GlobalTransform.origin, 0);
        }
        else if (CurrentWeapon.Kind == WeaponKind.AK)
        {
            Sfx.PlaySfx(SfxCatagory.AK_FIRE, 0, GlobalTransform.origin, 0);
        }
        else if (CurrentWeapon.Kind == WeaponKind.SHOTGUN)
        {
            Sfx.PlaySfx(SfxCatagory.SHOTGUN_FIRE, 0, GlobalTransform.origin, 0);
        }

        float RecoilDampen = ((1 - CalcAdsDisplay()) + ParentPlayer.CrouchPercent) / 2f;

        ParentPlayer.CamAnimations.Add(new WeaponRecoil(CurrentWeapon.RecoilTime, CurrentWeapon.RecoilAmount, RecoilDampen));

        int Index = TinkChooser.Choose();

        Sfx.PlaySfxSpatially(SfxCatagory.CASING_TINK, Index, GlobalTransform.origin + new Vector3(0, -2, 0), 0);
    }
示例#12
0
        protected override IEnumerator OnDeath(Object killer)
        {
            yield return(base.OnDeath(killer));

            StartCoroutine(Bgm.Stop(0.5f));
            Sfx.Play(DeathSfxId);
            ChangeSprite("entity.player.drown");
            var targetY = transform.position.y + 300;


            charaGravityScale = 0;

            UpdateUI();

            for (int y = (int)transform.position.y; y < targetY; y += 4)
            {
                transform.Rotate(Vector3.forward * 180 * Time.deltaTime);
                transform.position = new Vector3(transform.position.x, y, transform.position.z);

                yield return(null);
            }
            yield return(new WaitForSeconds(2.5f));

            Wyte.Initalize();
        }
示例#13
0
 public void PlayTaskFailSfx(int i)
 {
     if (taskFailSfx != null && i < taskFailSfx.Length)
     {
         Sfx.Play(taskFailSfx[i]);
     }
 }
示例#14
0
        public override void gererTouches(byte[] etats)
        {
            // Retour au menu précédent
            if (etats[(int)SDL.SDL_Scancode.SDL_SCANCODE_ESCAPE] > 0)
            {
                Gfx.changerEcran(ecranPrecedent);
            }

            // page précédente
            if (etats[(int)SDL.SDL_Scancode.SDL_SCANCODE_LEFT] > 0)
            {
                gererActionBouton(boutons.Find((b) => b.getId() == 0));
            }

            // page suivante
            if (etats[(int)SDL.SDL_Scancode.SDL_SCANCODE_RIGHT] > 0)
            {
                gererActionBouton(boutons.Find((b) => b.getId() == 1));
            }

            // Equivalent du clic gauche pour sélectionner un bouton dans le menu
            if (etats[(int)SDL.SDL_Scancode.SDL_SCANCODE_RETURN] > 0)
            {
                if (boutonSel != -1)
                {
                    Sfx.JouerSon("clic_bouton");
                    gererActionBouton(boutons.Find((b) => b.getId() == boutonSel));
                }
            }
        }
示例#15
0
 public override void activer(Joueur joueur)
 {
     // L'effet par défaut du bonus est d'augmenter le nombre de bombes de 1
     joueur.incrementerMaxBombe();
     joueur.incrementerBombe();
     Sfx.JouerSon("bonus_bombe_plus");
 }
示例#16
0
 protected override void Update()
 {
     foreach (var key in sfxKeys.Keys.Where(RawKeyboardInput.IsPressed).Select(key => key))
     {
         Sfx.PlaySfx(sfxKeys[key]);
     }
 }
示例#17
0
    IEnumerator Message(bool accessGranted, bool loopForever)
    {
        showingMessage = true;
        mainScreen.SetActive(false);
        GameObject m = (accessGranted) ? granted : denied;
        int        i = 3;

        while (i > 0 || loopForever)
        {
            i--;
            yield return(new WaitForSeconds(.2f));

            m.SetActive(true);
            if (!accessGranted)
            {
                Sfx.Play(deniedAudio, Mathf.Lerp(.8f, .3f, 1 - i / 3f));
            }
            yield return(new WaitForSeconds(.5f));

            m.SetActive(false);
        }

        if (!accessGranted)
        {
            hintsUI.text += "\n" + fullHintsTxt.Split('\n')[3 - attemptsRemaining];
        }

        m.SetActive(false);
        mainScreen.SetActive(true);
        showingMessage = false;
    }
示例#18
0
 public void TakeAir()
 {
     canTakeAir = false;
     HasTookAir = true;
     (Sprite as AnimatedSprite).Change("TakeAir");
     Sfx.Play("pegar_ar");
 }
示例#19
0
文件: Room.cs 项目: Tankooni/terunks
        public Room()
        {
            foreach (string file in Directory.EnumerateFiles("assets/Levels/", "*.oel"))
            {
                FP.Log("PreloadingXML");
                Library.GetXml(file);
            }
            Library.GetBuffer("assets/Bossedd.ogg");
            roomLoader = new Thread(LoadRooms);
            roomLoader.IsBackground = true;
            RegisterClass <wallColTile>("wallCollision");
            RegisterClass <Platform>("platform");
            RegisterClass <GfxTile>("wallGfx");
            RegisterClass <Door>("door");
            RegisterClass <PlayerSpawn>("playerSpawn");
            RegisterClass <GroundEnemy>("groundEnemy");
            RegisterClass <TextObj>("textObj");
            RegisterClass <FlyingEnemy>("flyingEnemy");
            RegisterClass <Chest>("chest");
            RegisterClass <Boss>("bossSpawn");
            RegisterClass <BackDrop>("backDrop");

            AddList(currentEnts = BuildWorldAsArray("assets/Levels/Level01.oel"));

            Add(cursor = new Cursor());
            musics     = new Sfx(Library.GetBuffer("assets/Preview2.ogg"));
        }
示例#20
0
文件: Audio.cs 项目: TheL94/GGJ18
 public static void Play(Sfx sfx)
 {
     if (GetInstance())
     {
         GetInstance().PlaySfx(sfx);
     }
 }
示例#21
0
 private void StartSound(Sfx sfx)
 {
     if (audio != null)
     {
         audio.StartSound(null, sfx);
     }
 }
示例#22
0
 private void ShootHold()
 {
     _shootHolding     = true;
     _shootHoldingTime = Time.time;
     _animation.Shooting(true);
     Sfx.Charging(true);
 }
示例#23
0
        public void gererSouris()
        {
            int  x, y;
            uint click = 0;

            // la fenêtre n'est pas active
            if (SDL.SDL_GetMouseFocus() == IntPtr.Zero)
            {
                return;
            }

            // récupére l'état des boutons de la souris appuyés
            click = SDL.SDL_GetGlobalMouseState(out x, out y);
            // récupére les coordonnées du curseur
            SDL.SDL_GetMouseState(out x, out y);
            // on itére à travers tout les boutons pour vérifier si notre curseur
            // est dans le cadre du bouton
            foreach (Bouton bouton in boutons)
            {
                if (bouton.curseurDans(new Point(x, y)))
                {
                    boutonSel = bouton.getId();
                    // clic gauche détecté
                    if ((uint)(click & 1) == 1)
                    {
                        Sfx.JouerSon("clic_bouton");
                        gererActionBouton(boutons.Find((b) => b.getId() == boutonSel));
                    }
                }
            }
        }
示例#24
0
 public Sfx ApplyEffect( Sfx sfx )
 {
     sfx.GetComponent<AudioSource>().pitch = -sfx.GetComponent<AudioSource>().pitch;
     if(sfx.GetComponent<AudioSource>().pitch < 0)
         sfx.GetComponent<AudioSource>().time = sfx.GetComponent<AudioSource>().clip.length;
     return sfx;
 }
 public void PlaySfx(Sfx type, float volume = 1)
 {
     //if (soundState) {
     //	m_refs.sfxAudioSource.volume = volume;
     //	m_refs.sfxAudioSource.PlayOneShot (GetSfxAudioClip (type));
     //}
 }
示例#26
0
    private IEnumerator Play(Sfx sound, Action onFinish)
    {
        PlaySound(sound);
        yield return(new WaitWhile(() => src.isPlaying));

        onFinish();
    }
    public void Open()
    {
        GameObject OpenSound = Instantiate(OpenSfxPrefab, transform.position, new Quaternion());
        Sfx        Sfx       = OpenSound.GetComponent <Sfx>();

        Sfx.InitializeIndex(-1);
    }
    public void Close()
    {
        GameObject OpenSound = Instantiate(CloseSfxPrefab, transform.position, new Quaternion());
        Sfx        Sfx       = OpenSound.GetComponent <Sfx>();

        Sfx.InitializeIndex(PreviousOpenIndex);
    }
	public void PlaySfxCar(Sfx.Type type)
	{
		if (MuteSfx) return;
		
		// name
		if (isPaused)
		{
			Debug.LogWarning("Its paused... get out");
			//    return;
		}
		
		string resName = Sfx.sfxFiles[(int)type];
		//Debug.Log("Load sfx:" + resName);
		AudioClip clip = (AudioClip)Resources.Load(resName,typeof(AudioClip));
		if (clip == null)
		{
			Debug.LogError("Unable to load clip: "+resName);
			return;
		}
		car = getFreeChannel();
		car.volume = _mute ? 0 : startVolume;
		car.pitch = startPitch;
		car.loop = true;
		car.clip = clip;
		car.Play();
		//XXXchan.PlayOneShot(clip);
	}
 private void IncreaseState()
 {
     soundToPlay = Sfx.LetterHappy;
     playSound   = true;
     stateDelta  = 0;
     currentState++;
 }
示例#31
0
 void Awake()
 {
     instance = this;
     //
     ToggleMusic();
     ToggleSFX();
 }
示例#32
0
 public FireHitscanComponentInfo(Sfx sound, int bullets, int spread, bool firstShotAccurate)
 {
     this.Sound             = sound;
     this.Bullets           = bullets;
     this.Spread            = spread;
     this.FirstShotAccurate = firstShotAccurate;
 }
示例#33
0
    IEnumerator StartUpRoutine()
    {
        while (Time.time < fadeTime)
        {
            float fadePercent = Time.time / fadeTime;
            fadePlane.color = Color.Lerp(Color.black, Color.clear, fadePercent);
            yield return(null);
        }

        readyToSkip = true;

        yield return(new WaitForSeconds(.5f));

        while (titleAnimIndex < titleAnim.Length)
        {
            title.text = titleAnim[titleAnimIndex].text;
            titleAnimIndex++;
            Sfx.Play(keyAudio[Random.Range(0, keyAudio.Length)]);

            if (titleAnimIndex < titleAnim.Length)
            {
                yield return(new WaitForSeconds(titleAnim[titleAnimIndex].delay));
            }
        }
        textRoutine = StartCoroutine(ShowExtraText());
    }
示例#34
0
 public Sfx ApplyEffect( Sfx sfx )
 {
     sfx.GetComponent<AudioSource>().pitch = Mathf.Lerp(min, max, scalar);
     return sfx;
 }
	public void PlaySfxForDynamic(Sfx.Type type)
	{
		if (MuteSfx || (dynChannel != null && dynChannel.isPlaying)) return;
		
        // name
        if (isPaused)
        {
            Debug.LogWarning("Its paused... get out");
        //    return;
        }

        string resName = Sfx.sfxFiles[(int)type];
        //Debug.Log("Load sfx:" + resName);
        AudioClip clip = (AudioClip)Resources.Load(resName,typeof(AudioClip));
        if (clip == null)
        {
            Debug.LogError("Unable to load clip: "+resName);
            return;
        }

        dynChannel = getFreeChannel();
        dynChannel.volume = _mute ? 0 : SfxVolume;
        dynChannel.loop = false;
        dynChannel.clip = clip;
        dynChannel.Play();
	}
	public IEnumerator PlaySfxCoroutine(Sfx.Type type)
    {
		if (MuteSfx) yield break;

        string resName = Sfx.sfxFiles[(int)type];
        //Debug.Log("Load sfx:" + resName);
        AudioClip clip = (AudioClip)Resources.Load(resName,typeof(AudioClip));
        if (clip == null)
        {
            Debug.LogError("Unable to load clip: "+resName);
            yield break;
        }

        AudioSource chan = getFreeChannel();
        chan.volume = _mute ? 0 : SfxVolume;
        chan.loop = false;
        chan.clip = clip;
        chan.Play();
		while(chan.isPlaying) yield return null;
    }
	public IEnumerator PlaySfxAndPauseMusic(Sfx.Type t)
	{
		PauseAll();
		yield return StartCoroutine(PlaySfxCoroutine(t));
	}
示例#38
0
 private static AudioClip LoadSfx(Sfx sfx)
 {
     return (AudioClip) Resources.Load("Sfx/"+sfx.ToString());
 }
示例#39
0
 public static void PlaySfx(Sfx sfx)
 {
     AudioSource.PlayClipAtPoint(LoadSfx(sfx), Vector3.zero);
 }
示例#40
0
 public Sfx ApplyEffect( Sfx sfx )
 {
     sfx.GetComponent<AudioSource>().pitch = Random.Range(min, max);
     return sfx;
 }