Base class for all elements in the HUD.
Inheritance: MonoBehaviour
示例#1
0
        private async Task DoCompileAndTest(HUDElement spinner)
        {
            try
            {
                var lvl = await Task.Run(() => LevelData.CompileToBlueprint(HUD));

                if (lvl == null)
                {
                    return;
                }

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new LevelEditorTestConfirmPanel(lvl, LevelData), true, 0.7f);
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("LEMP::DCAT", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_CPP_COMERR,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);
                });
            }
        }
示例#2
0
    /// <summary>
    /// Generate new HUD Element & push it into Stack container
    /// </summary>
    /// <param name="hudElement"></param>
    /// <returns></returns>
    public HUDElement GenHUDElements(HUDElement hudElement)
    {
        HUDElement genHUDElement = Instantiate(hudElement.gameObject, transform).GetComponent <HUDElement>();

        genHUDElement.OnHUDCreate(this);
        m_StackHUDElements.Push(genHUDElement);
        return(genHUDElement);
    }
示例#3
0
 /// <summary>
 /// Pop HUD Element out of Stack container
 /// </summary>
 public void PopHUDElements()
 {
     if (m_StackHUDElements.Count > 0)
     {
         HUDElement hudElement = m_StackHUDElements.Pop();
         hudElement.OnHUDDestroy();
     }
 }
        ////////////////

        public override Vector2 GetDisplacementDirection(HUDElement against)
        {
            if (this.DisplacementOverride != null)
            {
                return(this.DisplacementOverride());
            }
            return(base.GetDisplacementDirection(against));
        }
示例#5
0
        public override void InitHUD()
        {
            base.InitHUD();
            //Re-orient title and subtitle to be towards the top of the screen
            titleText.relativePosition    += new Vector2(0, 40);
            titleText.relativeAnchor       = new Vector2(0.5f, 0.1f);
            subtitleText.relativePosition += new Vector2(0, 40);
            subtitleText.relativeAnchor    = new Vector2(0.5f, 0.1f);

            highScoreTitle = new HUDElement("High   Scores:", Vector2.Zero);
            highScoreTitle.relativeAnchor = new Vector2(0.5f, 0.5f);
            highScoreTitle.alignment      = new Vector2(0.5f);
            hudManager.AddElement(highScoreTitle);

            var currentScore = GameEventManager.Instance.score;

            currentScoreText = new HUDElement("Score:   " + currentScore.ToString(), new Vector2(0, -40));
            currentScoreText.relativeAnchor = new Vector2(0.5f, 0.5f);
            currentScoreText.alignment      = new Vector2(0.5f);
            hudManager.AddElement(currentScoreText);

            resetText = new HUDElement("Press   R    to    reset    scoreboard", new Vector2(0, -40));
            resetText.relativeAnchor = new Vector2(0.5f, 1.0f);
            resetText.alignment      = new Vector2(0.5f);
            hudManager.AddElement(resetText);

            //Set up the list of high scores
            var highScoreData = GameData.GetHighScoreData();

            if (highScoreData == null)
            {
                highScoreData = new HighScoreData();
            }

            highScoreData.Update(currentScore);

            float spacing = 40.0f;

            //Create spaced list of high scores
            for (int i = 0; i < highScoreData.scores.Length; i++)
            {
                var amount = highScoreData.scores[i];

                HUDElement scoreText = new HUDElement(amount.ToString(), new Vector2(0, spacing * i));
                scoreText.relativeAnchor = new Vector2(0.5f, 0.6f);
                scoreText.alignment      = new Vector2(0.5f);

                highScoreTexts.Add(scoreText);
                hudManager.AddElement(scoreText);
            }

            highScoreData.Save();

            //Score has been recorded if relevant, now reset
            GameEventManager.Instance.ResetScore();
        }
        public override void InitHUD()
        {
            base.InitHUD();

            scoreText  = new HUDElement("Score:    0", new Vector2(0, 0));
            healthText = new HUDElement("Health:    " + GameData.Instance.playerData.startHealth.ToString(), new Vector2(0, 30));

            hudManager.AddElement(scoreText);
            hudManager.AddElement(healthText);
        }
