コード例 #1
0
    private static void LoadBackground(BackgroundSet bg)
    {
        if (Camera.main != null)
        {
            Camera.main.backgroundColor = bg.BackgroundColor;
        }

        TryUpdate <TextMeshProUGUI>("Title", t => t.color      = bg.TitleColor);
        TryUpdate <TextMeshProUGUI>("P1Score", t => t.color    = bg.ScoreColor);
        TryUpdate <TextMeshProUGUI>("P2Score", t => t.color    = bg.ScoreColor);
        TryUpdate <SpriteRenderer>("Background", s => s.sprite = bg.BackgroundSprite);
        TryUpdate <SpriteRenderer>("Ball", s =>
        {
            s.sprite = bg.BallSprite;
            s.color  = bg.BallColor;
        });

        TryUpdate <Image>("UI", i => i.color = bg.UiColor);
        TryUpdate <TextMeshProUGUI>("Loading", t => t.color = bg.TitleColor);


        foreach (ISkin s in FindObjectsOfType <MonoBehaviour>().OfType <ISkin>())
        {
            s.Paint(bg);
        }
    }
コード例 #2
0
    void StartTransition()
    {
        // Grab the current background
        currentBackgroundSet.generator.Active = false;
        currentBackgroundSet = backgroundDictionary[currentType];
        currentBackgroundSet.generator.Active = true;

        // Switch textures
        Texture lastTexture = backgroundMaterial.GetTexture(mainTexture);

        if (lastTexture.Equals(currentBackgroundSet.background) == false)
        {
            backgroundMaterial.SetTexture(blendTexture, lastTexture);
            backgroundMaterial.SetTexture(mainTexture, currentBackgroundSet.background);

            // Switch blending factor
            textureTransition = 1f - textureTransition;
            backgroundMaterial.SetFloat(blendFloat, textureTransition);
        }

        // Switch the audio clips
        if (mainBackgroundSoundSource.clip.Equals(currentBackgroundSet.music) == false)
        {
            // Grab the original volume
            volumeTransition = (maxVolume - mainBackgroundSoundSource.volume);

            // Swap the sound source
            playingSource1 = !playingSource1;
            if (playingSource1 == true)
            {
                mainBackgroundSoundSource = soundSource1;
                fadeInSoundSource         = soundSource2;
            }
            else
            {
                mainBackgroundSoundSource = soundSource1;
                fadeInSoundSource         = soundSource2;
            }

            // Update the main sound source, and play it.
            mainBackgroundSoundSource.clip   = currentBackgroundSet.music;
            mainBackgroundSoundSource.volume = volumeTransition;
            mainBackgroundSoundSource.Play();
        }
    }
コード例 #3
0
    // Use this for initialization
    void Awake()
    {
        msInstance = this;

        // Update hue
        hue = Random.value;
        IPowerUp.FromHSV(hue, saturation, brightness, ref backgroundColor);
        mainCamera.backgroundColor = backgroundColor;

        // Fill the dictionary
        currentBackgroundSet = allSets[0];
        backgroundDictionary.Clear();
        for (int index = 0; index < allSets.Length; ++index)
        {
            backgroundDictionary.Add(allSets[index].type, allSets[index]);
        }

        if (backgroundMesh != null)
        {
            // Retrieving the background material
            backgroundMaterial      = backgroundMesh.material;
            backgroundMeshTransform = backgroundMesh.transform;
            meshPosition            = backgroundMeshTransform.position;

            // Grab texture transition
            textureTransition = backgroundMaterial.GetFloat(blendFloat);
            backgroundMaterial.SetTexture(mainTexture, currentBackgroundSet.background);
        }

        // Grab volume transition
        maxVolume        = mainBackgroundSoundSource.volume;
        volumeTransition = maxVolume;
        soundSource1     = mainBackgroundSoundSource;
        soundSource2     = fadeInSoundSource;
        playingSource1   = true;

        // Startup current settings
        currentBackgroundSet.generator.Active = true;
        mainBackgroundSoundSource.clip        = currentBackgroundSet.music;
    }
コード例 #4
0
 public void Paint(BackgroundSet s)
 {
     _gameMode.color = s.UiColor;
     _info.color     = s.UiColor;
 }
コード例 #5
0
 public void Paint(BackgroundSet s)
 {
     _button.GetComponent <Image>().color = s.UiColor;
     title.color       = s.ScoreColor;
     description.color = s.ScoreColor;
 }
コード例 #6
0
 public void Paint(BackgroundSet s)
 {
     GetComponent <Image>().color = s.UiColor;
     GetComponentInChildren <TextMeshProUGUI>().color = s.ScoreColor;
 }