Beispiel #1
0
        public override void Create()
        {
            base.Create();

            Badge.LoadGlobal();

            uiCamera.Visible = false;

            var w = Camera.Main.CameraWidth;
            var h = Camera.Main.CameraHeight;

            var left   = (w - WIDTH) / 2;
            var top    = (h - HEIGHT) / 2;
            var bottom = h - top;

            var archs = new Archs();

            archs.SetSize(w, h);
            Add(archs);

            var title = BannerSprites.Get(BannerSprites.Type.SelectYourHero);

            title.X = Align((w - title.Width) / 2);
            title.Y = top;
            Add(title);

            btnNewGame             = new GameButton(TXT_NEW);
            btnNewGame.ClickAction = NewGameClick;
            Add(btnNewGame);

            btnLoad             = new GameButton(TXT_LOAD);
            btnLoad.ClickAction = LoadClick;
            Add(btnLoad);

            var classes = new[]
            {
                HeroClass.Warrior,
                HeroClass.Mage,
                HeroClass.Rogue,
                HeroClass.Huntress
            };

            const float shieldW = WIDTH / 2;
            var         shieldH = Math.Min((bottom - BUTTON_HEIGHT - title.Y - title.Height) / 2, shieldW * 1.2f);

            top = (bottom - BUTTON_HEIGHT + title.Y + title.Height - shieldH * 2) / 2;
            for (var i = 0; i < classes.Length; i++)
            {
                var shield = new ClassShield(classes[i], this);
                shield.SetRect(left + (i % 2) * shieldW, top + (i / 2) * shieldH, shieldW, shieldH);
                Add(shield);

                if (Shields.ContainsKey(classes[i]))
                {
                    Shields[classes[i]] = shield;
                }
                else
                {
                    Shields.Add(classes[i], shield);
                }
            }

            unlock = new Group();
            Add(unlock);

            var challenge = new ChallengeButton();

            challenge.SetPos(w / 2 - challenge.Width / 2, top + shieldH - challenge.Height / 2);
            Add(challenge);

            if (!(huntressUnlocked = Badge.IsUnlocked(Badge.BOSS_SLAIN_3)))
            {
                var text = CreateMultiline(TXT_UNLOCK, 9);
                text.MaxWidth = (int)WIDTH;
                text.Measure();

                float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.Height) / 2;
                foreach (var line in new LineSplitter(text.Font, text.Scale, text.Text()).Split())
                {
                    line.Measure();
                    line.Hardlight(0xFFFF00);
                    line.X = Align(left + WIDTH / 2 - line.Width / 2);
                    line.Y = Align(pos);
                    unlock.Add(line);

                    pos += line.Height;
                }
            }

            var btnExit = new ExitButton();

            btnExit.SetPos(Camera.Main.CameraWidth - btnExit.Width, 0);
            Add(btnExit);

            curClass = null;
            UpdateClass(HeroClass.Values()[PixelDungeon.LastClass()]);

            FadeIn();
        }