예제 #1
0
 public override void TStart()
 {
     base.TStart();
     randomTip           = Random.Range(0, tips.Length);
     loadingMessageLabel = null;
     tipMessageLabel     = null;
 }
    public IEnumerator UpdateScreenSpace()
    {
        yield return(new WaitForEndOfFrame());

        myLabel          = null;
        bFullScreen      = Screen.fullScreen;
        lastScreenWidth  = Screen.width;
        lastScreenHeight = Screen.height;
        float ar        = (float)Screen.width / (float)Screen.height;
        float variance2 = ar / 1.5f;

        if (variance2 > 1f)
        {
            variance2   = 1f / variance2;
            screenSpace = new Rect((int)((1f - variance2) / 2f * (float)Screen.width), 0f, (int)((float)Screen.width - (1f - variance2) * (float)Screen.width), Screen.height);
        }
        else if (variance2 < 1f)
        {
            screenSpace = new Rect(0f, (int)((1f - variance2) / 2f * (float)Screen.height), Screen.width, (int)((float)Screen.height - (1f - variance2) * (float)Screen.height));
        }
        else
        {
            screenSpace = new Rect(0f, 0f, Screen.width, Screen.height);
        }
    }
예제 #3
0
 private HeroCard() : base()
 {
     tableLayoutPanel.Controls.Remove(labelRules);
     labelRules = new FormattedLabel
     {
         AutoSize    = true,
         Location    = new Point(58, 127),
         MaximumSize = new Size(165, int.MaxValue),
         Name        = "labelRules",
         Padding     = new Padding(0),
         TabIndex    = 6
     };
     labelRules.Click += ctl_Click;
     tableLayoutPanel.Controls.Add(labelRules, 1, 3);
 }
 private void Start()
 {
     TextScroll = 0f;
     StartCoroutine(UpdateScreenSpace());
     mInstance = this;
     Frame[] array = mFrames;
     foreach (Frame frame in array)
     {
         frame.mText = frame.mText.Replace("[factionname]", GameData.getFactionDisplayName(GameData.MyFactionId));
         frame.mText = frame.mText.Replace("[exosuit]", GameData.getExosuit(GameData.MySuitID).mSuitName);
     }
     base.gameObject.AddComponent <AudioSource>();
     StartCoroutine(SendAvatarMessageSound());
     myLabel = null;
 }
예제 #5
0
        private void OnGUI()
        {
            // Simple GUI to select the text to format
            GUILayout.BeginArea(new Rect(0, 0, Screen.width, 50));
            GUILayout.BeginHorizontal();
            GUILayout.Label("Text:");
            var selectedText = GUILayout.SelectionGrid(
                _selectedText,
                _textLabels,
                _textLabels.Length);

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            // Format the new text
            if (selectedText != _selectedText || _formattedLabelText == null)
            {
                _selectedText = selectedText;
                var testText = (FormattedLabel.TestText)
                               Enum.Parse(typeof(FormattedLabel.TestText),
                                          _textLabels[_selectedText]);
                var textToFormat = FormattedLabel.GetTestText(testText);
                _formattedLabelText = new FormattedLabel(_windowPosition.width,
                                                         textToFormat);
                _formattedLabelText.setHyperlinkCallback(this);
            }

            // Draw the formatted text
            _windowPosition = GUILayout.Window(WINDOW_ID,
                                               _windowPosition,
                                               CreateFormattedLabelWindow,
                                               "Formatted Label");

            // Position and draw the mouse cursor
            var mousePosition = new Rect(Input.mousePosition.x,
                                         Screen.height - Input.mousePosition.y,
                                         _mouseCursorTexture.width,
                                         _mouseCursorTexture.height);

            GUI.Window(MOUSE_WINDOW_ID, mousePosition, CreateMouseCursorWindow, _mouseCursorTexture, "");
        }
    public TabHome(GameHome Parent)
    {
        ModelTransform       = null;
        mGuestFactionTexture = (Resources.Load("Menus/ex_guest_graphic_" + GameData.MyFactionId) as Texture2D);
        GameObject gameObject = GameObject.Find("homeGUI");
        GameHome   gameHome   = gameObject.GetComponent("GameHome") as GameHome;

        if (GameData.DoesEventExist("event_news") && GameData.eventObjects["event_news"] != null)
        {
            TextAsset textAsset = GameData.eventObjects["event_news"] as TextAsset;
            mNewsData = textAsset.text;
            Debug.Log("show news: " + mNewsData);
            bNewsLoaded = true;
            NewsLabel   = null;
        }
        if (!bNewsLoaded)
        {
            gameHome.StartCoroutine(LoadNews());
        }
    }
    public IEnumerator LoadNews()
    {
        bNewsLoaded = false;
        string url2 = string.Empty;

        url2 = ((!Application.isEditor) ? (Application.dataPath + GameData.NEWS_FILE) : ("file://" + Application.dataPath + GameData.NEWS_FILE));
        WWW newsWWW = new WWW(url2);

        yield return(newsWWW);

        if (newsWWW.error == null && !newsWWW.text.Contains("404 Not Found"))
        {
            mNewsData = newsWWW.text;
        }
        else
        {
            mNewsData = string.Empty;
        }
        bNewsLoaded = true;
        NewsLabel   = null;
    }
