Example #1
0
        public void Start(Savegame savegame)
        {
            ticks            = 0;
            Active           = true;
            actionIndex      = 0;
            scrolledAmount   = 0;
            scrollStartTicks = 0;
            nextActionTicks  = 0;
            waitForClick     = false;
            speedIndex       = 1;

            var option = OutroOption.ValdynNotInParty;

            if (savegame.CurrentPartyMemberIndices.Contains(12u)) // Valdyn in party
            {
                if (savegame.IsGameOptionActive(Data.Enumerations.Option.FoundYellowSphere))
                {
                    option = OutroOption.ValdynInPartyWithYellowSphere;
                }
                else
                {
                    option = OutroOption.ValdynInPartyNoYellowSphere;
                }
            }

            actions = outroData.OutroActions[option];

            Process();
        }
Example #2
0
        protected void UpdateAmulet(Savegame pSavegame, SceneData pScene)
        {
            if (pSavegame.SceneId != Hardcoded.Scene_Amulet || Amulet.m2ndState)
            {
                AmuletBlocksWaypoints = false;
                return;
            }
            AmuletBlocksWaypoints = true;
            AmuletCharged         = true;
            foreach (ChargeAmulet a in AmuletStates)
            {
                if (a.m2ndState == false)
                {
                    AmuletCharged = false;
                    return;
                }
            }

            /*
             * foreach (ChargeAmulet a in AmuletStates)
             *      a.m2ndState = false;
             * Witch w = null;
             * foreach (Enemy e in pScene.Enemies)
             *      if (e.GetType() == typeof(Witch))
             *      {
             *              w = (Witch)e;
             *      }
             * if (w == null) throw new Exception("Witch nicht gefunden!");
             * pScene.Enemies.Remove(w);
             */
        }
        public SavegameOutputFiles Write(Savegame savegame)
        {
            var files             = new SavegameOutputFiles();
            var partyMemberWriter = new Characters.PartyMemberWriter();
            var chestWriter       = new ChestWriter();
            var merchantWriter    = new MerchantWriter();
            var automapWriter     = new AutomapWriter();

            Dictionary <int, IDataWriter> WriteContainer <T>(Dictionary <uint, T> collection, Action <IDataWriter, T> writer)
            {
                var container = new Dictionary <int, IDataWriter>(collection.Count);

                foreach (var item in collection)
                {
                    var valueWriter = new DataWriter();
                    writer(valueWriter, item.Value);
                    container.Add((int)item.Key, valueWriter);
                }
                return(container);
            }

            files.PartyMemberDataWriters = WriteContainer(savegame.PartyMembers, (w, p) => partyMemberWriter.WritePartyMember(p, w));
            files.ChestDataWriters       = WriteContainer(savegame.Chests, (w, c) => chestWriter.WriteChest(c, w));
            files.MerchantDataWriters    = WriteContainer(savegame.Merchants, (w, m) => merchantWriter.WriteMerchant(m, w));
            files.AutomapDataWriters     = WriteContainer(savegame.Automaps, (w, a) => automapWriter.WriteAutomap(a, w));
            files.SaveDataWriter         = new DataWriter();
            WriteSaveData(savegame, files.SaveDataWriter);

            return(files);
        }
        private void SetupSavegame()
        {
            _savegameDisposer.Disposable?.Dispose();

            _savegame = new Savegame(_savegameData);
            _savegameDisposer.Disposable = _savegame;
        }