示例#7
0
 public virtual void OnHUDContDestroy()
 {
     // remove all of elements
     while (m_StackHUDElements.Count > 0)
     {
         HUDElement hudElement = m_StackHUDElements.Pop();
         hudElement.OnHUDDestroy();
         Destroy(hudElement.gameObject);
     }
 }
示例#8
0
        public HUD()
        {
            bottomBar = new HUDElement(new Rectangle(0, GameData.ScreenHeight - PercentageH(0.1f), GameData.ScreenWidth, PercentageH(0.1f)), new Color(0, 58, 88, 255));

            healthBar = new StatusBar(new Rectangle(PercentageW(0.1f), GameData.ScreenHeight - PercentageH(0.065f), 100, PercentageH(0.025f)), new Color(175, 10, 10, 255));
            healthBar.SetStatusString("HP:", 30, PercentageW(0.05f));

            staminaBar = new StatusBar(new Rectangle(PercentageW(0.32f), GameData.ScreenHeight - PercentageH(0.065f), 100, PercentageH(0.025f)), new Color(255, 229, 58, 255));
            staminaBar.SetStatusString("AMMO:", 30, PercentageW(0.1f));
        }
示例#9
0
 public override void AddElement(HUDElement e)
 {
     if (ChildrenCount == 0)
     {
         base.AddElement(e);
     }
     else
     {
         SAMLog.Error("SAM_INTERNAL", "Cannot add more than one element to HUDModalDialog");
     }
 }
示例#10
0
        public HUDModalDialog(int d, HUDElement child, float dimFactor, float dimTime, bool removeOnOOBorBack)
        {
            Depth = d;

            _initElement          = child;
            _initElementInterface = child as IHUDModalChild;

            _removeOnOutOfBoundsClick = removeOnOOBorBack;
            _removeOnBackKey          = removeOnOOBorBack;
            _dimFactor = dimFactor;
            _dimTime   = dimTime;
        }
示例#11
0
        /// <summary>
        /// Updates a HUD element
        /// </summary>
        /// <param name="element">The element to update</param>
        /// <param name="content">The content to update the element with</param>
        private void UpdateElement(HUDElement element, string content)
        {
            if (element == HUDElement.armor)
            {
                armorText.text = content;
            }

            else if (element == HUDElement.shield)
            {
                shieldText.text = content;
            }
        }
示例#12
0
        public void SetElement(HUDElement e)
        {
            ClearChildren();

            base.AddElement(e);

            var c = Child;

            if (c != null)
            {
                c.Alignment        = HUDAlignment.CENTER;
                c.RelativePosition = FPoint.Zero;
                c.Size             = this.Size;
            }
        }
示例#13
0
        public virtual void AddElement(HUDElement e)
        {
            if (!Initialized)
            {
                queuedChildren.Enqueue(e);
                return;
            }

            e.Owner = this;
            e.HUD   = HUD;
            children.Add(e);
            e.Initialize();

            OnChildrenChanged();
        }
示例#14
0
        public override void InitHUD()
        {
            base.InitHUD();
            titleText = new HUDElement(title, new Vector2(0, -30));
            titleText.relativeAnchor = new Vector2(0.5f, 0.5f); //Center of screen
            titleText.alignment      = new Vector2(0.5f, 0.5f); //Center text
            titleText.scale          = 2.0f;

            subtitleText = new HUDElement(subtitle, new Vector2(0, 40));
            subtitleText.relativeAnchor = new Vector2(0.5f, 0.5f); //Center of screen
            subtitleText.alignment      = new Vector2(0.5f, 0.5f); //Center text
            subtitleText.scale          = 1.0f;

            hudManager.AddElement(titleText);
            hudManager.AddElement(subtitleText);
        }
