Exemplo n.º 1
0
    public void OnRandEventNum(int eventNum)
    {
        System.Random random = new System.Random();
        bool          choice;

        int index = random.Next(1, 7);

        if (eventNum <= 1 && eventNum >= 5) // You find money on the ground
        {
            displayMessage.text = "Hey! Money! Take it?";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true)
            {
                ChangeValue(7, 10);
            }
            displayMessage.text = " ";
        }
        else if (eventNum >= 6 && eventNum <= 15) // You find slightly less money on the ground
        {
            Debug.Log("Rand Event");
            displayMessage.text = "Hey! Money! Take it?".ToString();
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true)
            {
                ChangeValue(7, 5);
            }
            displayMessage.text = " ";
        }
        else if (eventNum >= 16 && eventNum <= 25) // Someone steals a cookie
        {
            displayMessage.text = "Hey, kid. Those are some tasty looking cookies you got there. Why don't you hand one over...";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true)
            {
                ChangeValue(8, -1);
            }
            else if (choice == false) // You should've clicked confirm. Now you lose cookie and money
            {
                ChangeValue(8, -1);
                ChangeValue(7, -10);
            }
            displayMessage.text = " ";
        }
        else if (eventNum >= 26 && eventNum <= 40) // Gain inventory from another deliveryman
        {
            displayMessage.text = "Hello there, fellow delivery dino! I'm done for the day, so do you want to take my unsold cookies?";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true)
            {
                System.Random how_many    = new System.Random();
                System.Random which_kind  = new System.Random();
                int           extra_stock = how_many.Next(1, 4); // Maximum three types of inventory gained
                if (extra_stock == 1)
                {
                    int change = which_kind.Next(1, 7);
                    ChangeValue(9, change);
                }
                else if (extra_stock == 2)
                {
                    int change  = which_kind.Next(1, 7);
                    int change2 = which_kind.Next(1, 7);
                    while (change != 0)
                    {
                        if (change == change2)
                        {
                            change2 = which_kind.Next(1, 7);
                        }
                        else
                        {
                            break;
                        }
                    }
                    ChangeValue(9, change);
                    ChangeValue(9, change2);
                }
                else if (extra_stock == 3)
                {
                    int change  = which_kind.Next(1, 7);
                    int change2 = which_kind.Next(1, 7);
                    int change3 = which_kind.Next(1, 7);
                    while (change != 0)
                    {
                        if (change == change2)
                        {
                            change2 = which_kind.Next(1, 7);
                        }
                        else if (change == change3)
                        {
                            change3 = which_kind.Next(1, 7);
                        }
                        else if (change2 == change3)
                        {
                            change3 = which_kind.Next(1, 7);
                        }
                        else
                        {
                            break;
                        }
                    }
                    ChangeValue(9, change);
                    ChangeValue(9, change2);
                    ChangeValue(9, change3);
                }
            }
            displayMessage.text = " ";
        }
        else if (eventNum >= 41 && eventNum <= 50) // A little kid politely asks for a cookie, but he doesn't have any money
        {
            displayMessage.text = "Hi, Mister Deliveryman, could I have a cookie, please? I don't have any money, though...";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true)
            {
                System.Random random2 = new System.Random();
                int           type    = random2.Next(1, 7);
                while (type != 0)
                {
                    if (cookies[type - 1] < 1)
                    {
                        type = random2.Next(1, 7);
                    }
                    else
                    {
                        break;
                    }
                }
                ChangeValue(8, -1);
            }
            displayMessage.text = " ";
        }
        else if (eventNum >= 51 && eventNum <= 85) // Standard sale of a cookie
        {
            displayMessage.text = "Hi, you wouldn't happen to have a spare " + cookie_name[index - 1] + " cookie I could buy, would you?";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true && cookies[index - 1] > 0)
            {
                ChangeValue(index, -1);
                displayMessage.text = " ";
            }
            else if (choice == true && cookies[index - 1] <= 0)
            {
                displayMessage.text = "Oh, dear. It seems as though you don't have enough to fulfill the request.";
            }
        }
        else if (eventNum >= 86 && eventNum <= 100) // Sale of Multiple of one Cookie
        {
            System.Random random2 = new System.Random();
            int           change  = random2.Next(2, 6); // Sale of between 2 and 5 of the same cookie
            displayMessage.text = "Hi, could I buy " + change + " " + cookie_name[index - 1] + " cookies from you?";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true && cookies[index - 1] >= change)
            {
                ChangeValue(index, -change);
                displayMessage.text = " ";
            }
            else if (choice == true && cookies[index - 1] < change)
            {
                displayMessage.text = "Oh, dear. It seems as though you don't have enough to fulfill the request.";
            }
        }
    }
