Esempio n. 1
0
    public static List <SaveInfo> FindSaves()
    {
        var files = Directory.GetFiles(Application.persistentDataPath, "*.dat", SearchOption.TopDirectoryOnly);

        if (files.Length <= 0)
        {
            return(null);
        }

        BinaryFormatter bf    = new BinaryFormatter();
        var             saves = new List <SaveInfo>();

        foreach (var filePath in files)
        {
            var      fs   = File.OpenRead(filePath);
            SaveInfo info = (SaveInfo)bf.Deserialize(fs);
            fs.Close();
            if (info == null)
            {
                continue;
            }
            saves.Add(info);
        }

        return(saves);
    }
Esempio n. 2
0
        protected void FindLegacy()
        {
            string archive = Path.Combine(FolderPath + "ARCHIV.DS");

            if (!File.Exists(archive))
            {
                return;
            }

            using (var stream = File.OpenRead(archive))
                using (var reader = new BinaryReader(stream))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        var  name = Encoding.ASCII.GetString(reader.ReadBytes(15));
                        byte used = reader.ReadByte();

                        if (used == 1)
                        {
                            var info = new SaveInfo()
                            {
                                Name     = name,
                                Path     = Path.Combine(FolderPath, "/SAVE" + ('0' + (char)i) + ".DS"),
                                SaveType = SaveInfo.Type.Legacy
                            };

                            savedGames.Add(info);
                        }
                    }
                }
        }
        public void PrepareSave2(SaveInfo save)
        {
            PrepareSaveBase(save);

            // !string.IsNullOrEmpty(FolderName);
            // !save.IsActuallySaved

            try
            {
                if (save.FolderName.EndsWith(".zks") || save.Saver == null ||
                    save.Saver.GetType() != typeof(FolderSaver2))
                {
                    // set folderName, (remove file extension)
                    save.FolderName = save.FolderName.Replace(".zks", "");

                    //save.Saver = new FolderSaver(save.FolderName);
                    save.Saver = ((ISaver) new FolderSaver2(save.FolderName));

                    if (save.Type == SaveInfo.SaveType.Quick)
                    {
                        // set name of quicksave to folder name
                        // save.Name = Path.GetFileName(save.FolderName);
                    }
                }
            }
            catch (Exception ex)
            {
                BattleLogHelper.LogDebug($"err {ex.ToString()}");
            }
        }
Esempio n. 4
0
 public override void Save(SaveInfo info)
 {
     base.Save(info);
     info.msg.baseCombat        = Facepunch.Pool.Get <BaseCombat>();
     info.msg.baseCombat.state  = (int)lifestate;
     info.msg.baseCombat.health = Health();
 }
Esempio n. 5
0
        public static void SaveFile(SaveInfo saveInfo)
        {
            try
            {
                var name     = Strings.RemoveExt(saveInfo.FileName);
                var filePath = Storage.modEntryPath + Storage.savesFolder + "\\" + name + ".xml";

                Main.saveData.fileName  = name;
                Main.saveData.lockPicks = Storage.lockPicks;

                Common.ModLoggerDebug($"PrepareSave {name}");

                if (File.Exists(filePath))
                {
                    Serialize(Main.saveData, filePath);

                    Common.ModLoggerDebug($"{Storage.modEntryPath + Storage.savesFolder + "\\" + name} overwritten.");
                }
                else
                {
                    Serialize(Main.saveData, filePath);

                    Common.ModLoggerDebug($"{Storage.modEntryPath + Storage.savesFolder + "\\" + name} created.");
                }
            }
            catch (Exception e)
            {
                Main.modLogger.Log(e.ToString());
            }
        }
Esempio n. 6
0
    public void LoadSave()
    {
        Debug.Log(savePath);

        if (File.Exists(savePath))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(savePath, FileMode.Open);

            SaveInfo info = (SaveInfo)bf.Deserialize(file);

            saveInfo = info;

            file.Close();

            if (saveInfo.ver != expectedSaveVer)
            {
                UpdateSaveVer(saveInfo);
            }
        }
        else
        {
            Debug.Log("Save file not found. Creating new one");
            CreateNewSave();
        }
    }
Esempio n. 7
0
 public override void Save(SaveInfo info)
 {
     base.Save(info);
     info.msg.rcEntity.aim.x = pitchAmount;
     info.msg.rcEntity.aim.y = yawAmount;
     info.msg.rcEntity.aim.z = 0f;
 }