예제 #8
0
    public static void showLabelFormat(ref FormattedLabel fl, Rect rect, string text, string[] fonts)
    {
        try
        {
            Rect  textRect  = normalizeRectToScreenRect(rect);
            float textWidth = textRect.width;

            if (fl == null)
            {
                fl = new FormattedLabel(textWidth, text.Replace("\\n", "\n"), fonts);
            }

            GUILayout.BeginArea(textRect);
            fl.Draw();
            GUILayout.EndArea();
        }
        catch (System.ArgumentException e)
        {
            if (e != null)
            {
            }
        }
    }
    private void Update()
    {
        if (bFullScreen != Screen.fullScreen || lastScreenWidth != (float)Screen.width || lastScreenHeight != (float)Screen.height)
        {
            StartCoroutine(UpdateScreenSpace());
        }
        Frame frame = GetFrame();

        TextScroll += Time.deltaTime * TextScrollSpeed;
        bool flag = Input.GetKeyUp(KeyCode.Space) || Input.GetKeyUp(KeyCode.Mouse0) || Input.GetKeyUp(KeyCode.Mouse1) || Input.GetKeyUp(KeyCode.Mouse2);

        if (frame == null)
        {
            return;
        }
        if (TextScroll >= (float)frame.mText.Length)
        {
            if (frame.mNextButton && flag)
            {
                myLabel = null;
                mCurrentFrame++;
                TextScroll = 0f;
                StartCoroutine(SendAvatarMessageSound());
                StartCoroutine(ResetScroll());
                flag = false;
            }
        }
        else if (AvatarText.Length > 0 && !base.GetComponent <AudioSource>().isPlaying)
        {
            base.GetComponent <AudioSource>().clip = AvatarText[UnityEngine.Random.Range(0, AvatarText.Length)];
            base.GetComponent <AudioSource>().Play();
        }
        if (flag)
        {
            TextScroll = 10000f;
        }
    }
예제 #10
0
    public void OnGUI()
    {
        GuiUtils.aspectRatio = GuiUtils.AspectRatio.AspectRatio3by2;

        fontInResolution = textFont("[F ButtonFontSmall]", "[F ButtonFontBig]", "[F FontSize24]", "[F FontSize42]");

        timer += Time.deltaTime;

        fontLoading = "[c FFFFFFFF]" + loadingText.text;

        if (timer < 1.0f)
        {
            loadingMessageLabel = null;
            fontLoading        += ".";
        }
        else
        if (timer < 2.0f)
        {
            loadingMessageLabel = null;
            fontLoading        += "..";
        }
        else
        if (timer < 3.0f)
        {
            loadingMessageLabel = null;
            fontLoading        += "...";
        }
        else
        {
            loadingMessageLabel = null;
            timer = 0.0f;
        }

        fontLoading += "[c FFFFFFFF]";


        /*
         * progress +=0.1f;
         *
         * if(progress<0.5f)
         * {
         *      fontLoading = "[c FFFFFFFF]LOADING[c FFFFFFFF]";
         * }
         * else if(progress<4f)
         * {
         *      fontLoading = "[c FFFFFFFF]LOADING.[c FFFFFFFF]";
         * }
         * else if(progress<8f)
         * {
         *      fontLoading = "[c FFFFFFFF]LOADING..[c FFFFFFFF]";
         * }
         * else
         * {
         *      fontLoading = "[c FFFFFFFF]LOADING...[c FFFFFFFF]";
         * }
         *
         * if(progress>15f)
         * {
         *      progress = 0f;
         * }
         */
        showLabelFormat(ref loadingMessageLabel, animText, fontInResolution + fontLoading + fontInResolution, fonts);

        showLabelFormat(ref tipMessageLabel, tipTextRect, fontInResolution + "[c FFFFFFFF][HA C]" + tips[randomTip].text + "[c FFFFFFFF]" + fontInResolution, fonts);
    }
