Two-player vs. Game structure + function

Source: Internet
Author: User

classPvP 713 {structPlayer { Public stringName;  Public intBlood;  Public intattact;  Public intdefence;  Public intDuobi;  PublicArrayList Jineng;  PublicArrayList Shanghai; }        Static voidMain (string[] args) {            #regionDefine skill Basestring[] JN; int[] SH; Jineng ( outJN, outSH); #endregionConsole.WriteLine ("Please enter player 1 name:"); stringName1 =Console.ReadLine (); Console.WriteLine ("Please enter player 2 name:"); stringName2 =Console.ReadLine (); #regionCreate players, display basic information//Build PlayersRandom SJ =NewRandom (); //Build PlayersPlayer P1 =Wanjia (JN,SH,NAME1,SJ); Player P2=Wanjia (JN,SH,NAME2,SJ); #endregion            //Display InformationJBXX (refP1,refP2); Console.WriteLine ("Press ENTER to start the fight ."); Consolekeyinfo Key=Console.readkey (); if(Key. Key.tostring (). ToLower () = ="Enter")            {                       while(true)                {                    #regionOutcome conditionsif(P1. Blood = =0&& P2. Blood = =0) {Console.foregroundcolor=Consolecolor.yellow; Console.WriteLine ("{0} and {1} perish! ", P1. Name,p2.                    Name);  Break; }                    Else if(P2. Blood = =0) {Console.foregroundcolor=Consolecolor.yellow; Console.WriteLine ("{0} put {1}ko! ", P1. Name,p2.                        Name);  Break; }                    Else if(P1. Blood = =0) {Console.foregroundcolor=Consolecolor.yellow; Console.WriteLine ("{0} put {1}ko! ", P2. Name, P1.                        Name);  Break; }                    #endregion                    //P1 Dozen P2Dajia (SJ,refP1,refP2); //P2 Dozen P1Dajia (SJ,refP2,refP1); //Show the remaining amount of bloodXueliang (refP1,refP2);                    Console.WriteLine (); Thread.Sleep ( -); }            }        }        Private Static voidJBXX (refPlayer P1,refPlayer P2) {Console.WriteLine ("Name: {0}\t: {1}\t damage: {2}\t Defense: {3}\t Dodge: {4}\t learned skill: {5}, {6}, {7}", P1. Name, P1. Blood, P1. Attact, P1. Defence, P1. Duobi, P1. jineng[0], P1. jineng[1], P1. jineng[2]); Console.WriteLine ("Name: {0}\t: {1}\t damage: {2}\t Defense: {3}\t Dodge: {4}\t learned skill: {5}, {6}, {7}", P2. Name, P2. Blood, P2. Attact, P2. Defence, P2. Duobi, P2. jineng[0], P2. jineng[1], P2. jineng[2]); }        Private Static voidXueliang (refPlayer P1,refPlayer P2) {Console.foregroundcolor=Consolecolor.yellow; Console.WriteLine ("the remaining blood amount for {0} is: {1}\t{2} The remaining blood is: {3}", P1. Name, P1. Blood, P2. Name, P2.        Blood); }        Private Static voidDajia (Random SJ,refPlayer P1,refPlayer P2) {            if(SJ.) Next (Ten) >=8)//Use skills{Console.foregroundcolor=Consolecolor.white; intxx = sj. Next (3); Console.WriteLine ("{0} was using {1} skills, causing {3} point damage to {2}! ", P1. Name, P1. JINENG[XX], P2. Name, P1.                SHANGHAI[XX]); P2. Blood-=Convert.ToInt32 (P1.                SHANGHAI[XX]); if(P2. Blood <=0) {P2. Blood=0; }            }            Else  //Common Attack            {                //P2 Dodge Attack                if(P2. Duobi >= SJ. Next ( One) ) {Console.foregroundcolor=Consolecolor.green; Console.WriteLine ("{0} escaped the attack of {1} ~! ", P2. Name, P1.                Name); }                Else//P2 not hiding{Console.foregroundcolor=consolecolor.red; intPTSH1 = P1. Attact + SJ. Next ( -)-P2. DEFENCE-SJ. Next ( -);//damage caused by P1Console.WriteLine ("{ 0} attacks {1}, causing {2} point damage", P1. Name, P2.                    Name, PTSH1); P2. Blood-=Ptsh1; if(P2. Blood <=0) {P2. Blood=0; }                }            }        }        Private StaticPlayer Wanjia (string[] JN,int[] SH,stringname1, Random SJ) {Player P1=NewPlayer (); intseed1; if(name1. Length = =2) {seed1= (int) Convert.tochar (name1. Substring (0,1)) + (int) Convert.tochar (name1. Substring (1,1)); }            Else{seed1= (int) Convert.tochar (name1. Substring (0,1)) + (int) Convert.tochar (name1. Substring (1,1)) + (int) Convert.tochar (name1. Substring (2,1)); } Random R1=NewRandom (seed1); P1. Name=name1; P1. Blood= -+ R1. Next ( -); P1. Attact= $+ R1. Next ( -); P1. Defence= -+ R1. Next ( -); P1. Duobi=1+ R1. Next (3); P1. Jineng=NewArrayList (); P1. Shanghai=NewArrayList ();  for(inti =0; I <3; i++)            {                intx = SJ. Next (Ten); if(!P1. Jineng.contains (Jn[x])) {P1.                    Jineng.add (Jn[x]); P1.                Shanghai.add (Sh[x]); }                Else{i--; }            }            returnP1; }        Private Static voidJineng ( out string[] JN, out int[] SH) {JN=New string[] {            "Dragon",            "Annihilation",            "Striking",            "Dragon Play Beads",            "Magic Spell",            "Thunderstruck",            "Bash",            "Eagle Strike",            "Glamour",            "Yama Order"            }; SH=New int[] {              -,            480,             -,            420,            290,            460,             the,             -,            380,            399            }; }    }}

Two-player vs. Game structure + function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.