Esempio n. 8
0
    public void StartNewGame(int indexStage, SaveInfo info)
    {
        // 기존 플레이어 삭제
        if (objPlayer != null)
        {
            Destroy(objPlayer);
            objPlayer = null;
        }
        // 새 플레이어 오브젝트 생성
        CreateNewPlayer();
        // 새 UI Bar 생성
        CreateNewUIBar();

        // 플레이어 정보 로드
        if (info != null)
        {
            Player player = objPlayer.GetComponent <Player>();
            player.level = info.level;
            player.sp    = info.curSP;
            player.hp    = info.curHP;
            player.exp   = info.curExp;
            MoveStage(indexStage, new Vector3(info.posX, info.posY, info.posZ));
        }
        else
        {
            MoveStage(indexStage, listStage[indexStage].transDefaultStartingPos.position);
        }
    }
Esempio n. 9
0
    public override SaveInfo Save()
    {
        SaveInfo saveInfo = new SaveInfo();

        saveInfo.WriteProperty("isLocked", isLocked);
        return(saveInfo);
    }
Esempio n. 10
0
        private void SaveList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var psave = SaveList.SelectedItem;

            if (psave is ProfileSave ps)
            {
                SaveInfo_Name.Content = "이름: " + ps.savename;
                SaveInfo_Dir.Content  = "폴더: " + ps.directory;
                SaveInfo_Date.Content = "날짜: " + ps.formattedtime;

                if (SaveInfo.Visibility != Visibility.Visible)
                {
                    var anim = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2)))
                    {
                        DecelerationRatio = 1
                    };
                    SaveInfo.BeginAnimation(StackPanel.OpacityProperty, anim);

                    var anim0 = new DoubleAnimation(1, 0.8, new Duration(TimeSpan.FromSeconds(0.1)))
                    {
                        DecelerationRatio = 1,
                        AutoReverse       = true
                    };
                    SaveList.BeginAnimation(ListBox.OpacityProperty, anim0);
                }

                SaveInfo.Visibility = Visibility.Visible;
                if (TaskListPanel.Visibility == Visibility.Visible)
                {
                    SavegameChanged(true);
                }
            }
        }
Esempio n. 11
0
    public void SaveToFile(string filename)
    {
        SaveInfo save = new SaveInfo();

        save.name               = name;
        save.money              = money;
        save.health             = health;
        save.maxHealth          = maxHealth;
        save.maxcargo           = maxcargo;
        save.inventory          = inventory;
        save.maxSpeed           = maxSpeed;
        save.acceleration       = acceleration;
        save.yawPitchFactor     = yawPitchFactor;
        save.rollFactor         = rollFactor;
        save.wS1Name            = wS1Name;
        save.wS1Num             = wS1Num;
        save.wS2Name            = wS2Name;
        save.wS2Num             = wS2Num;
        save.auxName            = auxName;
        save.auxNum             = auxNum;
        save.spawnInNextScene   = spawnInNextScene;
        save.spawnPositionIndex = spawnPositionIndex;
        save.spawned            = spawned;
        save.hasActiveQuest     = hasActiveQuest;
        save.base1QuestNum      = base1QuestNum;
        save.base2QuestNum      = base2QuestNum;
        save.loadedLevel        = currentLevel;
        save.openedLocations    = openedLocations;
        save.populateLocations  = populateLocations;

        save.Save(Application.dataPath + "/Save/" + filename + ".xml");
    }
