“This article has participated in the good article call order activity, click to see: back end, big front end double track submission, 20,000 yuan prize pool for you to challenge!”


Idle to have nothing to do, using C# with a script to write a small text game, experience a oneself when the feeling of game planning, or pretty good ha ha ha ~

Script code is very simple, basically is the entry level can write, just also borrow this article, practice C# programming knowledge!

Simple text games

After learning some basic knowledge of C#, we need to do some small things to practice. For example, this article introduces a simple text game written in C# in VS. This small game is only completed by a script, mainly used to get some basic knowledge of C#. There are more if statements, struct, enum, staic, etc.

Interested partners can set up their own story, experience a small game planning feeling, hehe ~ more suitable for beginners to start using C# a small test, or very interesting, the effect is as follows:

Here is a brief introduction to the general content of the script.

The script defines one at the beginningThe enumerationTo define the type of equipment, and then there’s aThe structure of the bodyIt defines the specific properties of a piece of equipment in the game, and then defines the properties of some characters in the Program class. Then the first method, CreateCharacter, which is first executed in the Main function, is a method for creating a player character. It defines some random properties that make it different each time a character is created (which is the fun of most games). After creating the characters, we arrived at our first game scene — the novice village! Haha, really has a role playing RPG feeling ha ~~

In the beginner’s village, we’ll encounter some NPCS that we’ve set up to interact with, mainly through a series of if statements (to practice using if).

Then there will be several scenes to play the game, including suburbs, Chang ‘an, robbers’ cave, Luoyang and so on, are their own random play, mainly to increase a variety of different plot, make the game more interesting, here will give full play to our brains to carry out planning work haha. And then in the scenario you run into the store, and the store purchases are also simply written using the if statement, very simple.

The enemy part

The script defines a Battle method that governs the enemy’s attributes and Battle logic. You can call this method whenever you want the player to encounter an enemy and set attributes such as the enemy’s name and damage. In this script, the Random method is used to add Random enemy encounters to play. If you don’t use it, look at the basics

Equipment items

Then we write a equipment-for-use method, Equipment-item, which is called every time we buy a piece of equipment from a store or get it from an NPC to equip our character.

Print output log

The script itself has a printout method, which is simple enough to print out statements and pause them for a while

This is the framework, the main purpose is to practice the basics of C# without being boring.

A script to get a small game, learn it!!