示例#15
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return) && transform.Find("Button_Login").GetComponent <HUDElement>().active)
        {
            LoginFunc();
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            HUDElement element = transform.Find("InputMail").GetComponent <HUDElement>();
            if (element.active)
            {
                SetFocus("InputPassword");
            }
        }
    }
示例#16
0
        private async Task CreateNewUserLevelInternal(HUDElement spinner)
        {
            try
            {
                var r = await MainGame.Inst.Backend.GetNewCustomLevelID(MainGame.Inst.Profile);

                if (!r.Item1)
                {
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_CPP_COMERR,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                    });
                    return;
                }

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    MainGame.Inst.SetLevelEditorScreen(new SCCMLevelData(r.Item2, MainGame.Inst.Profile.OnlineUserID));
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("SCCMLENUL::DL", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_CPP_COMERR,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);
                });
            }
        }
示例#17
0
    // Update is called once per frame
    void Update()
    {
        // close info box on first click since it has been awaken
        if (Input.GetMouseButtonDown(0))
        {
            // start game by activating the gamecontroller
            gameController.SetActive(true);
            // allow camera movement
            cameraController.enabled = true;

            // Show HUD elements
            foreach (var HUDElement in HUDElementsToShow)
            {
                HUDElement.SetActive(true);
            }

            // trigger closing animation
            animator.SetTrigger("CloseTrigger");
        }
    }
示例#18
0
        public override void InitHUD()
        {
            base.InitHUD();

            //Re-orient title and subtitle to be towards the top of the screen
            titleText.relativePosition    += new Vector2(0, 40);
            titleText.relativeAnchor       = new Vector2(0.5f, 0.1f);
            subtitleText.relativePosition += new Vector2(0, 40);
            subtitleText.relativeAnchor    = new Vector2(0.5f, 0.1f);


            string controlsString = "Controls:\n" +
                                    "A->move    left\n" +
                                    "D->move    right\n" +
                                    "SPACE->jump\n" +
                                    "LMB->shoot    (if    possible)";

            controlsText           = new HUDElement(controlsString, Vector2.Zero, Color.White, new Vector2(0.5f, 0.4f), 1);
            controlsText.alignment = new Vector2(0.5f, 0);
            hudManager.AddElement(controlsText);
        }
示例#19
0
 public void Add(string type, string key, HUDElement value)
 {
     //Debug.Log("###### adding element: " + key);
     if (T_elements.ContainsKey(type))
     {
         if (!T_elements[type].ContainsKey(key))
         {
             T_elements[type].Add(key, value);
         }
         else
         {
             //Debug.LogWarning("Key " + key + " already exists, creating new");
             ((Component)value).name += " " + 1;
             Add(type, ((Component)value).name, value);
         }
     }
     else
     {
         T_elements.Add(type, new Dictionary <string, HUDElement>());
         T_elements[type].Add(key, value);
     }
 }
示例#20
0
    public void registerElement(Type_HUD key, HUDElement element)
    {
        if (elements == null)
        {
            elements = new Dictionary <Type_HUD, HUDElement>();
        }

        elements.Add(key, element);

        if (key == Type_HUD.Jinjo_Violet_On ||
            key == Type_HUD.Jinjo_Yellow_On ||
            key == Type_HUD.Jinjo_Orange_On ||
            key == Type_HUD.Jinjo_Green_On ||
            key == Type_HUD.Jinjo_Blue_On ||
            key == Type_HUD.Jinjo_Black_On)
        {
            element.SetEnable(false);
        }

        if (key == Type_HUD.Pause)
        {
            element.displayGroup(false, .0f, false, false);
        }

        if (key == Type_HUD.GameOver)
        {
            element.displayGroup(false, .0f, false, false);
        }

        if (key == Type_HUD.End)
        {
            element.displayGroup(false, .0f, false, false);
        }

        if (key == Type_HUD.MusicControl)
        {
            element.initMusicControl(mixer_groups);
        }
    }
