예제 #1
0
    public static void SetOpacityToGameObject(float opacity, GameObject obj)
    {
        CFontRenderer font = obj.GetComponent <CFontRenderer>();

        if (font != null)
        {
            font.mColor.a = opacity;
            if (opacity <= 0.0f)
            {
                font.setEnabled(false);
            }
            else
            {
                font.setEnabled(true);
            }
        }
        CDiffuseRenderer diffuse = obj.GetComponent <CDiffuseRenderer>();

        if (diffuse != null)
        {
            Color clr = diffuse.GetMaterial().GetColor();
            clr.a = opacity;
            diffuse.GetMaterial().SetColor(clr);

            if (opacity <= 0.0f)
            {
                diffuse.setEnabled(false);
            }
            else
            {
                diffuse.setEnabled(true);
            }
        }
    }
예제 #2
0
    void UpdateScreenFadeScreen(float dt)
    {
        switch (screenFadeState)
        {
        case 0: break;

        case 1:     // Fading to black
            screenFadeOpacity += 1.0f / fadeTotalTime * dt;
            if (screenFadeOpacity >= 1.0f)
            {
                screenFadeOpacity = 1.0f;
                screenFadeState   = 0;   // Stop fading
            }
            Color clr = screenImageMesh.GetMaterial().GetColor();
            clr.a = screenFadeOpacity;
            screenImageMesh.GetMaterial().SetColor(clr);

            Common.SetOpacityToGameObject(screenFadeOpacity, menuPointer);
            break;

        case 2:     // Fading to transparent
            screenFadeOpacity -= 1.0f / fadeTotalTime * dt;
            if (screenFadeOpacity <= 0.0f)
            {
                screenFadeOpacity = 0.0f;
                screenFadeState   = 0;   // Stop fading
            }
            Color color = screenImageMesh.GetMaterial().GetColor();
            color.a = screenFadeOpacity;
            screenImageMesh.GetMaterial().SetColor(color);

            Common.SetOpacityToGameObject(screenFadeOpacity, menuPointer);
            break;
        }
    }
예제 #3
0
    public void OnStart()
    {
        mSound = gameObject.RequireComponent <CSound>();

        // scale should be 0.221f, 0124f
        menuPointer = GameObject.GetGameObjectByName(Common.prefix + menuPointerName);
        menuPointer.transform.SetParent(null);

        Common.SetOpacityToGameObject(0.0f, menuPointer);
        menuPointerInitPos = new Vector3(-2.75f, 1.23f, -0.05f);
        menuPointer.transform.SetPosition(menuPointerInitPos);

        screenImageMesh = gameObject.RequireComponent <CDiffuseRenderer>();
        screenImageMesh.GetMaterial().SetColor(new Color(1.0f, 1.0f, 1.0f, 0.0f));

        optionsPos   = new Vector3(0.0f, -90.0f, 0.0f); // Position to look at options menu
        pauseOptions = Common.GetPauseOptionsScreen().RequireComponent <CDiffuseRenderer>();
        Common.GetPauseOptionsScreen().transform.SetPosition(optionsPos);
        pauseOptions.setEnabled(false);
        GameObject pausePointerObj = Common.GetChildByName(pauseOptions.gameObject, "menuPointer");

        pauseMenuPointer = pausePointerObj.RequireComponent <CDiffuseRenderer>();
        pauseMenuPointer.setEnabled(false);
        Common.GetMenuFullscreenX().setEnabled(false); // Init all options stuff to invisible
        Common.GetMenuMuteX().setEnabled(false);
        Common.GetMenuVolumeFont().setEnabled(false);

        fadeScreen = GameObject.GetGameObjectByName(Common.prefix + fadeScreenName);
        Common.SetOpacityToGameObject(fadeOpacity, fadeScreen); // Start with full black

        optionsFadeScreen = GameObject.GetGameObjectByName(Common.prefix + optionsFadeScreenName);
        Common.SetOpacityToGameObject(fadeOpacity, optionsFadeScreen);

        mLoadingFirstTime  = true;
        mPrevMainMenuState = -1;
        mMainMenuState     = -1;

        mPointerPosition = new List <Vector2>();
        // 0.227, 0.115
        mPointerPosition.Add(new Vector2(-0.0753f, 0.028f));
        mPointerPosition.Add(new Vector2(-0.0753f, 0.0233f));
        mPointerPosition.Add(new Vector2(-0.0753f, 0.0186f));
        mPointerPosition.Add(new Vector2(-0.0753f, 0.0139f));
        mPointerPosition.Add(new Vector2(-0.0753f, -0.0051f)); // wrong

        mPointerPosForMainMenuConfirmation = new List <Vector2>();
        mPointerPosForMainMenuConfirmation.Add(new Vector2(-0.0693f, 0.0043f));
        mPointerPosForMainMenuConfirmation.Add(new Vector2(-0.0693f, -0.0004f));

        mPointerPosForQuitConfirmation = new List <Vector2>();
        mPointerPosForQuitConfirmation.Add(new Vector2(-0.0693f, -0.0145f));
        mPointerPosForQuitConfirmation.Add(new Vector2(-0.0693f, -0.0193f));

        mCurrPointerPos = mPointerPosition[0];

        // When going to How To Play / Options, change camera to Ortho, at (0,0,0), with 0 rotation
        // Bring up the ortho image
    }
