Ejemplo n.º 1
0
    private void _ShowMainMenu()
    {
        // Create main menu stuff
        CToolkitUI ui = CGame.ToolkitUI;

        CJSONParser json       = new CJSONParser();
        CJSONValue  levelArray = json.Parse(CGame.DataDirectory + "campaign.txt");

        GameObject button;

        if (levelArray != null)
        {
            int levelCount = 0;

            for (int i = 0; i < levelArray.GetCount(); ++i)
            {
                CJSONValue level = levelArray[i];

                string levelName = level.GetString("name", "unknown");
                string assetName = level.GetString("asset", "unknown");
                bool   playable  = level.GetBool("playable");
                bool   visible   = level.GetBool("visible");

                if (visible)
                {
                    button = ui.CreateMenuButton(_base, levelName + " (" + assetName + ".pwa)", () =>
                    {
                        CGame.UIManager.PlaySound(CGame.PrimaryResources.AudioClips[15]);
                        _PlayLevel(assetName);
                    }, 1, playable);
                    ui.SetTransform(button, 50, -100 - (levelCount++ *30), 512, 50);
                }
            }
        }

        /*
         * button = CreateButton(_base, "Sample (cutscene)", null);
         * ui.SetTransform(button, 50, -150, 256, 50);
         */

        /*
         * button = CreateButton(_base, "Multiplayer", null);
         * ui.SetTransform(button, 50, -200, 256, 50);
         *
         * button = CreateButton(_base, "Options", null);
         * ui.SetTransform(button, 50, -250, 256, 50);
         */

        button = ui.CreateMenuButton(_base, "Quit", _Exit);
        ui.SetTransform(button, 50, -30, 256, 50);
    }
Ejemplo n.º 2
0
    public CTooltip(CToolkitUI Toolkit, CGameUIStyle Style, GameObject Root)
    {
        _ui    = Toolkit;
        _style = Style;

        _tooltipOverGame = false;
        _tooltip         = _ui.CreateElement(Root, "tooltip");
        _ui.AddImage(_tooltip, _style.TooltipBackground);
        _ui.SetTransform(_tooltip, 0, 0, 256, 256);
        _ui.AddVerticalLayout(_tooltip, new RectOffset(3, 3, 3, 3), 3);
        _tooltip.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        _tooltip.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
        ContentSizeFitter fitter = _tooltip.AddComponent <ContentSizeFitter>();

        fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
        fitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

        float width = 150.0f;

        GameObject title = _ui.CreateTextElement(_tooltip, "Title", "title", CToolkitUI.ETextStyle.TS_HEADING);

        _ui.AddLayout(title, width, -1, -1, -1);

        GameObject details = _ui.CreateTextElement(_tooltip, "Sub-title", "subtitle", CToolkitUI.ETextStyle.TS_DEFAULT);

        _ui.AddLayout(details, width, -1, -1, -1);

        GameObject desc = _ui.CreateTextElement(_tooltip, "Description text that can be longer.", "description", CToolkitUI.ETextStyle.TS_HEADING);

        _ui.AddLayout(desc, width, -1, -1, -1);

        Hide(false);
    }
Ejemplo n.º 3
0
    public CContextMenu(CToolkitUI Toolkit, CGameUIStyle Style, GameObject Root)
    {
        _ui    = Toolkit;
        _style = Style;

        _root = _ui.CreateElement(Root, "contextMenuRoot");
        _ui.AddImage(_root, new Color(0, 0, 0, 0.0f));
        _ui.SetRectFillParent(_root);
        _root.AddComponent <CUIContextMenuOverlay>();

        _contextMenu = _ui.CreateElement(_root, "contextMenu");
        _ui.AddImage(_contextMenu, _style.TooltipBackground);
        _ui.SetTransform(_contextMenu, 0, 0, 128, 256);
        _ui.AddVerticalLayout(_contextMenu, new RectOffset(3, 3, 3, 3), 3);
        _contextMenu.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        _contextMenu.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);

        ContentSizeFitter fitter = _contextMenu.AddComponent <ContentSizeFitter>();

        fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
        fitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

        Hide();
    }
