您的位置 首页 > 娱乐休闲

王者荣耀英雄从哪来的(王者荣耀里面的英雄是怎么来的)

比如王者荣耀。我常常在想,如果我可以自己创造一个英雄那该多好,现在我要开始以自己的想法来实现我的愿望,也来练习练习自己对于java对象的认识。

一、前期准备

我们要在IDEA上创建一个新的项目,创建好一个项目后,我们需要创建4个包,分别是英雄包,装备包,铭文包,野怪包,皮肤包 然后我们就可以一个一个的实现这些功能了。

二、实现我的英雄梦!

1.英雄基本属性实现

packageHero;//英雄的基本属性publicclassHero{publicStringname;//英雄的名字publicStringtype;//英雄的职业publicintblood;//英雄的基本血量publicintphyattack;//英雄的基本物理攻击publicintMagicattavk;//英雄的基本法术攻击publicintphyfangyu;//英雄的基础防御publicintattavknum;//普通伤害的值publicintmove;//移动速度publicintmoney;//经济publicHero(Stringname,Stringtype,intblood,intphyattack,intmagicattavk,intphyfangyu,intattavknum,intmove,intmoney){this.name=name;this.type=type;this.blood=blood;this.phyattack=phyattack;this.Magicattavk=magicattavk;this.phyfangyu=phyfangyu;this.attavknum=attavknum;this.move=move;this.money=money;}publicStringgetName(){returnname;}publicStringgetType(){returntype;}publicintgetBlood(){returnblood;}publicintgetPhyattack(){returnphyattack;}publicintgetMagicattavk(){returnMagicattavk;}publicintgetPhyfangyu(){returnphyfangyu;}publicintgetAttavknum(){returnattavknum;}publicvoidsetName(Stringname){this.name=name;}publicvoidsetType(Stringtype){this.type=type;}publicvoidsetBlood(intblood){this.blood=blood;}publicvoidsetPhyattack(intphyattack){this.phyattack=phyattack;}publicvoidsetMagicattavk(intmagicattavk){Magicattavk=magicattavk;}publicvoidsetPhyfangyu(intphyfangyu){this.phyfangyu=phyfangyu;}publicvoidsetAttavknum(intattavknum){this.attavknum=attavknum;}//受到普通攻击publicintbnormalAttack(intattavknum){if(this.phyfangyu-this.attavknum<=0){intres=this.phyfangyu-this.attavknum;returnthis.blood res;}returnblood-this.attavknum;}//普通攻击publicintznormalAttack(){if(this.type==射手||this.type==战士||this.type==刺客){this.attavknum =phyattack;}if(this.type==法师){this.attavknum =Magicattavk;}returnattavknum;}}

2.装备包

装备太多了,我主要写一些我平时比较喜欢的几个装备,有兴趣的朋友可以自己练习多写几个 鞋子

packagezhuangbei;//抵抗之靴/***效果:减低敌方的攻击,也就是增加自己的物防*/publicclassShoe{publicStringname=抵抗之靴;publicintphyattack=200;publicintmckattack=0;publicintmove=200;//英雄移动速度 200;publicShoe(){}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicintgetPhyattack(){returnphyattack;}publicvoidsetPhyattack(intphyattack){this.phyattack=phyattack;}publicintgetMckattack(){returnmckattack;}publicvoidsetMckattack(intmckattack){this.mckattack=mckattack;}publicintgetMove(){returnmove;}publicvoidsetMove(intmove){this.move=move;}}

反甲

packagezhuangbei;//反甲publicclassFajia{publicStringname=反甲;publicintphyattack=40;publicintphyfanyu=420;publicdoublefashang=0.2;//冷却时间publicintgetPhyattack(){returnphyattack;}publicvoidsetPhyattack(intphyattack){this.phyattack=phyattack;}publicintgetPhyfanyu(){returnphyfanyu;}publicvoidsetPhyfanyu(intphyfanyu){this.phyfanyu=phyfanyu;}publicdoublegetFashang(){returnfashang;}publicvoidsetFashang(doublefashang){this.fashang=fashang;}}

暗影战斧

