Exemple #1
0
    static protected List <string> GeneratePlayerResource(List <string> occupiedBuildingResources, string scenarioID, JSONObject json, ProfileSettings profileSettings)
    {
        for (int i = 0; i < json.Count; i++)
        {
            JSONObject player = json[i];

            new Resources_Player(
                // profile settings, home, money, income, expenses, strength, presence, opinion, inventory
                profileSettings,
                Manager_Resources.GetBuildingByID(player.GetField("home").str),
                Mathf.Clamp(int.Parse(player.GetField("money").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(player.GetField("income").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(player.GetField("expenses").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(player.GetField("strength").str), statMin, statMax),
                Mathf.Clamp(int.Parse(player.GetField("presence").str), statMin, statMax),
                Mathf.Clamp(int.Parse(player.GetField("opinion").str), statMin, statMax),
                Resources_Inventory.GetInventoryByID(player.GetField("inventory").str)
                );

            if (occupiedBuildingResources.Contains(player.GetField("home").str))
            {
                Debug.LogError("Easy, Nelly. Someone messed up. Go tell whoever was messing with the static data that the player's safehouse can't be in " + player.GetField("home").str + ". Someone else is already in there! -Scott");
            }
            else
            {
                occupiedBuildingResources.Add(player.GetField("home").str);
            }
        }
        return(occupiedBuildingResources);
    }
Exemple #2
0
    static protected List <string> GenerateShopkeeperResources(List <string> occupiedBuildingResources, string scenarioID, JSONObject json)
    {
        for (int i = 0; i < json.Count; i++)
        {
            JSONObject shopkeeper = json[i];

            Resources_Shopkeeper newShopkeeper = new Resources_Shopkeeper(
                //id, name, image, gender, home, money, income, expenses,
                //strength, respect, fear, greed, integrity, stubbornness, personality, inventory
                shopkeeper.GetField("id").str,
                shopkeeper.GetField("name").str,
                shopkeeper.GetField("image").str,
                Enums.GenderFromString(shopkeeper.GetField("gender").str),
                Manager_Resources.GetBuildingByID(shopkeeper.GetField("home").str),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("money").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("income").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("expenses").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("strength").str), statMin, statMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("respect").str), statMin, statMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("fear").str), statMin, statMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("greed").str), statMin, statMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("integrity").str), statMin, statMax),
                Mathf.Clamp(int.Parse(shopkeeper.GetField("stubbornness").str), statMin, statMax),
                Enums.PersonalityFromStatic(shopkeeper.GetField("personality").str),
                Resources_Inventory.GetInventoryByID(shopkeeper.GetField("inventory").str)
                );

            if (occupiedBuildingResources.Contains(shopkeeper.GetField("home").str))
            {
                Debug.LogError("Whoa there, Sally. Someone done goofed. Go tell whoever was messing with the static data that " + shopkeeper.GetField("id").str + " can't set up shop in " + shopkeeper.GetField("home").str + ". Someone else is already in there! -Scott");
            }
            else
            {
                occupiedBuildingResources.Add(shopkeeper.GetField("home").str);
                // to be moved to a different section
                Building_Script buildingScriptRef = Building_Script.GetBuilding(shopkeeper.GetField("home").str);
                if (buildingScriptRef != null)
                {
                    buildingScriptRef.shopkeeper = newShopkeeper;
                }
            }
        }
        return(occupiedBuildingResources);
    }
Exemple #3
0
    static protected List <string> GenerateOfficerResources(List <string> occupiedBuildingResources, string scenarioID, JSONObject json)
    {
        List <string> policeStations = new List <string>();

        for (int i = 0; i < json.Count; i++)
        {
            JSONObject officer = json[i];

            new Resources_Officer(
                //id, name, image, gender, home, money, income, expenses,
                //strength, respect, fear, greed, integrity, stubbornness, personality, inventory
                officer.GetField("id").str,
                officer.GetField("name").str,
                officer.GetField("image").str,
                Enums.GenderFromString(officer.GetField("gender").str),
                Manager_Resources.GetBuildingByID(officer.GetField("home").str),
                Mathf.Clamp(int.Parse(officer.GetField("money").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(officer.GetField("income").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(officer.GetField("expenses").str), moneyMin, moneyMax),
                Mathf.Clamp(int.Parse(officer.GetField("strength").str), statMin, statMax),
                Mathf.Clamp(int.Parse(officer.GetField("respect").str), statMin, statMax),
                Mathf.Clamp(int.Parse(officer.GetField("fear").str), statMin, statMax),
                Mathf.Clamp(int.Parse(officer.GetField("greed").str), statMin, statMax),
                Mathf.Clamp(int.Parse(officer.GetField("integrity").str), statMin, statMax),
                Mathf.Clamp(int.Parse(officer.GetField("stubbornness").str), statMin, statMax),
                Enums.PersonalityFromStatic(officer.GetField("personality").str),
                Resources_Inventory.GetInventoryByID(officer.GetField("inventory").str)
                );

            if (occupiedBuildingResources.Contains(officer.GetField("home").str))
            {
                Debug.LogError("Dial it back there, toots. " + officer.GetField("home").str + " isn't a police station. Go tell whoever was doing the static data to send officer " + officer.GetField("id").str + " someplace else! -Scott");
            }
            else if (!policeStations.Contains(officer.GetField("home").str))
            {
                policeStations.Add(officer.GetField("home").str);
            }
        }
        occupiedBuildingResources.AddRange(policeStations);
        return(occupiedBuildingResources);
    }