Esempio n. 12
0
    public void LoadFromFile(string filename)
    {
        SaveInfo save = SaveInfo.Load(Application.dataPath + "/Save/" + filename + ".xml");

        name               = save.name;
        money              = save.money;
        health             = save.health;
        maxHealth          = save.maxHealth;
        maxcargo           = save.maxcargo;
        inventory          = save.inventory;
        maxSpeed           = save.maxSpeed;
        acceleration       = save.acceleration;
        yawPitchFactor     = save.yawPitchFactor;
        rollFactor         = save.rollFactor;
        wS1Name            = save.wS1Name;
        wS1Num             = save.wS1Num;
        wS2Name            = save.wS2Name;
        wS2Num             = save.wS2Num;
        auxName            = save.auxName;
        auxNum             = save.auxNum;
        spawnInNextScene   = save.spawnInNextScene;
        spawnPositionIndex = save.spawnPositionIndex;
        spawned            = save.spawned;
        hasActiveQuest     = save.hasActiveQuest;
        base1QuestNum      = save.base1QuestNum;
        //Debug.Log("Load quest:"+base1QuestNum);
        base2QuestNum     = save.base2QuestNum;
        currentLevel      = save.loadedLevel;
        openedLocations   = save.openedLocations;
        populateLocations = save.populateLocations;
    }
        /// <summary>
        /// Close this menu.
        /// </summary>
        public override void Deactivate()
        {
            int shipIndex = 0;

            foreach (MenuItem mItem in menuItems)
            {
                if (menuItems.IndexOf(mItem) > 3)
                {
                    continue;
                }

                for (int i = 0; i < mItem.shipArray.Length; i++)
                {
                    FrameworkCore.skirmishShipArray[shipIndex] = Helpers.getShipByType(mItem.shipArray[i]);
                    shipIndex++;
                }
            }

            SaveInfo save = FrameworkCore.storagemanager.GetDefaultSaveData();

            save.skirmishArray = FrameworkCore.skirmishShipArray;
            FrameworkCore.storagemanager.SaveData(save);

            base.Deactivate();
        }
Esempio n. 14
0
 public override void Save(SaveInfo info)
 {
     base.Save(info);
     info.msg.motorBoat               = Facepunch.Pool.Get <Motorboat>();
     info.msg.motorBoat.storageid     = storageUnitInstance.uid;
     info.msg.motorBoat.fuelStorageID = fuelSystem.fuelStorageInstance.uid;
 }
Esempio n. 15
0
    //현재 정보를 저장
    void SaveSphereInfo()
    {
        //정보를 저장하기위한 클래스 생성
        SaveInfo saveInfo = new SaveInfo();
        saveInfo.posX = this.transform.position.x;
        saveInfo.posY = this.transform.position.y;
        saveInfo.posZ = this.transform.position.z;

        saveInfo.scaleX = this.transform.localScale.x;
        saveInfo.scaleY = this.transform.localScale.y;
        saveInfo.scaleZ = this.transform.localScale.z;

        saveInfo.name = this.gameObject.name;

        //메모리를 2진데이터로 바꿔준다.
        BinaryFormatter formatter = new BinaryFormatter();

        //2진데이터화 된 메모리를 저장할 공간.
        MemoryStream memStream = new MemoryStream();

        //BinaryFormatter 인스턴스를 통해 saveInfo 의 메모리블럭을 2진데이터화하여 memStream 에 저장
        formatter.Serialize(memStream, saveInfo);

        //저장된 메모리스트림에 있는 메모리를 문자로 강제 치환
        string memStr = Convert.ToBase64String(memStream.GetBuffer());

        print(memStr);

        //플레이어프리펩에 문자열 자체로 저장
        PlayerPrefs.SetString("SphereInfo", memStr);
    }
Esempio n. 16
0
    void Load(SaveInfo info)
    {
        moveCount = info.moveCount;
        game.UpdateMoveCountText();

        transform.position = new Vector3(info.playerPosition[0], info.playerPosition[1], info.playerPosition[2]);
        print(info.playerPosition[0]);
        isFall = info.playerIsFall;
        if (!info.playerIsFall)
        {
            RevertFall();
        }

        playerColorCon.SetColor(info.playerCurrentColorIndex);

        moveHistory.Clear();
        for (int i = 0; i < info.playerMoveHistory_Directions.Length; i++)
        {
            moveHistory.Add(new MoveHistoryItem((Direction)info.playerMoveHistory_Directions[i], info.playerMoveHistory_heights[i], info.playerMoveHistory_playerColorIndexes[i]));
        }

        teleportHistory.Clear();
        for (int i = 0; i < info.teleportHistoryKeys.Length; i++)
        {
            Vector3Int v = new Vector3Int(info.teleportHistoryValues[i * 3], info.teleportHistoryValues[i * 3 + 1], info.teleportHistoryValues[i * 3 + 2]);
            teleportHistory.Add(info.teleportHistoryKeys[i], v);
        }
    }
Esempio n. 17
0
 void OnSaveComplete(AsyncApiEdit sender, SaveInfo saveInfo)
 {
     if (SaveComplete != null)
     {
         SaveComplete(sender, saveInfo);
     }
 }
