static public Dialogue_Prompt DefaultAmount(Resources_Player player, Resources_Shopkeeper shopkeeper, int askingPrice)
    {
        Resources_Building shop = shopkeeper.home;
        float profit            = shop.income - shop.expenses;

        if (profit == 0)
        {
            profit = 0.0001f;
        }

        float affordValue   = 2 * ((1 - askingPrice / profit * shopkeeper.greed) * (shopkeeper.fear / shopkeeper.greed) - 50);
        float strengthValue = (Utilities.difficultyHandicap / 5 + player.strength) * player.presence - (shopkeeper.strength * 100 / shopkeeper.fear);
        float moralValue    = Utilities.difficultyHandicap * shopkeeper.fear / 10 - shopkeeper.integrity / shopkeeper.respect;

        Debug.Log("Afford Value: " + affordValue + ". Strength Value: " + strengthValue + ". Moral Value: " + moralValue + ". Total: " + (affordValue + strengthValue + moralValue) + ".");

        if ((affordValue + strengthValue + moralValue) >= 0)
        {
            Dialogue_Prompt_Logic.OfferAccepted();
            return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_offerAccepted"));
        }
        else
        {
            Dialogue_Prompt_Logic.OfferRefused();
            return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_offerRefused"));
        }
    }
 static public Dialogue_Prompt TakeRegisterMoney(Resources_Player player, Resources_Shopkeeper shopkeeper, int amount)
 {
     shopkeeper.home.money -= amount;
     player.money          += amount;
     Dialogue_Prompt_Logic.Root();
     return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_root"));
 }
예제 #3
0
    static public List <string> FilterRoot(List <string> keys, Resources_Shopkeeper shopkeeper)
    {
        List <string> returnKeys = new List <string>();

        if (shopkeeper.home.payment > 0)
        {
            if (shopkeeper.home.day == Manager_GameTime.Instance.currentDayOfTheWeek && !shopkeeper.home.hasPaid)
            {
                returnKeys.Add("dialogue_option_requestPayment");
            }
            else
            {
                returnKeys.Add("dialogue_option_earlyPayment");
            }
            returnKeys.Add("dialogue_option_renegotiate");
        }
        else
        {
            returnKeys.Add("dialogue_option_offerProtection");
        }
        returnKeys.Add("dialogue_option_intimidate");
        returnKeys.Add("dialogue_option_goShopping");
        returnKeys.Add("dialogue_option_chitChat");
        returnKeys.Add("dialogue_option_exitShop");
        return(returnKeys);
    }
    private void DetermineShopOptions(Resources_Player player, Resources_Shopkeeper shopkeeper)
    {
        List <string> Options = new List <string>();

        shopkeeperState = Enums.ShopkeeperState.Passive;

        if (shopkeeperState != Enums.ShopkeeperState.Robbed)
        {
            Options.Add("Purchase Wares");
            if (shopkeeperState == Enums.ShopkeeperState.Vandalized)
            {
                Options.Add("Inquire");
            }
        }
        else
        {
            /*if(player.getProof(shopkeeper.referenceID))
             * { Options.Add ("Placate"); }*/
            Options.Add("Inquire");
        }

        if (shopkeeper.home.payment > 0)
        {
            Options.Add("Request Payment");
            Options.Add("Renegotiate Payment");
        }
        else
        {
            Options.Add("Suggest Protection");
        }
    }
 static public void NewShopkeeper(Resources_Shopkeeper value)
 {
     if (IDIsUnique(value.id))
     {
         _shopkeepers.Add(value);
         _referenceIDs.Add(value);
     }
     else
     {
         Debug.LogError("Attempted to create a shopkeeper with the existing ID '" + value.id + "'.");
     }
 }
    public static List<string> FilterKeys(Dialogue_Prompt prompt, Resources_Shopkeeper shopkeeper)
    {
        List<string> returnKeys = new List<string>();

        switch (prompt.promptID)
        {
            case "dialogue_prompt_root": {
                returnKeys = FilterRoot (prompt.followUpKeys, shopkeeper);
                break;
            }
            default: {
                returnKeys = prompt.followUpKeys;
                break;
            }
        }
        return returnKeys;
    }
예제 #7
0
    static public List <string> FilterKeys(Dialogue_Prompt prompt, Resources_Shopkeeper shopkeeper)
    {
        List <string> returnKeys = new List <string>();

        switch (prompt.promptID)
        {
        case "dialogue_prompt_root": {
            returnKeys = FilterRoot(prompt.followUpKeys, shopkeeper);
            break;
        }

        default: {
            returnKeys = prompt.followUpKeys;
            break;
        }
        }
        return(returnKeys);
    }
