private void AddContractTargetImage(ContractTargetImage targetImage) { string filepath = ContractElement.ContractElementFilePath; JSON elementJSON = ContractUtils.LoadJSONFromFile(filepath); //Do a bit of deserialization to see if any conflicting contracts exist List <JSON> contractTargetImages = elementJSON.ToArray <JSON>("ContractTargetImages").ToList(); if (replacementIndex >= 0) { contractTargetImages.RemoveAt(replacementIndex); contractTargetImages.Insert(replacementIndex, targetImage); } else { contractTargetImages.Add(targetImage); } elementJSON["ContractTargetImages"] = contractTargetImages; ContractUtils.WriteJSONToFile(filepath, elementJSON); Close(); }
private void AddContractTargetImage(ContractTargetImage targetImage) { string filepath = ContractElement.ContractElementFilePath; JSON elementJSON = ContractUtils.LoadJSONFromFile(filepath); //Do a bit of deserialization to see if any conflicting contracts exist List<JSON> contractTargetImages = elementJSON.ToArray<JSON>("ContractTargetImages").ToList(); if (replacementIndex >= 0) { contractTargetImages.RemoveAt(replacementIndex); contractTargetImages.Insert(replacementIndex, targetImage); } else { contractTargetImages.Add(targetImage); } elementJSON["ContractTargetImages"] = contractTargetImages; 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; }
public static ContractTargetImageForm Init(ContractTargetImage targetImage, int replacementIndex) { ContractTargetImageForm editor = (ContractTargetImageForm)GetWindow(typeof(ContractTargetImageForm)); editor.minSize = new Vector2(300, 100); editor.Tier = targetImage.Tier; editor.TargetImagePath = targetImage.TargetImagePath; editor.replacementIndex = replacementIndex; editor.closeButtonText = "Save"; editor.Show(); return editor; }
public static ContractTargetImageForm Init(ContractTargetImage targetImage, int replacementIndex) { ContractTargetImageForm editor = (ContractTargetImageForm)GetWindow(typeof(ContractTargetImageForm)); editor.minSize = new Vector2(300, 100); editor.Tier = targetImage.Tier; editor.TargetImagePath = targetImage.TargetImagePath; editor.replacementIndex = replacementIndex; editor.closeButtonText = "Save"; editor.Show(); return(editor); }
void PopulateTargetImages() { JSON[] targetImages = elements.ToArray <JSON>("ContractTargetImages"); for (int i = 0; i < targetImages.Length; i++) { ContractTargetImage targetImage = (ContractTargetImage)targetImages[i]; int tierIndex = targetImage.Tier - 1; List <ContractTargetImage> tierList = TargetImages[tierIndex]; if (tierList == null) { tierList = new List <ContractTargetImage>(); TargetImages[tierIndex] = tierList; } tierList.Add(targetImage); } }
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); }