Ejemplo n.º 4
0
    protected override void _Update(CUserSession UserSession)
    {
        CToolkitUI ui = CGame.ToolkitUI;

        // TODO: Do this after we have moved the unit -__-
        Vector3 pivot = _Gob.transform.position;

        mBounds = new Bounds(pivot + new Vector3(0.0f, 0.5f, 0.0f), new Vector3(1.0f, 1.0f, 1.0f));

        if (_carryGOB != null)
        {
            if (!mCarryingPickup)
            {
                GameObject.Destroy(_carryGOB);
            }
            else
            {
                if (mWalking)
                {
                    _carryGOB.transform.localPosition = new Vector3(0.0f, 1.05f + Mathf.Sin(Time.time * 20.0f) * 0.05f, 0.3f);
                }
            }
        }
        else
        {
            if (mCarryingPickup)
            {
                _carryGOB = CGame.AssetManager.GetAsset <CModelAsset>("pickup").mVectorModel.CreateGameObject();
                _carryGOB.GetComponent <MeshRenderer>().material.SetColor("_FloorColor", new Color(150.0f / 255.0f, 150.0f / 255.0f, 150.0f / 255.0f, 1.0f));

                _carryGOB.transform.SetParent(_Gob.transform);
                _carryGOB.transform.localPosition = new Vector3(0.0f, 1.0f, 0.3f);
                _carryGOB.transform.localRotation = Quaternion.Euler(-10, 0, 0);
            }
        }

        // Icon Stack

        /*
         * {
         *      Vector3 screenPos = Camera.main.WorldToScreenPoint(_Gob.transform.position + new Vector3(0.0f, 1.6f, 0.0f));
         *      Vector2 bubbleUIPos = CGame.UIManager.ConvertScreenSpaceToUISpace(new Vector2(screenPos.x, screenPos.y));
         *      ((RectTransform)_iconStackGob.transform).anchoredPosition = bubbleUIPos;
         * }
         * if (_bubbleTime > 0.0f)
         * {
         *      _UIThought.SetActive(true);
         *      _UIThoughtText.text = _thoughtText;
         *
         *      float y = ((RectTransform)_UIThought.transform).anchoredPosition.y;
         *      // TODO: Safegaurd lerp.
         *      y = Mathf.Lerp(y, _iconStackBaselineTarget, 10.0f * Time.deltaTime);
         *      ((RectTransform)_UIThought.transform).anchoredPosition = new Vector2(0.0f, y);
         *      _bubbleTime -= Time.deltaTime;
         * }
         * else
         * {
         *      _UIThought.SetActive(false);
         * }
         *
         * if (_iconSelectorGob != null)
         * {
         *      _iconSelectorLerp -= Time.deltaTime * 7.0f;
         *
         *      if (_iconSelectorLerp < 0.0f)
         *              _iconSelectorLerp = 0.0f;
         *
         *      ((RectTransform)_iconSelectorGob.transform).anchoredPosition = new Vector2(0.0f, Mathf.Sin(Time.time * 10.0f) * 8.0f - 4.0f + 600.0f * CGame.UIResources.UnitIconDropCurve.Evaluate(1.0f - _iconSelectorLerp));
         * }
         */

        /*
         * if (!mDead)
         * {
         *      _HealthBar.SetActive(true);
         *      Vector3 screenPos = Camera.main.WorldToScreenPoint(GetVisualPos() + new Vector3(0.0f, 2.0f, 0.0f));
         *      ((RectTransform)_HealthBar.transform).anchoredPosition = new Vector2((int)screenPos.x, (int)screenPos.y);
         *      _HealthBarFill.transform.localScale = new Vector3(mStamina / mMaxStamina, 1.0f, 1.0f);
         * }
         * else
         * {
         *      _HealthBar.SetActive(false);
         * }
         */

        /*
         * if (mPathing)
         * {
         *      if (mSpeed >= 4.0f)
         *              _footStepAudioTimer += 3.0f * Time.deltaTime;
         *      else if (mSpeed >= 2.0f)
         *              _footStepAudioTimer += 2.2f * Time.deltaTime;
         *      else if (mSpeed > 0.0f)
         *              _footStepAudioTimer += 1.6f * Time.deltaTime;
         *
         *      if (_footStepAudioTimer > 1.0f)
         *      {
         *              _footStepAudioTimer = 0.0f;
         *              PlaySound(0, 6.0f);
         *      }
         *
         *      // Walking
         *
         *      //_Animator.SetFloat("Speed", mSpeed);
         * }
         * else
         * {
         *      _footStepAudioTimer = 0.0f;
         *      //_Animator.SetFloat("Speed", 0.0f);
         * }
         */

        //_Animator.SetBool("Sitting", mSitting);
        //_Animator.SetBool("Dead", mDead);

        /*
         * if (mFrustrated || mEating)
         *      _Animator.SetLayerWeight(1, 1.0f);
         * else
         *      _Animator.SetLayerWeight(1, 0.0f);
         *
         * _Animator.SetBool("Eating", mEating);
         *
         * if (mFrustrated != _oldFrustrated)
         * {
         *      _oldFrustrated = mFrustrated;
         *
         *      if (mFrustrated)
         *              _Animator.SetTrigger("FrustrateTrigger");
         * }
         * */

        //CDebug.DrawZRect(_unit.mBounds.center, 0.1f, 0.01f * _unit.mStamina, Color.red);

        // Interpolate to simulated position
        Vector3 targetPos  = new Vector3(mPosition.x, 0.0f, mPosition.y);
        Vector3 currentPos = _Gob.transform.position;
        Vector3 dir        = targetPos - currentPos;
        float   distance   = dir.magnitude;

        // Teleport to position if we are too far away
        if (distance >= 3.0f)
        {
            currentPos = targetPos;

            // Reset dynamics on teleport
            Transform neck    = _Gob.transform.FindChild("unit_test/Hips/Spine/Chest/Neck");
            Vector3   forward = _Gob.transform.TransformDirection(Vector3.forward);

            _joints[0] = new SDynamicsJoint(neck.position + forward * 0.1f, true);
            _joints[1] = new SDynamicsJoint(_joints[0].mPosition + Vector3.down * 0.13f, false);
            _joints[2] = new SDynamicsJoint(_joints[1].mPosition + Vector3.down * 0.13f, false);
            _joints[3] = new SDynamicsJoint(_joints[2].mPosition + Vector3.down * 0.13f, false);
        }
        else
        {
            currentPos = Vector3.Lerp(currentPos, targetPos, Mathf.Clamp(Time.deltaTime * 10.0f, 0.0f, 1.0f));
        }

        _prevRotation = Quaternion.Slerp(_prevRotation, mRotation, 5.0f * Time.deltaTime);
        //_prevRotation = Quaternion.RotateTowards(_prevRotation, mRotation, 300.0f * Time.deltaTime);
        _Gob.transform.position = currentPos;
        _Gob.transform.rotation = _prevRotation;

        _Animator.speed = 1.0f;

        if (_Animator.isInitialized)
        {
            if (mDead)
            {
                _PlayAnimation("dying_1", -1);
            }
            else if (mActionAnim != "")
            {
                _Animator.speed = mAnimSpeed;
                _PlayAnimation(mActionAnim, -1, false);
            }
            else if (mWalking)
            {
                if (mCarryingPickup)
                {
                    _PlayAnimation("walking_with_item", -1);
                }
                else
                {
                    if (mSpeed > 2.0f)
                    {
                        _PlayAnimation("running_no_item", -1);
                        _Animator.SetFloat("walkSpeed", mSpeed * 0.6f);
                    }
                    else
                    {
                        if (mStamina < 50.0f)
                        {
                            _Animator.SetFloat("walkSpeed", mSpeed * 1.0f);
                            _PlayAnimation("walking_exhausted", -1);
                        }
                        else
                        {
                            _Animator.SetFloat("walkSpeed", mSpeed * 0.5f + 0.5f);
                            _PlayAnimation("walking_no_item", -1);
                        }
                    }
                }
            }
            else if (mAttacking)
            {
                _PlayAnimation("combat_bashing", -1);
            }
            else
            {
                float r = UnityEngine.Random.value;

                if (r > 0.8f)
                {
                    _PlayAnimation("idle_standing_action_1", 1.0f);
                }
                else if (r > 0.6f)
                {
                    _PlayAnimation("idle_standing_action_2", 1.0f);
                }
                else
                {
                    _PlayAnimation("idle_standing_general", 5.0f);
                }
            }
        }

        // Sound
        if (SoundID > SoundLastPlayedID)
        {
            _AudioSource.pitch = CGame.UniversalRandom.GetNextFloat() * 0.5f + 0.75f;
            _AudioSource.PlayOneShot(CGame.Resources.GetAudioClip(SoundType), SoundVolume);
            SoundLastPlayedID = SoundID;
        }

        if (mAssignedDeskID == -1)
        {
            if (_texState != 0)
            {
                _texState = 0;
                _Gob.transform.GetChild(0).GetChild(0).GetComponent <SkinnedMeshRenderer>().material.SetTexture("_MainTex", CGame.PrimaryResources.UnitTexTie);
            }
        }
        else
        {
            if (_texState == 0)
            {
                _texState = 1;
                //_Gob.transform.GetChild(0).GetChild(0).GetComponent<SkinnedMeshRenderer>().material.SetTexture("_MainTex", CGame.PrimaryResources.UnitTexTieArmband);
            }
        }

        // TODO: Hide briefcase when sitting/using?

        /*
         * if (_briefcaseGOB != null)
         * {
         *      if (mAssignedDeskID == -1)
         *      {
         *              _briefcaseGOB.SetActive(true);
         *      }
         *      else
         *      {
         *              _briefcaseGOB.SetActive(false);
         *      }
         * }
         */

        if (mOwner == UserSession.mPlayerIndex)
        {
            if (_indicatorGob == null)
            {
                _indicatorGob = ui.CreateElement(CGame.UIManager.overlayLayer, "indicator");
                ui.SetAnchors(_indicatorGob, Vector2.zero, Vector2.zero, new Vector2(0.5f, 0.0f));
                ui.SetTransform(_indicatorGob, 50, -200, 56, 65);
                Image indImg = _indicatorGob.AddComponent <Image>();
                indImg.color  = new Color(0.2f, 0.2f, 0.2f, 0.5f);
                indImg.sprite = ui.IndicatorBkg;

                GameObject indIcon = ui.CreateElement(_indicatorGob, "icon");
                ui.SetAnchors(indIcon, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f));
                ui.SetTransform(indIcon, 0, 3, 56, 56);
                indImg       = indIcon.AddComponent <Image>();
                indImg.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);

                _indicatorGob.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
                //_indicatorGob.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
            }

            mThoughtTime += Time.deltaTime;

            if (mLastThoughtState != mThoughtState)
            {
                mThoughtTime = 0.0f;
                Image indImg = _indicatorGob.transform.GetChild(0).GetComponent <Image>();
                mLastThoughtState = mThoughtState;

                indImg.sprite = ui.IndicatorNoDesk;
            }

            if (mThoughtTime < 2.0f)
            {
                mThoughtAlpha += Time.deltaTime * 5.0f;
            }
            else
            {
                mThoughtAlpha -= Time.deltaTime * 5.0f;
            }

            mThoughtAlpha = Mathf.Clamp01(mThoughtAlpha);

            if (mThoughtAlpha > 0.0f)
            {
                _indicatorGob.SetActive(true);
                Vector3 screenPos = Camera.main.WorldToScreenPoint(_Gob.transform.position + new Vector3(0.0f, 1.8f, 0.0f));
                ((RectTransform)_indicatorGob.transform).anchoredPosition = new Vector2((int)screenPos.x, (int)screenPos.y);
                _indicatorGob.GetComponent <Image>().color = new Color(0.2f, 0.2f, 0.2f, 0.5f * mThoughtAlpha);
                _indicatorGob.transform.GetChild(0).GetComponent <Image>().color = new Color(1.0f, 1.0f, 1.0f, 1.0f * mThoughtAlpha);
            }
            else
            {
                _indicatorGob.SetActive(false);
            }
        }

        if (mSpeech != "")
        {
            if (mSpeechBubble == null)
            {
                mSpeechBubble = ui.CreateElement(CGame.UIManager.overlayLayer, "speechBubble");
                ui.SetAnchors(mSpeechBubble, Vector2.zero, Vector2.zero, new Vector2(0.5f, 0.0f));
                ui.SetTransform(mSpeechBubble, 50, -200, 100, 20);
                ui.AddImage(mSpeechBubble, new Color(1.0f, 1.0f, 1.0f, 1.0f));
                ui.AddHorizontalLayout(mSpeechBubble, new RectOffset(8, 8, 8, 8));
                ContentSizeFitter fitter = mSpeechBubble.AddComponent <ContentSizeFitter>();
                fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
                fitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

                GameObject text = ui.CreateElement(mSpeechBubble, "text");
                mSpeechBubbleText       = text.AddComponent <Text>();
                mSpeechBubbleText.font  = CGame.GameUIStyle.FontB;
                mSpeechBubbleText.color = CGame.GameUIStyle.ThemeColorC;
                mSpeechBubbleText.text  = "";

                mSpeechTimer = 0;
            }

            Vector3 screenPos = Camera.main.WorldToScreenPoint(_Gob.transform.position + new Vector3(0.0f, 2.0f, 0.0f));
            ((RectTransform)mSpeechBubble.transform).anchoredPosition = new Vector2((int)screenPos.x, (int)screenPos.y);

            while (mSpeechTimer >= 0.03f)
            {
                mSpeechTimer -= 0.03f;

                if (mSpeechBubbleText.text != mSpeech)
                {
                    if (mSpeech.Length < mSpeechBubbleText.text.Length)
                    {
                        mSpeechBubbleText.text = mSpeech[0].ToString();
                    }
                    else
                    {
                        bool match = true;
                        for (int i = 0; i < mSpeechBubbleText.text.Length; ++i)
                        {
                            if (mSpeechBubbleText.text[i] != mSpeech[i])
                            {
                                mSpeechBubbleText.text = mSpeech[0].ToString();
                                match = false;
                                break;
                            }
                        }

                        if (match)
                        {
                            mSpeechBubbleText.text += mSpeech[mSpeechBubbleText.text.Length];
                        }
                    }
                }
            }

            mSpeechTimer += Time.deltaTime;
        }
        else
        {
            GameObject.Destroy(mSpeechBubble);
            mSpeechBubble     = null;
            mSpeechBubbleText = null;
        }

        if (mOwner == UserSession.mPlayerIndex)
        {
            Vector3 pos = _Gob.transform.position;
            CPunchOut.UpdateMesh(_punchOutMesh, _worldView, pos.ToWorldVec2(), 8.0f);
            _punchOut.transform.position = new Vector3(pos.x, 0.0f, pos.z);
            _punchOut.transform.rotation = Quaternion.identity;

            if (mUIEmployeeEntry != null)
            {
                //mUIEmployeeEntry.mStaminaBar.localScale = new Vector3(mStamina / mStats.mMaxStamina, 1, 1);
            }
        }

        /*
         * if (mID == 6)
         * {
         *      CGame.CameraManager.SetTargetPosition(mPosition.ToWorldVec3());
         * }
         */

        _Gob.transform.GetChild(0).GetChild(0).GetComponent <SkinnedMeshRenderer>().material.SetFloat("_Stam", mStamina / 100.0f);
    }
