示例#1
0
        public static bool IsInstalled(string packageName)
        {
            var fileName = Path.Combine(PackagesFolder, "PackagesState.txt");

            if (File.Exists(fileName))
            {
                var block = TextBlockUtility.LoadFromRealFile(fileName, out var error);
                if (!string.IsNullOrEmpty(error))
                {
                    EditorMessageBox.ShowWarning(error);
                    return(false);
                }

                foreach (var child in block.Children)
                {
                    if (child.Name == "Package")
                    {
                        if (child.GetAttribute("Name") == packageName)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
示例#2
0
        public static bool ChangeInstalledState(string packageName, bool installed)
        {
            var fileName = Path.Combine(PackagesFolder, "PackagesState.txt");

            //load
            TextBlock block;

            if (File.Exists(fileName))
            {
                block = TextBlockUtility.LoadFromRealFile(fileName, out var error);
                if (!string.IsNullOrEmpty(error))
                {
                    EditorMessageBox.ShowWarning(error);
                    return(false);
                }
            }
            else
            {
                block = new TextBlock();
            }

            //update
            {
                foreach (var child in block.Children)
                {
                    if (child.Name == "Package")
                    {
                        if (child.GetAttribute("Name") == packageName)
                        {
                            block.DeleteChild(child);
                            break;
                        }
                    }
                }

                if (installed)
                {
                    var child = block.AddChild("Package");
                    child.SetAttribute("Name", packageName);
                }
            }

            //save
            {
                if (!Directory.Exists(PackagesFolder))
                {
                    Directory.CreateDirectory(PackagesFolder);
                }

                TextBlockUtility.SaveToRealFile(block, fileName, out var error);
                if (!string.IsNullOrEmpty(error))
                {
                    EditorMessageBox.ShowWarning(error);
                    return(false);
                }
            }

            return(true);
        }
        public void LoadGame(String filename)
        {
            if (!VirtualFile.Exists("Store\\AndreyKorolev\\5MinGame\\Saves\\" + filename + ".lvldata"))
            {
                ScreenMessages.Add("No file");
                return;
            }
            TextBlock block = TextBlockUtility.LoadFromVirtualFile("Store\\AndreyKorolev\\5MinGame\\Saves\\" + filename + ".lvldata");

            EnemiesKill = int.Parse(block.FindChild("EnemiesKill").Data);
            ScreenMessages.Add("EnemiesKill = " + EnemiesKill);
            Level = int.Parse(block.FindChild("Level").Data);
            ScreenMessages.Add("Level = " + Level);
            CheckPoint = block.FindChild("CheckPoint").Data;
            ScreenMessages.Add("CheckPoint = " + CheckPoint);
            hasWeapon = bool.Parse(block.FindChild("hasWeapon").Data);
            ScreenMessages.Add("hasWeapon = " + hasWeapon);

            ShowWin(false);
            AddEK(0);
            if (Level == 1)
            {
                LoadSc("File");
            }
            else if (Level == 2)
            {
                LoadSc("File2");
            }
            else
            {
                ScreenMessages.Add("No level");
            }

            var sc      = Component_Scene.First;
            var chpoint = (Component_Sensor)sc?.GetComponentByPath(CheckPoint);
            var chr     = (Component_Character)sc?.GetComponentByPath("Character");
            var chrcol  = (Component_RigidBody)sc?.GetComponentByPath("Character\\Collision Body");

            chrcol.Transform = chrcol.TransformV.UpdatePosition(new Vector3(chpoint.TransformV.Position.X, chpoint.TransformV.Position.Y, chr.TransformV.Position.Z));

            GetWeapon(sc, chr, hasWeapon);

            ScreenMessages.Add("Load Done");
        }
        public void SaveGame(String filename)
        {
            TextBlock block = new TextBlock();
            TextBlock b1    = block.AddChild("EnemiesKill", EnemiesKill.ToString());
            TextBlock b2    = block.AddChild("Level", Level.ToString());
            TextBlock b3    = block.AddChild("CheckPoint", CheckPoint);

            var sc  = Component_Scene.First;
            var chr = (Component_Character)sc?.GetComponentByPath("Character");

            if (chr.ItemGetEnabledFirst() != null)
            {
                hasWeapon = true;
            }

            TextBlock b4 = block.AddChild("hasWeapon", hasWeapon.ToString());

            TextBlockUtility.SaveToVirtualFile(block, "Store\\AndreyKorolev\\5MinGame\\Saves\\" + filename + ".lvldata");
        }