Ejemplo n.º 1
0
        public Menu()
        {
            CanFire = false;

            var menumusic = Sounds.snd_birds.ToSoundAsset().play(0, 999);

            Mouse.show();

            Aim.visible = false;

            GetWarzone().filters = new[] { new BlurFilter() };

            var InfoMenu = new Sprite
            {
                x = 120,
                y = 120
            }.AttachTo(this);

            var y = 0d;

            // X:\jsc.svn\examples\actionscript\FlashTowerDefense\FlashTowerDefense\ActionScript\Menu.cs
            // public override event Action<MouseEvent> contextMenu;
            // public ContextMenu contextMenu { get; set; }
            // um the jsc rewriter should rename
            // either the field or the event.
            // or the flash natives gen should stop
            // creating events that have the same name
            // as fields.
            // carlo! :)

            // can jsc send a comment?

            //"this is a comment";
            "this is a comment".Comment();


#if FContextMenu
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201404/20140402



            this.contextMenu = new ContextMenu();
            this.contextMenu.hideBuiltInItems();
#endif


            foreach (var v in this.Settings.KnownActors)
            {
                AddInfo(InfoMenu, y, v);

                y += 72;
            }

            #region Play
            var PlayButton = new TextField
            {
                defaultTextFormat = new TextFormat
                {
                    size = 36
                },
                autoSize = TextFieldAutoSize.LEFT,
                htmlText = "Play!",
                selectable = false,
                textColor = ColorBlue,
                filters = new[] { new GlowFilter(ColorBlueLight) }

            }.AttachTo(this);

            PlayButton.x = DefaultWidth - PlayButton.width - 32;
            PlayButton.y = DefaultHeight - PlayButton.height - 32;

            PlayButton.OnHoverUseColor(ColorRed);



            PlayButton.click +=
                delegate
                {
                    menumusic.stop();

                    InfoMenu.mouseEnabled = false;
                    InfoMenu.mouseChildren = false;

                    InfoMenu.FadeOutAndOrphanize(1000 / 64, 0.21);


                    GetWarzone().filters = null;

                    Action PlaySound = () => Sounds.snd_click.ToSoundAsset().play();

                    PlaySound();

                    //PlaySound.InvokeAtDelays(0, 500, 800);


                    CanFire = true;
                    PlayButton.Orphanize();
                    Aim.visible = true;
                    Mouse.hide();
                };
            #endregion

        }