public void calcProbabilities()
    {
        // Shhh.. I shouldn't call this here
        crewText = RarityText.CreateFromJSON(Resources.Load <TextAsset>("itemText/crewText").ToString());
        // Calc level probabilities
        this.levelProps = new float[this.skillLevelsPropabilities.Length];
        int levelSum = 0;

        for (int i = 0; i < this.skillLevelsPropabilities.Length; ++i)
        {
            this.levelProps[i] = this.skillLevelsPropabilities[i];
            levelSum          += this.skillLevelsPropabilities[i];
        }
        for (int i = 0; i < this.levelProps.Length; ++i)
        {
            this.levelProps[i] /= levelSum;
        }
        // Calc type probabilities
        this.skillTypeProps = new float[this.skillLevelsPropabilities.Length];
        int skillSum = 0;

        for (int i = 0; i < this.skillTypesPropabilities.Length; ++i)
        {
            this.skillTypeProps[i] = this.skillTypesPropabilities[i];
            skillSum += this.skillTypesPropabilities[i];
        }
        for (int i = 0; i < this.skillTypeProps.Length; ++i)
        {
            this.skillTypeProps[i] /= skillSum;
        }
    }
    private void setItem(ItemSO item, RarityText text, float rarity)
    {
        int bucket = (int)(text.names.Length * rarity);
        int choice = 0;

        // choose item name
        choice = (int)((text.names[bucket].choices.Length + text.universalNames.Length) * rarity);
        if (choice < text.names[bucket].choices.Length)
        {
            item.itemName = text.names[bucket].choices[choice];
        }
        else
        {
            item.itemName = text.universalNames[choice - text.names[bucket].choices.Length];
        }
        // choose item flavor text
        choice = (int)((text.flavors[bucket].choices.Length + text.universalFlavors.Length) * rarity);
        if (choice < text.flavors[bucket].choices.Length)
        {
            item.flavorText = text.flavors[bucket].choices[choice];
        }
        else
        {
            item.flavorText = text.universalFlavors[choice - text.flavors[bucket].choices.Length];
        }
    }
 public void Start()
 {
     junkText       = RarityText.CreateFromJSON(Resources.Load <TextAsset>("itemText/junkText").ToString());
     alcoholText    = RarityText.CreateFromJSON(Resources.Load <TextAsset>("itemText/alcoholText").ToString());
     fuelText       = RarityText.CreateFromJSON(Resources.Load <TextAsset>("itemText/fuelText").ToString());
     airText        = RarityText.CreateFromJSON(Resources.Load <TextAsset>("itemText/airText").ToString());
     flairShipText  = RarityText.CreateFromJSON(Resources.Load <TextAsset>("itemText/flairShipText").ToString());
     flairClothText = RarityText.CreateFromJSON(Resources.Load <TextAsset>("itemText/flairClothText").ToString());
 }
    private void setText(ProfileSO profile, RarityText text, float rarity)
    {
        bool male   = Random.value > 0.5f;
        int  bucket = male ? 0 : 1;
        int  choice = 0;

        // choose item name
        choice = (int)((text.names[bucket].choices.Length + text.universalNames.Length) * rarity);
        if (choice < text.names[bucket].choices.Length)
        {
            profile.crewName = text.names[bucket].choices[choice];
        }
        else
        {
            profile.crewName = text.universalNames[choice - text.names[bucket].choices.Length];
        }
        // Decide temperment text
        string temperment;

        if (profile.temperment < this.maxTempRate * 0.3)
        {
            temperment = string.Format("Looks like {0}'s about to cry.", myPronouns(male));
        }
        else if (profile.temperment < this.maxTempRate * 0.75)
        {
            temperment = string.Format("Looks like {0} could easily complete a days work.", myPronouns(male));
        }
        else
        {
            temperment = string.Format("{0} looks quite cheery.", myPronouns(male));
        }
        // Decide tolerence text
        string tolerance;

        if (profile.tolerance < this.maxTol * 0.3)
        {
            tolerance = string.Format("A drink or two and this crewmate is high as the crow's nest!", myPronouns(male));
        }
        else if (profile.tolerance < this.maxTol * 0.75)
        {
            tolerance = string.Format("", myPronouns(male));
        }
        else
        {
            tolerance = string.Format("Don't get in a drinking bout with this fellow!", myPronouns(male));
        }
        // Decide weight text
        string weight;

        if (profile.weight < this.maxTempRate * 0.3)
        {
            weight = string.Format("{0} has worked {1} to the bone.", myPronouns(male), male ? "himself" : "herself");
        }
        else if (profile.weight < this.maxTempRate * 0.75)
        {
            weight = "";
        }
        else
        {
            weight = string.Format("Remember, don't assign them to climb the rigging.", myPronouns(male));
        }

        profile.flavorText = string.Format("An {4} {3}. {0} {1} {2}", temperment, weight, tolerance, profile.skillType, profile.skillLevel);

        // choose item flavor text
        // choice = (int)((text.flavors[bucket].choices.Length + text.universalFlavors.Length) * rarity);
        // if (choice < text.flavors[bucket].choices.Length)
        // {
        //     item.flavorText = text.flavors[bucket].choices[choice];
        // }
        // else
        // {
        //     item.flavorText = text.universalFlavors[choice - text.flavors[bucket].choices.Length];
        // }
    }
Example #5
0
 public static string ToJSON(RarityText obj)
 {
     return(JsonUtility.ToJson(obj));
 }