Example #5
0
    private IEnumerator Start()
    {
        // If there is a save file
        if (Savegame.checkIfSaveExists())
        {
            Savegame.load();

            yield return(null);

            if (Player.checkForUpdatesOnStart)
            {
                yield return(checkIfLastVersion());
            }

            yield return(null);

            SceneManager.LoadScene("TitleScreen");
        }
        else // If no save file
        {
            Destroy(GameObject.Find("BlankImage"));
            ao = SceneManager.LoadSceneAsync("TitleScreen", LoadSceneMode.Single);
            ao.allowSceneActivation = false;
        }
    }
        /// <summary>
        /// Aktualisiert den FadingProgress des Switchings.
        /// </summary>
        public void Switch(Savegame pSavegame, ref SceneData pScene, Hansel pHansel, Gretel pGretel, Camera pCamera, TwoDRenderer pRenderer)
        {
            AIManager.Instance.ClearAgents();
            FadingProgress += EngineSettings.Time.ElapsedGameTime.Milliseconds;
            pHansel.MoveManually(LeaveHansel, 1f, pScene);
            pGretel.MoveManually(LeaveGretel, 1f, pScene);
            if (FadingProgress >= FadingDuration)
            {
                //Switch
                pHansel.MoveInteractiveObject(DestinationHansel - pHansel.SkeletonPosition);
                pGretel.MoveInteractiveObject(DestinationGretel - pGretel.SkeletonPosition);
                pSavegame.SceneId  = DestinationScene;
                pScene             = pSavegame.Scenes[DestinationScene];
                pCamera.GameScreen = pScene.GamePlane;
                pScene.SetupRenderList(pHansel, pGretel);
                pRenderer.AmbientLight = pScene.SceneAmbientLight;
                //Show on new Scene
                FadingProgress = 0;
                CurrentState   = State.Entering;

                GameReferenzes.Level = pScene;
                AIManager.Instance.ChangeMap(pCamera.GameScreen, pScene.MoveArea);

                // Für alle weiteren Felder die nicht betreten werden können.
                AIManager.Instance.SetInterActiveObjects(pScene.InteractiveObjects);
                AIManager.Instance.SetAgents(pScene.Enemies);

                GameReferenzes.SceneID = DestinationScene;

                SoundHandler.Instance.ResetTime();
                FmodMediaPlayer.Instance.SetBackgroundSong(GameReferenzes.GetBackgroundMusic());
                GameReferenzes.IsSceneSwitching = false;
            }
        }
Example #7
0
        public void test_RAlert()
        {
            int level, counter = 0;

            int[] turns = new int[4];
            // 4 turns in which combat starts
            turns[0] = 1;
            turns[1] = 10;
            turns[2] = 22;
            turns[3] = 34;
            g        = new Game(5, 2, 30, true);
            gs       = new Gamestate(g);
            savegame = new Savegame(gs);
            path     = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game9/game9_turn";
            for (int j = 0; j < turns.Length; j++)
            {
                for (int h = j; h < j + 2; h++)
                {
                    data = savegame.OpenFile(h, path);
                    Gamestate gamestate1 = new Gamestate(g, data);
                    data = savegame.OpenFile(h + 1, path);
                    Gamestate gamestate = new Gamestate(g, data);
                    level = gamestate1.g.dungeon.CurrentLevel(gamestate1.g.dungeon.player.location);
                    for (int i = (level * 4); i < (level * 4) + 3; i++)
                    {
                        counter = 0;
                        foreach (Pack pack in gamestate1.g.dungeon.nodeList[i].packs)
                        {
                            Always always = new Always((G => G.dungeon.Shortestpath(pack.location, G.dungeon.player.location).Count() <= G.dungeon.Shortestpath(gamestate.g.dungeon.nodeList[i].packs[counter++].location, G.dungeon.player.location).Count()));
                            Assert.True(always.test(gamestate1.g));
                        }
                    }
                }
            }
        }
Example #8
0
 public Gameplaytest()
 {
     g = new Game(5, 1, 5, false);
     g.dungeon.player.bag.Add(new HealingPotion("0"));
     gs       = new Gamestate(g);
     savegame = new Savegame(gs);
 }
Example #9
0
 public void savesheild(Savegame sg)
 {
     sg.damageC  = _damageC;
     sg.damageL  = _damageL;
     sg.damageFL = _damageFL;
     sg.damageR  = _damageR;
     sg.damageFR = _damageFR;
     sg.damageRC = _damageRC;
     sg.damageLC = _damageLC;
 }