예제 #11
0
    public void drawWindow(GuiUtils.ButtonDelegate onItemSell,
                           GuiUtils.ButtonDelegate onItemSelect,
                           bool showAmmount, bool isBuying)
    {
        nTotalPages = 1 + (items.Count - 1) / maxItemsPerPage;
        currentPage = Mathf.Min(currentPage, nTotalPages - 1);

        float xoffset = 0.0f;
        float yoffset = 0.0f;
        int   i       = 0;

        int itemFrom         = currentPage * maxItemsPerPage;
        int itemTo           = Mathf.Min(((currentPage + 1) * maxItemsPerPage) - 1, items.Count - 1);
        int currentItemIndex = 0;

        foreach (KeyValuePair <Item, int> item in items)
        {
            if (currentItemIndex < itemFrom || currentItemIndex > itemTo)
            {
                currentItemIndex++;
                continue;
            }

            currentItemIndex++;

            GuiUtilButton btn = new GuiUtilButton();

            btn.enabled  = item.Key.icon;
            btn.disabled = item.Key.disabledIcon;

            float x = (float)(i % itemsInXAxis);
            float y = (float)(i / itemsInYAxis);

            xoffset = itemPivotAndSize.x + spaceBetweenButtons.x * x;
            yoffset = itemPivotAndSize.y + spaceBetweenButtons.y * y;

            btn.rect.x      = itemPivotAndSize.x + xoffset;
            btn.rect.y      = itemPivotAndSize.y + yoffset;
            btn.rect.width  = itemPivotAndSize.width;
            btn.rect.height = itemPivotAndSize.height;

            GuiUtils.showButton(btn, true, delegate(Object o){ selectedItem = item.Key; onItemSelect(item.Key); });

            Rect ammountRect = new Rect(_ammountRect);
            ammountRect.x += _shopKeeperWindowAmmountOffsetX + _ammountOffsetX * x;
            ammountRect.y += _ammountOffsetY * y;

            if (selectedItem != null)
            {
                if (item.Key == selectedItem)
                {
                    if (lastSelectedItem != selectedItem)
                    {
                        lastSelectedItem     = selectedItem;
                        itemNameLabel        = null;
                        itemDescriptionLabel = null;
                    }

                    btn.rect.x      -= textureSelectRect.x;
                    btn.rect.y      -= textureSelectRect.y;
                    btn.rect.width  += textureSelectRect.width;
                    btn.rect.height += textureSelectRect.height;

                    GuiUtils.showImage(textureSelect, btn.rect);

                    fontInResolution = GuiUtils.textFont("[F Description]", "[F DescriptionMidle]", "[F DescriptionBig]", "[F DescriptionXXL]");

                    //show item's name
                    GuiUtils.showLabelFormat(ref itemNameLabel, this.infoItemRect, fontInResolution + "[c F8A81CFF][HA L]" + selectedItem.itemNameTranslation.text + fontInResolution, new string[] { "DescriptionMidle", "DescriptionBig", "Description", "DescriptionXXL" });

                    //show item's description
                    string description = fontInResolution + "[c FFFFFFFF]" + selectedItem.descriptionTranslation.text + "[c FFFFFFFF]";

                    Game.fillDescription(ref description, selectedItem.gameObject);

                    GuiUtils.showLabelFormat(ref itemDescriptionLabel, this.infoDescriptionRect, description, new string[] { "DescriptionMidle", "DescriptionBig", "Description", "DescriptionXXL" });

                    infoStyle.font = GuiUtils.styleInResolution(infoStyle, smallFont, midleFont, bigFont, bigXLFont);

                    //show item's coins price
                    if (selectedItem.coinsPrice > 0)
                    {
                        GuiUtils.showImage(this.coinTexture, this.coinTextureRect);
                        if (isBuying)
                        {
                            GuiUtils.showLabel(this.infoPriceRect, selectedItem.coinsPrice.ToString(), infoStyle);
                        }
                        else
                        {
                            GuiUtils.showLabel(this.infoPriceRect, (selectedItem.coinsPrice / 3).ToString(), infoStyle);
                        }
                    }
                    //show item's gems price
                    else if (selectedItem.gemsPrice > 0)
                    {
                        if (isBuying)
                        {
                            GuiUtils.showImage(this.gemTexture, this.coinTextureRect);
                            GuiUtils.showLabel(this.infoPriceRect, selectedItem.gemsPrice.ToString(), infoStyle);
                        }
                        else
                        {
                            GuiUtils.showImage(this.coinTexture, this.coinTextureRect);
                            GuiUtils.showLabel(this.infoPriceRect, (selectedItem.gemsPrice * 80).ToString(), infoStyle);
                        }
                    }

                    //if hero's window
                    if (!isShopKeeper)
                    {
                        GuiUtils.showButton(btnAction, true, this.actionButton, delegate(Object o){ selectedItem = item.Key; onItemSell(item.Key); }, this.btnStyle);
                    }
                    //if keeper's window
                    else
                    {
                        bool canMakeTransaction = false;
                        //if the currency is coins and can be bought
                        if (selectedItem.gemsPrice == 0 && selectedItem.coinsPrice > 0 && selectedItem.coinsPrice <= Game.game.gameStats.coins)
                        {
                            canMakeTransaction = true;
                        }
                        //if the currency is gems and can be bought
                        else if (selectedItem.gemsPrice > 0 && selectedItem.coinsPrice == 0 && selectedItem.gemsPrice <= Game.game.gameStats.gems)
                        {
                            canMakeTransaction = true;
                        }

                        //if transaction can be made
                        if (canMakeTransaction)
                        {
                            GuiUtils.showButton(btnAction, true, this.actionButton, delegate(Object o){ selectedItem = item.Key; onItemSell(item.Key); }, this.btnStyle);
                        }
                        //otherwise
                        else
                        {
                            GuiUtils.showButton(btnAction, false, this.actionButton, delegate(Object o){}, this.btnStyle);
                        }
                    }
                }
            }

            if (showAmmount)
            {
                GuiUtils.showImage(numberValueStyle.normal.background, ammountRect);

                GUIStyle style = new GUIStyle();
                style.normal.textColor = Color.white;
                style.font             = GuiUtils.styleInResolution(style, smallFont, midleFont, bigFont, bigXLFont);
                style.alignment        = TextAnchor.MiddleCenter;

                GuiUtils.showLabel(ammountRect, item.Value.ToString(), style);
            }

            i++;
        }

        if (currentPage < (nTotalPages - 1))
        {
            GuiUtils.showButton(nextPageButton, true, delegate(Object o)
            {
                Game.game.playSound(audioHud.audioPool[9]);
                currentPage++;
            });
        }

        if (currentPage > 0)
        {
            GuiUtils.showButton(prevPageButton, true, delegate(Object o)
            {
                Game.game.playSound(audioHud.audioPool[9]);
                currentPage--;
            });
        }
    }
