Ejemplo n.º 1
0
    private void OnLevelLoaded(Scene scene, LoadSceneMode mode)
    {
        //    if (levelMusic[scene.buildIndex])
        //    {
        //        audioSource.clip = levelMusic[scene.buildIndex];
        // play the ambient water sounds everywhere but the splash screen

        if (!audioSource)
        {
            audioSource = GetComponent <AudioSource>();
            if (!audioSource)
            {
                Debug.LogWarning("audioSource component not found");
            }
        }


        if (levelMusic /*&& LevelManager.GetLevel() != LevelManager.LEVELS.SPLASH*/)
        {
            audioSource.clip   = levelMusic;
            audioSource.loop   = true;
            audioSource.volume = PPrefsMgr.GetMusicVolume();
            audioSource.Play();
        }
        else
        {
            Debug.LogWarning("levelMusic not set in inspector");
        }
    }
Ejemplo n.º 2
0
 public void SaveAndExit()
 {
     PPrefsMgr.SetMusicVolume(musicVolumeSlider.value);
     PPrefsMgr.SetSfxVolume(sfxVolumeSlider.value);
     PPrefsMgr.SetDifficulty(difficultySlider.value);
     levelManager.LoadLevel("Start");
 }
Ejemplo n.º 3
0
 private void OnLevelLoaded(Scene scene, LoadSceneMode mode)
 {
     if (levelMusic[scene.buildIndex])
     {
         audioSource.clip   = levelMusic[scene.buildIndex];
         audioSource.loop   = true;
         audioSource.volume = PPrefsMgr.GetMasterVolume();
         audioSource.Play();
     }
 }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        musicManager = FindObjectOfType <MusicManager>();
        if (!musicManager)
        {
            Debug.LogWarning("MusicManager not found");
        }

        volumeSlider.value     = PPrefsMgr.GetMasterVolume();
        difficultySlider.value = PPrefsMgr.GetDifficulty();
    }
Ejemplo n.º 5
0
    private void ChangeColorState()
    {
        //Animator animator = GetComponent<Animator>();

        if (!firstColorChange && LevelManager.GetLevel() == LevelManager.LEVELS.TUTORIAL0)
        {
            GameObject tutorial = GameObject.Find("TutorialCollider");
            if (tutorial)
            {
                GameObject tutorialText = GameObject.Find("Tutorial Text");
                tutorialText.GetComponent <TutorialText>().NextText();
            }
            firstColorChange = true;
        }

        ParticleSystem.MainModule main = hitParticles.GetComponent <ParticleSystem>().main;

        if (hitParticles.GetComponent <ParticleSystem>())
        {
            switch (my_comp_color)
            {
            case COMP_COLOR.Purple:
                main.startColor = Color.yellow;      // yellow
                break;

            case COMP_COLOR.Red:
                main.startColor = Color.green;
                break;

            case COMP_COLOR.Orange:
                main.startColor = Color.blue;
                break;

            default:
                Debug.LogWarning("missing shark code");
                break;
            }

            Instantiate(hitParticles, transform.position, Quaternion.identity);

            AudioSource.PlayClipAtPoint(friendSound, transform.position, PPrefsMgr.GetSfxVolume());
            gameObject.layer = FRIENDLY_LAYER;
            if (score) // because no score on Start level
            {
                score.AddToScore(scoreValue);
            }

            Invoke("ChangeToFriendly", changetime); // will change shark color after particles
        }
    }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     musicManager = GameObject.FindObjectOfType <MusicManager>();
     if (musicManager)
     {
         float volume = PPrefsMgr.GetMasterVolume();
         musicManager.SetVolume(volume);
     }
     else
     {
         //this is not a problem if starting in Start level rather than Splash level
         Debug.LogWarning("Music Manager not found, can't set volume.");
     }
 }