Esempio n. 18
0
        /*
         * public static void SaveData(List<OptionsData> data, string filename)
         * {
         *  if (device == null)
         *      return;
         *
         *  using (StorageContainer container = device.OpenContainer(gamename))
         *  {
         *      string fullpath = Path.Combine(container.Path, filename);// Get the path of the save game.
         *
         *      // Open the file, creating it if necessary
         *      using (FileStream stream = File.Open(fullpath, FileMode.Create))
         *      {
         *          // Convert the object to XML data and put it in the stream
         *          XmlSerializer serializer = new XmlSerializer(typeof(List<OptionsData>));
         *          serializer.Serialize(stream, data);
         *      }
         *  }
         * }
         */

        public SaveInfo GetDefaultSaveData()
        {
            SaveInfo save = new SaveInfo();

            save.brightness = FrameworkCore.options.brightness;
            save.adventure  = FrameworkCore.adventureNumber;
            save.music      = FrameworkCore.options.musicVolume;
            save.volume     = FrameworkCore.options.soundVolume;

            save.p1InvertY   = FrameworkCore.options.p1InvertY;
            save.p1InvertX   = FrameworkCore.options.p1InvertX;
            save.p1vibration = FrameworkCore.options.p1Vibration;

            save.p2InvertY   = FrameworkCore.options.p2InvertY;
            save.p2InvertX   = FrameworkCore.options.p2InvertX;
            save.p2vibration = FrameworkCore.options.p2Vibration;

            save.skirmishArray = FrameworkCore.skirmishShipArray;

#if WINDOWS
            save.playerName = FrameworkCore.players[0].commanderName;
#endif

            return(save);
        }
Esempio n. 19
0
    void Start()
    {
        // Debug.Log("-=3=-");
        //  BallController.RedyToRunNewPlayerBall = false;

        if (explosiveBallTransform == null)
        {
            Debug.LogError("explosiveBallTransform==null");
        }
        //Завантажити збереження
        saveLoadManager = new SaveLoadGame();
        save            = saveLoadManager.LoadSave();
        Debug.Log(save.curLvl);

        // створити мапу, відповідно до рівня та отримати її скрипт
        map    = createMapGameobject(save.curLvl).GetComponent <MapInfo>();
        player = map.player;

        TextUpdate();
        LevelPreference(save.curLvl);

        TypesSphere typeSphere = ballCreator.randomType(true, CountColor);

        newSphere = ballCreator.getBall(ballTransform, map.pointToRespawnPlayersBall.position, typeSphere).gameObject;
        // newSphere.GetComponent<BallBehaviour>().TypeSphere = typeSphere;
        //  destroyLists = BallController.BallsLists;
    }
Esempio n. 20
0
 public void getInfo(SaveInfo info)
 {
     info.AddValue("MetacarpalAnimator", metacarpalAnimator);
     info.AddValue("ProximalAnimator", proximalAnimator);
     info.AddValue("IntermediateAnimator", intermediateAnimator);
     info.AddValue("DistalAnimator", distalAnimator);
 }
Esempio n. 21
0
 public override void Save(SaveInfo info)
 {
     base.Save(info);
     info.msg.ioEntity = Pool.Get <ProtoBuf.IOEntity>();
     info.msg.ioEntity.genericEntRef1 = hitchSpots[0].horse.uid;
     info.msg.ioEntity.genericEntRef2 = hitchSpots[1].horse.uid;
 }
Esempio n. 22
0
    public override SaveInfo Save()
    {
        SaveInfo saveInfo = base.Save();

        saveInfo.WriteProperty("isCathed", isCatched);
        return(saveInfo);
    }
Esempio n. 23
0
        private static void GetStatus(GSTNReturnsClient client2, SaveInfo info, string fp)
        {
            System.Console.WriteLine("Reference_ID: " + info.reference_id);
            var status = client2.GetStatus(fp, info.reference_id);

            System.Console.WriteLine(JsonConvert.SerializeObject(status.Data));
        }
Esempio n. 24
0
 public override void Save(SaveInfo info)
 {
     base.Save(info);
     info.msg.buildingBlock       = Facepunch.Pool.Get <ProtoBuf.BuildingBlock>();
     info.msg.buildingBlock.model = modelState;
     info.msg.buildingBlock.grade = (int)grade;
 }
