Esempio n. 1
0
        protected override void Initialize()
        {
            SteamIntegration.Init();
            device = this.graphics.GraphicsDevice;
            this.graphics.IsFullScreen              = false;
            this.graphics.PreferredBackBufferWidth  = 800;
            this.graphics.PreferredBackBufferHeight = 600;
            this.graphics.ApplyChanges();
            this.graphics.GraphicsProfile = GraphicsProfile.Reach;

            if (DebugMode)
            {
                base.Window.Title = "Cup of Ethanol: Debugging";
                //this.IsFixedTimeStep = false;
                debug = new Debug();
            }
            else
            {
                base.Window.Title = "Cup of Ethanol";
            }

            SquareObject.sqObjectArray  = new SquareObject[0, 0];
            Collectable.collectableList = new List <Collectable>();
            Entity.EntityList           = new List <Entity>();
            Checkpoint.checkpointList   = new List <Checkpoint>();
            InputManager.Mousestate     = new MouseState[5];
            InputManager.GamepadState   = new GamePadState[2];
            this.isAppStarting          = true;
            base.Initialize();
        }
Esempio n. 2
0
        public static void Init()
        {
            if (instance == null)
            {
                instance = new SteamIntegration();
                instance.IsRunning = SteamAPI.Init();
                if (instance.IsRunning)
                {
                    Console.WriteLine(SteamUtils.GetAppID());
                    instance.RemoteStoragePublishFileResult = CallResult<RemoteStoragePublishFileResult_t>.Create(instance.OnRemoteStoragePublishFileResult);
                    instance.RemoteStorageEnumerateUserSubscribedFilesResult = CallResult<RemoteStorageEnumerateUserSubscribedFilesResult_t>.Create(instance.OnRemoteStorageEnumerateUserSubscribedFilesResult);
                    instance.RemoteStorageEnumerateUserPublishedFilesResult = CallResult<RemoteStorageEnumerateUserPublishedFilesResult_t>.Create(instance.OnRemoteStorageEnumerateUserPublishedFilesResult);
                    instance.RemoteStorageGetPublishedFileDetailsResult = CallResult<RemoteStorageGetPublishedFileDetailsResult_t>.Create(instance.OnRemoteStorageGetPublishedFileDetailsResult);
                    instance.RemoteStorageDownloadUGCResult = CallResult<RemoteStorageDownloadUGCResult_t>.Create(instance.OnRemoteStorageDownloadUGCResult);
                    instance.RemoteStorageDownloadUGCThumbnailResult = CallResult<RemoteStorageDownloadUGCResult_t>.Create(instance.OnRemoteStorageDownloadUGCThumbnailResult);

                    instance.myLevels = new List<string>();
                    SteamAPICall_t handle = SteamRemoteStorage.EnumerateUserPublishedFiles(0);
                    instance.RemoteStorageEnumerateUserPublishedFilesResult.Set(handle);
                }
            }
        }
Esempio n. 3
0
        public static void Update()
        {
            SavingTimeout--;

            if (SavingTimeout == 0)
            {
                Console.WriteLine("Starting to save...");
                string path = Level.CurrentLevelButton.Path;

                SteamIntegration.Achievements.LevelCreated();
                string newPath = path.Substring(0, path.Length - Level.CurrentLevelButton.Name.Length) + TextInput.TextInputList[0].Text;

                Save_StaticObjects(Save_Objects(SaveFile.LoadDocument(newPath + "/LevelData.xml"))).Save(newPath + "/LevelData.xml");

                if (Level.CurrentLevelButton.Name != TextInput.TextInputList[0].Text)
                {
                    Directory.Delete(path, true);                     // Delete the level with the old name first
                    Level.CurrentLevelButton.Name = TextInput.TextInputList[0].Text;
                    Level.CurrentLevelButton.Path = newPath;
                }
                MessageBox.StatusMessage = new MessageBox("Save Successful!", new Vector2(217, 190), 120);

                if (IsPublishingToWorkshop)
                {
                    SteamIntegration.UploadWorkshopLevel();
                    IsPublishingToWorkshop = false;
                }

                if (ScreenManager.Testing)
                {
                    SaveFile.LoadSaveFiles();
                    LevelLoader.StartCustomLevel(Level.Current - 1, Level.CurrentLevelButton);
                    ScreenManager.Testing = true;
                }
            }
        }
Esempio n. 4
0
        protected override void Update(GameTime gameTime)
        {
            if (this.isAppStarting)
            {
                MainMenu.Activate();
                this.isAppStarting = false;
            }
            else
            {
                SteamIntegration.Update();
            }
            if (ScreenManager.GameClosing)
            {
                SteamAPI.Shutdown();
                base.Exit();
            }
            if (base.IsActive && !SteamIntegration.instance.IsPublishing)
            {
                MainMenu.Update();
                LevelSaver.Update();

                if (popupBox == null)
                {
                    InGame.Update();
                    Editor.Update();
                }
                else if (popupBox.IsFinished)
                {
                    popupBox = null;
                }
                InputManager.CheckInput();
            }
            else if (ScreenManager.Ingame)
            {
                PauseMenu.Pause();
            }
            if (LevelLoader.LevelComplete)
            {
                if (!ScreenManager.Custom)
                {
                    SaveFile.CompleteLevel();
                }
                if (Level.Current == Level.maxLevels)
                {
                    if (ScreenManager.Custom)
                    {
                        Level.Current = 0;
                        LevelLoader.NextLevel();
                    }
                    else
                    {
                        SteamIntegration.Achievements.GameComplete();
                        LevelLoader.LevelComplete = false;
                        ScreenManager.GameCompleteOn();
                    }
                }
                else
                {
                    LevelLoader.NextLevel();
                }
            }

            if (DebugMode)
            {
                debug.Update(gameTime);
            }

            TimeSinceLastUpdate = ((float)base.TargetElapsedTime.TotalMilliseconds) / 1000f;
            base.Update(gameTime);
        }
