Example #1
0
        internal static void Load(Level context)
        {
            FrostbyteLevel l = context as FrostbyteLevel;
            l.Theme = Element.None;
            LevelInitTime = TimeSpan.MinValue;

            Viewport v = This.Game.GraphicsDevice.Viewport;

            /** load music */
            This.Game.AudioManager.AddBackgroundMusic("Music/TitleScreenBG");
            This.Game.AudioManager.PlayBackgroundMusic("Music/TitleScreenBG", 0.1f);

            Text title = new Text("titletext", "Fonts/Title", "4Realms");
            title.CenterOn(new Vector2(v.Width / 2, v.Height / 2));
            title.Static = true;
            title.DisplayColor = Color.DodgerBlue;

            context.GetTexture("regen");
            RestorePlayerHealthTrigger t = new RestorePlayerHealthTrigger("trigger", v.Width);
            t.SpawnPoint = new Vector2(v.Width / 2, v.Height / 1.2f);

            if (GamePad.GetState(PlayerIndex.One).IsConnected)
            {
                gamePads.Add(new GamePadController(PlayerIndex.One));
            }
            if (GamePad.GetState(PlayerIndex.Two).IsConnected)
            {
                gamePads.Add(new GamePadController(PlayerIndex.Two));
            }
        }
Example #2
0
File: HUD.cs Project: nemec/4Realms
        internal void update()
        {
            tickCount = (tickCount + 1) % TicksPerScroll;
            if (onScreen.Count > 0 && tickCount == 0)
            {
                foreach (Text t in onScreen)
                {
                    t.Pos.Y -= 1;
                }

                Sprite fst = onScreen.First();
                if (fst.Pos.Y < Pos.Y)
                {
                    This.Game.CurrentLevel.RemoveSprite(fst);
                    onScreen.RemoveAt(0);
                }
            }
            if (buffer.Count != 0)
            {
                // We have room to scroll another line of text
                if (onScreen.Count == 0 ||
                    onScreen.Last().Pos.Y + onScreen.Last().GetAnimation().Height + TextSpacing <
                        Pos.Y + GetAnimation().Height - onScreen.Last().GetAnimation().Height)
                {
                    int width = GetAnimation().Width;
                    string toDisplay;

                    if (String.Join("", buffer.Take(2)) == "\n\n")
                    {
                        toDisplay = " ";
                        buffer.RemoveRange(0, 2);
                    }
                    else
                    {
                        buffer = buffer.SkipWhile(x => char.IsWhiteSpace(x)).ToList();
                        IEnumerable<char> pendingDisplay = buffer.TakeWhile((ch, ix) =>
                            theme.TextFont.MeasureString(
                                String.Join("", buffer.Take(ix + 1)).Trim()).X < width &&
                            ch != '\n');

                        if (SplitOnWhitespace &&
                            buffer.Count > pendingDisplay.Count() &&
                            buffer[pendingDisplay.Count()] != '\n')
                        {
                            // Find first instance of whitespace at end
                            pendingDisplay = pendingDisplay.Reverse().SkipWhile(x => !char.IsWhiteSpace(x)).Reverse();
                        }

                        toDisplay = String.Join("", pendingDisplay).Trim();
                        buffer.RemoveRange(0, pendingDisplay.Count());
                    }

                    Text line = new Text("text", theme.TextFont, toDisplay.ToString());
                    line.DisplayColor = theme.TextColor;
                    line.Pos = new Vector2(Pos.X, Pos.Y + GetAnimation().Height - line.GetAnimation().Height);
                    line.Static = true;
                    line.ZOrder = 101;
                    onScreen.Add(line);
                }
            }
        }
Example #3
0
File: HUD.cs Project: nemec/4Realms
        internal TextFader(string name, IHUDTheme theme, int width, int height)
            : base(name, new Actor(new DummyAnimation(name, width, height)))
        {
            ZOrder = 100;
            UpdateBehavior = update;
            this.theme = theme;
            Center = new Vector2(0, 0);
            Anchor = Orientations.Left;

            pendingText = new Queue<string>();
            mStates = States().GetEnumerator();

            toDisplay = new Text("fader_text", theme.TextFont, "");
            toDisplay.Visible = false;
            toDisplay.DisplayColor = theme.TextColor;
            toDisplay.Static = true;
            toDisplay.ZOrder = 101;
        }
Example #4
0
File: HUD.cs Project: nemec/4Realms
            internal PlayerHUD(IHUDTheme theme, Player p, int xOffset, int yOffset)
            {
                #region Name
                Text name = new Text("player_name_" + p.Name, "Text", p.Name);
                name.DisplayColor = theme.TextColor;
                name.Pos = new Vector2(xOffset, yOffset);
                name.Static = true;
                #endregion

                #region HealthBar
                healthBar = new ProgressBar("Health_" + p.Name, p.MaxHealth,
                    Color.DarkRed, Color.Firebrick, Color.Black, barSize);
                healthBar.Pos = new Vector2(xOffset, name.Pos.Y + name.GetAnimation().Height);
                healthBar.Static = true;
                healthBar.Value = p.MaxHealth;

                p.HealthChanged += delegate(object obj, int value)
                {
                    healthBar.Value = value;
                    if (value == 0)
                    {
                        name.DisplayColor = Color.Tomato;
                    }
                    else
                    {
                        name.DisplayColor = theme.TextColor;
                    }
                };
                #endregion

                #region ManaBar
                manaBar = new ProgressBar("Mana_" + p.Name, p.MaxMana,
                    Color.MidnightBlue, Color.Blue, Color.Black, barSize);
                manaBar.Pos = new Vector2(xOffset,
                    healthBar.Pos.Y + barSize.Y + barSpacing.Y);
                manaBar.Static = true;
                manaBar.Value = p.MaxMana;

                p.ManaChanged += delegate(object obj, int value)
                {
                    manaBar.Value = value;
                };
                #endregion

                #region Spell Queue
                spellQueue = new SpellQueue("Queue", theme, p);
                spellQueue.Pos = new Vector2(xOffset,
                    healthBar.Pos.Y + barSize.Y + 2 * barSpacing.Y + barSize.Y);
                spellQueue.Static = true;

                #endregion
            }