Exemplo n.º 2
0
    public void OnHouseEventNum(int eventNum)
    {
        System.Random random = new System.Random();
        int           index  = random.Next(1, 7);
        int           change;
        bool          choice;

        if (eventNum >= 1 && eventNum <= 40) //Standard Sale of a single cookie
        {
            displayMessage.text = "Hello, I ordered one " + cookie_name[index - 1] + " cookie. Have you come to deliver it?";
            choice = PlayerChoice.ReturnUserInput();

            if (choice == true && cookies[index - 1] > 0)
            {
                ChangeValue(index, -1);
                displayMessage.text = " ";
            }
            else if (choice == true && cookies[index - 1] <= 0)
            {
                displayMessage.text = "Oh, dear. It seems as though you don't have enough to fulfill the order.";
            }
        }
        else if (eventNum >= 41 && eventNum <= 65) // Sale of Multiple of One Type of Cookie
        {
            System.Random random2 = new System.Random();
            change = random2.Next(2, 6); // Sale of between 2 and 5 of the same cookie
            displayMessage.text = "Hello, I ordered " + change + " " + cookie_name[index - 1] + "cookies. Have you come to deliver them?";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true && cookies[index - 1] >= change)
            {
                ChangeValue(index, -change);
                displayMessage.text = " ";
            }
            else if (choice == true && cookies[index - 1] < change)
            {
                displayMessage.text = "Oh, dear. It seems as though you don't have enough to fulfill the order.";
            }
        }
        else if (eventNum >= 66 && eventNum <= 80) // Sale of Multiple Types of Cookies
        {
            int           index2;
            int           change2;
            System.Random random2 = new System.Random();
            change  = random2.Next(1, 4);
            change2 = random2.Next(2, 4); // 1 to 3 for the first type, 2 or 3 for the second
            System.Random random3 = new System.Random();
            index2 = random3.Next(1, 7);
            while (index != 0) // Prevents the same type from being sold twice
            {
                if (index == index2)
                {
                    index2 = random3.Next(1, 7);
                }
                else
                {
                    break;
                }
            }
            displayMessage.text = "Hello, I ordered " + change + " " + cookie_name[index - 1] + " and " + change2 + " " + cookie_name[index2 - 1] + " cookies. Have you come to deliver them?";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true && cookies[index - 1] >= change && cookies[index2 - 1] >= change2)
            {
                ChangeValue(index, -change);
                ChangeValue(index2, -change2);
                displayMessage.text = " ";
            }
            else if (choice == true && (cookies[index - 1] < change || cookies[index2 - 1] < change2))
            {
                displayMessage.text = "Oh, dear. It seems as though you don't have enough to fulfill the order.";
            }
        }
        else if (eventNum >= 81 && eventNum <= 90)
        {
            displayMessage.text = "Hello, I ordered one of each cookie. Have you come to deliver them?";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true && cookies[0] > 0 && cookies[1] > 0 && cookies[2] > 0 && cookies[3] > 0 && cookies[4] > 0 && cookies[5] > 0)
            {
                ChangeValue(1, -1);
                ChangeValue(2, -1);
                ChangeValue(3, -1);
                ChangeValue(4, -1);
                ChangeValue(5, -1);
                ChangeValue(6, -1);
                displayMessage.text = " ";
            }
            else if (choice == true && (cookies[0] < 1 || cookies[1] < 1 || cookies[2] < 1 || cookies[3] < 1 || cookies[4] < 1 || cookies[5] < 1))
            {
                displayMessage.text = "Oh, dear. It seems as though you don't have enough to fulfill the order.";
            }
        }
        else if (eventNum >= 91 && eventNum <= 100)
        {
            displayMessage.text = "Hello, I ordered one " + cookie_name[index - 1] + "cookie. Have you come to deliver it? I'll give you a tip if you did.";
            choice = PlayerChoice.ReturnUserInput();
            if (choice == true && cookies[index - 1] > 0)
            {
                ChangeValue(index, -1);
                ChangeValue(7, 7);
                displayMessage.text = " ";
            }
            else if (choice == true && cookies[index - 1] <= 0)
            {
                displayMessage.text = "Oh, dear. It seems as though you don't have enough to fulfill the order.";
            }
        }
        change = 0;
    }