The complete code is as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp1
{

    // Equipment type
    enum EquipType
    {
        Weapon,
        Clothes,
        Shoes,
        Jiezhi
    }

    / / equipment
    struct Equip
    {
        // Equipment type
        public EquipType type;
        / / name
        public string name;
        / / description
        public string des;
        / / health
        public int hp;
        / / damage
        public int atk;
        / / speed
        public int speed;
        // Ability release probability
        public int jineng;


        // The constructor
        public Equip(EquipType type, string name="Unequipped".string des="Unequipped".int hp=0.int atk=0.int speed=0.int jineng=0)
        {
            this.type = type;
            this.name = name;
            this.des = des;
            this.hp = hp;
            this.atk = atk;
            this.speed = speed;
            this.jineng = jineng; }}class Program
    {
        // Declare variables
        / / name
        static string name = "";
        // Max health
        static int hp;
        // Clothing health
        static int clothes_Hp;
        // Current health
        static int c_Hp;
        // Grow health
        static int g_hp;
        / / damage
        static int atk;
        // Weapon attack power
        static int weapon_atk;
        // Grow attack
        static int g_atk;
        // Skill probability
        static int jineng;
        // Ring with skill chance
        static int Jiezhi_jineng;
        / / speed
        static int speed;
        // Shoe speed
        static int shoes_speed;
        // Growth rate
        static int g_speed;
        // Level 1000 experience level increased by one level
        static int level = 0;
        / /
        static int exp = 0;
        / / money
        static int money = 300;
        / / weapons
        static Equip Weapon=new Equip(EquipType.Weapon);
        / / clothes
        static Equip Clothes = new Equip(EquipType.Clothes);
        / / shoes
        static Equip Shoes = new Equip(EquipType.Shoes);
        / / ring
        static Equip Jiezhi = new Equip(EquipType.Jiezhi);


        // Create a role
        static void CreateCharacter()
        {
            / / hint
            Log("The cold wind is like a knife, and the earth is the chopping board, and all living beings are fish.");
            Log("Thousands of miles of snow, the sky as a furnace, melting everything into silver.");
            Log("The snow will stop, the wind is uncertain, a carriage from the north, rolling wheels crushed the snow on the ground, but not the earth and the lonely.");
            Log("And so begins the story of a hero........");
            Console.WriteLine("Please enter your name:");
            // Enter the role name
            name = Console.ReadLine();
            // Check whether the name is correct
            if (string.IsNullOrEmpty(name))
            {
                // Give the default name
                name = "Han han";
            }
            // Random health between 90 and 111
            hp = new Random().Next(100.121);
            c_Hp = hp;
            // Grow health
            g_hp = new Random().Next(20.25);
            / / damage
            atk = new Random().Next(10.15);
            // Grow attack
            g_atk = new Random().Next(1.4);
            // Release the chance of a skill
            jineng = new Random().Next(20.40);
            / / speed
            speed = new Random().Next(90.111);
            // Growth rate
            g_speed = new Random().Next(10.16);
            // Give a hint
            Console.WriteLine("Congratulations! The role was created successfully! Your character name is {0}, health is {1}, damage is {2}, cast ability is {3}, speed is {4}., name, hp, atk, jineng, speed);
            / / sleep
            Thread.Sleep(2000);
            / / 203-242 < 210 > 205, 205-210,
            // Summation of basic values
            int num = hp + speed + atk;
            if (num < 205)
            {
                Log("Your character looks emaciated and may need to be reincarnated.");
            }
            else if (num < 210)
            {
                Log("Your role is a mediocre one. With a little effort, it might go somewhere.");
            }
            else
            {
                Log("Your character looks different and full of the air of a king!!");
            }
            Thread.Sleep(1000);
            // Total growth values 30-42 31-33 34-38 39-43
            num = g_hp + g_speed + g_atk;
            if (num <= 33)
            {
                Log("Your character doesn't seem to have much potential!");
            }
            else if (num <= 38)
            {
                Log("Your character looks ordinary, nothing special!");
            }
            else
            {
                Log("Your character seems to have a lot of potential, a lot of air.");
            }
            // Current attribute
            ShowInfo();
        }

        / / new village
        static void xinShouCun()
        {
            / / guide
            Console.WriteLine("There is a beggar in front of you, and a rich man is standing on the other side. Who do you want to talk to?");
            Console.WriteLine(1. Beggars 2. Plutocrats 3.);
            / / input
            string str = Console.ReadLine();
            / / determine
            if (str == "1")
            {
                / / a beggar
                if (new Random().Next(0.100) > 70)
                {
                    / / disability
                    c_Hp -= 30;
                    / / speed
                    speed -= 5;
                    / / hint
                    Console.WriteLine("The beggar takes out this unique martial arts, unfortunately did not comprehend! Hit points decreased by 30!");
                }
                else
                {
                    // Grow and improve
                    g_hp += 5;
                    g_atk += 1;
                    g_speed += 5;
                    / / hint
                    Console.WriteLine("The beggar takes out this unique martial arts, after you practice, the feeling is refreshed! Attributes have been improved!"); }}else if (str == "2")
            {
                / / rich
                if (new Random().Next(0.100) > 70)
                {
                    / / to make money
                    money += 20;
                    / / hint
                    Console.WriteLine("The rich see your face good, sent you 20 silver to go out experience.");
                }
                else
                {
                    // All is lost
                    money -= 9;
                    / / hint
                    Console.WriteLine("The rich man was in a bad mood, so he ordered his men to beat you, and you lost nine ounces of silver."); }}// Leave the novice village hint
            Console.WriteLine("In the villagers' encouragement, you left the novice village, to Chang 'an!");
            // Current attribute
            ShowInfo();
        }

        // Check the information
        static void ShowInfo()
        {
            Console.WriteLine("You are attributes for HP: {0} / ({1} + {2}), atk: {3} + {4}, speed: {5} + {6}, jineng: {7} + {8}, money: {9}", c_Hp, hp, clothes_Hp, atk, weapon_atk, speed, shoes_speed, jineng, Jiezhi_jineng, money);
            Log(Weapons: "[" + Weapon.name + "], armor: [" + Clothes.name + "], shoes :[" + Shoes.name + "], ring :[" + Jiezhi.name+"]");
            Thread.Sleep(500);
        }

        // Equip props
        static void EquipItem(Equip equip)
        {
            // Distinguish equipment types
            switch (equip.type)
            {
                case EquipType.Weapon:
                    Log(name + "Armed with weapons:" + equip.name + ", damage +" + equip.atk);
                    weapon_atk = equip.atk;// Save the damage of the equipment
                    Weapon = equip;// Save the equipment
                    break;
                case EquipType.Clothes:
                    Log(name + "Equipped with clothes:" + equip.name + ", health +" + equip.hp);
                    Clothes.hp = equip.hp;
                    Clothes = equip;
                    break;
                case EquipType.Shoes:
                    Log(name + "Equipped with shoes:" + equip.name + ", speed +" + equip.speed);
                    shoes_speed = equip.speed;
                    Shoes = equip;
                    break;
                case EquipType.Jiezhi:
                    Log(name + "Equipped with rings:" + equip.name + ", skill release chance +" + equip.jineng);
                    Jiezhi_jineng = equip.jineng;
                    Jiezhi = equip;
                    break; }}/ / field
        static void jiaoQu()
        {
            / / hint
            Console.WriteLine("At the entrance of the village stood a businessman carrying a bag, whether dialogue? 1. Dialogue 2. Robbery 3.);
            / / input
            string str = Console.ReadLine();
            if (str == "1")
            {
                / / dialogue
                Console.WriteLine("The merchant looked at you with a smile and said, 'If you give me twenty taels, I will make you a new man! 'Do you give? 1. Give 2. Don't give");
                / / input
                string str2 = Console.ReadLine();
                if (str2 == "1" && money >= 20)
                {
                    / / buckles money
                    money -= 20;
                    / / add attributes
                    g_hp += 10;
                    g_atk += 2;
                    g_speed += 8;
                    Console.WriteLine("After the merchant's exercise, you feel full of strength!");
                    ShowInfo();
                }
                else
                {
                    Console.WriteLine("The businessman looked at you contemptuously and left here."); }}else if (str == "2")
            {
                / / robbery
                int num = hp + speed + atk;
                // If it is greater than 210, the robbery will be successful
                if (num > 210)
                {
                    money += 30;
                    Console.WriteLine("You took out the martial arts you learned all your life and" tickled ", the merchant was scratched and fled, leaving 30 ounces of silver.");
                    ShowInfo();
                }
                else
                {
                    // The robbery failed
                    Console.WriteLine("You take out your life's knowledge of the martial arts" tickle, "but the businessman knocked you down with a backhand, but the businessman scratched you, and took all your money and beat you, loss of 20 health.");
                    money = 0;
                    c_Hp -= 20; ShowInfo(); }}/ / walk
            for (int i = 0; i < 30; i++)
            {
                Console.WriteLine("Press enter to move.");
                Console.ReadKey();
                // Chance to meet the enemy
                if (new Random().Next(0.6) > 3)
                {
                    if (new Random().Next(0.100) > 80)
                    {
                        // Meet the enemy - the robber
                        Battle("The robber".60.20.90.10.5.10.1500);
                    }
                    else
                    {
                        // Meet the enemy - rogue
                        Battle("Rogue".40.20.95.5.5.3.500); }}}// Enter Chang 'an
            ChangAn();
        }
        // Enter Chang 'an
        static void ChangAn()
        {
            Log("After many hardships and hardships, you finally arrived at the legendary big city, Chang 'an.");
            Log("You see a very busy market ahead, do you want to go to the market? 1. Go 2. Don't go");
            string str = Console.ReadLine();
            if (str == "1")
            {
                // Market related
                Log("You come to the market, and you see a lot of fighting ahead of you. Do you want to see it? 2. Don't watch, walk out of the market.");
                string str1 = Console.ReadLine();
                if (str1 == "1")
                {
                    / / onlookers
                    Log("You walk into the front, it is a wicked young man is bullying an old man. Will you go up and help? 1. Help 2. Don't help");
                    string str2 = Console.ReadLine();
                    if (str2 == "1")
                    {
                        / / help
                        int num = hp + speed + atk;
                        // If it is greater than 220, you have great talent and can help successfully
                        if (num > 220)
                        {
                            money += 10;
                            Log("You walk up to the young man and you kick him over, and the young man runs away.");
                            Log("The old man was very grateful and said that this man had been a bully to him, and he gave you some silver thanks for your help in driving him away.");
                            ShowInfo();
                        }
                        else
                        {
                            // Help failed
                            Console.WriteLine("You go up to help, and you find this young man has a great martial spirit. Instead, he throws you to the ground and humiliates you, taking all your silver and losing 10 blood.");
                            money = 0;
                            c_Hp -= 10;
                            ShowInfo();
                        }
                    }
                }
            }
            Log("You took one look at it and thought it was better to have more than one thing, and turned and walked out of the market.");

            / / market outside

            Log("Outside the market, there is a monk and a priest, do you want to talk to them? 1. Monk 2.");
            str = Console.ReadLine();
            if (str == "1")
            {
                / / monk
                Log("This monk looks shabby and beefy. He doesn't look like a good guy. You go up and say hello.");
                Log("The monk stares at you and asks," Donor, do you have silver? The poor monk has not eaten for ten days.");
                Log("Shall I give the monk 30 taels? 1. Give 2. Rob 3.");
                string str2 = Console.ReadLine();
                if (str2 == "1" && money >= 30)
                {

                    if (new Random().Next(0.10) > 3)
                    {
                        / / to
                        money -= 30;
                        Log("The monk took the money and left happily. You look at the monk's back and you feel something is missing.");
                    }
                    else
                    {
                        / / to
                        money += 30;
                        Log("The monk laughed and said," I'm just kidding you. I have some silver coins here. I will give them to you because of your kindness.");
                        Log("I got an extra 30 ounces of silver from the monk for doing good."); }}else if (str2 == "2")
                {
                    / / robbery
                    if (new Random().Next(0.10) > 3)
                    {
                        // Level 3 or higher can be heist
                        if (level >= 3)
                        {
                            Log("The monk looked at you and felt a little strong, so he obediently gave you 10 ounces of silver and taught you some experience in running a river's lake.");
                            //exp++ 
                            exp += 1000;
                            money += 10;
                        }
                        else
                        {
                            Log("The monk saw that you were weak, so he gave you a beating. You lost 10 ounces of silver and half your health.");
                            money -= 10;
                            c_Hp /= 2; }}else
                    {
                        Log("When you were robbing the monk, you were found by the street catcher and taken to prison...");
                        Log("One month left in prison.");
                        Thread.Sleep(5 * 1000);
                        Log("You out of the cell, in the cell wall to learn some of the former prison friends left the unique martial arts, attribute promotion!");
                        g_speed += 5; ShowInfo(); }}}else
            {
                / / long
                Log("This long look immortal style bone, not resemble a common person, you shiver of go up to dozen hello:" long your surname?" ");
                Log("The long way a face of righteous air say to you:" avoid your surname zhang, is jade emperor's descendant ". If you give me 30 ounces of silver now, I will keep you rich and safe all your life!");
                Log("Do you give the length 30 taels? 1. Give 2. Rob 3.");
                string str3 = Console.ReadLine();
                if (str3 == "1" && money >= 50)
                {

                    if (new Random().Next(0.10) > 5)
                    {
                        / / to
                        money -= 50;
                        Log("The chief took the money and disappeared. You look at the place where the daochang disappeared and feel what is missing.");
                    }
                    else
                    {
                        / / to
                        money += 30;
                        Log("After you gave the money to the head of the road, you saw the sky change and a colorful light came into your body.");
                        Log("You feel like your body is being reinvented and all your attributes are improving.");
                        hp += 50;
                        atk += 5;
                        speed += 20; }}else
                {
                    / / robbery
                    Log("The Lord saw you a little miserable, and he gave you a weapon, a pin.");
                    // Get the equipment
                    EquipItem(new Equip(EquipType.Weapon, "The Anchor"."Said to have been used by a Monkey King.".0.5.0.0)); }}/ / hint
            Log("After you have been in Chang 'an for a while, you have heard that there are a group of bandits who are highly skilled in fighting. They are capable of burning, killing and looting any evil. You are going to help the people of Chang 'an get rid of these bandits.");
            // Robber's Cave
            ChangAnFB();
        }

        // Robber's Cave
        static void ChangAnFB()
        {
            Log("You climb the mountain and wade through the water until you come to the robber's cave and start looking for the robber.");
            / / walk
            for (int i = 0; i < 30; i++)
            {
                Console.WriteLine("Press enter to move.");
                Console.ReadKey();
                // Chance to meet the enemy
                if (new Random().Next(0.5) > 3)
                {
                    if (new Random().Next(0.100) > 80)
                    {
                        // Meet the enemy - robber leader
                        Battle("The Chief robber".100.30.105.10.10.30.3000);
                    }
                    else
                    {
                        // Meet the enemy - the robber
                        Battle("The robber".60.20.90.10.5.10.1500);
                    }
                }
            }
            Log("You finally found the robber leader and attacked! Revenge for the villagers!");
            // Meet the enemy - Robber Leader 200 35
            Battle("Robber Leader".150.15.10.50.2.50.4000);
            Log("The robbers fled after you killed their leader.");
            LuoYang();
        }

        // To Luoyang
        static void LuoYang()
        {
            Log("Since you defeated the bandit leader, you feel like you are no different from the warrior. I heard that there are a number of counterthieves in Luoyang.");
            Log("So you headed for luoyang, which was farther away. You thought it would be cool to appease the rebels and become an official.");
            Log("After a few steps, you see a carriage coming, which seems to be heading in the direction of Luoyang city. Are you going to ask? 1. Ask 2. Don't ask");
            string str = Console.ReadLine();
            if (str == "1")
            {
                Log("You went to inquire about it, and sure enough, it was also going to Luoyang. So you gave me two ounces of silver and hitch a ride to Luoyang.");
                money -= 2;
                ShowInfo();
            }
            else
            {
                Log("You went to Luoyang alone without asking.");
            }
            LuoYangFB();
        }
        // Arriving in Luoyang
        static void LuoYangFB()
        {
            Log("After a long journey, you finally arrive in the city of Luoyang, thinking that the day of prosperity is coming.");
            Log("As soon as I reached the gate, I saw the flames and unrest inside.");
            for (int i = 0; i < 30; i++)
            {
                Console.WriteLine("Press enter to move.");
                Console.ReadKey();
                // Chance to meet the enemy
                if (new Random().Next(0.5) > 3)
                {
                    if (new Random().Next(0.100) > 80)
                    {
                        // Meet the enemy - the leader of the rebellion
                        Battle("The head of the Rebellion.".250.30.105.10.30.30.6000);
                    }
                    else
                    {
                        // Meet the enemy-rebel
                        Battle("The thief".200.20.90.10.25.10.4000);
                    }
                }
            }
            Log("You finally found the rebel leader and attacked! To bring peace to the court!");
            // Meet the enemy - Robber Leader 200 35
            Battle("The Leader of the Rebellion.".400.10.100.50.50.10.10000);
            Log("The rebels surrendered after you killed their leader.");
            ShowInfo();

            Log("The court is overjoyed now that you have wiped out all the rebels on your own.");
            Log("And he sent for you. Past or not? 1. Past 2. Not past and beat the messenger to come.");
            string str = Console.ReadLine();
            if (str == "1")
            {
                // Invited to the palace
                Log("You accepted the messenger's invitation, followed him to the palace and met the emperor, who asked you what kind of reward you wanted. 1. Gold 100 liang 2.");
                string str1 = Console.ReadLine();
                if (str1 == "1")
                {
                    money += 100;
                    Log("You got a thousand silver twins. you lived in the palace and had no problem with food and clothing.");
                }
                else if (str1 == "2")
                {

                    Log("You were made general of the Horse of Hussars, and the Emperor gave you a yellow mandarin jacket to wear. From then on, you were able to live a rich and secure life in the palace.");
                    EquipItem(new Equip(EquipType.Clothes, "Yellow Mandarin jacket"."Precious clothes from the Emperor.".500.0.0.0)); }}else
            {
                Log("You refuse the messenger's invitation, you go up to the messenger and you beat him, and you find that the messenger is very powerful, and you fight him.");
                // Fight the messenger
                Battle("Angel".500.15.100.10.30.10.10000);
                if (c_Hp > 0)
                {
                    Log("You killed the messenger and made your way to the palace.");

                    // Enter the palace alone
                    Log("You came to the palace and met the emperor. The emperor was impressed by your domineer and asked what kind of reward you wanted. 1. Gold thousand two 2.");
                    string str1 = Console.ReadLine();
                    if (str1 == "1")
                    {
                        money += 1000;
                        Log("You got a thousand silver twins. you lived in the palace and had no problem with food and clothing.");
                    }
                    else if (str1 == "2")
                    {

                        Log("You were made a great general of hussars, and the Emperor gave you a noble sword. From then on, you lived a rich life in the palace.");
                        EquipItem(new Equip(EquipType.Weapon, "The sword of grace."."A precious weapon from the Emperor.".0.100.0.0));
                    }
                }

            }
            ShowInfo();
            Log("So you began to work for the emperor in the imperial palace, and it was a pleasant time.");
            Log("During this time at the palace, you feel what a luxurious life is, but it seems to bind you, and you feel bored.");
            Log("So you decided to leave the palace and go on exploring the world outside.");
            LuoYangJQ();
        }

        // Leave Luoyang
        static void LuoYangJQ()
        {
            Log("As you are about to leave the palace, you see some shops next to it.");

            while (true)
            {
                Log("Which would you like to see?");
                ShowInfo();
                Log("1. Weapon store 2. Armor store 3. Shoe store 4. Ring store 5.);
                string str = Console.ReadLine();
                if (str == "1")
                {
                    Log("You've come to the weapons shop.");
                    Log("1. Buy things. 2. Sell things. 3.);
                    string str1 = Console.ReadLine();
                    if (str1 == "1")
                    {
                        Log("The merchant smiled and asked:" What do you want to buy? We don't have a lot of things here, but they're expensive. They're for cheating honest people.");
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
                        Log("1. Bronze sword damage +20 200 taels of silver");
                        Log("2. Silver Sword damage +30, 300 taels of silver");
                        Log("3. Gold Sword +40 400 taels of silver");
                        Log("4. Diamond Knife +50 500 taels of silver");
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
                        Log(5. It's too expensive. I can't afford any without money in my pocket.);
                        string str2 = Console.ReadLine();
                        if (str2 == "1")
                        {
                            if (money >= 200)
                            {
                                Log("You bought a bronze blade and equipped it.");
                                money -= 200;
                                EquipItem(new Equip(EquipType.Weapon, "Bronze knife"."A weapon made of bronze.".0.20.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "2")
                        {
                            if (money >= 300)
                            {
                                Log("You bought a silver blade and equipped it.");
                                money -= 300;
                                EquipItem(new Equip(EquipType.Weapon, "Silver Knife"."A weapon made of silver.".0.30.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "3")
                        {
                            if (money >= 400)
                            {
                                Log("You bought the gold knife and equipped it.");
                                money -= 400;
                                EquipItem(new Equip(EquipType.Weapon, "The Golden Knife"."A weapon made of gold.".0.40.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "4")
                        {
                            if (money >= 500)
                            {
                                Log("You bought a diamond knife and equipped it.");
                                EquipItem(new Equip(EquipType.Weapon, "Diamond knife"."A weapon made of diamonds.".0.50.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else
                        {
                            Log('I came in to see what I could find, but I didn't buy anything.'); }}else if (str1 == "2")
                    {
                        Log("The merchant smiled and asked," What do you want to sell? We're a small shop here, but we like to take an honest man down.");
                        Log("You don't seem to have anything to sell.");

                    }
                    Log("The merchant looked at you one eye, originally is to want white prostitute, hurry up go away, otherwise call a person to gather you!");
                }
                else if (str == "2")
                {
                    Log("You've come to the armor shop.");
                    Log("1. Buy things. 2. Sell things. 3.);
                    string str1 = Console.ReadLine();
                    if (str1 == "1")
                    {
                        Log("The merchant smiled and asked:" What do you want to buy? We don't have a lot of things here, but they're expensive. They're for cheating honest people.");
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -");
                        Log("1. Bronze Vestment health +100, 200 taels of silver");
                        Log("2. Silver Vestal health +200, 300 taels of silver");
                        Log("3. Gold Vestment health +250, 400 taels of silver");
                        Log("4. Diamond Vestment health +300 500 taels of silver");
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -");
                        Log(5. It's too expensive. I can't afford any without money in my pocket.);
                        string str2 = Console.ReadLine();
                        if (str2 == "1")
                        {
                            if (money >= 200)
                            {
                                Log("You bought the bronze vestments and equipped them.");
                                EquipItem(new Equip(EquipType.Clothes, "The Bronze vesture."."Sacred garments made of bronze.".100.0.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "2")
                        {
                            if (money >= 300)
                            {

                                Log("You bought the silver vestments and equipped them.");
                                EquipItem(new Equip(EquipType.Clothes, "Silver vesture."."Holy garments made of silver.".200.0.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "3")
                        {
                            if (money >= 400)
                            {
                                Log("You bought the golden vestments and equipped them.");
                                EquipItem(new Equip(EquipType.Clothes, "Golden Vesture."."Holy garments made of gold.".250.0.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "4")
                        {
                            if (money >= 500)
                            {
                                Log("You bought the diamond vesture and equipped it.");
                                EquipItem(new Equip(EquipType.Clothes, "The Diamond Vesture."."Holy garments made of diamonds.".300.0.0.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else
                        {
                            Log('I came in to see what I could find, but I didn't buy anything.'); }}else if (str1 == "2")
                    {
                        Log("The merchant smiled and asked," What do you want to sell? We're a small shop here, but we like to take an honest man down.");
                        Log("You don't seem to have anything to sell.");
                    }
                    Log("The merchant looked at you one eye, originally is to want white prostitute, hurry up go away, otherwise call a person to gather you!");
                }
                else if (str == "3")
                {
                    Log("You come to the shoe store.");
                    Log("1. Buy things. 2. Sell things. 3.);
                    string str1 = Console.ReadLine();
                    if (str1 == "1")
                    {
                        Log("The merchant smiled and asked:" What do you want to buy? We don't have a lot of things here, but they're expensive. They're for cheating honest people.");
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
                        Log("1. Bronze shoe speed +100 200 taels of silver");
                        Log("2. Silver shoe speed +150, 300 taels of silver");
                        Log("3. Gold shoes speed +200 400 taels of silver");
                        Log("4. Diamond shoe speed +250 500 taels of silver");
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
                        Log(5. It's too expensive. I can't afford any without money in my pocket.);
                        string str2 = Console.ReadLine();
                        if (str2 == "1")
                        {
                            if (money >= 200)
                            {

                                Log("You bought bronze shoes and equipped them.");
                                EquipItem(new Equip(EquipType.Weapon, "Bronze shoes"."Shoes made of bronze.".0.0.100.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "2")
                        {
                            if (money >= 300)
                            {

                                Log("You bought silver shoes and equipped them.");
                                EquipItem(new Equip(EquipType.Shoes, "Silver Shoes"."Shoes made of silver.".0.0.150.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "3")
                        {
                            if (money >= 400)
                            {
                                Log("You bought gold shoes and equipped them.");
                                EquipItem(new Equip(EquipType.Shoes, "Golden Shoes"."Shoes made of gold.".0.0.200.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "4")
                        {
                            if (money >= 500)
                            {
                                Log("You bought diamond shoes and equipped them.");
                                EquipItem(new Equip(EquipType.Shoes, "Diamond Shoes"."Shoes made of diamonds.".0.0.250.0));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else
                        {
                            Log('I came in to see what I could find, but I didn't buy anything.'); }}}else if (str == "4")
                {
                    Log("You've come to the ring shop.");
                    Log("1. Buy things. 2. Sell things. 3.);
                    string str1 = Console.ReadLine();
                    if (str1 == "1")
                    {
                        Log("The merchant smiled and asked:" What do you want to buy? We don't have a lot of things here, but they're expensive. They're for cheating honest people.");
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
                        Log("1. Bronze Ring casting chance +10 200 taels of silver");
                        Log("2. Silver Ring ability casting chance +20 300 taels of silver");
                        Log("3. Gold Ring ability +30, 400 taels of silver");
                        Log(4. Diamond Ring spells +40, 500 taels of silver.);
                        Log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -");
                        Log(5. It's too expensive. I can't afford any without money in my pocket.);
                        string str2 = Console.ReadLine();
                        if (str2 == "1")
                        {
                            if (money >= 200)
                            {
                                Log("You bought a bronze ring and equipped it.");
                                EquipItem(new Equip(EquipType.Jiezhi, "Bronze Ring"."A ring made of bronze.".0.0.0.10));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "2")
                        {
                            if (money >= 300)
                            {
                                Log("You bought a silver ring and equipped it.");
                                EquipItem(new Equip(EquipType.Jiezhi, "Silver Ring"."A ring made of silver.".0.0.0.20));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "3")
                        {
                            if (money >= 400)
                            {
                                Log("You bought a gold ring and equipped it.");
                                EquipItem(new Equip(EquipType.Jiezhi, "Gold Rings"."A ring made of gold.".0.0.0.30));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else if (str2 == "4")
                        {
                            if (money >= 500)
                            {
                                Log("You bought a diamond ring and equipped it.");
                                EquipItem(new Equip(EquipType.Jiezhi, "Diamond Ring"."A ring made of diamonds.".0.0.0.40));
                            }
                            else
                            {
                                Log("Money is not enough, embarrassed to leave."); }}else
                        {
                            Log('I came in to see what I could find, but I didn't buy anything.'); }}}if (str == "5")
                {
                    break; ;
                }
            }



            DongXue();


        }

        // Go to the cave
        static void DongXue()
        {
            Log("You left the imperial palace of Luoyang and came to the outskirts of Luoyang. You were going to kill some animals to eat as a snack on the road.");
            / / walk
            while (true)
            {
                Log("");
                Log("You came to the door of a cave and heard a little roar from inside, which made people tremble unconsciously.");
                Log("Hint: there is a super BOSS ahead, health :?? , attack power :?? , speed:????? , critical hit rate :?? , dodge:?????");
                Log("Do you want to challenge? \n 1. Challenge \n 2. Slip away, come back when you upgrade.");
                string str = Console.ReadLine();
                if (str == "1")
                {
                    Log('You showed you weren't a bit wimpy, and hit everyone you saw and went in.');
                    Log("I saw lying in front of a body glittering and translucent get rid of the white hair, there is a wisp of golden hair on the top of his head seems to be a" king "word, sending out a powerful majesty.");
                    Log("As soon as you walk in, it opens its eyes and sees you.");
                    Log("You see that the eyes of this giant are glowing with nine different colors, and the majesty of this giant is doubled.");
                    Log("And he jumped at you, into the fight!");

                    // Meet the enemy - Nine colors god eyes holy tiger
                    Battle("The Tiger with Nine colorful eyes.".6666.20.250.50.20.40.30000);
                    Log("Accompanied by a roar, you finally knocked down the nine color god eyes holy tiger.");
                }
                else
                    / / walk
                    for (int i = 0; i < 30; i++)
                    {
                        Console.WriteLine("Press enter to move.");
                        Console.ReadKey();
                        // Chance to meet the enemy
                        if (new Random().Next(0.6) > 3)
                        {
                            if (new Random().Next(0.100) > 80)
                            {
                                // Meet the enemy - the white tiger with evil eyes
                                Battle("White Tiger with Evil Eyes".700.20.150.20.30.30.15000);
                            }
                            else
                            {
                                // Meet the enemy - the White Tiger
                                Battle("The White Tiger of Darkness".400.20.150.15.15.13.5000); }}}if (str == "1")
                {
                    break;
                }
            }
            Log("");


        }

        //---------------------------------------------------------------------------------------
        Combat name Health Attack Speed Critical hit Rate (0-100) Dodge rate (0-100) Money experience
        static void Battle(string e_name, int e_hp, int e_atk, int e_speed, int e_satk, int e_miss, int e_money, int e_exp)
        {
            Console.WriteLine("Touch" + e_name + ! "" Does it cost 5 ounces of silver to return to full health? 1. Return full 2. Not return");
            string str = Console.ReadLine();
            // Determine whether the blood returns
            if (str == "1" && money >= 5)
            {
                // Return to full health
                c_Hp = hp + clothes_Hp;
                / / consumption
                money -= 5;
                Log("Full health! Current health is:" + c_Hp + ", the current money is:" + money);
            }
            // Judge first
            bool isPlayerAtk = speed + shoes_speed > e_speed;

            // Enter the battle
            while (true)
            {
                // If the player is attacking
                if (isPlayerAtk)
                {
                    // The next attack is the enemy
                    isPlayerAtk = false;
                    // Select whether to release the skill
                    /* Active skill release, if you like, there is a bug in this, it will be released every turn, so the comment ~~~ * Log(" Do you use skills? \n 1. Use skill "ten thousand poison palm" \n 2. Use skill "no sweet without sweat" \n 3. Do not use skills "); string str1 = Console.ReadLine(); if (str1 == "1") { for (int i=1; i<=2; i++) { if (e_hp<=0) { e_hp = 0; break; } int num = new Random().Next(e_hp ,e_hp*2); e_hp -= num * 1/10; Log(" + e_name + (num * 1/10) + "HP," + E_name +" remaining HP "+ E_HP); } //--------------- }else if (str1 == "2") { for (int i = 1; i <= 2; i++) { if (c_Hp>=hp) { c_Hp = hp; break; } int num = new Random().Next(hp, hp * 2); c_Hp += num * 1 / 10; Log(" +(num * 1/10) + "+(num * 1/10) +" + c_Hp); } }else */
                    // Judge dodge
                    if (new Random().Next(0.100) < e_miss)
                    {
                        Log("You swing a knife, and you get" + e_name + "Light escape!);
                        continue;
                    }
                    // Determine whether passive abilities will be released
                    // The enemy loses blood
                    int num1 = new Random().Next(atk + weapon_atk - 2, atk + weapon_atk + 3);
                    e_hp -= num1;
                    if (new Random().Next(0.100) < jineng)
                    {
                        e_hp -= num1 * 3;
                        Log("You used the passive skill" Sunflower Treasure "and attacked." + e_name + (num1 * 3) + "A little bit of health," + e_name + "Health surplus" + e_hp);
                    }
                    else
                    {
                        e_hp -= e_atk;
                        Log("Player pair." + e_name + "Cause" + num1 + "A little bit of health," + e_name + "Health surplus" + e_hp);
                    }


                    // Judge the enemy's death
                    if (e_hp <= 0)
                    {
                        int eMoney = new Random().Next(e_money - 1, e_money + 1);
                        int eExp = new Random().Next(e_exp - 50, e_exp + 50);
                        money += eMoney;
                        exp += eExp;
                        Log(e_name + "Defeated! You got it. "" + eMoney + "Money and" + eExp + "Experience!);
                        // Determine if the player is leveling up
                        if (exp > level * 1000)
                        {
                            / /
                            exp -= level * 1000;
                            / / level
                            level++;
                            // Add attributes
                            hp += g_hp;
                            c_Hp = hp + clothes_Hp;
                            atk += g_atk;
                            speed += g_speed;
                            // Console.ForegroundColor(ConsoleColor.Red);
                            Log("Congratulations on the upgrade. The current level is:" + level);
                            ShowInfo();
                        }
                        break; }}else
                {
                    // The current is an enemy attack, the next is a player attack
                    isPlayerAtk = true;
                    // Determine if critical strike is required
                    if (new Random().Next(0.100) < e_satk)
                    {
                        c_Hp -= e_atk * 2;
                        Log(e_name + "Attacked the player as hard as he could." + (e_atk * 2) + "Health, player health left:" + c_Hp + "/" + hp);
                    }
                    else
                    {
                        c_Hp -= e_atk;
                        Log(e_name + "Attacked the player." + e_atk + "Point health, player health left:" + c_Hp + "/" + hp);
                    }
                    // If the player dies
                    if (c_Hp <= 0)
                    {
                        Log("It seemed to you that you were dying. Did you spend a hundred ounces of silver to get back? No resurrection, eighteen years later is a hero! 2. The resurrection");
                        string str2 = Console.ReadLine();
                        if (str2 == "1")
                        {
                            / / no resurrection
                            Log("You are" + e_name + "Killed in cold blood.");
                            Log("Winning or losing is a common thing in military. After 18 years, he is a hero again. Let's try our best in our next life.");
                            / / exit
                            Environment.Exit(0);
                        }
                        if (str2 == "2")
                        {
                            / / the resurrection
                            if (money >= 100)
                            {
                                money -= 100;
                                c_Hp += 100;
                                Log("You chose resurrection, current health is:" + c_Hp + "Current gold remaining:" + money);
                            }
                            else
                            {
                                / / exit
                                Log("You are" + e_name + "Killed in cold blood.");
                                Log("Winning or losing is a common thing in military. After 18 years, he is a hero again. Let's try our best in our next life.");
                                Environment.Exit(0);
                            }
                        }

                    }
                }
            }
        }


        / / output
        static void Log(string text)
        {
            Console.WriteLine(text);
            / / sleep
            Thread.Sleep(500);
        }

        static void Main(string[] args)
        {
            // Create a role
            CreateCharacter();
            / / new village
            xinShouCun();
            / / fieldjiaoQu(); }}}Copy the code