Ejemplo n.º 5
0
    public CUIManager(CToolkitUI Toolkit, CGameUIStyle Style)
    {
        _ui    = Toolkit;
        _style = Style;
        _uiRes = CGame.UIResources;

        mPoseRT = new RenderTexture(512, 512, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
        mPoseRT.antiAliasing = 8;

        gameUI = _ui.CreateElement(_ui.Canvas, "gameUI");
        _ui.SetRectFillParent(gameUI);
        gameUI.transform.SetAsFirstSibling();

        underlayLayer = _ui.CreateElement(gameUI, "underlayLayer");
        _ui.SetRectFillParent(underlayLayer);

        CanvasGroup cgroup = underlayLayer.AddComponent <CanvasGroup>();

        cgroup.blocksRaycasts = false;

        primaryLayer             = _ui.CreateElement(gameUI, "primaryLayer");
        mPrimaryLayerGroup       = primaryLayer.AddComponent <CanvasGroup>();
        mPrimaryLayerGroup.alpha = 1.0f;
        _ui.SetRectFillParent(primaryLayer);

        overlayLayer = _ui.CreateElement(gameUI, "overlayLayer");
        _ui.SetRectFillParent(overlayLayer);

        cgroup = overlayLayer.AddComponent <CanvasGroup>();
        cgroup.blocksRaycasts = false;

        cutsceneLayer = _ui.CreateElement(gameUI, "cutsceneLayer");
        _ui.SetRectFillParent(cutsceneLayer);
        GameObject letterBox = _ui.CreateElement(cutsceneLayer);

        _ui.SetAnchors(letterBox, new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 1));
        _ui.AddImage(letterBox, _style.ThemeColorC);
        _ui.SetTransform(letterBox, 0, 0, 0, 54);

        letterBox = _ui.CreateElement(cutsceneLayer);
        _ui.SetAnchors(letterBox, new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 0));
        _ui.AddImage(letterBox, _style.ThemeColorC);
        _ui.SetTransform(letterBox, 0, 0, 0, 54);

        mCutsceneLayerGroup                = cutsceneLayer.AddComponent <CanvasGroup>();
        mCutsceneLayerGroup.alpha          = 0.0f;
        mCutsceneLayerGroup.blocksRaycasts = false;

        /*
         * fadeOverLayer = _ui.CreateElement(gameUI, "fadeOverLayer");
         * _ui.SetRectFillParent(fadeOverLayer);
         * _ui.AddImage(fadeOverLayer, Color.black);
         */

        contextMenuLayer = _ui.CreateElement(gameUI, "contextMenuLayer");
        _ui.SetRectFillParent(contextMenuLayer);

        mMenuLayer = _ui.CreateElement(gameUI, "menuLayer");
        _ui.SetRectFillParent(mMenuLayer);

        GameObject productText = _ui.CreateTextElement(overlayLayer, CGame.PRODUCT_NAME + " (" + CGame.VERSION_MAJOR + "." + CGame.VERSION_MINOR + ") " + CGame.VERSION_NAME, "productText", CToolkitUI.ETextStyle.TS_HEADING);

        _ui.SetAnchors(productText, new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 1));
        _ui.SetTransform(productText, 5, 0, -10, 20);
        productText.GetComponent <Text>().alignment = TextAnchor.MiddleRight;

        mContextMenu = new CContextMenu(Toolkit, Style, contextMenuLayer);
        mTooltip     = new CTooltip(Toolkit, Style, overlayLayer);

        SetupForGameSession();
    }
