增加角色死亡消息
This commit is contained in:
parent
080badc9cd
commit
4aff24ba8d
@ -5,7 +5,7 @@ import { PlayerHandler } from "./PlayerHandler";
|
|||||||
import CfgMan from "../CfgMan";
|
import CfgMan from "../CfgMan";
|
||||||
import { EffectCardType, GameCampType, GameUnitType, SkillEffectType, SkillRangeUnitType } from "../skill/SkillConst";
|
import { EffectCardType, GameCampType, GameUnitType, SkillEffectType, SkillRangeUnitType } from "../skill/SkillConst";
|
||||||
import { Pet } from "rooms/schema/Pet";
|
import { Pet } from "rooms/schema/Pet";
|
||||||
import {PetUpdateProcess, SkillParam, SkillResult, SkillTarget} from "../skill/SkillParam";
|
import {PetUpdateProcess, PlayerRemoveMsg, SkillParam, SkillResult, SkillTarget} from "../skill/SkillParam";
|
||||||
import { nosync, Room } from "colyseus";
|
import { nosync, Room } from "colyseus";
|
||||||
import { Skill } from "../skill/Skill";
|
import { Skill } from "../skill/Skill";
|
||||||
import { PetHandler } from "./PetHandler";
|
import { PetHandler } from "./PetHandler";
|
||||||
@ -13,6 +13,7 @@ import { SKillEffectData, SkillInfoMsg } from "message/SkillInfo";
|
|||||||
import { PetInfo } from "message/PetInfo";
|
import { PetInfo } from "message/PetInfo";
|
||||||
import arrUtil from "../../../utils/array.util";
|
import arrUtil from "../../../utils/array.util";
|
||||||
import { debugRoom } from "../../../common/Debug";
|
import { debugRoom } from "../../../common/Debug";
|
||||||
|
import { RemovePetMsg } from "message/RemovePetMsg";
|
||||||
|
|
||||||
|
|
||||||
export class BattleHandler {
|
export class BattleHandler {
|
||||||
@ -30,6 +31,8 @@ export class BattleHandler {
|
|||||||
private _cacheSkills: SkillTarget[] = [];
|
private _cacheSkills: SkillTarget[] = [];
|
||||||
private _cachePets: PetHandler[] = [];
|
private _cachePets: PetHandler[] = [];
|
||||||
|
|
||||||
|
private _cachePlayerMsgs: PlayerRemoveMsg[] = [];
|
||||||
|
|
||||||
private _lastlinkph: PlayerHandler;
|
private _lastlinkph: PlayerHandler;
|
||||||
|
|
||||||
//--------------------对外接口--player相关---(外部调用)----------------------------
|
//--------------------对外接口--player相关---(外部调用)----------------------------
|
||||||
@ -488,6 +491,7 @@ export class BattleHandler {
|
|||||||
this._sktime = 0;
|
this._sktime = 0;
|
||||||
this._cacheSkills.length = 0;
|
this._cacheSkills.length = 0;
|
||||||
this._cachePets.length = 0;
|
this._cachePets.length = 0;
|
||||||
|
this._cachePlayerMsgs.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._flowcount++;
|
this._flowcount++;
|
||||||
@ -505,23 +509,18 @@ export class BattleHandler {
|
|||||||
debugRoom(`[endFlow]${step}|${res}`);
|
debugRoom(`[endFlow]${step}|${res}`);
|
||||||
|
|
||||||
if(res == 0){
|
if(res == 0){
|
||||||
if(this._cacheSkills.length > 0){
|
this.handleCacheSkills();
|
||||||
this.onSkillResultNotify(this._cacheSkills);
|
|
||||||
this._cacheSkills.length = 0;
|
|
||||||
}
|
|
||||||
let nt = this._sktime * 1000;
|
let nt = this._sktime * 1000;
|
||||||
if(this._cachePets.length > 0){
|
if(this._cachePets.length > 0 || this._cachePlayerMsgs.length > 0){
|
||||||
if(nt > 0){
|
if(nt > 0){
|
||||||
nt += 100; // 延时100ms处理随从
|
nt += 100; // 延时100ms处理随从
|
||||||
this._room.clock.setTimeout(()=>{
|
this._room.clock.setTimeout(()=>{
|
||||||
this.onUpdatePets(this._cachePets, null);
|
this.handleCachePets();
|
||||||
this.checkPets(this._cachePets);
|
this.handleCachePlayers();
|
||||||
this._cachePets.length = 0;
|
|
||||||
}, nt);
|
}, nt);
|
||||||
}else{
|
}else{
|
||||||
this.onUpdatePets(this._cachePets, null);
|
this.handleCachePets();
|
||||||
this.checkPets(this._cachePets);
|
this.handleCachePlayers();
|
||||||
this._cachePets.length = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._flowcount = res;
|
this._flowcount = res;
|
||||||
@ -533,6 +532,28 @@ export class BattleHandler {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public handleCacheSkills(){
|
||||||
|
if(this._cacheSkills.length > 0){
|
||||||
|
this.onSkillResultNotify(this._cacheSkills);
|
||||||
|
this._cacheSkills.length = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public handleCachePets(){
|
||||||
|
if(this._cachePets.length > 0){
|
||||||
|
this.onUpdatePets(this._cachePets, null);
|
||||||
|
this.checkPets(this._cachePets);
|
||||||
|
this._cachePets.length = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public handleCachePlayers(){
|
||||||
|
if(this._cachePlayerMsgs.length > 0){
|
||||||
|
this.onPlayerDiedNotify(this._cachePlayerMsgs);
|
||||||
|
this._cachePlayerMsgs.length = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public onPlayerCardChanged(player: PlayerHandler){
|
public onPlayerCardChanged(player: PlayerHandler){
|
||||||
this._players.forEach((item: PlayerHandler) => {
|
this._players.forEach((item: PlayerHandler) => {
|
||||||
item.onCardChanged(player);
|
item.onCardChanged(player);
|
||||||
@ -785,7 +806,18 @@ export class BattleHandler {
|
|||||||
*/
|
*/
|
||||||
public onPlayerDead(aplayer: Player){
|
public onPlayerDead(aplayer: Player){
|
||||||
let ph = this.getPlayer(aplayer);
|
let ph = this.getPlayer(aplayer);
|
||||||
ph && ph.die();
|
if(!ph){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(this.isFlowing()){
|
||||||
|
let obj = this._cachePlayerMsgs.find((v: PlayerRemoveMsg)=>{
|
||||||
|
return ph.getId() == v.id;
|
||||||
|
});
|
||||||
|
if(!obj){
|
||||||
|
this._cachePlayerMsgs.push(ph.exportRemoveMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ph.die(this.isFlowing());
|
||||||
this._players.forEach((item: PlayerHandler) => {
|
this._players.forEach((item: PlayerHandler) => {
|
||||||
(item != ph) && item.onPlayerDie(ph);
|
(item != ph) && item.onPlayerDie(ph);
|
||||||
});
|
});
|
||||||
@ -816,6 +848,15 @@ export class BattleHandler {
|
|||||||
|
|
||||||
|
|
||||||
// --------------------调用外部接口函数--------------------------
|
// --------------------调用外部接口函数--------------------------
|
||||||
|
public onPlayerDiedNotify(players: PlayerRemoveMsg[]){
|
||||||
|
players && players.forEach((item: PlayerRemoveMsg)=>{
|
||||||
|
item.pets.forEach((pet: RemovePetMsg) =>{
|
||||||
|
this._room.bRemovePet(pet);
|
||||||
|
});
|
||||||
|
this._room.bPlayerDead({id: item.id});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
public onAddPetNotify(apet: PetHandler){
|
public onAddPetNotify(apet: PetHandler){
|
||||||
return this._room.bAddPet(apet.exportInfoMsg());
|
return this._room.bAddPet(apet.exportInfoMsg());
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ import { Pet } from "rooms/schema/Pet";
|
|||||||
import { CondDecideType, CondType, EffectCardType, GameUnitType, SkillEffectType, SkillType, SkillUserType, TriggerType } from "../skill/SkillConst";
|
import { CondDecideType, CondType, EffectCardType, GameUnitType, SkillEffectType, SkillType, SkillUserType, TriggerType } from "../skill/SkillConst";
|
||||||
import { UnitCfg } from "cfg/parsers/UnitCfg";
|
import { UnitCfg } from "cfg/parsers/UnitCfg";
|
||||||
import { Skill } from "../skill/Skill";
|
import { Skill } from "../skill/Skill";
|
||||||
import { SkillParam, SkillTarget } from "../skill/SkillParam";
|
import { PlayerRemoveMsg, SkillParam, SkillTarget } from "../skill/SkillParam";
|
||||||
import SkillMan from "../skill/SkillMan";
|
import SkillMan from "../skill/SkillMan";
|
||||||
import { Card } from "rooms/schema/Card";
|
import { Card } from "rooms/schema/Card";
|
||||||
import arrUtil from "utils/array.util";
|
import arrUtil from "utils/array.util";
|
||||||
@ -31,10 +31,12 @@ export class PlayerHandler {
|
|||||||
public _cardstate: CondType = CondType.NO_COND;
|
public _cardstate: CondType = CondType.NO_COND;
|
||||||
public _cardlinkfrom: PlayerHandler = null;
|
public _cardlinkfrom: PlayerHandler = null;
|
||||||
|
|
||||||
|
public _isdied: boolean = false;
|
||||||
|
|
||||||
_totalcc: number = 0;
|
_totalcc: number = 0;
|
||||||
|
|
||||||
private _totalem: number = 0;
|
private _totalem: number = 0;
|
||||||
|
|
||||||
public init(aplayer: Player, owner: BattleHandler){
|
public init(aplayer: Player, owner: BattleHandler){
|
||||||
this._owner = owner;
|
this._owner = owner;
|
||||||
this._player = aplayer;
|
this._player = aplayer;
|
||||||
@ -42,9 +44,9 @@ export class PlayerHandler {
|
|||||||
this.updateHero(true);
|
this.updateHero(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
public clear(){
|
public clear(cachedel: boolean = false){
|
||||||
this._pets.forEach((item: PetHandler) =>{
|
this._pets.forEach((item: PetHandler) =>{
|
||||||
this.delPet(item, true);
|
this.delPet(item, true, cachedel);
|
||||||
});
|
});
|
||||||
this._self = null;
|
this._self = null;
|
||||||
this._pets.length = 0;
|
this._pets.length = 0;
|
||||||
@ -104,7 +106,7 @@ export class PlayerHandler {
|
|||||||
return pr;
|
return pr;
|
||||||
};
|
};
|
||||||
|
|
||||||
public delPet(pet: PetHandler, isbatchdel: boolean = false){
|
public delPet(pet: PetHandler, isbatchdel: boolean = false, cachedel: boolean = false){
|
||||||
if(!pet){
|
if(!pet){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,7 +118,7 @@ export class PlayerHandler {
|
|||||||
(idx >= 0) && this._pets.splice(idx, 1);
|
(idx >= 0) && this._pets.splice(idx, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._owner.onDelPetNotify(pet);
|
!cachedel && this._owner.onDelPetNotify(pet);
|
||||||
};
|
};
|
||||||
|
|
||||||
public getPet(pet: Pet): PetHandler{
|
public getPet(pet: Pet): PetHandler{
|
||||||
@ -378,8 +380,9 @@ export class PlayerHandler {
|
|||||||
this._friend = aplayer;
|
this._friend = aplayer;
|
||||||
};
|
};
|
||||||
|
|
||||||
public die(){
|
public die(needcache: boolean){
|
||||||
this.clear();
|
this._isdied = true;
|
||||||
|
this.clear(needcache);
|
||||||
//todo:
|
//todo:
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -855,5 +858,9 @@ export class PlayerHandler {
|
|||||||
|
|
||||||
delBuff(buffid: number, buffcount: number, from: PetHandler): number{
|
delBuff(buffid: number, buffcount: number, from: PetHandler): number{
|
||||||
return this._self? this._self.delBuff(buffid, buffcount, from): -1;
|
return this._self? this._self.delBuff(buffid, buffcount, from): -1;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
public exportRemoveMsg(): PlayerRemoveMsg{
|
||||||
|
return new PlayerRemoveMsg(this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import { Skill } from "./Skill";
|
|||||||
import { GameUnitType, SkillEffectType, SkillUserType } from "./SkillConst";
|
import { GameUnitType, SkillEffectType, SkillUserType } from "./SkillConst";
|
||||||
import { SKillEffectData, SkillInfoData, SkillInfoMsg } from "../../../message/SkillInfo";
|
import { SKillEffectData, SkillInfoData, SkillInfoMsg } from "../../../message/SkillInfo";
|
||||||
import { PetInfo } from "message/PetInfo";
|
import { PetInfo } from "message/PetInfo";
|
||||||
|
import { RemovePetMsg } from "message/RemovePetMsg";
|
||||||
|
|
||||||
export class SkillParam{
|
export class SkillParam{
|
||||||
cardid: number;
|
cardid: number;
|
||||||
@ -401,4 +402,16 @@ export class PetUpdateProcess{
|
|||||||
this.from = from;
|
this.from = from;
|
||||||
this.info = pet.exportInfo();
|
this.info = pet.exportInfo();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export class PlayerRemoveMsg{
|
||||||
|
id: string;
|
||||||
|
pets: RemovePetMsg[];
|
||||||
|
constructor(player: PlayerHandler){
|
||||||
|
this.id = player.getId();
|
||||||
|
this.pets = [];
|
||||||
|
player._pets.forEach((item: PetHandler) =>{
|
||||||
|
this.pets.push(item.exportRemoveMsg());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user