Example #10
0
 public void loadsheild(Savegame sg)
 {
     _damageC  = sg.damageC;
     _damageL  = sg.damageL;
     _damageFL = sg.damageFL;
     _damageR  = sg.damageR;
     _damageFR = sg.damageFR;
     _damageRC = sg.damageRC;
     _damageLC = sg.damageLC;
 }
Example #11
0
    private void OnSaveButtonPressed(string filename, int savegameId)
    {
        Savegame savegame = new Savegame()
        {
            Id   = savegameId, Name = filename,
            Type = typeof(T).Name, File = JsonConvert.SerializeObject(Serialize())
        };

        backendManager.SaveGame(savegame);
    }
Example #12
0
        private void newGameButton_Click(object sender, EventArgs e)
        {
            string saveName = InputDialog.Show("Name of new save?", "New Save");

            if (saveName != null)
            {
                Savegame newSave = new Savegame(Game.Columns, Game.Rows, Game.GetSerialised(), saveName);
                db.AddSavegame(newSave, Username);
                EnumerateSavegames();
            }
        }
Example #13
0
        public void WriteSaveGameForPackString()
        {
            Game      withPacks   = new Game(5, 2, 10, false);
            Gamestate withPacksGS = new Gamestate(withPacks);
            Savegame  savegame    = new Savegame(withPacksGS);

            savegame.SaveTurn();
            Gamestate openFile = new Gamestate(withPacks, savegame.OpenFile(0, ""));

            Assert.Equal(withPacks.dungeon.packs, openFile.g.dungeon.packs);
        }
Example #14
0
    void loadGame()
    {
        if (File.Exists(MainMenuManager.savegamePath))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(MainMenuManager.savegamePath, FileMode.Open);
            Savegame        save = (Savegame)bf.Deserialize(file);
            file.Close();

            applySavegameDataToPlayer(save);
        }
    }
Example #15
0
    public void checkIfDeleteSavefile()
    {
        nTimesPressedDeleteButton++;
        Text deleteText = GameObject.Find("FinalDeleteButton").GetComponentInChildren <Text>();

        deleteText.text = TextScript.get(TextScript.Sentence.DELETE_BUTTON) + " (" + nTimesPressedDeleteButton + ")";

        if (nTimesPressedDeleteButton >= 7)
        {
            Savegame.deleteSaveFile();
        }
    }
Example #16
0
        public void GetValueReturnsDefaultTIfKeyDoesNotExist()
        {
            // Arrange
            var savegame = new Savegame("123/456".ToValidSavegameString());
            const int invalidKey = 1000;

            // Act
            var result = savegame.GetValue<int>(invalidKey);

            // Assert
            result.Should().Be(default(int));
        }
Example #17
0
        public void GetValueReturnsValueIfKeyDoesExist()
        {
            // Arrange
            var savegame = new Savegame("123/456".ToValidSavegameString());
            const int validKey = 2;

            // Act
            var result = savegame.GetValue<int>(validKey);

            // Assert
            result.Should().Be(456);
        }
Example #18
0
        public static Event GetEvent(this Map map, uint x, uint y, Savegame savegame)
        {
            var  mapEventId  = map.Type == MapType.Map2D ? map.Tiles[x, y].MapEventId : map.Blocks[x, y].MapEventId;
            bool hasMapEvent = mapEventId != 0 && savegame.IsEventActive(map.Index, mapEventId - 1);

            if (!hasMapEvent)
            {
                return(null);
            }

            return(map.EventList[(int)mapEventId - 1]);
        }
Example #19
0
        public void CreateInventoryShouldNotContainAnyItemsWithEmptyUri()
        {
            // Arrange
            var sut = new ItemProvider(TestConstants.ValidServerUri);
            var sg = new Savegame(TestConstants.ValidSavegameString);

            // Act
            var inventory = sut.CreateInventory(sg);

            // Assert
            inventory.AllItems.Should().NotContain(i => i.ImageUri == null);
        }