示例#21
0
 public void ShowHideHUD()
 {
     if (m_HUDEnabled)
     {
         foreach (GameObject HUDElement in m_HUDElements)
         {
             HUDElement.SetActive(false);
         }
         GameObject.Find("HUDOnText").GetComponent <RawImage> ().enabled  = false;
         GameObject.Find("HUDOffText").GetComponent <RawImage> ().enabled = true;
         m_HUDEnabled = false;
     }
     else
     {
         foreach (GameObject HUDElement in m_HUDElements)
         {
             HUDElement.SetActive(true);
         }
         GameObject.Find("HUDOnText").GetComponent <RawImage> ().enabled  = true;
         GameObject.Find("HUDOffText").GetComponent <RawImage> ().enabled = false;
         m_HUDEnabled = true;
     }
 }
示例#22
0
    public void setHUDElement(string elementName)
    {
        hudElement = elementName;

        if (!SceneManager.GetActiveScene().name.Contains("Menu"))
        {
            if (hudElement.Equals("armor"))
            {
                elementToUpdate = GameObject.Find("Armor Gauge Canvas").GetComponent<HUDElement>();
            }
            else if (hudElement.Equals("shield"))
            {
                elementToUpdate = GameObject.Find("Shield").GetComponent<HUDElement>();
            }
            else if (hudElement.Equals("powerup"))
            {
                elementToUpdate = GameObject.Find("Powerup Gauge Canvas").GetComponent<HUDElement>();
            }
            else if (hudElement.Equals("bomb"))
            {
                elementToUpdate = GameObject.FindGameObjectWithTag("Bomb").GetComponent<HUDElement>();
            }
        }
    }
示例#23
0
 public static HUDElement[] Add(HUDElement n, HUDElement[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(HUDElement str in list) tmp.Add(str);
     tmp.Add(n);
     return tmp.ToArray(typeof(HUDElement)) as HUDElement[];
 }
示例#24
0
 public static HUDElement[] Remove(int index, HUDElement[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(HUDElement str in list) tmp.Add(str);
     tmp.RemoveAt(index);
     return tmp.ToArray(typeof(HUDElement)) as HUDElement[];
 }
        private async Task DoSignup(HUDElement spinner, string username, string password)
        {
            try
            {
                var profile = MainGame.Inst.Profile;

                var r = await MainGame.Inst.Backend.UpgradeUser(profile, username, password);

                switch (r.Item1)
                {
                case UpgradeResult.Success:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(3, 1, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_ACCCREATED,
                            TextColor    = FlatColors.TextHUD,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),
                            CloseOnClick = true,
                        }, true);

                        Remove();
                    });
                    break;

                case UpgradeResult.UsernameTaken:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_USERTAKEN,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                    });
                    break;

                case UpgradeResult.AlreadyFullAcc:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_ALREADYCREATED,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case UpgradeResult.InternalError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(10, 2, 0.3f)
                        {
                            Text         = r.Item2,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case UpgradeResult.NoConnection:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_NOCOM,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case UpgradeResult.AuthError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_AUTHERROR,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                SAMLog.Error("CreateAccount", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText     = L10NImpl.STR_AAP_COULDNOTCREATE,
                        TextColor    = FlatColors.Clouds,
                        Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
        }
        private async Task DoUploadInternal(HUDElement spinner)
        {
            try
            {
                byte[] binData;
                using (var ms = new MemoryStream())
                    using (var bw = new BinaryWriter(ms))
                    {
                        Level.BinarySerialize(bw, true, GDConstants.LevelIntVersion, MainGame.Inst.Profile.OnlineUserID, SCCMData.OnlineID);
                        binData = ms.ToArray();
                    }

                var result = await MainGame.Inst.Backend.UploadUserLevel(MainGame.Inst.Profile, Level, SCCMData, binData, Time);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();

                    switch (result)
                    {
                    case UploadResult.InternalError:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_INTERNAL,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.NoConnection:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_CPP_COMERR,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.FileTooBig:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_FILETOOBIG,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.WrongUserID:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_WRONGUSER,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.LevelIDNotFound:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_LIDNOTFOUND,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.InvalidName:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_INVALIDNAME,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.DuplicateName:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_DUPLNAME,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.AlreadyUploaded:
                    case UploadResult.Success:
                        SCCMUtils.UpgradeLevel(SCCMData, binData);

                        MainGame.Inst.GetCurrentScreen().HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLED_UPLOAD_FIN,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),

                            CloseOnClick = true,
                        }, true);

                        MainGame.Inst.SetOverworldScreenWithSCCM(SCCMMainPanel.SCCMTab.MyLevels);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("SCCMUSP::DUI", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_CPP_COMERR,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);
                });
            }
        }
