/// <summary> /// Takes an ActorDraft.SO and converts to a SaveActorDraft.cs file suitable for serialising to file. /// </summary> /// <param name="actorDraft"></param> /// <returns></returns> private SaveActorDraft ConvertFromActorDraft(ActorDraft actorDraft) { SaveActorDraft saveDraft = new SaveActorDraft(); if (actorDraft != null) { saveDraft.draft = actorDraft.name; saveDraft.actorName = actorDraft.actorName; saveDraft.firstName = actorDraft.firstName; saveDraft.lastName = actorDraft.lastName; saveDraft.spriteName = actorDraft.sprite.name; saveDraft.arcName = actorDraft.arc.name; saveDraft.traitName = actorDraft.trait.name; saveDraft.level = actorDraft.level; saveDraft.power = actorDraft.power; saveDraft.statusName = actorDraft.status.name; saveDraft.sexName = actorDraft.sex.name; saveDraft.backstory0 = actorDraft.backstory0; saveDraft.backstory1 = actorDraft.backstory1; } else { Debug.LogError("Invalid actorDraft (Null)"); } return(saveDraft); }
/// <summary> /// Takes a SaveActorDraft.cs object and converts it to an ActorDraft.SO /// </summary> private void ConvertToActorDraft(SaveActorDraft saveDraft, ActorDraft draft) { if (saveDraft != null) { if (draft != null) { draft.actorName = saveDraft.actorName; draft.firstName = saveDraft.firstName; draft.lastName = saveDraft.lastName; //Sprite -> TO DO draft.level = saveDraft.level; draft.power = saveDraft.power; draft.backstory0 = saveDraft.backstory0; draft.backstory1 = saveDraft.backstory1; //trait Trait trait = ToolManager.i.toolDataScript.GetTrait(saveDraft.traitName); if (trait != null) { draft.trait = trait; } else { Debug.LogWarningFormat("Invalid trait (Null) for saveDraft.traitName \"{0}\"", saveDraft.traitName); } } else { Debug.LogError("Invalid ActorDraft.SO (Null)"); } } else { Debug.LogError("Invalid saveDraft (Null)"); } }
/// <summary> /// Takes an ActorPool.So and converts to a SaveActorPool.cs file suitable for serialising to file /// </summary> /// <param name="pool"></param> /// <returns></returns> private SaveActorPool ConvertFromActorPool(ActorPool pool) { SaveActorPool poolSave = new SaveActorPool(); if (pool != null) { poolSave.poolName = pool.name; poolSave.hqBoss0 = ConvertFromActorDraft(pool.hqBoss0); poolSave.hqBoss1 = ConvertFromActorDraft(pool.hqBoss1); poolSave.hqBoss2 = ConvertFromActorDraft(pool.hqBoss2); poolSave.hqBoss3 = ConvertFromActorDraft(pool.hqBoss3); //hq workers for (int i = 0; i < pool.listHqWorkers.Count; i++) { SaveActorDraft draft = ConvertFromActorDraft(pool.listHqWorkers[i]); if (draft != null) { poolSave.listHqWorkers.Add(draft); } else { Debug.LogErrorFormat("Invalid ActorDraft (Null) for listOfHqWorkers[{0}]", i); } } //onMap for (int i = 0; i < pool.listOnMap.Count; i++) { SaveActorDraft draft = ConvertFromActorDraft(pool.listOnMap[i]); if (draft != null) { poolSave.listOnMap.Add(draft); } else { Debug.LogErrorFormat("Invalid ActorDraft (Null) for listOfOnMap[{0}]", i); } } //level 1 for (int i = 0; i < pool.listLevelOne.Count; i++) { SaveActorDraft draft = ConvertFromActorDraft(pool.listLevelOne[i]); if (draft != null) { poolSave.listLevelOne.Add(draft); } else { Debug.LogErrorFormat("Invalid ActorDraft (Null) for listOfLevelOne[{0}]", i); } } //level 2 for (int i = 0; i < pool.listLevelTwo.Count; i++) { SaveActorDraft draft = ConvertFromActorDraft(pool.listLevelTwo[i]); if (draft != null) { poolSave.listLevelTwo.Add(draft); } else { Debug.LogErrorFormat("Invalid ActorDraft (Null) for listOfLevelTwo[{0}]", i); } } //level 3 for (int i = 0; i < pool.listLevelThree.Count; i++) { SaveActorDraft draft = ConvertFromActorDraft(pool.listLevelThree[i]); if (draft != null) { poolSave.listLevelThree.Add(draft); } else { Debug.LogErrorFormat("Invalid ActorDraft (Null) for listOfLevelThree[{0}]", i); } } } else { Debug.LogError("Invalid ActorPool (Null)"); } return(poolSave); }