Пример #1
0
    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;
    }
    private void AddContractTargetShipImage(ContractTargetShipImage targetShipImage)
    {
        string filepath = ContractElement.ContractElementFilePath;

        JSON elementJSON = ContractUtils.LoadJSONFromFile(filepath);

        //Do a bit of deserialization to see if any conflicting contracts exist
        List<JSON> contractTargetShipImages = elementJSON.ToArray<JSON>("ContractTargetShipImages").ToList();

        if (replacementIndex >= 0)
        {
            contractTargetShipImages.RemoveAt(replacementIndex);
            contractTargetShipImages.Insert(replacementIndex, targetShipImage);
        }
        else
        {
            contractTargetShipImages.Add(targetShipImage);
        }

        elementJSON["ContractTargetShipImages"] = contractTargetShipImages;

        ContractUtils.WriteJSONToFile(filepath, elementJSON);

        Close();
    }
Пример #3
0
    private void AddContractTargetShipImage(ContractTargetShipImage targetShipImage)
    {
        string filepath = ContractElement.ContractElementFilePath;

        JSON elementJSON = ContractUtils.LoadJSONFromFile(filepath);

        //Do a bit of deserialization to see if any conflicting contracts exist
        List <JSON> contractTargetShipImages = elementJSON.ToArray <JSON>("ContractTargetShipImages").ToList();

        if (replacementIndex >= 0)
        {
            contractTargetShipImages.RemoveAt(replacementIndex);
            contractTargetShipImages.Insert(replacementIndex, targetShipImage);
        }
        else
        {
            contractTargetShipImages.Add(targetShipImage);
        }

        elementJSON["ContractTargetShipImages"] = contractTargetShipImages;

        ContractUtils.WriteJSONToFile(filepath, elementJSON);

        Close();
    }
    public static ContractTargetShipImageForm Init(ContractTargetShipImage targetShipImage, int replacementIndex)
    {
        ContractTargetShipImageForm editor = (ContractTargetShipImageForm)GetWindow(typeof(ContractTargetShipImageForm));
        editor.minSize = new Vector2(300, 100);
        editor.Tier = targetShipImage.Tier;
        editor.TargetShipImagePath = targetShipImage.TargetShipImagePath;
        editor.replacementIndex = replacementIndex;
        editor.Show();

        return editor;
    }
Пример #5
0
    public static ContractTargetShipImageForm Init(ContractTargetShipImage targetShipImage, int replacementIndex)
    {
        ContractTargetShipImageForm editor = (ContractTargetShipImageForm)GetWindow(typeof(ContractTargetShipImageForm));

        editor.minSize             = new Vector2(300, 100);
        editor.Tier                = targetShipImage.Tier;
        editor.TargetShipImagePath = targetShipImage.TargetShipImagePath;
        editor.replacementIndex    = replacementIndex;
        editor.Show();

        return(editor);
    }
Пример #6
0
    void PopulateTargetShipImages()
    {
        JSON[] targetShipImages = elements.ToArray <JSON>("ContractTargetShipImages");
        for (int i = 0; i < targetShipImages.Length; i++)
        {
            ContractTargetShipImage targetShipImage = (ContractTargetShipImage)targetShipImages[i];
            int tierIndex = targetShipImage.Tier - 1;

            List <ContractTargetShipImage> tierList = TargetShipImages[tierIndex];
            if (tierList == null)
            {
                tierList = new List <ContractTargetShipImage>();
                TargetShipImages[tierIndex] = tierList;
            }

            tierList.Add(targetShipImage);
        }
    }
Пример #7
0
    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);
    }