示例#27
0
 public void RemoveChild(HUDElement c)
 {
     children.Remove(c);
 }
示例#28
0
 public void OnEnd(HUDElement element)
 {
     OnEnd((TElement)element);
 }
示例#29
0
        private async Task DoChangePassword(HUDElement spinner, string newPassword)
        {
            try
            {
                var profile = MainGame.Inst.Profile;

                var r = await MainGame.Inst.Backend.ChangePassword(profile, newPassword);

                switch (r.Item1)
                {
                case ChangePasswordResult.Success:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(3, 1, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_CPP_CHANGED,
                            TextColor    = FlatColors.TextHUD,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),
                            CloseOnClick = true,
                        }, true);

                        Remove();
                    });
                    break;

                case ChangePasswordResult.InternalError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(10, 2, 0.3f)
                        {
                            Text         = r.Item2,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case ChangePasswordResult.NoConnection:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_CPP_COMERR,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case ChangePasswordResult.AuthError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_CPP_AUTHERR,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                SAMLog.Error("ChangePassword", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText     = L10NImpl.STR_CPP_CHANGEERR,
                        TextColor    = FlatColors.Clouds,
                        Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
        }
示例#30
0
 /// <summary>
 /// Push HUD Element into Stack container
 /// </summary>
 /// <param name="hudElement"></param>
 public void PushHUDElements(HUDElement hudElement)
 {
     hudElement.OnHUDCreate(this);
     m_StackHUDElements.Push(hudElement);
 }
        private async Task DoLogin(HUDElement spinner, string username, string password)
        {
            try
            {
                var profile = MainGame.Inst.Profile;

                var r = await MainGame.Inst.Backend.MergeLogin(profile, username, password);

                var verifyResult = r.Item1;

                if (verifyResult != VerifyResult.Success)
                {
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        var text = "???";
                        if (verifyResult == VerifyResult.InternalError)
                        {
                            text = r.Item2;
                        }
                        if (verifyResult == VerifyResult.WrongPassword)
                        {
                            text = L10N.T(L10NImpl.STR_AAP_WRONGPW);
                        }
                        if (verifyResult == VerifyResult.WrongUsername)
                        {
                            text = L10N.T(L10NImpl.STR_AAP_USERNOTFOUND);
                        }
                        if (verifyResult == VerifyResult.NoConnection)
                        {
                            text = L10N.T(L10NImpl.STR_AAP_NOCOM);
                        }

                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            Text       = text,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);

                        Remove();
                    });
                    return;
                }

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();

                    MainGame.Inst.SetOverworldScreenCopy(HUD.Screen as GDOverworldScreen);
                    var screen = MainGame.Inst.GetCurrentScreen();
                    screen?.HUD?.AddModal(new HUDFadeOutInfoBox(3, 1, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_AAP_LOGINSUCCESS,
                        TextColor  = FlatColors.TextHUD,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),

                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("Login", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_AAP_NOLOGIN,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
        }
示例#32
0
 /// <summary>
 /// Can be used to notify the HUD to update an element
 /// </summary>
 /// <param name="element">The element to update</param>
 /// <param name="content">The content to update the element with</param>
 public void UpdateHUDElement(HUDElement element, string content)
 {
     OnUpdateHUDElement(element, content);
 }
示例#33
0
 public static IGDGameHUD GDHUD(this HUDElement e) => (IGDGameHUD)e.HUD;