Ejemplo n.º 7
0
 public void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "areas")  // all sea blocks, play collision sound
     {
         // sometimes when you hit blocks (especially from below) the sound is louder because two play at a time
         // (2 collisions happen), currently do not consider this a bug. Also this sound isn't as loud as colorray
         // which I could fix here if we want
         AudioSource.PlayClipAtPoint(bumpSound, transform.position, PPrefsMgr.GetSfxVolume());
     }
     else if (col.gameObject.tag == "enemy")
     {
         TriggerHurt();
     }
 }
Ejemplo n.º 8
0
    private void FireColorRay()
    {
        // for tutorial state
        if (!firstFireColorRay)
        {
            GameObject tutorial = GameObject.Find("TutorialCollider");
            if (tutorial)
            {
                GameObject tutorialText = GameObject.Find("Tutorial Text");
                if (tutorialText.GetComponent <TutorialText>().GetTutorialState() == TUTORIAL_STATE.SPACEBAR)
                {
                    firstFireColorRay = true;
                }
                else
                {
                    return; // you can't fire yet
                }
            }
            else
            {
                firstFireColorRay = true;
            }
        }
        // on my computer if i'm holding UP and LEFT at the same time then SPACEBAR doesn't work
        // but I'm fine using WA or the numberkey pad with numlock off

        //Debug.Log("FireColorRay " + my_facing);
        GameObject beam;

        beam = Instantiate(colorRayPrefabs[(int)my_Color], transform.position, Quaternion.identity) as GameObject;

        float speed = beam.gameObject.GetComponent <ColorRay>().GetSpeed();

        //Debug.Log("myspeed = " + my_speed + " coloray " + speed);
        // ensure colorRay faster than player
        if (speed < my_speed + 5f)
        {
            speed = my_speed + 5f;
        }

        beam.gameObject.GetComponent <ColorRay>().SetColor(my_Color);
        //beam.gameObject.GetComponent<ColorRay>().SetFacing(my_facing);

        //enum Facing { NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST };
        Vector3 facingVector = FacingVector(my_facing);

        beam.GetComponent <Rigidbody2D>().velocity = new Vector2(speed * facingVector.x, speed * facingVector.y);

        AudioSource.PlayClipAtPoint(fireSound, transform.position, PPrefsMgr.GetSfxVolume()); // andrea
    }
Ejemplo n.º 9
0
    void Start()
    {
        if (autoLoadNextLevelDelay > 0) // probably only used for the splash screen
        {
            Invoke("LoadNextLevel", autoLoadNextLevelDelay);
        }

        Debug.Log("******* Level " + GetLevelName() + " *******");
        thisLevel = (LEVELS)SceneManager.GetActiveScene().buildIndex;

        // initial sfx volume from disk
        if (!sfxVolumeInitialized)
        {
            PPrefsMgr.GetSfxVolumeFromDisk();
            sfxVolumeInitialized = true;
        }

        GameObject text = GameObject.Find("LevelName");

        if (text)
        {
            text.GetComponent <Text>().text = GetLevelName();
        }
        else if (IsLevel())
        {
            Debug.LogWarning("no LevelName text gameobject found in canvas");
        }

        StartByLevel();

        GameObject gO = GameObject.Find("AudioAmbient");

        if (gO)
        {
            Debug.LogError("Level " + GetLevelName() + ": AudioAmbient gameobject found, remove from this level");
        }

        //Debug.Log(GetLevelName());
    }
Ejemplo n.º 10
0
/*    private void EndHurt()
 *  {
 *      //isHurt = false;
 *      Animator animator = GetComponent<Animator>();
 *      animator.speed = 1f;
 *  }
 */

    public void TriggerGoal()
    {
        AudioSource.PlayClipAtPoint(successSound, transform.position, PPrefsMgr.GetSfxVolume());
        Invoke("LoadNextScene", .5f); // will load next scene in two seconds
    }
Ejemplo n.º 11
0
 public void SaveAndExit()
 {
     PPrefsMgr.SetMasterVolume(volumeSlider.value);
     PPrefsMgr.SetDifficulty(difficultySlider.value);
     levelManager.LoadLevel("Start");
 }