123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- import { Role } from "../../../common/InterfaceAddEnum";
- import { UptypeConf } from "../conf/UptypeConf";
- import { BattleDataPool } from "./BattleDataPool";
- import { BulletType, ObjectValueType } from "./BattleEnum";
- import { BattleUtil } from "./BattleUtil";
- import { BuffData, BuffDataPool } from "./BuffData";
- import { DataBase } from "./DataBase";
- import { EnemyData } from "./EnemyData";
- import { SkillData, SkillDataPool } from "./SkillData";
- //种族缩放因子
- export let HeroRaceSacle = 100;
- export class HeroData extends DataBase{
- level: number;
- //所属格子 -1表示暂无
- posID: number;
- //当前坐标
- protected _position:BattleUtil.Vector2;
- // //动画
- // //前摇时间
- // preTime: number;
- // //攻击动画时间
- // attackTime: number;
-
- //攻击类型 瞬发单体/瞬发群体/弹道单体/弹道群体
- attackType: BulletType;
- //攻击速度 攻击间隔
- protected _speed: number;
- //攻击范围
- protected _attackRadius: number;
- //攻击力
- protected _attackDamage: number;
- //暴击率
- protected _critical: number;
- //暴击伤害
- protected _criticalDamage: number;
- //攻击速度 攻击间隔
- protected _speedCur: number;
- //攻击范围
- protected _attackRadiusCur: number;
- //攻击力
- protected _attackDamageCur: number;
- //暴击率
- protected _criticalCur: number;
- //暴击伤害
- protected _criticalDamageCur: number;
- //种族
- protected _raceID: number;
-
- //特殊攻击
- spaceValueList:Map<ObjectValueType,BattleUtil.SpecialValue[]> = new Map();
-
- //技能列表
- skillList: number[];
- //实例化后的技能列表
- skillDataList: Array<SkillData> = [];
-
- //子弹命中后释放的技能列表
- skillBulletList: number[];
- skillDataBulletList: Array<SkillData> = [];
- //buff列表
- buffList: Array<BuffData> = [];
- //目标敌人
- targetEnemy:EnemyData;
- //冷却剩余时间
- coolDown: number;
- init(role:Role, level:number, posID: number) {
- super._init();
- this.level = level;
- this.typeID = Number(role.id);
- this.posID = posID;
- this._raceID = role.conf.Race
- // let roleData = RoleData.getRoleDataByID(this.typeID)
- //读地图
- this.position = new BattleUtil.Vector2(0, 0);
- let heroConf = role.conf
- if (heroConf) {
- this.attackType = heroConf.AttackType;
- this._speed = role.attr.speed;
- this.coolDown = this._speed
- this._attackRadius = heroConf.Radius;
- this._attackDamage = role.attr.attack;
- this._critical = role.attr.crite;
- this._criticalDamage = role.attr.critedamage;
- this.skillList = heroConf.SkillArray
- if(this.skillList && this.skillList.length > 0){
- for (let i = 0; i < this.skillList.length; i++) {
- let skillID = this.skillList[i];
- let skillData = SkillDataPool.getObject();
- skillData.init(skillID, this);
- this.skillDataList.push(skillData);
- }
- }
- this.skillBulletList = heroConf.SkillBulletArray
- if(this.skillBulletList && this.skillBulletList.length > 0){
- for (let i = 0; i < this.skillBulletList.length; i++) {
- let skillID = this.skillBulletList[i];
- let skillData = SkillDataPool.getObject();
- skillData.init(skillID, this);
- this.skillDataBulletList.push(skillData);
- }
- }
- this.updataLevel()
- return this;
- }
- return null;
- }
- set position(pos:BattleUtil.Vector2) {
- this._position = pos;
- }
- get position():BattleUtil.Vector2 {
- return this._position;
- }
- //攻击速度 攻击间隔
- get speed(): number{
- return this._speedCur;
- }
- //攻击范围
- get attackRadius(): number{
- return this._attackRadiusCur;
- }
- //攻击力
- get attackDamage(): number{
- return this._attackDamageCur;
- }
- //暴击率
- get critical(): number{
- return this._criticalCur;
- }
- //暴击伤害
- get criticalDamage(): number{
- return this._criticalDamageCur;
- }
- get raceID(): number{
- return this._raceID;
- }
- //只对buff进行记录
- addBuff(buff:BuffData) {
- this.buffList.push(buff);
- return this;
- }
- levelUp() {
- this.level++;
- this.updataLevel()
- }
- levelTo(newLevel: number){
- this.level = newLevel;
- this.updataLevel()
- }
- updataLevel() {
- let conf = UptypeConf.data
- this._speedCur = this._speed / (conf.HeroSpeedColArr[this.level]||1);
- this._attackRadiusCur = this._attackRadius;
- this._attackDamageCur = this._attackDamage* (conf.HeroAttackColArr[this.level]||1);
- this._criticalCur = this._critical;
- this._criticalDamageCur = this._criticalDamage;
- }
- updateRole(role:Role){
- let heroConf = role.conf
- if (heroConf) {
- this._speed = role.attr.speed;
- this._attackDamage = role.attr.attack;
- this._critical = role.attr.crite;
- this._criticalDamage = role.attr.critedamage;
- this.updataLevel()
- return this;
- }
- return null;
- }
- removeBuff(ID: number) {
- for (let i = 0; i < this.buffList.length; i++) {
- let buff = this.buffList[i];
- if (buff.ID == ID) {
- this.buffList.splice(i,1);
- break;
- }
- }
- return this;
- }
- // addSkill(skill:SkillData) {
- // this.skillDataList.push(skill);
- // return this;
- // }
- clear() {
- this.level = 0;
- this.typeID = BattleUtil.TypeID_Init;
- this.posID = BattleUtil.PosID_Init;
- //读表
- this.attackType = BulletType.Single;
- this._speed = 0;
- this._attackRadius = 0;
- this._attackDamage = 0;
- this._critical = 0;
- this._criticalDamage = 0;
- this._attackDamageCur = 0;
- this._attackRadiusCur = 0;
- this._criticalCur = 0;
- this._criticalDamageCur = 0;
- this._speedCur = 0;
- this.coolDown = 0;
- // this.spaceValueList.clear();
- for (let i = 0; i < this.skillDataList.length; i++) {
- SkillDataPool.putObject(this.skillDataList[i]);
- }
- this.skillDataList = [];
- this.skillList = [];
- for (let i = 0; i < this.skillDataBulletList.length; i++) {
- SkillDataPool.putObject(this.skillDataBulletList[i]);
- }
- this.skillDataBulletList = [];
- this.skillBulletList = [];
- this.buffList = [];
- this.targetEnemy = null;
- }
- }
- export let HeroDataPool = new BattleDataPool(HeroData,30)
|