Example #20
0
        public void CreateInventoryShouldReturnInventoryWith15Items()
        {
            // Arrange
            var sut = new ItemProvider(TestConstants.ValidServerUri);
            var sg = new Savegame(TestConstants.ValidSavegameString);

            // Act
            var inventory = sut.CreateInventory(sg);

            // Assert
            inventory.AllItems.Count().Should().Be(15);
        }
Example #21
0
        public void test_RNode()
        {
            int monstersOnNode = 0;
            int l, c, m;

            for (int k = 1; k < 9; k++)
            {
                if (k < 5)
                {
                    l = 5;
                }
                else
                {
                    l = 10;
                }
                if (k % 2 == 0)
                {
                    c = 3;
                }
                else
                {
                    c = 2;
                }
                if (k == 3 || k == 4 || k == 7 || k == 8)
                {
                    m = 50;
                }
                else
                {
                    m = 30;
                }
                g        = new Game(l, c, m, true);
                gs       = new Gamestate(g);
                savegame = new Savegame(gs);
                path     = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game" + k + "/game" + k + "_turn";
                for (int i = 0; i < gameturns[k - 1]; i++)
                {
                    data = savegame.OpenFile(i, path);
                    Gamestate gamestate = new Gamestate(g, data);
                    foreach (Node node in gamestate.g.dungeon.nodeList)
                    {
                        monstersOnNode = 0;
                        foreach (Pack pack in node.packs)
                        {
                            monstersOnNode += pack.members.Count();
                        }
                        Always always = new Always((G => monstersOnNode <= G.dungeon.multiplier * (G.dungeon.Level(node) + 1)));

                        Assert.True(always.test(gamestate.g));
                    }
                }
            }
        }
Example #22
0
    /// <summary>
    /// Load player game
    /// Currently only player position
    /// </summary>
    /// <param name="saveName"></param>
    public void LoadGame(string saveName)
    {
        if (PlayerPrefs.HasKey("Savegames"))
        {
            string    allSavegamesString = PlayerPrefs.GetString("Savegames");
            Savegames allSavegames       = JsonUtility.FromJson <Savegames>(allSavegamesString);

            Savegame save = null;
            foreach (Savegame s in allSavegames.savegames)
            {
                if (s.name == saveName)
                {
                    save = s;
                }
            }

            if (save != null)
            {
                foreach (string s in save.itemsNamesInventory)
                {
                    _player.inventory.Add(GetItem(s));
                }
                foreach (string s in save.itemsNamesStock)
                {
                    _player.stock.Add(GetItem(s));
                }

                Vector3 position = save.position;
                GameObject.Find("PlayerController").transform.position = position;

                foreach (AnimalData ad in save.animals)
                {
                    AnimalBody concernedAnimal = GetAnimal(ad.name);
                    Food       eat             = GetItem(ad.eat) as Food;
                    int        happiness       = ad.happiness;
                    int        hunger          = ad.hunger;
                    Vector3    animalPosition  = ad.position;
                    Vector3    animalRotation  = ad.rotation;
                    string     wearStr         = ad.wear;
                    RareItem   wear            = null;
                    if (wearStr != null)
                    {
                        wear = GetItem(wearStr) as RareItem;
                    }
                    RareItem canWear = GetItem(ad.canWear) as RareItem;
                    concernedAnimal.animal.SetProperties(happiness, hunger, eat, wear, canWear);
                    concernedAnimal.transform.position = animalPosition;
                    concernedAnimal.transform.rotation = Quaternion.Euler(animalRotation);
                }
            }
        }
    }