Esempio n. 25
0
    // Tracks HMD and Controller
    public static void TrackHeadAndController(int logSTID = -1)
    {
        string cs = SaveInfo.csvColSeparator;

        RaycastHit hitHead;
        Ray        rayHead = new Ray(Camera.main.transform.position, Camera.main.transform.forward);

        RaycastHit hitController;
        Ray        rayController = new Ray(steamController.transform.position, steamController.transform.forward);

        textBuffer += SaveInfo.strTimestamp() + cs + logSTID + cs;

        if (Physics.Raycast(rayHead, out hitHead, 100.0f))
        {
            textBuffer += hitHead.point.x + cs + hitHead.point.y + cs + hitHead.point.z + cs + Camera.main.transform.position.x + cs + Camera.main.transform.position.y + cs + Camera.main.transform.position.z + cs + hitHead.collider.gameObject.name + cs;
        }

        if (Physics.Raycast(rayController, out hitController, 100.0f))
        {
            textBuffer += hitController.point.x + cs + hitController.point.y + cs + hitController.point.z + cs + steamController.transform.position.x + cs + steamController.transform.position.y + cs + steamController.transform.position.z + cs + hitController.collider.gameObject.name;
        }

        textBuffer += "\n";

        // If it is an important move information (a selected item), write the buffer to disk immediately.
        if (logSTID != -1)
        {
            WriteToDisk();
        }
    }
        private void MenuDone()
        {
            bool invalidName = false;

            string playerName = FrameworkCore.players[0].commanderName;


            if (!Helpers.IsValidPlayerName(playerName))
            {
                invalidName = true;
            }

            if (invalidName)
            {
                FrameworkCore.players[0].commanderName = Helpers.GenerateName("Gamertag");
                return;
            }

            FrameworkCore.players[0].commanderName = Helpers.StripOutAmpersands(FrameworkCore.players[0].commanderName);


            SaveInfo save = FrameworkCore.storagemanager.GetDefaultSaveData();

            FrameworkCore.storagemanager.SaveData(save);

            Deactivate();
            Owner.AddMenu(new MainMenu());
        }
Esempio n. 27
0
        public static bool Prefix(SaveLoadPortraits __instance, SaveInfo saveInfo, ref List <SaveLoadPortait> ___m_Portraits)
        {
            try
            {
                __instance.Reset();
                if (saveInfo == null)
                {
                    return(false);
                }
                List <Sprite> list = new List <Sprite>();
                if (saveInfo.PartyPortraits != null)
                {
                    list.AddRange(from companions in saveInfo.PartyPortraits
                                  where companions != null && companions.Data != null
                                  select companions.Data.SmallPortrait);
                }
                for (int i = 0; i < ___m_Portraits.Count; i++)
                {
                    ___m_Portraits[i].Set((list.Count <= i) ? null : list[i]);
                }
            }
            catch (Exception e)
            {
                FileLog.Log(e.ToString());
            }

            return(false);
        }
Esempio n. 28
0
 public void getInfo(SaveInfo info)
 {
     info.AddValue("Text", Text);
     info.AddValue("Action", Action);
     info.AddValue("Image", Image);
     info.AddValue("Name", Name);
 }