예제 #4
0
    // The trigger point when screen is black, and state is changed
    void TriggerOnStartForMainMenu()
    {
        fadeState         = 2; // Fade transparent
        mLoadingFirstTime = false;
        Common.SetOpacityToGameObject(0.0f, menuPointer);

        Common.GetMenuFullscreenX().setEnabled(false);
        Common.GetMenuMuteX().setEnabled(false);
        Common.GetMenuVolumeFont().setEnabled(false);

        switch (mMainMenuState)
        {
        case -1:
            // Set pointer back to where it was clicked into
            menuPointerIndex = (mPrevMainMenuState == -1) ? 0 : mPrevMainMenuState;

            screenImageMesh.GetMaterial().SetTexture("Menu_Main.png");
            Common.SetOpacityToGameObject(1.0f, menuPointer);
            Vector3 currPointerPos = menuPointerInitPos;
            currPointerPos.Y -= (float)menuPointerIndex * amountYToMove;
            menuPointer.transform.SetPosition(currPointerPos);

            fadeTotalTime = 0.25f;     // Faster fade within main menu
            break;

        case (int)Items.I_START:
            Common.Reset();
            Map.LoadOnlyMap("Assets/Levels/tutorial_week12.mocha");
            break;

        case (int)Items.I_HOWTOPLAY:
            if (mPrevMainMenuState != mMainMenuState)     // from main menu
            {
                mHowToPlayState = 0;
            }
            else     // from page 1
            {
                mHowToPlayState = (mHowToPlayState == 0) ? 1 : 0;
            }

            string pngFile = (mHowToPlayState == 0) ? "howtoplay_Stealth.png" : "howtoplay_Surveillance.png";
            screenImageMesh.GetMaterial().SetTexture(pngFile);
            break;

        case (int)Items.I_OPTIONS:
            Common.SetOpacityToGameObject(1.0f, menuPointer);
            mOptionsPointerIndex = 0;
            PositionOptionsPointer(menuPointer, mOptionsPointerIndex, Vector3.Zero);

            Common.GetMenuFullscreenX().setEnabled(Engine.getInstance().GetGameWnd().IsFullScreen());
            Common.GetMenuMuteX().setEnabled(AudioManager.getInstance().GetMuteSound());
            Common.GetMenuVolumeFont().setEnabled(true);
            SetVolumeText();

            screenImageMesh.GetMaterial().SetTexture("Menu_options.png");
            break;

        case (int)Items.I_CREDITS:
            screenImageMesh.GetMaterial().SetTexture("menu_credits.png");
            break;

        case (int)Items.I_QUIT:
            Common.SetOpacityToGameObject(1.0f, menuPointer);
            screenImageMesh.GetMaterial().SetTexture("menu_cod.png");

            PositionMenuPointerForConfirmation(false);     // default at no
            break;
        }
    }