Example #23
0
    public void saveGame(GameObject savepoint)
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(MainMenuManager.savegamePath);

        String   sceneName     = SceneManager.GetActiveScene().name;
        Vector3  spawnPosition = savepoint.transform.position + Vector3.down * 0.5f;
        Savegame save          = new Savegame(sceneName, spawnPosition, maxHealth, healthContainers, playerColor, unlockedColors,
                                              spotlightRadius, globalVariables, gameTimer, nOfEnemiesKilled, totalDamageReceived);

        bf.Serialize(file, save);
        file.Close();
    }
Example #24
0
        public void test_player_heal()
        {
            int l, c, m;

            for (int k = 1; k < 9; k++)
            {
                if (k < 5)
                {
                    l = 5;
                }
                else
                {
                    l = 10;
                }
                if (k % 2 == 0)
                {
                    c = 3;
                }
                else
                {
                    c = 2;
                }
                if (k == 3 || k == 4 || k == 7 || k == 8)
                {
                    m = 50;
                }
                else
                {
                    m = 30;
                }
                g        = new Game(l, c, m, true);
                gs       = new Gamestate(g);
                savegame = new Savegame(gs);
                for (int j = 1; j < 6; j++)
                {
                    int previousHP      = g.dungeon.player.HPbase;
                    int previousPotions = 0;
                    path = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game" + k + "/game" + k + "_turn";
                    Unless unless = new Unless(G => G.dungeon.player.HP <= previousHP, G => G.dungeon.player.HP > previousHP && G.dungeon.player.bag.OfType <HealingPotion>().Count() == previousPotions - 1);
                    for (int i = 0; i < gameturns[k - 1]; i++)
                    {
                        data = savegame.OpenFile(i, path);
                        Gamestate gamestate = new Gamestate(g, data);
                        Assert.True(unless.test(g));
                        previousHP      = gamestate.g.dungeon.player.HP;
                        previousPotions = gamestate.g.dungeon.player.bag.OfType <HealingPotion>().Count();
                    }
                }
            }
        }
Example #25
0
        private void SaveGameButton_Click(object sender, EventArgs e)
        {
            string selected = (string)SavegameListBox.SelectedItem;

            if (selected != null)
            {
                DialogResult result = MessageBox.Show($"Overwrite save \"{selected}\"?", "Overwrite Save", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    Savegame newSave = new Savegame(Game.Columns, Game.Rows, Game.GetSerialised(), selected);
                    db.UpdateSavegame(newSave, Username);
                }
            }
        }
Example #26
0
        public SavegameFeatureModel(
            Savegame <SavegameContent> savegame,
            ISavegameService savegameService)
        {
            var savegameJson = JsonConvert.SerializeObject(savegame, Formatting.Indented);

            var sb = new StringBuilder()
                     .AppendLine("CURRENT SAVEGAME:")
                     .AppendLine($"{savegameJson}");

            StaticLogger.Log(sb.ToString());

            savegameService.Save();
        }
Example #27
0
        public void test_RZone()
        {
            int l, c, m;
            int counter = 0;

            for (int k = 1; k < 9; k++)
            {
                if (k < 5)
                {
                    l = 5;
                }
                else
                {
                    l = 10;
                }
                if (k % 2 == 0)
                {
                    c = 3;
                }
                else
                {
                    c = 2;
                }
                if (k == 3 || k == 4 || k == 7 || k == 8)
                {
                    m = 50;
                }
                else
                {
                    m = 30;
                }
                g        = new Game(l, c, m, true);
                gs       = new Gamestate(g);
                savegame = new Savegame(gs);

                path = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game" + k + "/game" + k + "_turn";
                for (int i = 0; i < gameturns[k - 1]; i++)
                {
                    counter = 0;
                    data    = savegame.OpenFile(i, path);
                    Gamestate gamestate = new Gamestate(g, data);
                    foreach (Pack pack in gamestate.g.dungeon.packs)
                    {
                        Always always = new Always((G => G.dungeon.packs[counter++].zone == G.dungeon.CurrentLevel(pack.location)));
                        Assert.True(always.test(gamestate.g));
                    }
                }
            }
        }
        private void OnSave(GameEvent e)
        {
            string path = (string)e.EventData;
            List<SerializedEntity> savedEntities =
                this.EntityManager.Entities.Select(
                    entityId =>
                    new SerializedEntity { EntityId = entityId, Blueprint = this.EntityManager.Save(entityId) })
                    .ToList();

            Savegame savegame = new Savegame { SavedEntities = savedEntities };

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(Savegame));
            Stream stream = File.Open(path, FileMode.Truncate);
            xmlSerializer.Serialize(stream, savegame);
        }
        public EditSavegamePage(Savegame savegameInput)
        {
            InitializeComponent();

            selectedSavegame = savegameInput;

            // Load existing data
            savegameNameEntry.Text = savegameInput.SavegameName;
            if (!String.IsNullOrEmpty(savegameInput.SavegamePassword))
            {
                passwordCheckBox.IsChecked        = true;
                savegamePasswordEntry.Text        = savegameInput.SavegamePassword;
                confirmSavegamePasswordEntry.Text = savegameInput.SavegamePassword;
            }
        }
