Exemple #1
0
    public GameData(SetupRouter sr)
    {
        PlayerTeam = new List <PlayerLunen>();
        //Debug.Log("Found " + sr.battleSetup.PlayerLunenTeam.Count + " Lunen!");
        foreach (GameObject monster in sr.battleSetup.PlayerLunenTeam)
        {
            PlayerTeam.Add(GeneratePlayerLunen(monster.GetComponent <Monster>(), sr));
        }
        StorageLunen = sr.storageSystem.StoredLunen;

        InventoryItems = new List <InventoryItem>();
        //Debug.Log("Found " + sr.inventory.listOfItems.Count + " Item" + (sr.inventory.listOfItems.Count == 1 ? "" : "s") + "!");
        for (int i = 0; i < sr.inventory.listOfItems.Count; i++)
        {
            Inventory.InventoryEntry currentItem = sr.inventory.listOfItems[i];
            InventoryItem            a           = new InventoryItem();
            a.itemIndex  = sr.database.ItemToIndex(currentItem.item);
            a.itemAmount = currentItem.amount;
            InventoryItems.Add(a);
        }

        SaveTriggers = new List <TriggerSet>();
        for (int i = 0; i < sr.database.GlobalStoryTriggerList.Count; i++)
        {
            TriggerSet set = new TriggerSet();
            set.setName = sr.database.GlobalStoryTriggerList[i].name;
            foreach (TriggerPart part in sr.database.GlobalStoryTriggerList[i].triggerParts)
            {
                TriggerSave save = new TriggerSave();
                save.triggerTITLE  = part.title;
                save.triggerType   = part.type;
                save.triggerBool   = part.triggerBool;
                save.triggerInt    = part.triggerInt;
                save.triggerFloat  = part.triggerFloat;
                save.triggerDouble = part.triggerDouble;
                save.triggerString = part.triggerString;
                set.triggerParts.Add(save);
            }
            SaveTriggers.Add(set);
        }

        GuidList        = sr.battleSetup.GuidList;
        positionX       = sr.playerLogic.transform.position.x;
        positionY       = sr.playerLogic.transform.position.y;
        currentScene    = sr.battleSetup.lastOverworld;
        facingDirection = (int)sr.playerLogic.move.lookDirection;
        gold            = sr.inventory.gold;

        respawnX         = sr.battleSetup.respawnLocation.x;
        respawnY         = sr.battleSetup.respawnLocation.y;
        respawnScene     = sr.battleSetup.respawnScene;
        respawnDirection = (int)sr.battleSetup.respawnDirection;
    }
 public void SaveTriggers()
 {
     try {
         Modding.Logger.Log("[HKTimer] Saving triggers");
         File.WriteAllText(
             Application.persistentDataPath + "/hktimer_triggers.json",
             JsonConvert.SerializeObject(
                 new TriggerSaveFile()
         {
             pb_ticks = this.pb.Ticks,
             start    = this.start == null ? null : TriggerSave.FromTrigger(this.start),
             end      = this.end == null ? null : TriggerSave.FromTrigger(this.end),
             other    = this.triggers?.ConvertAll(
                 x => x == null ? null : TriggerSave.FromTrigger(x)
                 ) ?? new List <TriggerSave>(),
         },
                 Formatting.Indented
                 )
             );
     } catch (Exception e) {
         Modding.Logger.LogError(e);
     }
 }
 public void setTriggerSave(TriggerSave ts)
 {
     lastTriggerSave = ts;
 }