Esempio n. 29
0
        /// <summary>
        /// 保存保存信息
        /// </summary>
        /// <returns></returns>
        public static void SaveSaveInfo(SaveInfo saveInfo)
        {
            if (saveInfo == null)
            {
                return;
            }

            try
            {
                // 创建文件
                var infoFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SteamAccount.txt");
                if (File.Exists(infoFilePath))
                {
                    File.Delete(infoFilePath);
                }

                // 创建新的文本
                var fileSteam = File.Create(infoFilePath);
                fileSteam.Dispose();

                // 追加信息
                var str = JsonConvert.SerializeObject(saveInfo);
                File.AppendAllText(infoFilePath, str);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 30
0
        public long LoadSaveDataFileSystem(ServiceCtx context)
        {
            SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();

            long titleId = context.RequestData.ReadInt64();

            UInt128 userId = context.RequestData.ReadStruct <UInt128>();

            long         saveId       = context.RequestData.ReadInt64();
            SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadByte();
            SaveInfo     saveInfo     = new SaveInfo(titleId, saveId, saveDataType, userId, saveSpaceId);
            string       savePath     = context.Device.FileSystem.GetGameSavePath(saveInfo, context);

            try
            {
                LocalFileSystem             fileSystem     = new LocalFileSystem(savePath);
                DirectorySaveDataFileSystem saveFileSystem = new DirectorySaveDataFileSystem(fileSystem);

                MakeObject(context, new IFileSystem(saveFileSystem));
            }
            catch (HorizonResultException ex)
            {
                return(ex.ResultValue.Value);
            }

            return(0);
        }
Esempio n. 31
0
        public static void LoadFile(SaveInfo saveInfo)
        {
            try
            {
                var name     = Strings.RemoveExt(saveInfo.FileName);
                var filePath = Storage.modEntryPath + Storage.savesFolder + "\\" + name + ".xml";

                Common.ModLoggerDebug($"LoadGame {name}");

                if (File.Exists(filePath))
                {
                    Main.saveData     = Deserialize(filePath);
                    Storage.lockPicks = Main.saveData.lockPicks;
                    Common.ModLoggerDebug($"{filePath} loaded.");
                }
                else
                {
                    Storage.lockPicks = 5;
                    Main.modLogger.Log($"{filePath} not found!");
                }
            }
            catch (Exception e)
            {
                Main.modLogger.Log(e.ToString());
            }
        }
Esempio n. 32
0
    /// <summary>
    /// 세이브 파일 정보 가져오기
    /// </summary>
    /// <param name="filepath"></param>
    /// <returns></returns>
    public static SaveInfo GetSaveFileInfo(string filepath)
    {
        var info				= new SaveInfo();

        var rawdata				= FSNUtils.LoadTextData(filepath);
        JSONObject json			= JSONObject.Create(rawdata);

        if (json != null)
        {
            info.saveDateTime	= json[c_field_saveDateTime].str;
            info.title			= json[c_field_saveTitle].str;
        }

        return info;
    }
Esempio n. 33
0
 // Use this for initialization
 void Start()
 {
     #if UNITY_EDITOR
     if(GameObject.Find("SaveInfo") == null)
     {
         Debug.Log("(Saving Disabled) Load Game from mainMenu.");
     }
     else
     {
         saveInfo = GameObject.Find("SaveInfo").GetComponent<SaveInfo>();
     }
     #else
     saveInfo = GameObject.Find("SaveInfo").GetComponent<SaveInfo>();
     #endif
 }
Esempio n. 34
0
 public Goal(Texture2D texture, int x, int y, int width, int height, Game1 game1, GameScreen gs)
 {
     game = game1;
     ls = new LevelScreen(game);
     theGame = game;
     save = new SaveInfo();
     state = new GameState(game);
     rect = new Rectangle(x, y, width, height);
     xPostion = x;
     yPostion = y;
     this.width = width;
     this.height = height;
     goalTexture = texture;
     gameScreen = gs;
 }
Esempio n. 35
0
 //Constructor
 public OptionScreen(Game1 game1)
 {
     game = game1;
     gameState = new GameState(game); // creates new gamestate object and assigns it to gameState
     font1 = game.Content.Load<SpriteFont>("Font1"); //loads Font1
     back = game.Content.Load<Texture2D>("back");
     soundOn1 = game.Content.Load<Texture2D>("soundOn1");
     soundOn2 = game.Content.Load<Texture2D>("soundOn2");
     soundOff1 = game.Content.Load<Texture2D>("soundOff1");
     soundOff2 = game.Content.Load<Texture2D>("soundOff2");
     levelUnlock1 = game.Content.Load<Texture2D>("levelUnlock1");
     levelUnlock2 = game.Content.Load<Texture2D>("levelUnlock2");
     resetHS1 = game.Content.Load<Texture2D>("resetHS1");
     resetHS2 = game.Content.Load<Texture2D>("resetHS2");
     info = new SaveInfo();
     count = 0;
 }
Esempio n. 36
0
        //Constructor
        public LevelScreen(Game1 game1)
        {
            save = new SaveInfo();
            game = game1;
            gameState = new GameState(game); // creates new gamestate object and assigns it to gameState
            font1 = game.Content.Load<SpriteFont>("Font1"); // loads Font1
            lastState = Keyboard.GetState();
            levels = save.ReadUnlock();

            back = game.Content.Load<Texture2D>("back");
            lvl1 = game.Content.Load<Texture2D>("level1");
            lvl2 = game.Content.Load<Texture2D>("level2");
            lvl3 = game.Content.Load<Texture2D>("level3");
            lvl4 = game.Content.Load<Texture2D>("level4");
            lvl5 = game.Content.Load<Texture2D>("level5");
            lvl6 = game.Content.Load<Texture2D>("level6");

            currentLvl = "level1.txt";
            nextLvl = "level2.txt";
        }
Esempio n. 37
0
        // Call this to get the savegame name
        public SaveInfo GetSaveInfo(int saveIndex)
        {
            SaveInfo saveInfo = new SaveInfo();
            SaveContainer container = SaveManager.instance.container;

            //reset value so game works with savegames made with older versions
            container.difficulty = DifficultySetting.NORMAL;

            saveInfo.screenshot = new Texture2D(320, 180);

            string filePath = saveDirectory + "\\savegame" + (saveIndex + 1) + ".dat";
            if (!File.Exists(filePath)){
                saveInfo.name = null;
            } else {
                container.formatVersion = 0;
                Load(saveIndex, false);
                if (container.formatVersion<3){ //don't show saved games from older versions
                    saveInfo.name = null;
                } else if  (container.name != null){
                    saveInfo.name = container.name;
                } else {
                    saveInfo.name = "Savegame " + (saveIndex + 1);
                }
                if (container.dateTime != null){
                    saveInfo.dateTime = container.dateTime;
                } else {
                    saveInfo.dateTime = "";
                }
                saveInfo.playTime = container.playTime;
                saveInfo.difficulty = container.difficulty;
                if (container.screenshot != null){
                    saveInfo.screenshot.LoadImage(container.screenshot);
                }
                saveInfo.level = container.level;
            }
            return saveInfo;
        }
Esempio n. 38
0
    //자동 저장
    void OnApplicationQuit()
    {
        GameObject[] spheres = GameObject.FindGameObjectsWithTag("SaveSphere");

        //List 준비
        List<SaveInfo> saveList = new List<SaveInfo>();

        for (int i = 0; i < spheres.Length; i++)
        {
            SaveInfo saveInfo = new SaveInfo();

            saveInfo.posX = spheres[i].transform.position.x;
            saveInfo.posY = spheres[i].transform.position.y;
            saveInfo.posZ = spheres[i].transform.position.z;

            saveInfo.scaleX = spheres[i].transform.localScale.x;
            saveInfo.scaleY = spheres[i].transform.localScale.y;
            saveInfo.scaleZ = spheres[i].transform.localScale.z;

            saveInfo.name = spheres[i].name;

            saveList.Add(saveInfo);

        }

        //메모리를 2진데이터로 바꿔준다.
        BinaryFormatter formatter = new BinaryFormatter();

        //2진데이터화 된 메모리를 저장할 공간.
        MemoryStream memStream = new MemoryStream();

        //BinaryFormatter 인스턴스를 통해 saveList 의 메모리블럭을 2진데이터화하여 memStream 에 저장
        formatter.Serialize(memStream, saveList);

        //저장된 메모리스트림에 있는 메모리를 문자로 강제 치환
        string memStr = Convert.ToBase64String(memStream.GetBuffer());

        print(memStr);

        //플레이어프리펩에 문자열 자체로 저장
        PlayerPrefs.SetString("SphereInfos", memStr);


    }
Esempio n. 39
0
    //자동 저장
    void OnApplicationQuit()
    {
        GameObject[] spheres = GameObject.FindGameObjectsWithTag("SaveSphere");

        //List 준비
        List<SaveInfo> saveList = new List<SaveInfo>();

        for (int i = 0; i < spheres.Length; i++)
        {
            SaveInfo saveInfo = new SaveInfo();

            saveInfo.posX = spheres[i].transform.position.x;
            saveInfo.posY = spheres[i].transform.position.y;
            saveInfo.posZ = spheres[i].transform.position.z;

            saveInfo.scaleX = spheres[i].transform.localScale.x;
            saveInfo.scaleY = spheres[i].transform.localScale.y;
            saveInfo.scaleZ = spheres[i].transform.localScale.z;

            saveInfo.name = spheres[i].name;

            saveList.Add(saveInfo);

        }

        //메모리를 2진데이터로 바꿔준다.
        BinaryFormatter formatter = new BinaryFormatter();

        //2진데이터화 된 메모리를 저장할 공간.
        MemoryStream memStream = new MemoryStream();

        //BinaryFormatter 인스턴스를 통해 saveList 의 메모리블럭을 2진데이터화하여 memStream 에 저장
        formatter.Serialize(memStream, saveList);

        //버퍼에 있는 내용을 파일에 그대로 써재낀다.
        byte[] memArr = memStream.GetBuffer();

        //Application.persistentDataPath 유니티 Application 에 할당된 로컬 저장 경로 ( 여기에 파일저장하면 Save Load 아무문제 없다 )
        string savePath = Application.persistentDataPath + "/SaveFile.Dat";

        //파일스트림 생성
        FileStream fileStream = new FileStream(
                                savePath,                   //파일경로 ( 파일경로에 폴더가 만들어지지 않았다면 DirectoryNotFoundException 가 발생한다 )
                                FileMode.Create,            //파일모드
                                FileAccess.Write            //파일접근 권한
                                );

        //파일스트림에 쓴다.
        fileStream.Write(memArr, 0, memArr.Length);

        //파일스트림 닫는다.
        fileStream.Close();
        
        print(savePath + "에 저장완료!!!!!");

    }
Esempio n. 40
0
        //basic game screen constructor
        public GameScreen(Game1 game)
        {
            this.game = game;
            gameState = new GameState(game); //creates new gameState object and assigns it to game screen
            font1 = game.Content.Load<SpriteFont>("Font1"); //loads Font1

            drawList = new List<GameObject>();
            enemyList = new List<Enemy>();
            timeSinceLastMove = 0;
            enemyPathList = new List<EnemyPathEnd>();
            colList = new List<Rectangle>();
            gemsList = new List<Gold>();
            bulletList = new List<Bullet>();
            platformList = new List<Platform>();

            SaveInfo info = new SaveInfo();
            Dictionary<string, int> highscoreDict = info.ReadHighScore();
            highScore = highscoreDict[levelName];
            // reading in the file
            StreamReader input = null;

            input = new StreamReader(levelFile); // this will load in whatever level the player picks
            string text = "";
            level = input.ReadLine(); // brings in the level name
            text = input.ReadLine(); // brings in the high score as a string
            //int.TryParse(text, out highScore); // now its an int
            text = input.ReadLine(); // brings in the best time as a string
            double.TryParse(text, out bestTime); // now its a double

            text = input.ReadLine(); // read in width
            int.TryParse(text, out gameWidth);

            text = input.ReadLine(); // read in height
            int.TryParse(text, out gameHeight);

            int xPos = game.screenWidth / gameWidth;
            //int yPos = game.screenHeight / gameHeight;

            grappleableObjectList = new List<GameObject>();
            int y = -gameHeight + 8;
            while ((text = input.ReadLine()) != null)
            {

                int x = 0;
                string[] gamePiece = text.Split();
                foreach (string piece in gamePiece)
                {
                    if (piece == "w")
                    {
                        Platform block = new Platform(game.wallSprite, xPos * x + x, xPos * y + y, xPos, xPos);
                        drawList.Add(block);
                        colList.Add(block.rect);
                        platformList.Add(block);
                        grappleableObjectList.Add(block);
                    }
                    else if (piece == "c")
                    {
                        player = new Player(game.playerSprite, xPos * x + x, xPos * y + y, game.playerSprite.Width * 4, game.playerSprite.Height * 4, colList, game, this, enemy, block);
                    }
                    else if (piece == "f")
                    {
                        endGoal = new Goal(game.goalSprite, xPos * x + x, xPos * y + y, xPos, xPos, game, this);
                    }
                    else if (piece == "g")
                    {
                        gem = new Gold(game.gemSprite, xPos * x + 25, xPos * y + 35, game.gemSprite.Width, game.gemSprite.Height, this, game.coinS);
                        gemsList.Add(gem);
                    }
                    else if (piece == "e")
                    {
                        enemy = new Enemy(game.enemySprite, xPos * x, xPos * y + y, game.enemySprite.Width, game.enemySprite.Height, game, this, true, bulletList);
                        enemyList.Add(enemy);
                        bulletList.Add(enemy.MyBullet);
                    }
                    else if (piece == "t")
                    {
                        epe = new EnemyPathEnd(xPos * x + x, xPos * y + y, game.wallSprite.Width, 1, true, game);
                        enemyPathList.Add(epe);
                    }

                    // will add code later for all the other objects that are going to be shown

                    x++;
                }
                y++;
            }
            input.Close();
            input.Close();
            y--;
            lavaRect = new Rectangle(0, game.screenHeight - game.lavaBack.Height, game.screenWidth, game.lavaBack.Height);
        }