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

            Music.Instance.Play(Assets.HAPPY, true);
            Music.Instance.Volume(1f);

            uiCamera.Visible = false;

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

            var archs = new Archs();

            archs.Reversed = true;
            archs.SetSize(w, h);
            Add(archs);

            var vx = Align((w - WIDTH) / 2);
            var vy = Align((h - HEIGHT) / 2);

            var s = pdsharp.noosa.Camera.Main.CameraToScreen(vx, vy);

            _viewport = new pdsharp.noosa.Camera(s.X, s.Y, WIDTH, HEIGHT, defaultZoom);
            pdsharp.noosa.Camera.Add(_viewport);

            var window = new Group();

            window.Camera = _viewport;
            Add(window);

            var dayTime = !Dungeon.NightMode;

            var sky = new Sky(dayTime);

            sky.Scale.Set(WIDTH, HEIGHT);
            window.Add(sky);

            if (!dayTime)
            {
                for (var i = 0; i < Nstars; i++)
                {
                    var size = pdsharp.utils.Random.Float();
                    var star = new ColorBlock(size, size, Color.Argb(255, 255, 255, 255));
                    star.X  = pdsharp.utils.Random.Float(WIDTH) - size / 2;
                    star.Y  = pdsharp.utils.Random.Float(HEIGHT) - size / 2;
                    star.Am = size * (1 - star.Y / HEIGHT);
                    window.Add(star);
                }
            }

            const float range = HEIGHT * 2 / 3;

            for (var i = 0; i < Nclouds; i++)
            {
                var cloud = new Cloud((Nclouds - 1 - i) * (range / Nclouds) + pdsharp.utils.Random.Float(range / Nclouds), dayTime);
                window.Add(cloud);
            }

            var nPatches = (int)(sky.Width / GrassPatch.WIDTH + 1);

            for (var i = 0; i < nPatches * 4; i++)
            {
                var patch = new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, HEIGHT + 1, dayTime);
                patch.Brightness(dayTime ? 0.7f : 0.4f);
                window.Add(patch);
            }

            var a = new Avatar(Dungeon.Hero.heroClass);

            a.X = Align((WIDTH - a.Width) / 2);
            a.Y = HEIGHT - a.Height + 1;
            window.Add(a);

            var pet = new Pet();

            pet.Rm = pet.Gm = pet.Bm = 1.2f;
            pet.X  = WIDTH / 2 + 2;
            pet.Y  = HEIGHT - pet.Height;
            window.Add(pet);

            if (dayTime)
            {
                a.Brightness(1.2f);
                pet.Brightness(1.2f);
            }

            //window.Add(new TouchArea(sky) { protected void OnClick(Touch touch) { pet.Jump(); }; });

            for (var i = 0; i < nPatches; i++)
            {
                var patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, HEIGHT, dayTime);
                patch.Brightness(dayTime ? 1.0f : 0.8f);
                window.Add(patch);
            }

            var frame = new Image(Assets.SURFACE);

            if (!dayTime)
            {
                frame.Hardlight(0xDDEEFF);
            }

            frame.Frame(0, 0, 88, 125);
            frame.X = vx - 4;
            frame.Y = vy - 9;
            Add(frame);

            var gameOver = new RedButton("Game Over");

            gameOver.ClickAction = GameOverClickAction;
            gameOver.SetSize(WIDTH - 10, 20);
            gameOver.SetPos(5 + frame.X + 4, frame.Y + frame.Height + 4);
            Add(gameOver);

            Badge.ValidateHappyEnd();

            FadeIn();
        }