예제 #12
0
 public void showTab(Rect tabGroup)
 {
     if (NewsLabel == null)
     {
         if (bNewsLoaded)
         {
             NewsLabel = new FormattedLabel(newsGroup.width - 30f, mNewsData);
         }
         else
         {
             NewsLabel = new FormattedLabel(newsGroup.width - 30f, "Loading News");
         }
     }
     if (GameData.getExosuit(GameData.MySuitID) == null)
     {
         Logger.traceError("My Exosuit was Null = " + GameData.MySuitID);
     }
     if (GameData.getExosuit(GameData.MySuitID).getHighPolyModel() != null)
     {
         ModelTransform = GameData.getExosuit(GameData.MySuitID).getHighPolyModel().transform;
     }
     else
     {
         ModelTransform = null;
     }
     if (ModelTransform != null)
     {
         AnimationState animationState = ModelTransform.GetComponent <Animation>()[ModelTransform.GetComponent <Animation>().clip.name];
         if (animationState != null)
         {
             float num = Time.realtimeSinceStartup / animationState.length;
             animationState.time = (num - (float)Mathf.RoundToInt(num)) * animationState.length;
         }
     }
     GUI.color = Color.white;
     GUI.BeginGroup(newsGroup);
     GUI.color = Color.white;
     if (bNewsLoaded)
     {
         float num2 = 5f;
         if (mNewsTexture != null)
         {
             GUI.Box(new Rect(0f, 0f, newsGroup.width, newsGroup.height), GUIContent.none, GUI.skin.GetStyle("BoxTRCutaway"));
             GUI.DrawTexture(new Rect((newsGroup.width - (float)mNewsTexture.width) / 2f, num2, mNewsTexture.width, mNewsTexture.height), mNewsTexture);
             num2 += (float)mNewsTexture.height;
         }
         else
         {
             GUI.Box(new Rect(0f, 0f, newsGroup.width, newsGroup.height), "NEWS", GUI.skin.GetStyle("BoxTRCutaway"));
         }
         if (mNewsData != null && mNewsData.Length > 0)
         {
             GUI.BeginGroup(new Rect(15f, num2 + 10f, newsGroup.width - 30f, newsGroup.height - num2 - 15f));
             NewsLabel.draw();
             GUI.EndGroup();
         }
     }
     else
     {
         GUI.Box(new Rect(0f, 0f, newsGroup.width, newsGroup.height), "LOADING NEWS...", GUI.skin.GetStyle("BoxTRCutaway"));
     }
     GUI.EndGroup();
     GUI.BeginGroup(missionGroup);
     if (GameData.MyPlayStatus == 1)
     {
         GUI.Box(new Rect(0f, 0f, missionGroup.width, missionGroup.height), GUIContent.none, GUI.skin.GetStyle("BoxTRCutaway"));
         GUI.DrawTexture(new Rect(5f, 10f, missionGroup.width - 10f, missionGroup.height - 15f), mGuestFactionTexture);
     }
     else
     {
         GUI.color = Color.white;
         GUI.Label(new Rect(0f, 0f, missionGroup.width, 35f), "MISSIONS", "MissionHeader");
         GUI.Label(new Rect(0f, 37f, missionGroup.width, 15f), "IN PROGRESS", "MissionLabel");
         List <SFSObject> latestMissionsInProgress = GameData.LatestMissionsInProgress;
         if (latestMissionsInProgress.Count > 0)
         {
             SFSObject sFSObject = latestMissionsInProgress[latestMissionsInProgress.Count - 1];
             GUI.Label(new Rect(0f, 50f, missionGroup.width, 56f), sFSObject.GetUtfString("Name"), GUI.skin.GetStyle("MedalBGNew"));
             GUI.Box(new Rect(5f, 53f, missionGroup.width, 50f), GUIContent.none, GUI.skin.GetStyle("MedalGeneric"));
             GUI.Label(new Rect(0f, 53f, missionGroup.width, 50f), sFSObject.GetUtfString("Description"), GUI.skin.GetStyle("MedalDesc"));
             GUIUtil.DrawProgressBar(new Rect(0f, 108f, missionGroup.width, 15f), sFSObject.GetInt("Count"), 0f, sFSObject.GetInt("Total"), GUIUtil.BarDirection.Right, "MissionProgressBG", "MissionProgressBar");
             GUI.Label(new Rect(0f, 110f, missionGroup.width, 16f), sFSObject.GetInt("Count") + "/" + sFSObject.GetInt("Total"), "MissionProgressText");
         }
         else
         {
             GUI.Label(new Rect(0f, 50f, missionGroup.width, 56f), ":(", GUI.skin.GetStyle("MedalBGNew"));
             GUI.Box(new Rect(5f, 53f, missionGroup.width, 50f), GUIContent.none, GUI.skin.GetStyle("MedalGeneric"));
             GUI.Label(new Rect(0f, 53f, missionGroup.width, 50f), "You have no missions in progress", GUI.skin.GetStyle("MedalDesc"));
         }
         GUI.Label(new Rect(0f, 147f, missionGroup.width, 15f), "RECENTLY COMPLETED", "MissionLabel");
         List <SFSObject> latestCompletedMissions = GameData.LatestCompletedMissions;
         if (latestCompletedMissions.Count > 0)
         {
             SFSObject sFSObject2 = latestCompletedMissions[latestCompletedMissions.Count - 1];
             GUI.Label(new Rect(0f, 160f, missionGroup.width, 56f), sFSObject2.GetUtfString("Name"), GUI.skin.GetStyle("MedalBGNew"));
             string utfString = sFSObject2.GetUtfString("Image");
             if (utfString != null && utfString.Length > 0)
             {
                 Texture2D texture2D = Resources.Load("Menus/Medals/" + utfString) as Texture2D;
                 if (texture2D == null)
                 {
                     GUI.Box(new Rect(5f, 163f, missionGroup.width - 8f, 50f), GUIContent.none, GUI.skin.GetStyle("MedalGeneric"));
                 }
                 else
                 {
                     GUI.DrawTexture(new Rect(5f, 163f, 50f, 50f), texture2D);
                 }
             }
             else
             {
                 int @int = sFSObject2.GetInt("Credits");
                 int int2 = sFSObject2.GetInt("XP");
                 if (int2 > 0)
                 {
                     if (@int > 0)
                     {
                         GUI.Box(new Rect(5f, 163f, missionGroup.width - 8f, 50f), GUIContent.none, GUI.skin.GetStyle("XPCreditsMedal"));
                     }
                     else
                     {
                         GUI.Box(new Rect(5f, 163f, missionGroup.width - 8f, 50f), GUIContent.none, GUI.skin.GetStyle("MedalNoReward"));
                     }
                 }
                 else if (@int > 0)
                 {
                     GUI.Box(new Rect(5f, 163f, missionGroup.width - 8f, 50f), GUIContent.none, GUI.skin.GetStyle("CreditsMedal"));
                 }
                 else
                 {
                     GUI.Box(new Rect(5f, 183f, missionGroup.width - 8f, 50f), GUIContent.none, GUI.skin.GetStyle("MedalNoReward"));
                 }
             }
             GUI.Label(new Rect(0f, 163f, missionGroup.width, 50f), sFSObject2.GetUtfString("Description"), GUI.skin.GetStyle("MedalDesc"));
         }
         else
         {
             GUI.Label(new Rect(0f, 160f, missionGroup.width, 56f), ":(", GUI.skin.GetStyle("MedalBGNew"));
             GUI.Box(new Rect(5f, 163f, missionGroup.width, 50f), GUIContent.none, GUI.skin.GetStyle("MedalGeneric"));
             GUI.Label(new Rect(0f, 163f, missionGroup.width, 50f), "You have no recently completed missions", GUI.skin.GetStyle("MedalDesc"));
         }
     }
     GUI.EndGroup();
 }
    private void OnGUI()
    {
        GUI.skin = mSkin;
        if (mCurrentFrame >= mFrames.Length)
        {
            Kill();
            return;
        }
        GUI.BeginGroup(screenSpace);
        Frame frame = GetFrame();

        GUI.depth = 4;
        frame.mBoxSize.PreCalc = frame.mBoxSize.Calculate();
        Rect position = frame.mFocusRect.Calculate();

        if (myLabel == null)
        {
            myLabel = new FormattedLabel(frame.mBoxSize.x - 305f, frame.mText);
        }
        myLabel.mDrawlength = (int)TextScroll;
        switch (frame.mRectType)
        {
        case Frame.RectType.Game_Point:
            if (Camera.main != null)
            {
                Vector3 vector    = Camera.main.WorldToScreenPoint(new Vector3(position.x, position.y, 0f));
                Rect    rect      = new Rect(vector.x - position.width / 2f - screenSpace.x, (float)Screen.height - vector.y - 10f - position.height - screenSpace.y, position.width, position.height);
                Rect    position2 = rect;
                position2.width = rect.width * 8f;
                position2.x     = (float)(-(int)(Time.realtimeSinceStartup * 8f) % 8) * rect.width;
                position2.y     = 0f;
                GUI.BeginGroup(rect);
                GUI.DrawTexture(position2, mArrowTexture[0]);
                GUI.EndGroup();
            }
            break;

        case Frame.RectType.Outline_Box:
            GUI.color = new Color(1f, 1f, 1f, 0.75f + Mathf.Sin(Time.realtimeSinceStartup * 4f) / 4f);
            GUI.Box(position, string.Empty, "GreenOutline");
            GUI.color = Color.white;
            break;

        case Frame.RectType.Arrow_Left:
        {
            Rect pos4 = new Rect(position.x - 138f, position.y + position.height / 2f - 64f, 128f, 128f);
            GUIUtil.DrawAnimatedTexture(pos4, mArrowTexture[1], 8, 8, MirrorX: true, MirrorY: false);
            break;
        }

        case Frame.RectType.Arrow_Right:
        {
            Rect pos3 = new Rect(position.x + position.width + 10f, position.y + position.height / 2f - 64f, 128f, 128f);
            GUIUtil.DrawAnimatedTexture(pos3, mArrowTexture[1], 8, 8, MirrorX: false, MirrorY: false);
            break;
        }

        case Frame.RectType.Arrow_Top:
        {
            Rect pos2 = new Rect(position.x + position.width / 2f - 64f, position.y - 138f, 128f, 128f);
            GUIUtil.DrawAnimatedTexture(pos2, mArrowTexture[0], 8, 8, MirrorX: false, MirrorY: false);
            break;
        }

        case Frame.RectType.Arrow_Bottom:
        {
            Rect pos = new Rect(position.x + position.width / 2f - 64f, position.y + position.height + 10f, 128f, 128f);
            GUIUtil.DrawAnimatedTexture(pos, mArrowTexture[0], 8, 8, MirrorX: false, MirrorY: true);
            break;
        }
        }
        mWindowGroup = GetGroupPos();
        if (frame.mDrawBackdrop)
        {
            Rect position3 = new Rect(0f, 0f, mBGTexture.width, mBGTexture.height);
            while ((float)Screen.width > position3.x)
            {
                GUI.DrawTexture(position3, mBGTexture);
                position3.x += mBGTexture.width;
            }
        }
        GUI.Window(1600, mWindowGroup, DrawDialog, GUIContent.none, GUIStyle.none);
        if (bInFrontOfOptions)
        {
            GUI.BringWindowToFront(1600);
            GUI.FocusWindow(1600);
        }
        else if (DynamicOptions.bDrawing)
        {
            GUI.BringWindowToFront(1500);
            GUI.FocusWindow(1500);
        }
        else if (MessageBox.mMessageBox.Queuesize > 0)
        {
            GUI.BringWindowToFront(1000);
            GUI.FocusWindow(1000);
        }
        GUI.color = Color.white;
        if (frame.mAction == Frame.RequiredAction.Nothing)
        {
            GUI.Button(new Rect(0f, 0f, Screen.width, Screen.height), string.Empty, "invis");
        }
        else
        {
            GUI.Button(new Rect(0f, 0f, position.x, Screen.height), string.Empty, GUIStyle.none);
            GUI.Button(new Rect(position.x + position.width, 0f, (float)Screen.width - (position.x + position.width), Screen.height), string.Empty, GUIStyle.none);
            GUI.Button(new Rect(0f, 0f, Screen.width, position.y), string.Empty, GUIStyle.none);
            GUI.Button(new Rect(0f, position.y + position.height, Screen.width, (float)Screen.height - (position.y + position.height)), string.Empty, GUIStyle.none);
        }
        GUI.EndGroup();
    }
