王者荣耀里面的英雄是怎么来的,王者荣耀怎么看有哪些英雄

首页 > 经验 > 作者:YD1662024-01-15 14:25:48

二、实现我的英雄梦!

1. 英雄基本属性实现

package Hero;
//英雄的基本属性public class Hero { public String name; //英雄的名字 public String type; //英雄的职业 public int blood; //英雄的基本血量 public int phyattack; //英雄的基本物理攻击 public int Magicattavk; //英雄的基本法术攻击 public int phyfangyu; //英雄的基础防御 public int attavknum; //普通伤害的值 public int move; //移动速度 public int money; //经济

public Hero(String name, String type, int blood, int phyattack, int magicattavk, int phyfangyu,int attavknum,int move,int money) { 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; }
public String getName { return name; }
public String getType { return type; }
public int getBlood { return blood; }
public int getPhyattack { return phyattack; }
public int getMagicattavk { return Magicattavk; }
public int getPhyfangyu { return phyfangyu; }
public int getAttavknum { return attavknum; }
public void setName(String name) { this.name = name; }
public void setType(String type) { this.type = type; }
public void setBlood(int blood) { this.blood = blood; }
public void setPhyattack(int phyattack) { this.phyattack = phyattack; }
public void setMagicattavk(int magicattavk) { Magicattavk = magicattavk; }
public void setPhyfangyu(int phyfangyu) { this.phyfangyu = phyfangyu; }
public void setAttavknum(int attavknum) { this.attavknum = attavknum; }
//受到普通攻击 public int bnormalAttack(int attavknum){ if(this.phyfangyu-this.attavknum<=0){ int res = this.phyfangyu-this.attavknum; return this.blood res; } return blood-this.attavknum; } //普通攻击 public int znormalAttack{ if(this.type=="射手"||this.type=="战士"||this.type=="刺客"){ this.attavknum =phyattack; } if(this.type=="法师"){ this.attavknum =Magicattavk; } return attavknum; }}

2. 装备包

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

鞋子

package zhuangbei;//抵抗之靴/** * 效果:减低敌方的攻击,也就是增加自己的物防 */
public class Shoe { public String name = "抵抗之靴"; public int phyattack=200; public int mckattack=0; public int move = 200;//英雄移动速度 200;
public Shoe {
}
public String getName { return name; }
public void setName(String name) { this.name = name; }
public int getPhyattack { return phyattack; }
public void setPhyattack(int phyattack) { this.phyattack = phyattack; }
public int getMckattack { return mckattack; }
public void setMckattack(int mckattack) { this.mckattack = mckattack; }
public int getMove { return move; }
public void setMove(int move) { this.move = move; }}

反甲

package zhuangbei;//反甲public class Fajia { public String name = "反甲"; public int phyattack = 40; public int phyfanyu = 420; public double fashang = 0.2; //冷却时间
public int getPhyattack { return phyattack; }
public void setPhyattack(int phyattack) { this.phyattack = phyattack; }
public int getPhyfanyu { return phyfanyu; }
public void setPhyfanyu(int phyfanyu) { this.phyfanyu = phyfanyu; }
public double getFashang { return fashang; }
public void setFashang(double fashang) { this.fashang = fashang; }}

暗影战斧

package zhuangbei;//暗影战斧/*** */public class Anyinzhanfu { public String name = "暗影战斧"; public int phyattack = 85; //加物理攻击85 public int blood = 500; //生命值加500 public int cool = 15; //冷却缩减15
public int getPhyattack { return phyattack; }
public void setPhyattack(int phyattack) { this.phyattack = phyattack; }
public int getBlood { return blood; }
public void setBlood(int blood) { this.blood = blood; }
public int getCool { return cool; }
public void setCool(int cool) { this.cool = cool; }}

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

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

野猪

package yeguai;
public class Pig { public int num = 80;
public int getNum { return num; }
public void setNum(int num) { this.num = num; }}

小鸟

package yeguai;
public class Bird { public int num = 100;
public int getNum { return num; }
public void setNum(int num) { this.num = num; }}

河蟹

package yeguai;
public class Heixie { public int num = 150;
public int getNum { return num; }
public void setNum(int num) { this.num = num; }}

小兵

package yeguai;
public class Xiaobing { public int num = 150;
public int getNum { return num; }
public void setNum(int num) { this.num = num; }}三、开始游戏啦

import Hero.Hero;import yeguai.Bird;import yeguai.Heixie;import yeguai.Pig;import yeguai.Xiaobing;import zhuangbei.Anyinzhanfu;import zhuangbei.Fajia;import zhuangbei.Shoe;
public class Deom { public static void main(String[] args) { Hero yase = new Hero("亚瑟","战士",1000,200,0,500,200,50,0);
System.out.println(yase.name); System.out.println(yase.money); //开始发育(先产生野怪,小兵,河蟹的实例化对象) Pig pig1 = new Pig; Bird Bird = new Bird; Xiaobing xiaobing = new Xiaobing; Heixie heixie = new Heixie; for(int i =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){ Shoe shoe = new Shoe; System.out.println(yase.name "购买了" shoe.name); yase.phyfangyu =shoe.getPhyattack; yase.move =shoe.getMove; yase.money=yase.money-200; } if(yase.money>=1200){ Fajia fajia = new Fajia; System.out.println(yase.name "购买了" fajia .name); yase.phyattack =fajia.getPhyattack; //攻击力 yase.phyfangyu =fajia.getPhyfanyu; //防御力 yase.money=yase.money-1200; } if(yase.money>=2000){ Anyinzhanfu anyinzhanfu = new Anyinzhanfu; 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); }}

王者荣耀里面的英雄是怎么来的,王者荣耀怎么看有哪些英雄(5)

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

PS:如果觉得我的分享不错,欢迎大家随手点赞、在看。

王者荣耀里面的英雄是怎么来的,王者荣耀怎么看有哪些英雄(6)

之前,给大家发过三份Java面试宝典,这次新增了一份,目前总共是四份面试宝典,相信在跳槽前一个月按照面试宝典准备准备,基本没大问题。

分别适用于初中级,中高级资深级工程师的面试复习。

内容包含java基础、javaweb、mysql性能优化、JVM、锁、百万并发、消息队列,高性能缓存、反射、Spring全家桶原理、微服务、Zookeeper、数据结构、限流熔断降级等等。

王者荣耀里面的英雄是怎么来的,王者荣耀怎么看有哪些英雄(7)

看到这里,证明有所收获

上一页12末页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.