예제 #1
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++;
                    if (playerData.Notes >= totalNotes)
                    {
                        SteamWorker.SetAchievement("cheevo_notes");
                    }
                    SteamWorker.IncrementStat("notes_read", 1);
                }
            }, this.IsCollected));
        }
예제 #2
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
                    );
                }
            };
        }
예제 #3
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;
                }
            });
        }
예제 #4
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++;
                            }
                        }
                    }
                }));
            }
        }
예제 #5
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++;
                            }
                        }
                    }
                }));
            }
        }