예제 #8
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);
    }
    public static Dialogue_Prompt DefaultAmount(Resources_Player player, Resources_Shopkeeper shopkeeper, int askingPrice)
    {
        Resources_Building shop = shopkeeper.home;
        float profit = shop.income - shop.expenses;
        if(profit == 0) { profit = 0.0001f; }

        float affordValue = 2 * ((1 - askingPrice / profit * shopkeeper.greed) * (shopkeeper.fear / shopkeeper.greed) - 50);
        float strengthValue = (Utilities.difficultyHandicap/5 + player.strength) * player.presence - (shopkeeper.strength * 100/shopkeeper.fear);
        float moralValue = Utilities.difficultyHandicap * shopkeeper.fear/10 - shopkeeper.integrity / shopkeeper.respect;
        Debug.Log ("Afford Value: " + affordValue + ". Strength Value: " + strengthValue + ". Moral Value: " + moralValue + ". Total: " + (affordValue+strengthValue+moralValue) + ".");

        if((affordValue + strengthValue + moralValue) >= 0)
        {
            Dialogue_Prompt_Logic.OfferAccepted();
            return Dialogue_Prompt.GetPromptByName("dialogue_prompt_offerAccepted");
        } else {
            Dialogue_Prompt_Logic.OfferRefused();
            return Dialogue_Prompt.GetPromptByName("dialogue_prompt_offerRefused");
        }
    }
    public static List<string> FilterRoot(List<string> keys, Resources_Shopkeeper shopkeeper)
    {
        List<string> returnKeys = new List<string>();

        if(shopkeeper.home.payment > 0)
        {
            if(shopkeeper.home.day == Manager_GameTime.Instance.currentDayOfTheWeek && !shopkeeper.home.hasPaid)
            {
                returnKeys.Add ("dialogue_option_requestPayment");
            } else {
                returnKeys.Add ("dialogue_option_earlyPayment");
            }
            returnKeys.Add ("dialogue_option_renegotiate");
        } else {
            returnKeys.Add ("dialogue_option_offerProtection");
        }
        returnKeys.Add("dialogue_option_intimidate");
        returnKeys.Add("dialogue_option_goShopping");
        returnKeys.Add("dialogue_option_chitChat");
        returnKeys.Add("dialogue_option_exitShop");
        return returnKeys;
    }
 static public Dialogue_Prompt OtherAmount(Resources_Player player, Resources_Shopkeeper shopkeeper, int askingPrice)
 {
     return(DefaultAmount(player, shopkeeper, askingPrice));
 }
 public static Dialogue_Prompt OtherAmount(Resources_Player player, Resources_Shopkeeper shopkeeper, int askingPrice)
 {
     return DefaultAmount (player, shopkeeper, askingPrice);
 }
    public static Dialogue_Prompt RequestPayment(Resources_Player player, Resources_Shopkeeper shopkeeper)
    {
        int randNum  = Random.Range(0, 50);
        int paymentAmount = shopkeeper.home.payment;

        // Determine if the shopkeeper is feeling cocky enough to not pay you.
        if(randNum > shopkeeper.respect && shopkeeper.strength > player.strength)
        {
            // The shopkeeper doesn't respect you, and isn't afraid of you, so you are not getting your payment
            Dialogue_Prompt_Logic.PaymentNone();
            return Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentNone");
        } else {
            // Check to see if the store can afford to make the payment
            if (shopkeeper.home.money < paymentAmount)
            {
                // If the shop can't afford the payment
                // Check to see if the shopkeeper is fearful enough to try to pay out of pocket
                if (shopkeeper.fear > 50)
                {
                    // The shopkeeper is fearful enought to pay out of pocket
                    // Check to see if the shopkeeper can afford it
                    if (shopkeeper.home.money + shopkeeper.money < paymentAmount)
                    {
                        // The shopkeeper can't make up the difference and must pay only partially
                        player.money += shopkeeper.home.money;
                        shopkeeper.home.money = 0;
                        Dialogue_Prompt_Logic.PaymentPartial();
                        return Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentPartial");
                    }
                    else
                    {
                        // The shopkeeper will make up the difference out of pocket
                        player.money += paymentAmount;
                        int difAmount = paymentAmount;
                        difAmount -= shopkeeper.home.money;
                        shopkeeper.home.money = 0;
                        shopkeeper.money -= difAmount;
                        Dialogue_Prompt_Logic.PaymentFull();
                        return Dialogue_Prompt.GetPromptByName ("dialogue_prompt_paymentFull");
                    }
                } else {
                    // The shopkeeper is unwilling to pay out of pocket and will pay only partially
                    player.money += shopkeeper.home.money;
                    shopkeeper.home.money = 0;
                    Dialogue_Prompt_Logic.PaymentPartial();
                    return Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentPartial");
                }
            } else {
                // The shopkeeper can afford the full payment
                player.money += paymentAmount;
                shopkeeper.home.money -= paymentAmount;
                Dialogue_Prompt_Logic.PaymentFull();
                return Dialogue_Prompt.GetPromptByName ("dialogue_prompt_paymentFull");
            }
        }
    }
 public static Dialogue_Prompt TakeRegisterMoney(Resources_Player player, Resources_Shopkeeper shopkeeper, int amount)
 {
     shopkeeper.home.money -= amount;
     player.money += amount;
     Dialogue_Prompt_Logic.Root();
     return Dialogue_Prompt.GetPromptByName("dialogue_prompt_root");
 }
 public static void NewShopkeeper(Resources_Shopkeeper value)
 {
     if (IDIsUnique (value.id)) {
         _shopkeepers.Add (value);
         _referenceIDs.Add (value);
     } else {
         Debug.LogError ("Attempted to create a shopkeeper with the existing ID '" + value.id + "'."); }
 }
 public static Dialogue_Prompt EarlyPayment(Resources_Player player, Resources_Shopkeeper shopkeeper)
 {
     shopkeeper.respect -= 10;
     return RequestPayment (player, shopkeeper);
 }
    static public Dialogue_Prompt RequestPayment(Resources_Player player, Resources_Shopkeeper shopkeeper)
    {
        int randNum       = Random.Range(0, 50);
        int paymentAmount = shopkeeper.home.payment;

        // Determine if the shopkeeper is feeling cocky enough to not pay you.
        if (randNum > shopkeeper.respect && shopkeeper.strength > player.strength)
        {
            // The shopkeeper doesn't respect you, and isn't afraid of you, so you are not getting your payment
            Dialogue_Prompt_Logic.PaymentNone();
            return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentNone"));
        }
        else
        {
            // Check to see if the store can afford to make the payment
            if (shopkeeper.home.money < paymentAmount)
            {
                // If the shop can't afford the payment
                // Check to see if the shopkeeper is fearful enough to try to pay out of pocket
                if (shopkeeper.fear > 50)
                {
                    // The shopkeeper is fearful enought to pay out of pocket
                    // Check to see if the shopkeeper can afford it
                    if (shopkeeper.home.money + shopkeeper.money < paymentAmount)
                    {
                        // The shopkeeper can't make up the difference and must pay only partially
                        player.money         += shopkeeper.home.money;
                        shopkeeper.home.money = 0;
                        Dialogue_Prompt_Logic.PaymentPartial();
                        return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentPartial"));
                    }
                    else
                    {
                        // The shopkeeper will make up the difference out of pocket
                        player.money += paymentAmount;
                        int difAmount = paymentAmount;
                        difAmount            -= shopkeeper.home.money;
                        shopkeeper.home.money = 0;
                        shopkeeper.money     -= difAmount;
                        Dialogue_Prompt_Logic.PaymentFull();
                        return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentFull"));
                    }
                }
                else
                {
                    // The shopkeeper is unwilling to pay out of pocket and will pay only partially
                    player.money         += shopkeeper.home.money;
                    shopkeeper.home.money = 0;
                    Dialogue_Prompt_Logic.PaymentPartial();
                    return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentPartial"));
                }
            }
            else
            {
                // The shopkeeper can afford the full payment
                player.money          += paymentAmount;
                shopkeeper.home.money -= paymentAmount;
                Dialogue_Prompt_Logic.PaymentFull();
                return(Dialogue_Prompt.GetPromptByName("dialogue_prompt_paymentFull"));
            }
        }
    }
    private void DetermineShopOptions(Resources_Player player, Resources_Shopkeeper shopkeeper)
    {
        List<string> Options = new List<string>();

        shopkeeperState = Enums.ShopkeeperState.Passive;

        if(shopkeeperState != Enums.ShopkeeperState.Robbed)
        {
            Options.Add ("Purchase Wares");
            if(shopkeeperState == Enums.ShopkeeperState.Vandalized)
            { Options.Add("Inquire"); }
        } else {
            /*if(player.getProof(shopkeeper.referenceID))
            { Options.Add ("Placate"); }*/
            Options.Add ("Inquire");
        }

        if(shopkeeper.home.payment > 0)
        {
            Options.Add ("Request Payment");
            Options.Add ("Renegotiate Payment");
        } else {
            Options.Add ("Suggest Protection");
        }
    }
 static public Dialogue_Prompt EarlyPayment(Resources_Player player, Resources_Shopkeeper shopkeeper)
 {
     shopkeeper.respect -= 10;
     return(RequestPayment(player, shopkeeper));
 }
    protected static 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;
    }