Example #30
0
        private void LoadGameButton_Click(object sender, EventArgs e)
        {
            string selected = (string)SavegameListBox.SelectedItem;

            if (selected != null)
            {
                Savegame save = db.LoadSavegame(Username, selected);
                rowNumericUpDown.Value    = save.Rows;
                columnNumericUpDown.Value = save.Columns;
                Game = ToroidalGameOfLife.Deserialise(save.Serialised, save.Rows, save.Columns);
                GameTypeComboBox.SelectedIndex = 0;
                ThresholdsChanged(sender, e);
                renderPictureBox.Invalidate();
            }
        }
Example #31
0
        public static bool TriggerEvents(this Map map, Game game, EventTrigger trigger,
                                         uint x, uint y, uint ticks, Savegame savegame, out bool hasMapEvent, Func <Event, bool> filter = null)
        {
            var mapEventId = map.Type == MapType.Map2D ? map.Tiles[x, y].MapEventId : map.Blocks[x, y].MapEventId;

            hasMapEvent = mapEventId != 0 && savegame.IsEventActive(map.Index, mapEventId - 1);

            if (!hasMapEvent)
            {
                return(false);
            }

            var @event = map.EventList[(int)mapEventId - 1];

            if (filter != null && !filter(@event))
            {
                return(false);
            }

            if (trigger == EventTrigger.Move && LastMapEventIndexMap == map.Index && LastMapEventIndex == mapEventId)
            {
                var ev = @event;

                while (ev?.Type == EventType.Condition ||
                       ev?.Type == EventType.Dice100Roll)
                {
                    ev = ev.Next;
                }

                // avoid triggering the same event twice, but only for some events
                if (ev != null &&
                    ev.Type != EventType.Teleport &&
                    ev.Type != EventType.Chest &&
                    ev.Type != EventType.Door &&
                    ev.Type != EventType.EnterPlace &&
                    ev.Type != EventType.RemoveBuffs &&
                    ev.Type != EventType.Riddlemouth &&
                    (map.Type == MapType.Map3D || ev.Type != EventType.Trap))
                {
                    return(false);
                }
            }

            LastMapEventIndexMap = map.Index;
            LastMapEventIndex    = mapEventId;

            return(map.TriggerEventChain(game, trigger, x, y, ticks, @event));
        }
Example #32
0
    /// <summary>
    /// Does a POST or PUT request to the server, depending on if the SaveGame you provide has an id or not. If the id is present, the savegame will be updated by of PUT request. Else
    /// a new savegame will be POST'ed to the server. On success, the OnSaveGameSuccess delegate will be called. On fail, the OnSaveGameFailed delegate will be called.
    /// </summary>
    /// <param name="savegame"></param>
    public void SaveGame(Savegame savegame)
    {
        WWWForm form = new WWWForm();

        form.AddField("name", savegame.Name);
        form.AddField("type", savegame.Type);
        form.AddBinaryData("file", System.Text.Encoding.UTF8.GetBytes(savegame.File));
        if (savegame.Id == -1)
        {
            Send(RequestType.Post, "savegame", form, OnSaveGameResponse, authenticationToken);
        }
        else
        {
            Send(RequestType.Put, "savegame/" + savegame.Id + "/", form, OnSaveGameResponse, authenticationToken);
        }
    }