예제 #14
0
    public static void showLabelFormat(Rect rect, string text, string[] fonts)
    {
        FormattedLabel fl = null;

        showLabelFormat(ref fl, rect, text, fonts);
    }
예제 #15
0
    public void showInGameHud()
    {
        Game game = Game.game;

        Game.GameStates currentState = Game.game.currentState;

        if (currentState == Game.GameStates.Town || currentState == Game.GameStates.InTutorialTown)
        {
            if (Screen.height >= 480)
            {
                healthStatBar.fillRect.y     = 0.085f;
                magicStatBar.fillRect.y      = 0.13f;
                experienceStatBar.fillRect.y = 0.176f;
                levelRect.y = 0.235f;

                portraitRect.y = 0.05f;
                infoBarRect.y  = 0.05f;
            }
            else
            {
                healthStatBar.fillRect.y     = 0.13f;
                magicStatBar.fillRect.y      = 0.18f;
                experienceStatBar.fillRect.y = 0.227f;
                levelRect.y = 0.27f;

                portraitRect.y = 0.1f;
                infoBarRect.y  = 0.1f;
            }
        }

        //level of the player
        Rect lvlRect = new Rect(levelRect);

        float h      = (float)Screen.height;
        float w      = (float)Screen.width;
        float aspect = w / h;

        if (aspect > (16.0f / 9.0f))
        {
            float pw = (w - h * 16.0f / 9.0f) * 0.5f;
            lvlRect.x += pw / Screen.width;
        }

        string fontInResolution = textFont("[F ButtonFontBigXL]", "[F ButtonFontBig28]", "[F ButtonFontBig32]", "[F FontSize72]");

        if (lastlvl != game.getPlayerLevel())
        {
            lastlvl  = game.getPlayerLevel();
            lvlLabel = null;
        }

        showLabelFormat(ref lvlLabel, lvlRect, fontInResolution + "[c FFFFFFFF]" + lvlNoCapsString.text + " : " + game.getPlayerLevel().ToString() + fontInResolution,
                        new string[] { "ButtonFontBigXL", "ButtonFontBig28", "ButtonFontBig32", "FontSize72" });
        //health bar
        healthStatBar.fillRect.x      = infoBarRect.x + (originalHealthFillRect.x - infoBarRect.x) * 1.5f * ((float)Screen.height / (float)Screen.width);
        healthStatBar.getCurrentValue = game.getPlayerHealth;
        healthStatBar.getMaximumValue = game.getPlayerMaxHealth;
        healthStatBar.draw();

        //magic bar
        magicStatBar.fillRect.x      = infoBarRect.x + (originalMagicFillRect.x - infoBarRect.x) * 1.5f * ((float)Screen.height / (float)Screen.width);
        magicStatBar.getCurrentValue = game.getPlayerMagic;
        magicStatBar.getMaximumValue = game.getPlayerMaxMagic;
        magicStatBar.draw();

        //exp bar
        experienceStatBar.fillRect.x      = infoBarRect.x + (originalExperienceFillRect.x - infoBarRect.x) * 1.5f * ((float)Screen.height / (float)Screen.width);
        experienceStatBar.getCurrentValue = delegate()
        {
            if (Game.game.gameStats.level < Game.levelCap)
            {
                return(game.getPlayerExperience() - game.getExperienceForCurrentLevel());
            }
            else
            {
                return(1);
            }
        };
        experienceStatBar.getMaximumValue = delegate()
        {
            if (Game.game.gameStats.level < Game.levelCap)
            {
                return(game.getExperienceNeededForNextLevel() - game.getExperienceForCurrentLevel());
            }
            else
            {
                return(1);
            }
        };
        experienceStatBar.draw();

        //hero's icon
        showImage(portrait, portraitRect);

        //hud layout
        showImage(infoBarHero, infoBarRect);

        // Pause Button

        bool inTown            = Game.game.InTown();
        bool townButtonEnabled = TownGui.townButtonsEnabled();

        if (Game.game.pauseButtonEnabled)
        {
            if (!inTown || (inTown && townButtonEnabled))
            {
                showHudButton(pauseButton, true, inventoryActive);
            }
        }

        ButtonDelegate btHealDelegate  = delegate(Object o){};
        ButtonDelegate btMagicDelegate = delegate(Object o){};

        bool canUseHealingPotion = true;
        bool canUseMagicPotion   = true;

        TutSkillAndMagic skillAndMagic = Game.game.GetComponent <TutSkillAndMagic>();

        if (skillAndMagic != null && skillAndMagic.runningTutorial)
        {
            canUseHealingPotion = false;
        }

        if (Game.game.playableCharacter != null)
        {
            if (Game.game.playableCharacter.isAlive())
            {
                //use healing potion
                btHealDelegate = delegate(Object o)
                {
                    if (!inventoryVisible && canUseHealingPotion)
                    {
                        Inventory.inventory.consume(healingPotionItem, 1);
                        Game.game.healingPotionButton = true;
                        if (audioHud != null)
                        {
                            Game.game.playSound(audioHud.audioPool[0]);
                        }
                    }
                };

                //use magic potion
                btMagicDelegate = delegate(Object o)
                {
                    if (!inventoryVisible && canUseMagicPotion)
                    {
                        Inventory.inventory.consume(manaPotionItem, 1);
                        if (audioHud != null)
                        {
                            Game.game.playSound(audioHud.audioPool[1]);
                        }
                    }
                };
            }
        }

        if (!Game.game.InTown())
        {
            //show current buffs
            showBuffStack();

            //enemy life bar
            enemyLifeBar.draw();

            if (Game.game.currentDialog == null)
            {
                itemPotionEnabled  = Inventory.inventory.getItemAmmount(healingPotionItem) > 0;
                magicPotionEnabled = Inventory.inventory.getItemAmmount(manaPotionItem) > 0;
                chestPotionEnabled = true;

                //life potion button
                if (Game.game.healingPotionEnabled)
                {
                    showHudButton(healingPotion, itemPotionEnabled, btHealDelegate);

                    if (Inventory.inventory.getItemAmmount(healingPotionItem) > 0)
                    {
                        potionUseStyle.font = styleInResolution(potionFontStyle, buttonSmall, buttonMidle, buttonBig, buttonBigXXL, 0f);
                        showLabel(healingPotionNRect, Inventory.inventory.getItemAmmount(healingPotionItem).ToString(), potionUseStyle);
                    }
                }
                // if potions > 1


                //magic potion button
                if (Game.game.magicPotionEnabled)
                {
                    showHudButton(magicPotion, magicPotionEnabled, btMagicDelegate);

                    if (Inventory.inventory.getItemAmmount(manaPotionItem) > 0)
                    {
                        potionUseStyle.font = styleInResolution(potionFontStyle, buttonSmall, buttonMidle, buttonBig, buttonBigXXL, 0f);
                        showLabel(manaPotionNRect, Inventory.inventory.getItemAmmount(manaPotionItem).ToString(), potionUseStyle);
                    }
                }

                //open chest button
                if (Game.game.quickChestEnabled)
                {
                    showHudButton(chest, chestPotionEnabled, delegate(Object o)
                    {
                        if (!inventoryVisible)
                        {
                            toogleQuickPotions(null);
                        }
                    }
                                  );
                }

                //skill images
                Texture2D[] currentSkillImages         = new Texture2D[4];
                Texture2D[] currentDisabledSkillImages = new Texture2D[4];

                TexturePool tpool = (Resources.Load("TexturePools/Skills") as GameObject).GetComponent <TexturePool>();

                for (int i = 0; i < 4; i++)
                {
                    if (Game.game.currentSkills[i] != -1)
                    {
                        Texture2D image  = tpool.getFromList(Game.skillData[(int)Game.game.currentSkills[i]].enabled);
                        Texture2D dimage = tpool.getFromList(Game.skillData[(int)Game.game.currentSkills[i]].disabled);

                        currentSkillImages[i]         = image;
                        currentDisabledSkillImages[i] = dimage;
                    }
                }

                skill1.enabled = currentSkillImages[0]; skill1.disabled = currentDisabledSkillImages[0];
                skill2.enabled = currentSkillImages[1]; skill2.disabled = currentDisabledSkillImages[1];
                skill3.enabled = currentSkillImages[2]; skill3.disabled = currentDisabledSkillImages[2];
                skill4.enabled = currentSkillImages[3]; skill4.disabled = currentDisabledSkillImages[3];

                bool canUseSkillButtons = true;

                if (skillAndMagic != null && skillAndMagic.runningTutorial && Game.game.magicPotionEnabled)
                {
                    canUseSkillButtons = false;
                }

                //skills buttons
                showHudButton(skill1, Game.game.canUseSkill((int)Game.game.currentSkills[0]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[0]);
                    }
                });
                showHudButton(skill2, Game.game.canUseSkill((int)Game.game.currentSkills[1]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[1]);
                    }
                });
                showHudButton(skill3, Game.game.canUseSkill((int)Game.game.currentSkills[2]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[2]);
                    }
                });
                showHudButton(skill4, Game.game.canUseSkill((int)Game.game.currentSkills[3]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[3]);
                    }
                });
            }
        }
    }