protected void AddContract(ContractContent content) { string filepath = ContractElement.ContractElementFilePath; JSON elementJSON = ContractUtils.LoadJSONFromFile(filepath); //Do a bit of deserialization to see if any conflicting contracts exist List<JSON> contractContents = elementJSON.ToArray<JSON>("ContractContents").ToList(); if (replacementIndex >= 0) { contractContents.RemoveAt(replacementIndex); contractContents.Insert(replacementIndex, content); } else { contractContents.Add(content); } elementJSON["ContractContents"] = contractContents; ContractUtils.WriteJSONToFile(filepath, elementJSON); Close(); }
protected void AddContract(ContractContent content) { string filepath = ContractElement.ContractElementFilePath; JSON elementJSON = ContractUtils.LoadJSONFromFile(filepath); //Do a bit of deserialization to see if any conflicting contracts exist List <JSON> contractContents = elementJSON.ToArray <JSON>("ContractContents").ToList(); if (replacementIndex >= 0) { contractContents.RemoveAt(replacementIndex); contractContents.Insert(replacementIndex, content); } else { contractContents.Add(content); } elementJSON["ContractContents"] = contractContents; ContractUtils.WriteJSONToFile(filepath, elementJSON); Close(); }
public static Contract GetRandomContract(int Tier) { Contract contract = new Contract(); //Get Contract element Tier lists int indexedTier = Tier - 1; List<ContractContent> contents = ContractManager.Contents[indexedTier]; List<ContractTargetName> targetNames = ContractManager.TargetNames[indexedTier]; List<ContractTargetImage> targetImages = ContractManager.TargetImages[indexedTier]; List<ContractTargetShipImage> targetShipImages = ContractManager.TargetShipImages[indexedTier]; ContractContent content = new ContractContent(); ContractTargetName targetName = new ContractTargetName(); ContractTargetImage targetImage = new ContractTargetImage(); ContractTargetShipImage targetShipImage = new ContractTargetShipImage(); //Get random content if (contents != null) content = contents[Random.Range(0, contents.Count)]; if (targetNames != null) targetName = targetNames[Random.Range(0, targetNames.Count)]; if (targetImages != null) targetImage = targetImages[Random.Range(0, targetImages.Count)]; if (targetShipImages != null) targetShipImage = targetShipImages[Random.Range(0, targetShipImages.Count)]; //Build contract contract = new Contract(targetName.TargetName, content.Description, content.Title, targetImage.TargetImagePath, targetShipImage.TargetShipImagePath, content.Objectives); return contract; }
internal static void ReplaceKeyWordsFromDictionary() { ContractContent = ContractContent.ConvertAll(s => s.Replace("{paragraphbreak}", " ")); foreach (ContractDictionary item in DictionaryData) { ContractContent = ContractContent.ConvertAll(s => s.Replace("{" + item.Key + "}", item.Value)); } }
internal static SectionBuilder ReplaceKeyWordsFromDictionary(this SectionBuilder s) { ContractContent = ContractContent.ConvertAll(c => c.Replace("{paragraphbreak}", " ")); foreach (ContractDictionary item in DictionaryData) { ContractContent = ContractContent.ConvertAll(c => c.Replace("{" + item.Key + "}", item.Value)); } return(s); }
void PopulateContents() { JSON[] contents = elements.ToArray <JSON>("ContractContents"); for (int i = 0; i < contents.Length; i++) { ContractContent content = (ContractContent)contents[i]; int tierIndex = content.Tier - 1; List <ContractContent> tierList = Contents[tierIndex]; if (tierList == null) { tierList = new List <ContractContent>(); Contents[tierIndex] = tierList; } tierList.Add(content); } }
public static ContractContentForm Init(ContractContent contractContent, int replacementIndex) { ContractContentForm editor = (ContractContentForm)GetWindow(typeof(ContractContentForm)); editor.minSize = new Vector2(400, 200); editor.Tier = contractContent.Tier; editor.Title = contractContent.Title; editor.Description = contractContent.Description; editor.Objectives = contractContent.Objectives.ToList(); editor.replacementIndex = replacementIndex; editor.closeButtonText = "Save"; editor.InternalInit(); editor.Show(); return editor; }
public static ContractContentForm Init(ContractContent contractContent, int replacementIndex) { ContractContentForm editor = (ContractContentForm)GetWindow(typeof(ContractContentForm)); editor.minSize = new Vector2(400, 200); editor.Tier = contractContent.Tier; editor.Title = contractContent.Title; editor.Description = contractContent.Description; editor.Objectives = contractContent.Objectives.ToList(); editor.replacementIndex = replacementIndex; editor.closeButtonText = "Save"; editor.InternalInit(); editor.Show(); return(editor); }
public static Contract GetRandomContract(int Tier) { Contract contract = new Contract(); //Get Contract element Tier lists int indexedTier = Tier - 1; List <ContractContent> contents = ContractManager.Contents[indexedTier]; List <ContractTargetName> targetNames = ContractManager.TargetNames[indexedTier]; List <ContractTargetImage> targetImages = ContractManager.TargetImages[indexedTier]; List <ContractTargetShipImage> targetShipImages = ContractManager.TargetShipImages[indexedTier]; ContractContent content = new ContractContent(); ContractTargetName targetName = new ContractTargetName(); ContractTargetImage targetImage = new ContractTargetImage(); ContractTargetShipImage targetShipImage = new ContractTargetShipImage(); //Get random content if (contents != null) { content = contents[Random.Range(0, contents.Count)]; } if (targetNames != null) { targetName = targetNames[Random.Range(0, targetNames.Count)]; } if (targetImages != null) { targetImage = targetImages[Random.Range(0, targetImages.Count)]; } if (targetShipImages != null) { targetShipImage = targetShipImages[Random.Range(0, targetShipImages.Count)]; } //Build contract contract = new Contract(targetName.TargetName, content.Description, content.Title, targetImage.TargetImagePath, targetShipImage.TargetShipImagePath, content.Objectives); return(contract); }