Ejemplo n.º 6
0
    public void ShowErrorMessage(string Message, string Title)
    {
        if (mErrorMessageBox != null)
        {
            GameObject.Destroy(mErrorMessageBox);
        }

        mErrorMessageBox = _ui.CreateElement(mMenuLayer, "ErrorMessage");
        //errorMsg.SetActive(false);
        _ui.AddImage(mErrorMessageBox, _style.TooltipBackground);
        _ui.SetAnchors(mErrorMessageBox, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f));
        _ui.SetTransform(mErrorMessageBox, 0, 0, 600, 256);
        _ui.AddVerticalLayout(mErrorMessageBox).childForceExpandWidth   = true;
        mErrorMessageBox.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;

        GameObject titleBar = _ui.CreateElement(mErrorMessageBox, "TitleBar");

        _ui.AddImage(titleBar, _style.ThemeColorC);
        _ui.SetAnchors(titleBar, new Vector2(0.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, 1.0f));
        _ui.AddLayout(titleBar, -1, 30, -1, -1);
        //_ui.SetTransform(optsTitle, 0, 0, 0, 26);

        GameObject titleText = _ui.CreateElement(titleBar);

        _ui.SetAnchors(titleText, new Vector2(0.0f, 0.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, 1.0f));
        _ui.SetTransform(titleText, 5, 0, -10, 0);
        Text optsTitleTextComp = titleText.AddComponent <Text>();

        optsTitleTextComp.text      = Title;
        optsTitleTextComp.font      = _style.FontA;
        optsTitleTextComp.alignment = TextAnchor.MiddleLeft;


        GameObject messageBody = _ui.CreateElement(mErrorMessageBox, "MsgBorder");

        _ui.AddVerticalLayout(messageBody, new RectOffset(10, 10, 10, 10));

        GameObject message = _ui.CreateElement(messageBody);
        //_ui.SetAnchors(optsTitleText, new Vector2(0.0f, 0.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, 1.0f));
        //_ui.SetTransform(optsTitleText, 5, 0, -10, 0);
        Text messageTextComp = message.AddComponent <Text>();

        messageTextComp.text = Message;
        messageTextComp.font = _style.FontA;
        //messageTextComp.alignment = TextAnchor.MiddleLeft;

        // TODO: This message should be removed when session terminated with other game related UI.

        /*
         * GameObject button = _ui.CreateMenuButton(errorMsg, "Exit", () => {
         *      GameObject.Destroy(errorMsg);
         *      CGame.UIManager.PlaySound(CGame.PrimaryResources.AudioClips[15]);
         *      CGame.Game.TerminateGameSession();
         *      CGame.UIManager.AddInterface(new CMainMenuUI());
         * });
         * _ui.SetTransform(button, 50, -100, 256, 50);
         */

        GameObject button = _ui.CreateButton(mErrorMessageBox, "Close", () => {
            GameObject.Destroy(mErrorMessageBox);
            mErrorMessageBox = null;
            CGame.UIManager.PlaySound(CGame.PrimaryResources.AudioClips[15]);
        });

        _ui.AddLayout(button, -1, 20, 1.0f, -1);
    }