Example #33
0
        public Savegame LoadInitial(IGameData gameData, ISavegameSerializer savegameSerializer)
        {
            var savegame = new Savegame();
            SavegameInputFiles savegameFiles;
            IFileContainer     partyTextContainer;

            try
            {
                savegameFiles = new SavegameInputFiles
                {
                    SaveDataReader         = gameData.Files["Initial/Party_data.sav"].Files[1],
                    PartyMemberDataReaders = gameData.Files["Initial/Party_char.amb"],
                    ChestDataReaders       = gameData.Files["Initial/Chest_data.amb"],
                    MerchantDataReaders    = gameData.Files["Initial/Merchant_data.amb"],
                    AutomapDataReaders     = gameData.Files["Initial/Automap.amb"]
                };
            }
            catch
            {
                try
                {
                    savegameFiles = new SavegameInputFiles
                    {
                        SaveDataReader         = gameData.Files["Save.00/Party_data.sav"].Files[1],
                        PartyMemberDataReaders = gameData.Files["Save.00/Party_char.amb"],
                        ChestDataReaders       = gameData.Files["Save.00/Chest_data.amb"],
                        MerchantDataReaders    = gameData.Files["Save.00/Merchant_data.amb"],
                        AutomapDataReaders     = gameData.Files["Save.00/Automap.amb"]
                    };
                }
                catch
                {
                    savegameFiles = new SavegameInputFiles
                    {
                        SaveDataReader         = gameData.Files["Party_data.sav"].Files[1],
                        PartyMemberDataReaders = gameData.Files["Party_char.amb"],
                        ChestDataReaders       = gameData.Files["Chest_data.amb"],
                        MerchantDataReaders    = gameData.Files["Merchant_data.amb"],
                        AutomapDataReaders     = gameData.Files["Automap.amb"]
                    };
                }
            }

            partyTextContainer = gameData.Files["Party_texts.amb"];
            savegameSerializer.Read(savegame, savegameFiles, partyTextContainer);
            return(savegame);
        }
Example #34
0
        public void test_monsters_never_increase()
        {
            int l, c, m;

            for (int k = 1; k < 9; k++)
            {
                if (k < 5)
                {
                    l = 5;
                }
                else
                {
                    l = 10;
                }
                if (k % 2 == 0)
                {
                    c = 3;
                }
                else
                {
                    c = 2;
                }
                if (k == 3 || k == 4 || k == 7 || k == 8)
                {
                    m = 50;
                }
                else
                {
                    m = 30;
                }
                g        = new Game(l, c, m, true);
                gs       = new Gamestate(g);
                savegame = new Savegame(gs);
                for (int j = 1; j < 6; j++)
                {
                    path = @"C:/Users/Gebruiker/Documents/GitHub/Software-Testing-Assignment-2/STVRogue/Gameplays/game" + k + "/game" + k + "_turn";
                    Unless unless = new Unless(G => G.dungeon.numberOfMonsters > G.dungeon.countMonsters(), G => G.dungeon.numberOfMonsters == G.dungeon.countMonsters());
                    for (int i = 0; i < gameturns[k - 1]; i++)
                    {
                        data = savegame.OpenFile(i, path);
                        Gamestate gamestate = new Gamestate(g, data);
                        Assert.True(unless.test(g));
                    }
                }
            }
        }