packagezhuangbei;//暗影战斧/****/publicclassAnyinzhanfu{publicStringname=暗影战斧;publicintphyattack=85;//加物理攻击85publicintblood=500;//生命值加500publicintcool=15;//冷却缩减15publicintgetPhyattack(){returnphyattack;}publicvoidsetPhyattack(intphyattack){this.phyattack=phyattack;}publicintgetBlood(){returnblood;}publicvoidsetBlood(intblood){this.blood=blood;}publicintgetCool(){returncool;}publicvoidsetCool(intcool){this.cool=cool;}}

3.没有经济来源怎么行?野怪实现

我主要写了野猪,小鸟,河蟹,小兵的类 野猪

packageyeguai;publicclassPig{publicintnum=80;publicintgetNum(){returnnum;}publicvoidsetNum(intnum){this.num=num;}}

小鸟

packageyeguai;publicclassBird{publicintnum=100;publicintgetNum(){returnnum;}publicvoidsetNum(intnum){this.num=num;}}

河蟹

packageyeguai;publicclassHeixie{publicintnum=150;publicintgetNum(){returnnum;}publicvoidsetNum(intnum){this.num=num;}}

小兵

packageyeguai;publicclassXiaobing{publicintnum=150;publicintgetNum(){returnnum;}publicvoidsetNum(intnum){this.num=num;}}

开始游戏啦

importHero.Hero;importyeguai.Bird;importyeguai.Heixie;importyeguai.Pig;importyeguai.Xiaobing;importzhuangbei.Anyinzhanfu;importzhuangbei.Fajia;importzhuangbei.Shoe;publicclassDeom{publicstaticvoidmain(String[]args){Heroyase=newHero(亚瑟,战士,1000,200,0,500,200,50,0);System.out.println(yase.name);System.out.println(yase.money);//开始发育(先产生野怪,小兵,河蟹的实例化对象)Pigpig1=newPig();BirdBird=newBird();Xiaobingxiaobing=newXiaobing();Heixieheixie=newHeixie();for(inti=0;i<=10;i ){//打了10轮yase.money =pig1.getNum() Bird.getNum() xiaobing.getNum() heixie.getNum();}System.out.println(yase.name 的经济现在是 yase.money);//开始创建装备类System.out.println(购买装备前:);System.out.println(yase.name 当前的属性 生命值: yase.blood 物理攻击: yase.phyattack 法术攻击: yase.Magicattavk 物理防御: yase.phyfangyu 移动速度: yase.move);if(yase.money=200){Shoeshoe=newShoe();System.out.println(yase.name 购买了 shoe.name);yase.phyfangyu =shoe.getPhyattack();yase.move =shoe.getMove();yase.money=yase.money-200;}if(yase.money=1200){Fajiafajia=newFajia();System.out.println(yase.name 购买了 fajia.name);yase.phyattack =fajia.getPhyattack();//攻击力 yase.phyfangyu =fajia.getPhyfanyu();//防御力 yase.money=yase.money-1200;}if(yase.money=2000){Anyinzhanfuanyinzhanfu=newAnyinzhanfu();System.out.println(yase.name 购买了 anyinzhanfu.name);yase.phyattack =anyinzhanfu.getPhyattack();//攻击力 yase.blood =anyinzhanfu.getBlood();//生命力 yase.money=yase.money-2000;}System.out.println(购买装备后:);System.out.println(yase.name 当前的属性 生命值: yase.blood 物理攻击: yase.phyattack 法术攻击: yase.Magicattavk 物理防御: yase.phyfangyu 移动速度: yase.move);}}

我基本可以实现简单地创建一个英雄,实现刷野怪,购买装备的简单操作,后续我将实现英雄的三个技能和铭文的实现。

沉默着忍受

https://blog.csdn.net/ILOVEMYDEAR/article/details/116431337

责任编辑: 鲁达

1.内容基于多重复合算法人工智能语言模型创作,旨在以深度学习研究为目的传播信息知识,内容观点与本网站无关,反馈举报请
2.仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证;
3.本站属于非营利性站点无毒无广告,请读者放心使用!

相关推荐