Esempio n. 5
0
        public static void LevelSelectOn()
        {
            //int i;
            //int j;
            LevelButton.CurrentGroup = 0;
            TextSprite.TextList      = new List <TextSprite>();
            Button.ButtonList        = new List <Button>();
            LevelButton.lvButtonList = new List <LevelButton>();


            TextSprite ts = new TextSprite("Main Menu", "Medium", Color.White);

            Button.ButtonList.Add(new Button(ts, new Vector2(525f, 25f), 1));

            ts = new TextSprite("Next", "Medium", Color.White);
            Button.ButtonList.Add(new Button(ts, new Vector2(565f, 550f), 1));

            ts = new TextSprite("Previous", "Medium", Color.White);
            Button.ButtonList.Add(new Button(ts, new Vector2(40f, 550f), 1));

            if (!ScreenManager.Custom && !ScreenManager.Editing)
            {
                ts = new TextSprite("Erase Save Data", "Medium", Color.White);
                Button.ButtonList.Add(new Button(ts, new Vector2(40f, 25f), 1));
            }

            Button.ButtonList[2].Active = false;
            if (!ScreenManager.Editing && !ScreenManager.Custom)
            {
                SaveFile.LoadSaveFiles();
                for (int j = 0; j < Level.maxLevels / 3; j++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        int levelIndex = (j * 3) + i;
                        int collected  = 0;
                        for (int h = 0; h < SaveFile.SaveData.MainCoastersCollected[levelIndex].Length; h++)
                        {
                            if (SaveFile.SaveData.MainCoastersCollected[levelIndex][h])
                            {
                                collected++;
                            }
                        }

                        string status = "Locked";
                        if (SaveFile.SaveData.LevelsCompleted > (levelIndex))
                        {
                            if (collected == 3)
                            {
                                status = "Complete";
                            }
                            else
                            {
                                status = "Unlocked";
                            }
                        }
                        if (SaveFile.SaveData.LevelsCompleted == (levelIndex))
                        {
                            status = "Unlocked";
                        }

                        LevelButton.lvButtonList.Add(new LevelButton(levelIndex + 1, new Vector2((float)((220 * (i % 3)) + 80), (float)((220 * (j % 2)) + 0x69)), status, collected));
                    }
                }
            }
            else
            {
                if (!Directory.Exists(LevelSaver.CustomLevelsPath))
                {
                    Directory.CreateDirectory(LevelSaver.CustomLevelsPath);
                    string[] premadeCustoms = Directory.GetDirectories(@"Content\Levels\Custom");
                    foreach (string custom in premadeCustoms)
                    {
                        string[] parts      = custom.Split('\\');
                        string   customName = parts[parts.Length - 1];
                        Directory.CreateDirectory(LevelSaver.CustomLevelsPath + customName);
                        if (File.Exists(custom + "\\LevelData.xml"))
                        {
                            File.Copy(custom + "\\LevelData.xml", LevelSaver.CustomLevelsPath + customName + "\\LevelData.xml", true);
                        }
                        if (File.Exists(custom + "\\Thumbnail.png"))
                        {
                            File.Copy(custom + "\\Thumbnail.png", LevelSaver.CustomLevelsPath + customName + "\\Thumbnail.png", true);
                        }
                    }
                }

                SteamIntegration.LoadWorkshopLevels();

                //Load custom levels here
                String[]  levels     = Directory.GetDirectories(LevelSaver.CustomLevelsPath);
                int       levelIndex = 0;
                Texture2D thumbnail;
                for (int j = 0; j < Math.Ceiling(levels.Length / 3f); j++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        while (levelIndex < levels.Length && !File.Exists(levels[levelIndex] + "/LevelData.xml"))
                        {
                            // Delete folders that don't contain a level
                            Directory.Delete(levels[levelIndex], true);
                            levelIndex++;
                        }
                        if (levelIndex < levels.Length)
                        {
                            if (File.Exists(levels[levelIndex] + "/Thumbnail.png"))
                            {
                                FileStream filestream = new FileStream(levels[levelIndex] + "/Thumbnail.png", FileMode.Open);
                                thumbnail = Texture2D.FromStream(MainMethod.device, filestream, 160, 120, true);
                                filestream.Close();
                            }
                            else
                            {
                                thumbnail = Textures.GetCustomThumbnail();
                            }
                            LevelButton.lvButtonList.Add(new CustomLevelButton(levels[levelIndex], new Vector2((float)((220 * (i % 3)) + 80), (float)((220 * (j % 2)) + 0x69)), thumbnail));
                            levelIndex++;
                        }
                    }
                }
                int    x           = (LevelButton.lvButtonList.Count) % 3;
                int    y           = (int)Math.Floor((LevelButton.lvButtonList.Count) / 3f) % 2;
                int    levelSuffix = LevelButton.lvButtonList.Count;
                string name        = "";
                do
                {
                    levelSuffix++;
                    name = "Untitled" + levelSuffix;
                } while (LevelButton.lvButtonList.Exists(item => (item as CustomLevelButton).Name == name));

                LevelButton.lvButtonList.Add(new NewLevelButton(name, new Vector2((float)((220 * (x % 3)) + 80), (float)((220 * (y % 2)) + 0x69))));
            }

            if (LevelButton.lvButtonList.Count < 7)
            {
                Button.ButtonList[1].Active = false;
            }
        }