Example #35
0
    void applySavegameDataToPlayer(Savegame save)
    {
        if (SceneManager.GetActiveScene().name != save.sceneName)
        {
            SceneManager.LoadScene(save.sceneName);
        }

        transform.position  = new Vector3(save.pos[0], save.pos[1], 0);
        maxHealth           = save.maxHealth;
        healthContainers    = save.healthContainers;
        playerColor         = new Color(save.playerColor[0], save.playerColor[1], save.playerColor[2]);
        unlockedColors      = save.unlockedColors;
        spotlightRadius     = save.spotlightRadius;
        globalVariables     = save.globalVariables;
        gameTimer           = save.gameTimer;
        nOfEnemiesKilled    = save.nOfEnemiesKilled;
        totalDamageReceived = save.totalDamageReceived;
    }
        public static ISavegame Deserialize(string data)
        {
            if (data == null) throw new ArgumentNullException(nameof(data));
            try
            {
                var savegame = new Savegame(data.GetFilledLines().Select(DataWrapper.Parse).ToArray());

                if (savegame.Header == null)
                    throw new InvalidSavegameException("SavegameHeader is missing");
                if (savegame.Park == null)
                    throw new InvalidSavegameException("Park is missing");

                return savegame;
            }
            catch (Exception e)
            {
                throw e is InvalidSavegameException
                    ? e
                    : new InvalidSavegameException("Invalid savegame", e);
            }
        }
Example #37
0
 public void Loaded(Savegame savegame)
 {
     LogsCount = new Savegame.DataValue(savegame, Savegame.DataValue.BLUEPRINT, this.Logs, 0, Constants.MaxValues["LogHolderLogs"]);
 }
Example #38
0
 public void Loaded(Savegame savegame)
 {
     SticksCount = new Savegame.DataValue(savegame, Savegame.DataValue.BLUEPRINT, this.Sticks, 0, Constants.MaxValues["StickHolderSticks"]);
 }
Example #39
0
        public void SetValueThrowsNoExceptionIfKeyDoesNotExist()
        {
            // Arrange
            var savegame = new Savegame("123/456".ToValidSavegameString());
            const int invalidKey = 1000;

            // Act
            Action a = () => savegame.SetValue(invalidKey, 0);

            // Assert
            a.ShouldNotThrow<Exception>();
        }
Example #40
0
        public void SetValueSfChangesValue()
        {
            // Arrange
            var savegame = new Savegame("123/456".ToValidSavegameString());
            const SF validKey = (SF) 2;
            var oldValue = savegame.GetValue(validKey); // 456

            // Act
            savegame.SetValue(validKey, 0);

            // Assert
            var newValue = savegame.GetValue(validKey);
            newValue.Should().NotBe(oldValue);
        }
 /// <summary>
 /// Does a POST or PUT request to the server, depending on if the SaveGame you provide has an id or not. If the id is present, the savegame will be updated by of PUT request. Else
 /// a new savegame will be POST'ed to the server. On success, the OnSaveGameSuccess delegate will be called. On fail, the OnSaveGameFailed delegate will be called.
 /// </summary>
 /// <param name="savegame"></param>
 public void SaveGame(Savegame savegame) {
     WWWForm form = new WWWForm();
     form.AddField("name", savegame.Name);
     form.AddField("type", savegame.Type);
     form.AddBinaryData("file", System.Text.Encoding.UTF8.GetBytes(savegame.File));
     if (savegame.Id == -1) {
         Send(RequestType.Post, "savegame", form, OnSaveGameResponse, authenticationToken);
     } else {
         Send(RequestType.Put, "savegame/" + savegame.Id + "/", form, OnSaveGameResponse, authenticationToken);
     }
     
 }
 /// <summary>
 /// Adds a new savegame
 /// </summary>
 public void AddSave(CharacterType playerType)
 {
     if (!saves.ContainsKey(CurrentSaveName))
     { saves.Add(CurrentSaveName, new Savegame(playerType)); }
     else
     { saves[CurrentSaveName] = new Savegame(playerType); }
     Save();
 }