dd
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.1.50",
|
|
||||||
"importer": "prefab",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d0be7733-e160-4cff-8733-8fd75f10813d",
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {
|
|
||||||
"syncNodeName": "hero_box"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2569,10 +2569,7 @@
|
|||||||
"b": 255,
|
"b": 255,
|
||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"_spriteFrame": {
|
"_spriteFrame": null,
|
||||||
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@fa9fd",
|
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
|
||||||
},
|
|
||||||
"_type": 1,
|
"_type": 1,
|
||||||
"_fillType": 0,
|
"_fillType": 0,
|
||||||
"_sizeMode": 0,
|
"_sizeMode": 0,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.1.50",
|
|
||||||
"importer": "prefab",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "e9d4aea4-d78a-40ff-9300-ad76fec45cfe",
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {
|
|
||||||
"syncNodeName": "item_box"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.1.50",
|
|
||||||
"importer": "prefab",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "64e975de-f7e2-4499-9dfc-b12f58bf5e33",
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {
|
|
||||||
"syncNodeName": "mon_box"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,84 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2021-11-18 17:47:56
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-04 15:43:04
|
|
||||||
*/
|
|
||||||
import { instantiate, Node, Prefab, tween, Vec3,Label,resources ,SpriteAtlas,Sprite,v3} from "cc";
|
|
||||||
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { UIID } from "../common/config/GameUIConfig";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import { RoleModelComp } from "./RoleModelComp";
|
|
||||||
import { RoleSpine } from "./RoleSpine";
|
|
||||||
import { RoleViewComp } from "./RoleViewComp";
|
|
||||||
import { BoxSet } from "../common/config/BoxSet";
|
|
||||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
|
||||||
import { Talents } from "../common/config/TalentSet";
|
|
||||||
/** 角色实体 */
|
|
||||||
@ecs.register(`Role`)
|
|
||||||
export class Role extends ecs.Entity {
|
|
||||||
// 数据层
|
|
||||||
RoleModel!: RoleModelComp;
|
|
||||||
HeroModel!: HeroModelComp;
|
|
||||||
// 视图层
|
|
||||||
RoleView!: RoleViewComp;
|
|
||||||
|
|
||||||
protected init() {
|
|
||||||
this.addComponents<ecs.Comp>(
|
|
||||||
RoleModelComp,HeroModelComp);
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy(): void {
|
|
||||||
this.remove(RoleViewComp);
|
|
||||||
super.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 加载角色 */
|
|
||||||
load(pos: Vec3 = Vec3.ZERO,uuid:number=101) {
|
|
||||||
// var path = "game/monster/"+prefab_path;
|
|
||||||
var path = "game/heros/role";
|
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
var node = instantiate(prefab);
|
|
||||||
var scene = smc.map.MapView.scene;
|
|
||||||
node.parent = scene.entityLayer!.node!;
|
|
||||||
node.setScale(node.scale.x, node.scale.y, node.scale.z);
|
|
||||||
node.setPosition(pos)
|
|
||||||
this.hero_init(uuid,node)
|
|
||||||
|
|
||||||
}
|
|
||||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
|
||||||
var rv = node.getComponent(RoleViewComp)!;
|
|
||||||
let role=smc.vmdata.role;
|
|
||||||
let role_talent= smc.vmdata.talent
|
|
||||||
let talents=Talents;
|
|
||||||
rv.hero_uuid=uuid;
|
|
||||||
rv.speed =rv.ospeed = role.speed;
|
|
||||||
rv.atk_dis = role.atk_dis;
|
|
||||||
rv.hero_name= "role";
|
|
||||||
rv.level = role.lv;
|
|
||||||
rv.power = role.power;
|
|
||||||
rv.skill1 = role.skill1;
|
|
||||||
rv.skill2 = role.skill2;
|
|
||||||
rv.skill3 = role.skill3;
|
|
||||||
rv.skill4 = role.skill4;
|
|
||||||
rv.skill5 = role.skill5;
|
|
||||||
rv.skill = role.skill;
|
|
||||||
rv.skill1.cd=rv.skill1.cd_max=rv.skill1.cd_max*(1-talents[1004].bonus*role_talent[1004].lv)
|
|
||||||
rv.skill2.cd=rv.skill2.cd_max=rv.skill1.cd_max*(1-talents[1004].bonus*role_talent[1004].lv)
|
|
||||||
rv.skill3.cd=rv.skill3.cd_max=rv.skill1.cd_max*(1-talents[1004].bonus*role_talent[1004].lv)
|
|
||||||
rv.skill4.cd=rv.skill4.cd_max=rv.skill1.cd_max*(1-talents[1004].bonus*role_talent[1004].lv)
|
|
||||||
rv.skill5.cd=rv.skill5.cd_max=rv.skill1.cd_max*(1-talents[1004].bonus*role_talent[1004].lv)
|
|
||||||
rv.hp= rv.hp_max = role.hp*(1+talents[1001].bonus*role_talent[1001].lv);
|
|
||||||
rv.atk = role.atk*(1+talents[1002].bonus*role_talent[1002].lv);
|
|
||||||
rv.atk_cd = role.atk_cd*(1-talents[1003].bonus*role_talent[1003].lv);
|
|
||||||
rv.st_boncus=1+talents[1005].bonus*role_talent[1005].lv;
|
|
||||||
rv.s_boncus=1+talents[1006].bonus*role_talent[1006].lv;
|
|
||||||
rv.box_group = BoxSet.HERO;
|
|
||||||
this.add(rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "9457fea4-0213-4426-a3ed-5234cc7985dc",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2022-08-04 15:08:35
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-04 15:26:26
|
|
||||||
*/
|
|
||||||
import { Color, Component, EventTouch, sp, Vec3, _decorator ,Animation, AnimationClip, AnimationState} from "cc";
|
|
||||||
import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import RoleSpineAnimator from "./RoleSpineAnimator";
|
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RPG SPINE角色模型
|
|
||||||
*/
|
|
||||||
@ccclass('RoleSpine')
|
|
||||||
export class RoleSpine extends Component {
|
|
||||||
@property({ type: Animation, tooltip: '动画控制器' })
|
|
||||||
animator: Animation = null!;
|
|
||||||
atk_clip: AnimationClip = null!;
|
|
||||||
idle_clip: AnimationClip = null!;
|
|
||||||
move_clip: AnimationClip = null!;
|
|
||||||
dead_clip: AnimationClip = null!;
|
|
||||||
private spine!: sp.Skeleton;
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
// 角色控制组件
|
|
||||||
|
|
||||||
this.initAnimator();
|
|
||||||
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
|
|
||||||
this.atk_clip = this.animator.clips[1];
|
|
||||||
this.idle_clip = this.animator.clips[0];
|
|
||||||
this.move_clip = this.animator.clips[2];
|
|
||||||
this.dead_clip = this.animator.clips[3];
|
|
||||||
let animation = this.animator.getComponent(Animation);
|
|
||||||
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 初始化动画 */
|
|
||||||
protected initAnimator() {
|
|
||||||
this.animator=this.node.getChildByName("hero").getComponent(Animation);
|
|
||||||
// console.log("role view comp init",this.animator);
|
|
||||||
|
|
||||||
}
|
|
||||||
onAnimationEvent(type: Animation.EventType, state: AnimationState){
|
|
||||||
// console.log("onAnimationEvent",type,state);
|
|
||||||
if(type==Animation.EventType.FINISHED){
|
|
||||||
if(state.name==this.atk_clip.name){
|
|
||||||
this.idle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
atk() {
|
|
||||||
if(!this.animator.getState(this.atk_clip.name).isPlaying){
|
|
||||||
this.animator.play(this.atk_clip.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
magic() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
checkTouch(event: EventTouch): boolean {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
onDestroy() {
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
walk() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
idle() {
|
|
||||||
if(!this.animator.getState(this.idle_clip.name).isPlaying){
|
|
||||||
this.animator.play(this.idle_clip.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d1d8d0c9-9cff-4d85-a359-628a29fd5191",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
import { _decorator,Sprite ,Color} from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
||||||
import { RoleViewComp } from "./RoleViewComp";
|
|
||||||
import { RoleSpine } from "./RoleSpine";
|
|
||||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import { BoxSet } from "../common/config/BoxSet";
|
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 视图层对象 */
|
|
||||||
@ccclass('RoleBuffComp')
|
|
||||||
@ecs.register('RoleBuff', false)
|
|
||||||
export class RoleBuffComp extends CCComp {
|
|
||||||
// as: RoleSpine = null!;
|
|
||||||
mv!: RoleViewComp
|
|
||||||
|
|
||||||
timer:Timer = new Timer(0.1);
|
|
||||||
buffs:any=[];
|
|
||||||
group:number=BoxSet.HERO;
|
|
||||||
/**
|
|
||||||
skill_uuid:number=0;
|
|
||||||
atk:number=0;
|
|
||||||
hp:number=0;
|
|
||||||
shield:number=0;
|
|
||||||
time:number=0;
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
// this.as = this.node.getComponent(RoleSpine);
|
|
||||||
this.mv= this.getComponent(RoleViewComp);
|
|
||||||
} /** 视图层逻辑代码分离演示 */
|
|
||||||
start () {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
add_buff(uuid:number=0,args:any[]){
|
|
||||||
|
|
||||||
let new_buff={
|
|
||||||
skill_uuid:uuid,
|
|
||||||
skill_name:smc.skills[uuid].name,
|
|
||||||
atk:smc.skills[uuid].atk,
|
|
||||||
hp:smc.skills[uuid].hp,
|
|
||||||
shield:smc.skills[uuid].shield,
|
|
||||||
time:smc.skills[uuid].bsd,
|
|
||||||
bcd:smc.skills[uuid].bcd,
|
|
||||||
sk_uuid:smc.skills[uuid].uuid,
|
|
||||||
args:args
|
|
||||||
}
|
|
||||||
this.buff_add(new_buff);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
update(dt: number){
|
|
||||||
if (this.timer.update(dt)) {
|
|
||||||
this.buff_update()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reset() {
|
|
||||||
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
buff_add(buff:any){
|
|
||||||
if(!this.node.isValid){ return }
|
|
||||||
let i = 0
|
|
||||||
if(this.buffs.length >=0){
|
|
||||||
this.buffs.forEach((b:any,index:number)=>{
|
|
||||||
if(b.skill_uuid==buff.skill_uuid){
|
|
||||||
b.time=buff.time;
|
|
||||||
if(buff.atk>0){
|
|
||||||
this.node.getChildByName("avatar").setScale(1.2,1.2)
|
|
||||||
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
|
|
||||||
this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
|
|
||||||
}
|
|
||||||
if(buff.hp>0){
|
|
||||||
this.mv.hp+=(buff.hp+buff.args.hp);
|
|
||||||
this.mv.add_hp(buff.hp+buff.args.hp);
|
|
||||||
// this.mv.hp_max+=(buff.hp-b.hp);
|
|
||||||
}
|
|
||||||
if(buff.shield>0){
|
|
||||||
this.mv.shield=(buff.shield+buff.args.shield);
|
|
||||||
// this.mv.shield_max=(buff.shield+buff.args.shield);
|
|
||||||
}
|
|
||||||
|
|
||||||
i=index
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (i==0||this.buffs.length==0) {
|
|
||||||
this.buffs.push(buff);
|
|
||||||
if(buff.atk>0){
|
|
||||||
this.mv.atk+=(buff.atk+buff.args.atk);
|
|
||||||
this.node.getChildByName("avatar").setScale(1.2,1.2)
|
|
||||||
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
|
|
||||||
}
|
|
||||||
if(buff.hp>0){
|
|
||||||
this.mv.hp+=(buff.hp+buff.args.hp);
|
|
||||||
this.mv.add_hp(buff.hp+buff.args.hp);
|
|
||||||
// this.mv.hp_max+=buff.hp;
|
|
||||||
}
|
|
||||||
if(buff.shield>0){
|
|
||||||
this.mv.shield=(buff.shield+buff.args.shield);
|
|
||||||
// this.mv.shield_max=(buff.shield+buff.args.shield);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buff_remove(index:number){
|
|
||||||
if(this.buffs[index].atk>0){
|
|
||||||
this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk);
|
|
||||||
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#FFFFFF");
|
|
||||||
this.node.getChildByName("avatar").setScale(1,1)
|
|
||||||
}
|
|
||||||
if(this.buffs[index].shield>0){
|
|
||||||
this.mv.shield=0
|
|
||||||
// this.mv.shield_max-=(this.buffs[index].shield+this.buffs[index].args.shield);
|
|
||||||
}
|
|
||||||
// if(this.buffs[index].hp>0){
|
|
||||||
// this.mv.hp_max-=this.buffs[index].hp;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
buff_update(){
|
|
||||||
this.buffs.forEach((buff:any,index:number)=>{
|
|
||||||
buff.time -= 0.1;
|
|
||||||
if(buff.time <= 0){
|
|
||||||
this.buff_remove(index);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.buffs = this.buffs.filter((buff:any) => buff.time > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "e5f012c8-982e-4eef-8f95-edc5d4bcef52",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2021-11-18 15:56:01
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-17 13:43:25
|
|
||||||
*/
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色属性数据
|
|
||||||
*/
|
|
||||||
@ecs.register('RoleModel')
|
|
||||||
export class RoleModelComp extends ecs.Comp {
|
|
||||||
/** 角色编号 */
|
|
||||||
id: number = -1;
|
|
||||||
|
|
||||||
/** 角色名 */
|
|
||||||
name: string = "Role";
|
|
||||||
|
|
||||||
/** 动画名资源 */
|
|
||||||
anim: string = "Role";
|
|
||||||
|
|
||||||
reset() {
|
|
||||||
this.id = -1;
|
|
||||||
this.name = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "1ae88b75-8890-46c0-a795-faf44c20ff92",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
import { _decorator,Contact2DType,Collider2D ,IPhysics2DContact,v3, v2,Vec3} from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
||||||
import { BoxSet } from "../common/config/BoxSet";
|
|
||||||
import { RoleViewComp } from "./RoleViewComp";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 视图层对象 */
|
|
||||||
@ccclass('RoleRangComp')
|
|
||||||
@ecs.register('RoleRang', false)
|
|
||||||
export class RoleRangComp extends CCComp {
|
|
||||||
Hero_node: any=null!;
|
|
||||||
RoleViewComp:RoleViewComp = null!;
|
|
||||||
box_group:number = BoxSet.HERO;
|
|
||||||
box_tag:number = BoxSet.ATK_RANGE;
|
|
||||||
offset_x:number = 0;
|
|
||||||
atk_range:number = 150;
|
|
||||||
/** 视图层逻辑代码分离演示 */
|
|
||||||
start() {
|
|
||||||
let collider = this.getComponent(Collider2D);
|
|
||||||
collider.group = this.box_group;
|
|
||||||
collider.tag = this.box_tag;
|
|
||||||
this.Hero_node = this.node.parent;
|
|
||||||
this.RoleViewComp=this.Hero_node.getComponent(RoleViewComp);
|
|
||||||
// console.log("range box",this.RoleViewComp);
|
|
||||||
if (collider) {
|
|
||||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
|
||||||
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
|
||||||
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
|
||||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
|
|
||||||
// if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
|
||||||
// console.log(this.node.name+"onBeginContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
|
|
||||||
// this.RoleViewComp.is_atking = true;
|
|
||||||
// if(Math.abs(otherCollider.node.position.x-selfCollider.node.position.x) < 120){
|
|
||||||
// this.RoleViewComp.stop_cd = 0.1
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
|
|
||||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0 ){
|
|
||||||
// console.log(this.node.name+"onEndContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
|
|
||||||
this.RoleViewComp.is_atking = false;
|
|
||||||
this.RoleViewComp.enemy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
|
||||||
let scene =smc.map.MapView.scene.mapLayer!.node!
|
|
||||||
let other_pos = otherCollider.node.getWorldPosition() ;
|
|
||||||
let self_pos = this.node.getWorldPosition();
|
|
||||||
// console.log("onPreSolve:",self_pos,other_pos);
|
|
||||||
if(this.RoleViewComp.enemy==null){
|
|
||||||
this.RoleViewComp.enemy = otherCollider.node;
|
|
||||||
}else{
|
|
||||||
if(this.RoleViewComp.enemy.isValid==false){
|
|
||||||
this.RoleViewComp.enemy = otherCollider.node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Math.abs(other_pos.x-self_pos.x) < this.atk_range){
|
|
||||||
this.RoleViewComp.is_atking = true;
|
|
||||||
this.RoleViewComp.stop_cd = 0.1
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
||||||
reset() {
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d67dc462-2b08-4fe2-922c-502509f68ff4",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2022-08-04 15:08:35
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-04 15:26:26
|
|
||||||
*/
|
|
||||||
import { Color, Component, EventTouch, sp, Vec3, _decorator ,Animation, AnimationClip, AnimationState} from "cc";
|
|
||||||
import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import RoleSpineAnimator from "./RoleSpineAnimator";
|
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RPG SPINE角色模型
|
|
||||||
*/
|
|
||||||
@ccclass('RoleSpine')
|
|
||||||
export class RoleSpine extends Component {
|
|
||||||
private loop: boolean = true;
|
|
||||||
private spine!: sp.Skeleton;
|
|
||||||
private default:string = "idle";
|
|
||||||
private atk_name: string = "atk";
|
|
||||||
private move_name: string = "move";
|
|
||||||
private max_name: string = "max";
|
|
||||||
private idel_name: string = "move";
|
|
||||||
start() {
|
|
||||||
this.spine.setAnimation(0, this.default, true);
|
|
||||||
}
|
|
||||||
mixTime:number= 0.2;
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
this.spine = this.node.getChildByName("anm")!.getComponent(sp.Skeleton);
|
|
||||||
this.spine.setEndListener(trackEntry => {
|
|
||||||
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
|
|
||||||
// console.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
|
|
||||||
if (animationName == "atk" || animationName== "max" ) {
|
|
||||||
this.spine.setAnimation(0, this.default, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
protected play(animName: string, loop: boolean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
atk(){
|
|
||||||
this.spine.setAnimation(0, this.atk_name, false);
|
|
||||||
}
|
|
||||||
idle(){
|
|
||||||
this.default = this.idel_name;
|
|
||||||
this.spine.setAnimation(0, this.idel_name, true);
|
|
||||||
}
|
|
||||||
move(){
|
|
||||||
this.default = this.move_name;
|
|
||||||
this.spine.setAnimation(0, this.move_name, true);
|
|
||||||
}
|
|
||||||
max(){
|
|
||||||
this.spine.setAnimation(0, this.max_name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "de8f3803-ed59-466e-b93b-f1e3e587113d",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2022-08-04 15:08:35
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-04 15:26:38
|
|
||||||
*/
|
|
||||||
import { sp, _decorator ,Component} from "cc";
|
|
||||||
|
|
||||||
const { ccclass, property, requireComponent, disallowMultiple } = _decorator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spine状态机组件(主状态机),trackIndex为0
|
|
||||||
*/
|
|
||||||
@ccclass
|
|
||||||
@disallowMultiple
|
|
||||||
@requireComponent(sp.Skeleton)
|
|
||||||
export default class RoleSpineAnimator extends Component {
|
|
||||||
private animName: string = "move";
|
|
||||||
private loop: boolean = true;
|
|
||||||
private spine!: sp.Skeleton;
|
|
||||||
start() {
|
|
||||||
this.spine = this.getComponent(sp.Skeleton)!;
|
|
||||||
// console.log("MonsterSpineAnimator start");
|
|
||||||
this.playAnimation(this.animName, this.loop);
|
|
||||||
}
|
|
||||||
mixTime:number= 0.2;
|
|
||||||
|
|
||||||
protected onLoad(): void {
|
|
||||||
this.spine = this.getComponent(sp.Skeleton)!;
|
|
||||||
// this.spine?.setMix('atk', 'Idle', this.mixTime);
|
|
||||||
// this.spine?.setMix('Idle','atk', this.mixTime);
|
|
||||||
this.spine.setEndListener(trackEntry => {
|
|
||||||
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
|
|
||||||
// console.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
|
|
||||||
if (animationName == "atk2" ||animationName == "magic"||animationName=="max") {
|
|
||||||
this.spine.setAnimation(0, "move", true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
lateUpdate(dt: number) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
play(animName: string, loop: boolean) {
|
|
||||||
if (animName) {
|
|
||||||
this.animName = animName;
|
|
||||||
this.loop = loop;
|
|
||||||
this.spine.setAnimation(0, this.animName, this.loop);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 播放动画
|
|
||||||
* @override
|
|
||||||
* @param animName 动画名
|
|
||||||
* @param loop 是否循环播放
|
|
||||||
*/
|
|
||||||
protected playAnimation(animName: string, loop: boolean) {
|
|
||||||
// console.log("MonsterSpineAnimator playAnimation");
|
|
||||||
if (animName) {
|
|
||||||
// console.log("MonsterSpineAnimator playAnimation animName", animName);
|
|
||||||
this.animName = animName;
|
|
||||||
this.loop = loop;
|
|
||||||
this.spine.setAnimation(0, this.animName, this.loop);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "7238526c-ee07-4d38-be30-ec2a4a5359c4",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,551 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2021-11-18 17:42:59
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-17 12:36:18
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Vec3, v3,_decorator ,Collider2D,Contact2DType,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite,Animation, director, Vertex} from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
||||||
import { RoleSpine } from "./RoleSpine";
|
|
||||||
import {BoxSet, GameSet} from "../common/config/BoxSet"
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import { SkillCom } from "../skills/SkillCom";
|
|
||||||
import { Skill } from "../skills/Skill";
|
|
||||||
import { SkillSet } from "../common/config/SkillSet";
|
|
||||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
|
||||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
||||||
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
|
||||||
import { RoleRangComp } from "./RoleRangComp";
|
|
||||||
import { Tooltip } from "../skills/Tooltip";
|
|
||||||
import { MonViewComp } from "../mon/MonViewComp";
|
|
||||||
import { MonModelComp } from "../mon/MonModelComp";
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 角色显示组件 */
|
|
||||||
@ccclass('RoleViewComp') // 定义为 Cocos Creator 组件
|
|
||||||
@ecs.register('RoleView', false) // 定义为 ECS 组件
|
|
||||||
export class RoleViewComp extends CCComp {
|
|
||||||
@property(Material)
|
|
||||||
hitFlashMaterial: Material;
|
|
||||||
orginalFlashMaterial: Material;
|
|
||||||
@property(Material)
|
|
||||||
atkMaterial: Material;
|
|
||||||
sprite: Sprite;
|
|
||||||
/** 角色动画 */
|
|
||||||
|
|
||||||
|
|
||||||
as:RoleSpine =null!;
|
|
||||||
is_role:boolean = false;
|
|
||||||
enemy_pos:Vec3=null!;
|
|
||||||
enemy:any=null!;
|
|
||||||
atk_enemy:any=null!;
|
|
||||||
neraster_enemy:any=null!;
|
|
||||||
/** 角色动画 */
|
|
||||||
hero_uuid:number = 1001;
|
|
||||||
hero_name : string = "role";
|
|
||||||
level:number =1;
|
|
||||||
scale: number = 1; /** 角色阵营 1:hero -1 :monster */
|
|
||||||
state: number = 1; /** 状态 1:move ,2: act 3: stop */
|
|
||||||
|
|
||||||
hp: number = 100; /** 血量 */
|
|
||||||
hp_max: number = 100; /** 最大血量 */
|
|
||||||
hp_speed: number = 0; //每秒回复量
|
|
||||||
|
|
||||||
power: number = 0; /**能量**/
|
|
||||||
power_max: number = 1200; /** 能量最大值 */
|
|
||||||
power_speed: number = 1; //能量回复速度每0.1秒回复量
|
|
||||||
skill:8001;
|
|
||||||
skills:any=[]
|
|
||||||
skill1:any=[]
|
|
||||||
skill2:any=[]
|
|
||||||
skill3:any=[]
|
|
||||||
skill4:any=[]
|
|
||||||
skill5:any=[]
|
|
||||||
st_boncus: number = 1; //技能持续时间加成
|
|
||||||
s_boncus: number = 1; //技能效果加成
|
|
||||||
buff_atks:any = [];
|
|
||||||
buff_atk:number = 0;
|
|
||||||
|
|
||||||
atk: number = 10; /**攻击力 */
|
|
||||||
mission_atk:number = 0;//局内攻击
|
|
||||||
// atk_speed: number = 1;
|
|
||||||
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
|
|
||||||
atk_dis: number = 800;
|
|
||||||
atk_time: number = 0; /** 冷却时间 */
|
|
||||||
|
|
||||||
speed: number = 100; /** 角色移动速度 */
|
|
||||||
ospeed: number = 100; /** 角色初始速度 */
|
|
||||||
Tpos: Vec3 = v3(0,-60,0);
|
|
||||||
stop_cd: number = 0.5; /*停止倒计时*/
|
|
||||||
//暴击
|
|
||||||
crit: number = 1.5;
|
|
||||||
crit_rate: number = 0;
|
|
||||||
//免伤
|
|
||||||
dodge_rate: number = 0;
|
|
||||||
shield:number = 0; //护盾量
|
|
||||||
shield_max:number = 200;
|
|
||||||
shield_time:number = 0; //护盾持续时间
|
|
||||||
|
|
||||||
box_group:number = BoxSet.HERO;
|
|
||||||
atk_range:number = 150;
|
|
||||||
private timer:Timer = new Timer(0.1); //计时器
|
|
||||||
is_dead:boolean = false; //是否摧毁
|
|
||||||
is_stop:boolean = false;
|
|
||||||
is_atking:boolean = false;
|
|
||||||
is_moving:boolean = false;
|
|
||||||
type:number = 0;
|
|
||||||
onLoad() {
|
|
||||||
// this.BoxRang = this.node.getChildByName("range_box");
|
|
||||||
this.as = this.node.getComponent(RoleSpine);
|
|
||||||
|
|
||||||
}
|
|
||||||
start () {
|
|
||||||
// this.sprite = this.node.getChildByName("hero").getComponent(Sprite);
|
|
||||||
this.node.getChildByName("top").setScale(this.scale,1);
|
|
||||||
// this.node.getChildByName("atk").setScale(this.scale,1);
|
|
||||||
// this.node.getChildByName("atk").getComponent(Label).string = this.atk.toString();
|
|
||||||
// this.node.getChildByName("hp_max").setScale(this.scale,1);
|
|
||||||
// this.node.getChildByName("hp_max").getComponent(Label).string=this.hp_max.toString();
|
|
||||||
// this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
|
|
||||||
// 注册单个碰撞体的回调函数
|
|
||||||
let collider = this.getComponent(Collider2D);
|
|
||||||
smc.vmdata.role.atk_time=smc.vmdata.role.atk_cd;
|
|
||||||
collider.group = this.box_group;
|
|
||||||
if (collider) {
|
|
||||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
|
||||||
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
|
||||||
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
|
||||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
|
|
||||||
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
|
|
||||||
if(selfCollider.group != otherCollider.group){
|
|
||||||
let skill = otherCollider.node.getComponent(SkillCom)!;
|
|
||||||
// console.log('onPostSolve',skill);
|
|
||||||
this.in_atked();
|
|
||||||
if(this.hp <= 0 ){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let loss_hp=skill.atk*(100-this.dodge_rate)/100
|
|
||||||
this.hp_change(loss_hp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
|
|
||||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
|
||||||
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
|
||||||
// console.log(selfCollider.node.position.y+":role:hero:"+otherCollider.node.position.y);
|
|
||||||
if(selfCollider.node.position.y <= otherCollider.node.position.y){
|
|
||||||
if(selfCollider.node.getSiblingIndex() <= otherCollider.node.getSiblingIndex()){
|
|
||||||
selfCollider.node.setSiblingIndex(200)
|
|
||||||
// selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
|
||||||
// console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
|
||||||
|
|
||||||
}else{
|
|
||||||
selfCollider.node.setSiblingIndex(-1)
|
|
||||||
// console.log("onPreSolve f:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
|
||||||
// if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
|
|
||||||
// let self_pos=selfCollider.node.getPosition();
|
|
||||||
// let other_pos=otherCollider.node.getPosition();
|
|
||||||
// // console.log('monster view group 相同');
|
|
||||||
// switch (selfCollider.group) {
|
|
||||||
// case BoxSet.HERO:
|
|
||||||
// if(self_pos.x < other_pos.x){
|
|
||||||
// this.stop_cd=0.1
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case BoxSet.MONSTER:
|
|
||||||
// if(self_pos.x > other_pos.x){
|
|
||||||
// this.stop_cd=0.1
|
|
||||||
// }
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
update(dt: number){
|
|
||||||
if(!smc.vmdata.mission.play||smc.vmdata.pause){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.timer.update(dt)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
this.in_destroy();
|
|
||||||
this.check_buff_atks(dt)
|
|
||||||
this.in_shield(dt);
|
|
||||||
this.in_stop(dt);
|
|
||||||
smc.vmdata.role.atk_time -= dt;
|
|
||||||
this.in_atk();
|
|
||||||
this.skill_cds(dt);
|
|
||||||
this.move(dt);
|
|
||||||
this.check_enemy_alive()
|
|
||||||
}
|
|
||||||
skill_cds(dt:number){
|
|
||||||
if(this.skill1.alive) this.skill1.cd -= dt;
|
|
||||||
if(this.skill2.alive) this.skill2.cd -= dt;
|
|
||||||
if(this.skill3.alive) this.skill3.cd -= dt;
|
|
||||||
if(this.skill4.alive) this.skill4.cd -= dt;
|
|
||||||
if(this.skill5.alive) this.skill5.cd -= dt;
|
|
||||||
|
|
||||||
if(this.skill1.cd <= 0){
|
|
||||||
this.handle_skill(this.skill1.uuid);
|
|
||||||
this.skill1.cd=this.skill1.cd_max
|
|
||||||
console.log("shoot skill1 uuid :"+this.skill1.uuid);
|
|
||||||
}
|
|
||||||
if(this.skill2.cd <= 0){
|
|
||||||
this.handle_skill(this.skill2.uuid);
|
|
||||||
this.skill2.cd=this.skill2.cd_max
|
|
||||||
console.log("shoot skill2 uuid :"+this.skill2.uuid);
|
|
||||||
}
|
|
||||||
if(this.skill3.cd <= 0){
|
|
||||||
this.handle_skill(this.skill3.uuid);
|
|
||||||
this.skill3.cd=this.skill3.cd_max
|
|
||||||
console.log("shoot skill3 uuid :"+this.skill3.uuid);
|
|
||||||
}
|
|
||||||
if(this.skill4.cd <= 0){
|
|
||||||
this.handle_skill(this.skill4.uuid);
|
|
||||||
this.skill4.cd=this.skill4.cd_max
|
|
||||||
console.log("shoot skill4 uuid :"+this.skill4.uuid);
|
|
||||||
}
|
|
||||||
if(this.skill5.cd <= 0){
|
|
||||||
this.handle_skill(this.skill5.uuid);
|
|
||||||
this.skill5.cd=this.skill5.cd_max
|
|
||||||
console.log("shoot skill5 uuid :"+this.skill5.uuid);
|
|
||||||
}
|
|
||||||
// this.skills.forEach((e:any) => {
|
|
||||||
// if(e.cd > 0&&e.alive){
|
|
||||||
// e.cd -= dt;
|
|
||||||
// if(e.cd <= 0){
|
|
||||||
// this.shoot(e.uuid);
|
|
||||||
// e.cd=smc.skills[e.uuid].cd
|
|
||||||
// console.log("shoot uuid :"+e.uuid);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// console.log(this.skills);
|
|
||||||
}
|
|
||||||
handle_skill(uuid:number){
|
|
||||||
// console.log("handle_skill uuid:"+uuid);
|
|
||||||
this.as.max();
|
|
||||||
this.scheduleOnce(()=>{
|
|
||||||
this.shoot(uuid);
|
|
||||||
},0.3)
|
|
||||||
}
|
|
||||||
// check_enemys(){
|
|
||||||
// let enemys=ecs.query(ecs.allOf(MonViewComp));
|
|
||||||
// if(enemys.length > 0){
|
|
||||||
// let x= 720
|
|
||||||
// for (let i = 0; i < enemys.length; i++) {
|
|
||||||
// let enemy:any = enemys[i];
|
|
||||||
// if(!enemy.MonView) continue
|
|
||||||
// let node=enemy.MonView.node
|
|
||||||
// if(node.isValid){
|
|
||||||
// if(node.position.x < x){
|
|
||||||
// x=node.position.x
|
|
||||||
// this.enemy = node.position;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
// this.enemy = v3(720,this.node.position.y);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
move(dt:number){
|
|
||||||
if(this.stop_cd > 0){
|
|
||||||
this.as.idle()
|
|
||||||
this.is_moving=false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.move_to()
|
|
||||||
let move_x=1
|
|
||||||
let move_y=1
|
|
||||||
if(Math.abs(this.enemy.x - this.node.position.x) < this.atk_dis) move_x = 0
|
|
||||||
if(Math.abs(this.enemy.y - this.node.position.y) < this.atk_dis) move_y = 0
|
|
||||||
if(this.enemy.x < this.node.position.x){
|
|
||||||
this.scale = -1
|
|
||||||
}else{
|
|
||||||
this.scale = 1
|
|
||||||
}
|
|
||||||
this.node.setScale(this.scale,1);
|
|
||||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale*move_x, this.node.position.y+dt*this.speed*move_y, this.node.position.z);
|
|
||||||
}
|
|
||||||
move_to(){
|
|
||||||
if(this.is_moving) return
|
|
||||||
this.is_moving=true
|
|
||||||
this.as.move()
|
|
||||||
}
|
|
||||||
//使用max_skill
|
|
||||||
|
|
||||||
get_enemy_pos(){
|
|
||||||
let pos = v3(0,50)
|
|
||||||
let t_pos:Vec3 = v3(0,0)
|
|
||||||
if(this.enemy){
|
|
||||||
t_pos = v3(this.enemy.x-this.node.position.x,this.enemy.y-this.node.position.y)
|
|
||||||
}else{
|
|
||||||
t_pos=v3(720,0)
|
|
||||||
}
|
|
||||||
return {pos,t_pos}
|
|
||||||
}
|
|
||||||
check_enemy_alive(){
|
|
||||||
let dir = 360
|
|
||||||
this.enemy = v3(720,this.node.position.y)
|
|
||||||
for (let i = 0; i < GameSet.ATK_LINES; i++) {
|
|
||||||
let mon:any = smc.enemy_pos[i];
|
|
||||||
// let x=Math.abs(mon.x-this.node.position.x)
|
|
||||||
// let y = Math.abs(mon.y-this.node.position.y)
|
|
||||||
// let squaredDistance =x*x+y*y
|
|
||||||
// let distance = Math.sqrt(squaredDistance);
|
|
||||||
// if(distance < dir){
|
|
||||||
// dir = distance
|
|
||||||
// this.enemy = mon
|
|
||||||
// }
|
|
||||||
if(mon.x < this.enemy.x){
|
|
||||||
this.enemy = mon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(dir < this.atk_dis){
|
|
||||||
this.is_atking=true
|
|
||||||
}else{
|
|
||||||
this.is_atking=false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in_atk() {
|
|
||||||
if(smc.vmdata.role.atk_time <= 0 ){
|
|
||||||
if(this.is_atking){
|
|
||||||
smc.vmdata.role.atk_time = smc.vmdata.role.atk_cd;
|
|
||||||
console.log("atk_cd:"+smc.vmdata.role.atk_cd);
|
|
||||||
this.as.atk();
|
|
||||||
this.scheduleOnce(()=>{
|
|
||||||
this.shoot(this.skill,0,30);
|
|
||||||
},0.4)
|
|
||||||
}
|
|
||||||
// smc.vmdata.role.atk_time = 0;
|
|
||||||
// this.as.atk();
|
|
||||||
// this.scheduleOnce(()=>{
|
|
||||||
// this.shoot(this.skill,-30,45);
|
|
||||||
// },0.3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shoot(skill_uuid:number,y:number=0,x:number=0){
|
|
||||||
// console.log("mon shoot");
|
|
||||||
let skill = ecs.getEntity<Skill>(Skill);
|
|
||||||
let atk = smc.skills[skill_uuid].atk+this.atk+this.buff_atk+this.mission_atk;
|
|
||||||
let {pos,t_pos}=this.get_enemy_pos()
|
|
||||||
pos.y=pos.y + y
|
|
||||||
pos.x=pos.x + x
|
|
||||||
if(smc.skills[skill_uuid].type==11){
|
|
||||||
pos.y=300
|
|
||||||
t_pos.y=t_pos.y-300
|
|
||||||
}
|
|
||||||
skill.load(pos,this.box_group,this.node,skill_uuid,atk,t_pos,this.atk_dis);
|
|
||||||
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
|
|
||||||
}
|
|
||||||
hp_change(hp: number){
|
|
||||||
if(this.is_dead){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let lhp=this.shield_change(hp);
|
|
||||||
if(lhp == 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.hp += lhp;
|
|
||||||
// this.tooltip(1,hp.toString());
|
|
||||||
if(this.hp > this.hp_max){
|
|
||||||
this.hp = this.hp_max;
|
|
||||||
}
|
|
||||||
let hp_progress= this.hp/this.hp_max;
|
|
||||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
|
||||||
if(this.hp <= 0){
|
|
||||||
this.dead();
|
|
||||||
this.is_dead = true;
|
|
||||||
this.ent.remove(MoveToComp)
|
|
||||||
smc.vmdata.game_over = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.ent.destroy();
|
|
||||||
}, 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
heathed(){
|
|
||||||
this.node.getChildByName("heathed").active=true
|
|
||||||
// console.log("role heathed");
|
|
||||||
// var path = "game/skills/heathed";
|
|
||||||
// var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
// var node = instantiate(prefab);
|
|
||||||
// let pos = v3(0,0)
|
|
||||||
// node.setPosition(pos)
|
|
||||||
// node.parent = this.node;
|
|
||||||
}
|
|
||||||
add_hp(hp: number=0){
|
|
||||||
this.heathed();
|
|
||||||
this.tooltip(2,hp.toString());
|
|
||||||
let hp_progress= this.hp/this.hp_max;
|
|
||||||
this.hp += hp;
|
|
||||||
if(this.hp > this.hp_max){
|
|
||||||
this.hp = this.hp_max;
|
|
||||||
}
|
|
||||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
|
||||||
}
|
|
||||||
add_atk(atk: number,time:number=0){
|
|
||||||
if(time > 0){
|
|
||||||
this.buff_atk=0
|
|
||||||
let buff={atk:atk,time:time}
|
|
||||||
this.buff_atks.push(buff);
|
|
||||||
this.buff_atks.forEach((element: { atk: number; }) => {
|
|
||||||
this.buff_atk += element.atk
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
this.mission_atk += atk;
|
|
||||||
}
|
|
||||||
// this.sprite.setSharedMaterial(this.atkMaterial, 0);
|
|
||||||
// this.scheduleOnce(() => {
|
|
||||||
// this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
|
|
||||||
// }, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
check_buff_atks(dt: number){
|
|
||||||
for(let i=0;i<this.buff_atks.length;i++){
|
|
||||||
let buff=this.buff_atks[i];
|
|
||||||
buff.time -= dt;
|
|
||||||
if(buff.time <= 0){
|
|
||||||
this.buff_atk -= buff.atk
|
|
||||||
this.buff_atks.splice(i,1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(this.buff_atks.length <= 0){
|
|
||||||
this.buff_atk = 0
|
|
||||||
this.buff_icon_change("atk",false)
|
|
||||||
}else{
|
|
||||||
this.buff_icon_change("atk",true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
buff_icon_change(icon:string,value:boolean){
|
|
||||||
this.node.getChildByName("top").getChildByName("buff").getChildByName(icon).active=value
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_shield(shield: number,time:number=0){
|
|
||||||
this.shield =this.shield_max=shield
|
|
||||||
this.shield_time = time;
|
|
||||||
}
|
|
||||||
shield_change(hp: number){
|
|
||||||
let ls=this.shield - hp;
|
|
||||||
if(ls <= 0){
|
|
||||||
this.shield = 0;
|
|
||||||
return ls;
|
|
||||||
}else{
|
|
||||||
this.shield = ls;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in_shield(dt: number){
|
|
||||||
if(this.shield <= 0){
|
|
||||||
this.shield_time=0
|
|
||||||
this.node.getChildByName("shielded").active=false
|
|
||||||
}else{
|
|
||||||
this.node.getChildByName("shielded").active=true
|
|
||||||
}
|
|
||||||
if(this.shield_time <= 0){
|
|
||||||
this.shield = this.shield_max=0;
|
|
||||||
this.node.getChildByName("shielded").active=false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if(this.shield_time > 0){
|
|
||||||
this.shield_time -= dt;
|
|
||||||
if(this.shield_time <= 0){
|
|
||||||
this.shield_time = 0;
|
|
||||||
this.shield = this.shield_max=0;
|
|
||||||
// this.node.getChildByName("top").getChildByName("shield").active=false
|
|
||||||
}
|
|
||||||
// let shield_progress= this.shield/this.shield_max;
|
|
||||||
// this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tooltip(type:number=1,value:string="",s_uuid:number=1001){
|
|
||||||
// console.log("tooltip",type);
|
|
||||||
let tip =ecs.getEntity<Tooltip>(Tooltip);
|
|
||||||
let pos = this.node.getPosition();
|
|
||||||
let node =this.node.parent
|
|
||||||
pos.y=pos.y+60;
|
|
||||||
tip.load(pos,type,value,s_uuid,node);
|
|
||||||
}
|
|
||||||
get_monster_pos(){
|
|
||||||
return this.node.getPosition()
|
|
||||||
}
|
|
||||||
/** 静止时间 */
|
|
||||||
in_stop (dt: number) {
|
|
||||||
if(this.stop_cd > 0){
|
|
||||||
this.stop_cd -= dt;
|
|
||||||
if(this.stop_cd <= 0){
|
|
||||||
this.stop_cd = 0;
|
|
||||||
this.is_atking = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in_destroy(){
|
|
||||||
// switch (this.scale) {
|
|
||||||
// case -1:
|
|
||||||
// if(this.node.position.x < BoxSet.LETF_END){
|
|
||||||
// this.toDestroy();
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case 1:
|
|
||||||
// if(this.node.position.x > BoxSet.RIGHT_END){
|
|
||||||
// this.toDestroy();
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
in_atked() {
|
|
||||||
|
|
||||||
// var path = "game/skills/atked";
|
|
||||||
// var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
// var node = instantiate(prefab);
|
|
||||||
// let pos = v3(0,30)
|
|
||||||
// node.setPosition(pos)
|
|
||||||
// node.parent = this.node;
|
|
||||||
|
|
||||||
|
|
||||||
// this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
|
||||||
// this.scheduleOnce(() => {
|
|
||||||
// this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
|
|
||||||
// }, 0.1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
dead(){
|
|
||||||
oops.message.dispatchEvent("minssion_defeat");
|
|
||||||
var path = "game/skills/dead";
|
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
var node = instantiate(prefab);
|
|
||||||
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
|
|
||||||
node.parent = this.node.parent;
|
|
||||||
}
|
|
||||||
toDestroy(){
|
|
||||||
|
|
||||||
}
|
|
||||||
reset() {
|
|
||||||
this.is_dead = false;
|
|
||||||
// director.pause();
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "b8b21b3c-dd6b-466b-8bdf-010481a9c576",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
|||||||
import { Initialize } from "../initialize/Initialize";
|
import { Initialize } from "../initialize/Initialize";
|
||||||
import { GameMap } from "../map/GameMap";
|
import { GameMap } from "../map/GameMap";
|
||||||
import { BoxSet } from "./config/BoxSet";
|
import { BoxSet } from "./config/BoxSet";
|
||||||
import { Role } from "../Role/Role";
|
|
||||||
import { v3 } from "cc";
|
import { v3 } from "cc";
|
||||||
import { Skill } from "../skills/Skill";
|
import { Skill } from "../skills/Skill";
|
||||||
|
|
||||||
@@ -47,8 +46,6 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
];
|
];
|
||||||
monster_buffs: any = [];
|
monster_buffs: any = [];
|
||||||
/** 游戏主角 */
|
/** 游戏主角 */
|
||||||
Role: Role = null;
|
|
||||||
|
|
||||||
heros:any = [];
|
heros:any = [];
|
||||||
mheros:any = [];
|
mheros:any = [];
|
||||||
monsters:any = [];
|
monsters:any = [];
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { CCVMParentComp } from "../../../../../extensions/oops-plugin-framework/
|
|||||||
import { UIID } from "../../common/config/GameUIConfig";
|
import { UIID } from "../../common/config/GameUIConfig";
|
||||||
import { smc } from "../../common/SingletonModuleComp";
|
import { smc } from "../../common/SingletonModuleComp";
|
||||||
import { GameMap } from "../../map/GameMap";
|
import { GameMap } from "../../map/GameMap";
|
||||||
// import { Role } from "../../role/Role";
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/** 游戏资源加载 */
|
/** 游戏资源加载 */
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import { GameMap } from "./GameMap";
|
|||||||
import { MapModelComp } from "./model/MapModelComp";
|
import { MapModelComp } from "./model/MapModelComp";
|
||||||
import { Talent } from "../Role/Talent";
|
import { Talent } from "../Role/Talent";
|
||||||
import { Talents } from "../common/config/TalentSet";
|
import { Talents } from "../common/config/TalentSet";
|
||||||
import { MonViewComp } from "../mon/MonViewComp";
|
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
import { RoleViewComp } from "../Role/RoleViewComp";
|
|
||||||
import { BossViewComp } from "../Boss/BossViewComp";
|
import { BossViewComp } from "../Boss/BossViewComp";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import { GameMap } from "./GameMap";
|
|||||||
import { MapModelComp } from "./model/MapModelComp";
|
import { MapModelComp } from "./model/MapModelComp";
|
||||||
import { Talent } from "../Role/Talent";
|
import { Talent } from "../Role/Talent";
|
||||||
import { Talents } from "../common/config/TalentSet";
|
import { Talents } from "../common/config/TalentSet";
|
||||||
import { MonViewComp } from "../mon/MonViewComp";
|
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
import { RoleViewComp } from "../Role/RoleViewComp";
|
|
||||||
import { BossViewComp } from "../Boss/BossViewComp";
|
import { BossViewComp } from "../Boss/BossViewComp";
|
||||||
import { Hero } from "../hero/Hero";
|
import { Hero } from "../hero/Hero";
|
||||||
import { HeroSet } from "../common/config/heroSet";
|
import { HeroSet } from "../common/config/heroSet";
|
||||||
|
|||||||
@@ -8,11 +8,8 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
|||||||
import { MapViewScene } from "./view/MapViewScene";
|
import { MapViewScene } from "./view/MapViewScene";
|
||||||
import { MissionSet,MissionNum,MonsetList, BossList } from "../common/config/MissionSet";
|
import { MissionSet,MissionNum,MonsetList, BossList } from "../common/config/MissionSet";
|
||||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||||
import { Role } from "../Role/Role";
|
|
||||||
import { Hero } from "../hero/Hero";
|
import { Hero } from "../hero/Hero";
|
||||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||||
import { Mon } from "../mon/Mon";
|
|
||||||
import { MonModelComp } from "../mon/MonModelComp";
|
|
||||||
import { Boss} from "../Boss/Boss";
|
import { Boss} from "../Boss/Boss";
|
||||||
import { UIID } from "../common/config/GameUIConfig";
|
import { UIID } from "../common/config/GameUIConfig";
|
||||||
import { Talents } from "../common/config/TalentSet";
|
import { Talents } from "../common/config/TalentSet";
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
|||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
import { MonViewComp } from "../mon/MonViewComp";
|
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
import { RoleViewComp } from "../Role/RoleViewComp";
|
|
||||||
import { BossViewComp } from "../Boss/BossViewComp";
|
import { BossViewComp } from "../Boss/BossViewComp";
|
||||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||||
import { MissionReward } from "../common/config/MissionSet";
|
import { MissionReward } from "../common/config/MissionSet";
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { BoxSet } from "../../common/config/BoxSet";
|
|||||||
import { MapViewScene } from "./MapViewScene";
|
import { MapViewScene } from "./MapViewScene";
|
||||||
import { Timer } from "../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
import { Timer } from "../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||||
import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
import { Role } from "../../Role/Role";
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass('MapViewComp')
|
@ccclass('MapViewComp')
|
||||||
|
|||||||
@@ -1 +1,9 @@
|
|||||||
{"ver":"1.2.0","importer":"directory","imported":true,"uuid":"b7c4b5b8-e8b2-4730-8c73-11759c02c1b1","files":[],"subMetas":{},"userData":{}}
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "4aa9eb83-72b3-400f-8340-0ee05db5860f",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
import { _decorator,Contact2DType,Collider2D ,IPhysics2DContact,v3, v2,Vec3} from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
||||||
import { BoxSet } from "../common/config/BoxSet";
|
|
||||||
import { MonViewComp } from "./MonViewComp";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 视图层对象 */
|
|
||||||
@ccclass('BoxRangComp')
|
|
||||||
@ecs.register('BoxRang', false)
|
|
||||||
export class BoxRangComp extends CCComp {
|
|
||||||
Hero_node: any=null!;
|
|
||||||
MonViewComp:MonViewComp = null!;
|
|
||||||
box_group:number = BoxSet.MONSTER;
|
|
||||||
box_tag:number = BoxSet.ATK_RANGE;
|
|
||||||
offset_x:number = 300;
|
|
||||||
atk_range:number = 150;
|
|
||||||
/** 视图层逻辑代码分离演示 */
|
|
||||||
start() {
|
|
||||||
let collider = this.getComponent(Collider2D);
|
|
||||||
collider.group = this.box_group;
|
|
||||||
collider.tag = this.box_tag;
|
|
||||||
// collider.offset = v2(300*this.Hero_node.MonView.scale,collider.offset.y);
|
|
||||||
this.Hero_node = this.node.parent;
|
|
||||||
this.MonViewComp=this.Hero_node.getComponent(MonViewComp);
|
|
||||||
// console.log("range box",this.MonViewComp);
|
|
||||||
if (collider) {
|
|
||||||
// collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
|
||||||
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
|
||||||
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
|
||||||
// collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
|
|
||||||
// if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
|
||||||
// console.log(this.node.name+"onBeginContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
|
|
||||||
// this.MonViewComp.is_atking = true;
|
|
||||||
// if(Math.abs(otherCollider.node.position.x-selfCollider.node.position.x) < 120){
|
|
||||||
// this.MonViewComp.stop_cd = 0.1
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
|
|
||||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0 ){
|
|
||||||
// console.log(this.node.name+"onEndContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
|
|
||||||
this.MonViewComp.is_atking = false;
|
|
||||||
this.MonViewComp.enemy = null;
|
|
||||||
this.MonViewComp.as.change_default("move");
|
|
||||||
this.MonViewComp.as.move();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
// if(selfCollider.node.parent.position.y < otherCollider.node.parent.position.y){
|
|
||||||
// console.log("onPreSolve f:"+selfCollider.node.parent.getSiblingIndex()+"/"+otherCollider.node.parent.getSiblingIndex());
|
|
||||||
// selfCollider.node.parent.setSiblingIndex(otherCollider.node.parent.getSiblingIndex()+1)
|
|
||||||
// console.log("onPreSolve b:"+selfCollider.node.parent.getSiblingIndex()+"/"+otherCollider.node.parent.getSiblingIndex());
|
|
||||||
// }
|
|
||||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
|
||||||
let other_pos = otherCollider.node.getWorldPosition() ;
|
|
||||||
let self_pos = this.node.getWorldPosition();
|
|
||||||
// console.log("onPreSolve:",self_pos,other_pos);
|
|
||||||
if(this.MonViewComp.enemy==null){
|
|
||||||
this.MonViewComp.enemy = otherCollider.node;
|
|
||||||
}else{
|
|
||||||
if(this.MonViewComp.enemy.isValid==false){
|
|
||||||
this.MonViewComp.enemy = otherCollider.node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Math.abs(other_pos.x-self_pos.x) < this.MonViewComp.atk_dis){
|
|
||||||
|
|
||||||
this.MonViewComp.is_atking = true;
|
|
||||||
this.MonViewComp.stop_cd = 0.1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
||||||
reset() {
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"14659f87-1333-46e0-9b7d-69c369c6f852","files":[],"subMetas":{},"userData":{}}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2021-11-18 17:47:56
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-04 15:43:04
|
|
||||||
*/
|
|
||||||
import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,SpriteAtlas} from "cc";
|
|
||||||
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { UIID } from "../common/config/GameUIConfig";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import { MonModelComp } from "./MonModelComp";
|
|
||||||
import { MonSpine } from "./MonSpine";
|
|
||||||
import { MonViewComp } from "./MonViewComp";
|
|
||||||
import { BoxSet } from "../common/config/BoxSet";
|
|
||||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
|
||||||
import { HeroInfo,MonSet } from "../common/config/heroSet";
|
|
||||||
/** 角色实体 */
|
|
||||||
@ecs.register(`Mon`)
|
|
||||||
export class Mon extends ecs.Entity {
|
|
||||||
// 数据层
|
|
||||||
MonModel!: MonModelComp;
|
|
||||||
// 视图层
|
|
||||||
MonView!: MonViewComp;
|
|
||||||
|
|
||||||
protected init() {
|
|
||||||
this.addComponents<ecs.Comp>( MonModelComp);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy(): void {
|
|
||||||
this.remove(MonViewComp);
|
|
||||||
super.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 加载角色 */
|
|
||||||
load(pos: Vec3 = Vec3.ZERO,scale:number = -1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!) {
|
|
||||||
var path = "game/monster/"+MonSet[uuid].path;
|
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
var node = instantiate(prefab);
|
|
||||||
node.parent=layer
|
|
||||||
// var as = node.getComponent(MonSpine);
|
|
||||||
// let ratio=this.set_ratio(uuid);
|
|
||||||
// node.setScale(node.scale.x*scale*ratio, node.scale.y*ratio, 0);
|
|
||||||
node.setPosition(pos)
|
|
||||||
this.hero_init(uuid,node)
|
|
||||||
oops.message.dispatchEvent("mon_load",this)
|
|
||||||
}
|
|
||||||
set_ratio(uuid:number){
|
|
||||||
let ratio=1;
|
|
||||||
switch (MonSet[uuid].level) {
|
|
||||||
case 2:
|
|
||||||
ratio=1.05
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
ratio=1.1
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
ratio=1.15
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
ratio=1.2
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ratio=1
|
|
||||||
}
|
|
||||||
return ratio;
|
|
||||||
}
|
|
||||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
|
||||||
var mv = node.getComponent(MonViewComp)!;
|
|
||||||
// console.log("hero_init",buff)
|
|
||||||
mv.speed =mv.ospeed = smc.monsters[uuid].speed;
|
|
||||||
mv.hero_name= smc.monsters[uuid].name;
|
|
||||||
mv.hp= mv.hp_max = smc.monsters[uuid].hp;
|
|
||||||
mv.level = smc.monsters[uuid].level;
|
|
||||||
mv.atk = smc.monsters[uuid].atk;
|
|
||||||
mv.atk_cd = smc.monsters[uuid].atk_cd;
|
|
||||||
mv.atk_dis = smc.monsters[uuid].atk_dis;
|
|
||||||
mv.power = smc.monsters[uuid].power;
|
|
||||||
mv.power_max = smc.monsters[uuid].power_max;
|
|
||||||
|
|
||||||
mv.type = smc.monsters[uuid].type;
|
|
||||||
mv.skill_uuid = smc.monsters[uuid].skill_uuid;
|
|
||||||
mv.max_skill_uuid = smc.monsters[uuid].max_skill_uuid;
|
|
||||||
mv.scale = -1;
|
|
||||||
mv.Tpos = v3(0,0,0);
|
|
||||||
this.add(mv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"7a43618b-14af-4545-b90a-e87402ae1875","files":[],"subMetas":{},"userData":{}}
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2021-11-18 17:42:59
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-17 12:36:18
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { _decorator,Sprite,Color} from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
||||||
import { MonSpine } from "./MonSpine";
|
|
||||||
import { Mon } from "./Mon";
|
|
||||||
import { MonModelComp } from "./MonModelComp";
|
|
||||||
import { BoxSet } from "../common/config/BoxSet";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
||||||
import { Skill } from "../skills/Skill";
|
|
||||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
|
||||||
import { SkillCom } from "../skills/SkillCom";
|
|
||||||
import { BoxRangComp } from "./BoxRangComp";
|
|
||||||
import { Tooltip } from "../skills/Tooltip";
|
|
||||||
import { MonViewComp } from "./MonViewComp";
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 角色显示组件 */
|
|
||||||
@ccclass('MonBuffComp') // 定义为 Cocos Creator 组件
|
|
||||||
@ecs.register('MonBuff', false) // 定义为 ECS 组件
|
|
||||||
export class MonBuffComp extends CCComp {
|
|
||||||
/** 角色动画 */
|
|
||||||
as: MonSpine = null!;
|
|
||||||
mv!: MonViewComp;
|
|
||||||
|
|
||||||
timer:Timer = new Timer(0.1);
|
|
||||||
buffs:any=[];
|
|
||||||
group:number=BoxSet.MONSTER;
|
|
||||||
/**
|
|
||||||
skill_uuid:number=0;
|
|
||||||
atk:number=0;
|
|
||||||
hp:number=0;
|
|
||||||
shield:number=0;
|
|
||||||
time:number=0;
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
this.as = this.node.getComponent(MonSpine);
|
|
||||||
this.mv= this.getComponent(MonViewComp);
|
|
||||||
} /** 视图层逻辑代码分离演示 */
|
|
||||||
start () {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
add_buff(uuid:number=0,args:any[]){
|
|
||||||
|
|
||||||
let new_buff={
|
|
||||||
skill_uuid:uuid,
|
|
||||||
skill_name:smc.skills[uuid].name,
|
|
||||||
atk:smc.skills[uuid].atk,
|
|
||||||
hp:smc.skills[uuid].hp,
|
|
||||||
shield:smc.skills[uuid].shield,
|
|
||||||
time:smc.skills[uuid].bsd,
|
|
||||||
bcd:smc.skills[uuid].bcd,
|
|
||||||
sk_uuid:smc.skills[uuid].uuid,
|
|
||||||
args:args
|
|
||||||
}
|
|
||||||
this.buff_add(new_buff);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
update(dt: number){
|
|
||||||
if (this.timer.update(dt)) {
|
|
||||||
this.buff_update()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reset() {
|
|
||||||
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
buff_add(buff:any){
|
|
||||||
if(!this.node.isValid){ return }
|
|
||||||
let i = 0
|
|
||||||
if(this.buffs.length >=0){
|
|
||||||
this.buffs.forEach((b:any,index:number)=>{
|
|
||||||
if(b.skill_uuid==buff.skill_uuid){
|
|
||||||
b.time=buff.time;
|
|
||||||
if(buff.atk>0){
|
|
||||||
this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
|
|
||||||
}
|
|
||||||
if(buff.hp>0){
|
|
||||||
this.mv.hp+=(buff.hp+buff.args.hp);
|
|
||||||
this.mv.add_hp(buff.hp+buff.args.hp);
|
|
||||||
// this.mv.hp_max+=(buff.hp-b.hp);
|
|
||||||
}
|
|
||||||
if(buff.shield>0){
|
|
||||||
this.mv.shield=(buff.shield+buff.args.shield);
|
|
||||||
// this.mv.shield_max=(buff.shield+buff.args.shield);
|
|
||||||
}
|
|
||||||
|
|
||||||
i=index
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (i==0||this.buffs.length==0) {
|
|
||||||
this.buffs.push(buff);
|
|
||||||
if(buff.atk>0){
|
|
||||||
this.mv.atk+=(buff.atk+buff.args.atk);
|
|
||||||
}
|
|
||||||
if(buff.hp>0){
|
|
||||||
this.mv.hp+=(buff.hp+buff.args.hp);
|
|
||||||
this.mv.add_hp(buff.hp+buff.args.hp);
|
|
||||||
// this.mv.hp_max+=buff.hp;
|
|
||||||
}
|
|
||||||
if(buff.shield>0){
|
|
||||||
this.mv.shield=(buff.shield+buff.args.shield);
|
|
||||||
// this.mv.shield_max=(buff.shield+buff.args.shield);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buff_remove(index:number){
|
|
||||||
if(this.buffs[index].atk>0){
|
|
||||||
this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk);
|
|
||||||
}
|
|
||||||
if(this.buffs[index].shield>0){
|
|
||||||
this.mv.shield=0
|
|
||||||
// this.mv.shield_max-=(this.buffs[index].shield+this.buffs[index].args.shield);
|
|
||||||
}
|
|
||||||
// if(this.buffs[index].hp>0){
|
|
||||||
// this.mv.hp_max-=this.buffs[index].hp;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
buff_update(){
|
|
||||||
this.buffs.forEach((buff:any,index:number)=>{
|
|
||||||
buff.time -= 0.1;
|
|
||||||
if(buff.time <= 0){
|
|
||||||
this.buff_remove(index);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.buffs = this.buffs.filter((buff:any) => buff.time > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"dc9c4c07-be34-4d1c-8141-8ec3f9ff8275","files":[],"subMetas":{},"userData":{}}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2022-08-04 15:08:35
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-04 15:26:26
|
|
||||||
*/
|
|
||||||
import { Color, Component, EventTouch, sp, Vec3, _decorator ,Animation, AnimationClip, AnimationState,} from "cc";
|
|
||||||
import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
|
|
||||||
import { smc } from "../../../script/game/common/SingletonModuleComp";
|
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RPG SPINE角色模型
|
|
||||||
*/
|
|
||||||
@ccclass('MonSpine')
|
|
||||||
export class MonSpine extends Component {
|
|
||||||
@property(Animation)
|
|
||||||
animator: Animation = null!;
|
|
||||||
atk_clip: AnimationClip = null!;
|
|
||||||
move_clip: AnimationClip = null!;
|
|
||||||
default_clip:string = "move";
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
// 角色控制组件
|
|
||||||
this.initAnimator();
|
|
||||||
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
|
|
||||||
this.atk_clip = this.animator.clips[0];
|
|
||||||
this.move_clip = this.animator.clips[1];
|
|
||||||
let animation = this.animator.getComponent(Animation);
|
|
||||||
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 初始化动画 */
|
|
||||||
protected initAnimator() {
|
|
||||||
this.animator=this.node.getChildByName("anm").getComponent(Animation);
|
|
||||||
// console.log("mon spine init",this.animator);
|
|
||||||
}
|
|
||||||
|
|
||||||
onAnimationEvent(type: Animation.EventType, state: AnimationState){
|
|
||||||
if(type==Animation.EventType.FINISHED){
|
|
||||||
if(state.name==this.atk_clip.name){
|
|
||||||
this.default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
change_default(value:string){
|
|
||||||
this.default_clip=value;
|
|
||||||
}
|
|
||||||
default() {
|
|
||||||
if(!this.animator.getState(this.default_clip).isPlaying){
|
|
||||||
this.animator.play(this.default_clip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
idle(){
|
|
||||||
if(!this.animator.getState(this.move_clip.name).isPlaying){
|
|
||||||
this.animator.play(this.move_clip.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
atk() {
|
|
||||||
if(!this.animator.getState(this.atk_clip.name).isPlaying){
|
|
||||||
this.animator.play(this.atk_clip.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
max(){
|
|
||||||
if(!this.animator.getState(this.atk_clip.name).isPlaying){
|
|
||||||
this.animator.play(this.atk_clip.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
move(){
|
|
||||||
if(!this.animator.getState(this.move_clip.name).isPlaying){
|
|
||||||
this.animator.play(this.move_clip.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onDestroy() {
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"0ca2f72a-0c8c-41d7-8572-673428a71537","files":[],"subMetas":{},"userData":{}}
|
|
||||||
@@ -1,439 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2021-11-18 17:42:59
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-08-17 12:36:18
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,RigidBody2D ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
||||||
import { MonSpine } from "./MonSpine";
|
|
||||||
import { Mon } from "./Mon";
|
|
||||||
import { MonModelComp } from "./MonModelComp";
|
|
||||||
import { BoxSet, GameSet } from "../common/config/BoxSet";
|
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
|
||||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
||||||
import { Skill } from "../skills/Skill";
|
|
||||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
|
||||||
import { SkillCom } from "../skills/SkillCom";
|
|
||||||
import { SkillSet } from "../common/config/SkillSet";
|
|
||||||
import { Tooltip } from "../skills/Tooltip";
|
|
||||||
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
|
||||||
import { BoxRangComp } from "./BoxRangComp";
|
|
||||||
import { Talents } from "../common/config/TalentSet";
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 角色显示组件 */
|
|
||||||
@ccclass('MonViewComp') // 定义为 Cocos Creator 组件
|
|
||||||
@ecs.register('MonView', false) // 定义为 ECS 组件
|
|
||||||
export class MonViewComp extends CCComp {
|
|
||||||
@property(Material)
|
|
||||||
hitFlashMaterial: Material;
|
|
||||||
orginalFlashMaterial: Material;
|
|
||||||
sprite: Sprite;
|
|
||||||
|
|
||||||
// @property(Node)
|
|
||||||
// BoxRang:Node =null!
|
|
||||||
|
|
||||||
is_role:boolean = false;
|
|
||||||
enemy_pos:Vec3=null!;
|
|
||||||
enemy:any=null!;
|
|
||||||
/** 角色动画 */
|
|
||||||
as: MonSpine = null!;
|
|
||||||
hero_uuid:number = 1001;
|
|
||||||
hero_name : string = "hero";
|
|
||||||
level:number =1;
|
|
||||||
scale: number = 1; /** 角色阵营 1:hero -1 :mon */
|
|
||||||
type: number = 1; /**角色类型 1:前排 2 后排 */
|
|
||||||
state: number = 1; /** 状态 1:move ,2: act 3: stop */
|
|
||||||
|
|
||||||
hp: number = 100; /** 血量 */
|
|
||||||
hp_max: number = 100; /** 最大血量 */
|
|
||||||
hp_speed: number = 0; //每秒回复量
|
|
||||||
|
|
||||||
power: number = 0; /**能量**/
|
|
||||||
power_max: number = 1200; /** 能量最大值 */
|
|
||||||
power_speed: number = 1; //能量回复速度每0.1秒回复量
|
|
||||||
|
|
||||||
skill_name: string = "base"; //技能名称
|
|
||||||
max_skill_name: string = "base"; //大技能名称
|
|
||||||
skill_uuid:number = 9001;
|
|
||||||
max_skill_uuid:number = 0;
|
|
||||||
atk: number = 10; /**攻击力 */
|
|
||||||
// atk_speed: number = 1;
|
|
||||||
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
|
|
||||||
atk_dis: number = 80;
|
|
||||||
atk_time: number = 0; /** 冷却时间 */
|
|
||||||
|
|
||||||
speed: number = 100; /** 角色移动速度 */
|
|
||||||
ospeed: number = 100; /** 角色初始速度 */
|
|
||||||
Tpos: Vec3 = v3(0,-60,0);
|
|
||||||
stop_cd: number = 0.5; /*停止倒计时*/
|
|
||||||
|
|
||||||
shield:number = 0; //护盾量
|
|
||||||
shield_max:number = 200;
|
|
||||||
shield_time:number = 0; //护盾持续时间
|
|
||||||
|
|
||||||
box_group:number = BoxSet.MONSTER;
|
|
||||||
atk_range:number = 150;
|
|
||||||
private timer:Timer = new Timer(1); //计时器
|
|
||||||
private m_timer:Timer = new Timer(0.1);
|
|
||||||
is_dead:boolean = false; //是否摧毁
|
|
||||||
is_stop:boolean = false;
|
|
||||||
is_atking:boolean = false;
|
|
||||||
buff_shields:any=[];
|
|
||||||
buff_atks:any = [];
|
|
||||||
dir_y:number = 0;
|
|
||||||
speek_time:number = 0;
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
this.as = this.getComponent(MonSpine);
|
|
||||||
// this.BoxRang = this.node.getChildByName("range_box");
|
|
||||||
// this.BoxRang = this.node.getChildByName("range_box");
|
|
||||||
} /** 视图层逻辑代码分离演示 */
|
|
||||||
start () {
|
|
||||||
this.as.move()
|
|
||||||
this.sprite = this.node.getChildByName("anm").getComponent(Sprite);
|
|
||||||
// this.node.getChildByName("top").setScale(this.scale,1);
|
|
||||||
// this.node.getChildByName("atk").setScale(this.scale,1);
|
|
||||||
// this.node.getChildByName("atk").getComponent(Label).string = this.atk.toString();
|
|
||||||
// this.node.getChildByName("hp_max").setScale(this.scale,1);
|
|
||||||
// this.node.getChildByName("hp_max").getComponent(Label).string=this.hp_max.toString();
|
|
||||||
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
|
|
||||||
// this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
|
|
||||||
// this.BoxRang.getComponent(BoxRangComp).atk_range = this.atk_range
|
|
||||||
// this.BoxRang.getComponent(BoxRangComp).offset_x = 300;
|
|
||||||
// console.log("monseter ",this.BoxRang);
|
|
||||||
// console.log("monseter ",this.BoxRang);
|
|
||||||
|
|
||||||
// 注册单个碰撞体的回调函数
|
|
||||||
let collider = this.getComponent(Collider2D);
|
|
||||||
collider.group = this.box_group;
|
|
||||||
if (collider) {
|
|
||||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
|
||||||
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
|
||||||
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
|
||||||
// collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
|
||||||
}
|
|
||||||
// this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = this.level.toString();
|
|
||||||
|
|
||||||
}
|
|
||||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
|
|
||||||
|
|
||||||
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
|
|
||||||
if(selfCollider.group != otherCollider.group){
|
|
||||||
let skill = otherCollider.node.getComponent(SkillCom)!;
|
|
||||||
// console.log('onPostSolve',skill);
|
|
||||||
this.in_atked();
|
|
||||||
if(this.hp <= 0 ){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.hp_change(skill.atk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
|
|
||||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
|
||||||
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
|
||||||
if(selfCollider.node.position.y < otherCollider.node.position.y){
|
|
||||||
if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
|
|
||||||
selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
|
||||||
// console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
|
||||||
this.stop_cd = 0.1;
|
|
||||||
this.is_atking=true
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {}
|
|
||||||
|
|
||||||
|
|
||||||
update(dt: number){
|
|
||||||
if(!smc.vmdata.mission.play||smc.vmdata.pause){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.timer.update(dt)) {
|
|
||||||
this.power_change(this.power_speed)
|
|
||||||
}
|
|
||||||
this.in_destroy();
|
|
||||||
this.in_speek(dt);
|
|
||||||
this.in_shield(dt);
|
|
||||||
this.in_stop(dt);
|
|
||||||
this.check_enemy_alive()
|
|
||||||
this.atk_time += dt;
|
|
||||||
this.in_atk(dt);
|
|
||||||
this.hp_show()
|
|
||||||
this.move(dt);
|
|
||||||
|
|
||||||
}
|
|
||||||
check_enemy_alive(){
|
|
||||||
let dir = 320
|
|
||||||
this.enemy = v3(720,this.node.position.y)
|
|
||||||
for (let i = 0; i < GameSet.ATK_LINES; i++) {
|
|
||||||
let ho:any = smc.hero_pos[i];
|
|
||||||
let x=Math.abs(ho.x-this.node.position.x)
|
|
||||||
// console.log("check_enemy_alive,x:"+ho.x+"-"+this.node.position.x+"="+x);
|
|
||||||
let y = Math.abs(ho.y-this.node.position.y)
|
|
||||||
let squaredDistance =x*x+y*y
|
|
||||||
let distance = Math.sqrt(squaredDistance);
|
|
||||||
// console.log("check_enemy_alive,z:"+x+":"+y+":"+this.atk_dis+":"+distance);
|
|
||||||
if(distance < dir){
|
|
||||||
dir = distance
|
|
||||||
this.enemy = ho
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if(dir < this.atk_dis){
|
|
||||||
if(dir < this.atk_cd-60) this.stop_cd = 0.1
|
|
||||||
this.is_atking=true
|
|
||||||
}else{
|
|
||||||
this.is_atking=false
|
|
||||||
}
|
|
||||||
// console.log("check_enemy_alive", this.enemy);
|
|
||||||
}
|
|
||||||
hp_show(){
|
|
||||||
if(this.hp == this.hp_max){
|
|
||||||
this.node.getChildByName("top").getChildByName("hp").active = false;
|
|
||||||
} else{
|
|
||||||
this.node.getChildByName("top").getChildByName("hp").active = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
move(dt: number){
|
|
||||||
if(this.stop_cd > 0){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// this.set_diry()
|
|
||||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
|
|
||||||
}
|
|
||||||
set_diry(){
|
|
||||||
this.dir_y=-(this.node.position.y-BoxSet.GAME_LINE)/20
|
|
||||||
}
|
|
||||||
|
|
||||||
power_change(power: number){
|
|
||||||
if(this.max_skill_uuid == 0){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.power += power;
|
|
||||||
if(this.power >= this.power_max){
|
|
||||||
this.as.atk()
|
|
||||||
// this.to_speek(smc.skills[this.max_skill_uuid].name)
|
|
||||||
this.scheduleOnce(()=>{
|
|
||||||
this.do_max_skill();
|
|
||||||
},0.5)
|
|
||||||
this.power = 0
|
|
||||||
}
|
|
||||||
// let power_progress= this.power/this.power_max;
|
|
||||||
// this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
|
|
||||||
}
|
|
||||||
shoot(skill_uuid:number,y:number=0,x:number=0){
|
|
||||||
// console.log("mon shoot");
|
|
||||||
let skill = ecs.getEntity<Skill>(Skill);
|
|
||||||
let atk = smc.skills[skill_uuid].atk+this.atk;
|
|
||||||
let {pos,t_pos}=this.get_enemy_pos()
|
|
||||||
pos.y=pos.y + y
|
|
||||||
pos.x=pos.x + x
|
|
||||||
skill.load(pos,BoxSet.MONSTER,this.node,skill_uuid,atk,t_pos);
|
|
||||||
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
|
|
||||||
}
|
|
||||||
//使用max_skill
|
|
||||||
do_max_skill(){
|
|
||||||
this.shoot(this.max_skill_uuid)
|
|
||||||
}
|
|
||||||
to_speek(words:string,time:number=0.5){
|
|
||||||
this.speek_time=0.5
|
|
||||||
this.node.getChildByName("tooltip").active=true
|
|
||||||
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = words
|
|
||||||
}
|
|
||||||
in_speek(dt: number){
|
|
||||||
if(this.speek_time <= 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.speek_time -= dt;
|
|
||||||
if(this.speek_time <= 0){
|
|
||||||
this.speek_time = 0;
|
|
||||||
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = "";
|
|
||||||
this.node.getChildByName("tooltip").active=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get_enemy_pos(){
|
|
||||||
let pos = v3(35*this.scale,25)
|
|
||||||
let t_pos:Vec3 = v3(-720,0)
|
|
||||||
if(this.enemy){
|
|
||||||
t_pos = v3(this.enemy.x-this.node.position.x,this.enemy.y-this.node.position.y)
|
|
||||||
}
|
|
||||||
return {pos,t_pos}
|
|
||||||
}
|
|
||||||
|
|
||||||
in_atk(dt: number) {
|
|
||||||
if(this.atk_time >= this.atk_cd){
|
|
||||||
if(this.is_atking){
|
|
||||||
this.atk_time = 0;
|
|
||||||
this.as.atk();
|
|
||||||
this.scheduleOnce(()=>{
|
|
||||||
// console.log("mon skill_cd:"+this.skill_uuid);
|
|
||||||
this.shoot(this.skill_uuid);
|
|
||||||
},0.4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hp_change(hp: number){
|
|
||||||
if(this.is_dead){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let lhp=this.shield_change(hp);
|
|
||||||
if(lhp == 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.hp += lhp;
|
|
||||||
this.tooltip(1,hp.toString());
|
|
||||||
if(this.hp > this.hp_max){
|
|
||||||
this.hp = this.hp_max;
|
|
||||||
}
|
|
||||||
let hp_progress= this.hp/this.hp_max;
|
|
||||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
|
||||||
if(this.hp <= 0){
|
|
||||||
this.dead();
|
|
||||||
this.is_dead = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.ent.destroy();
|
|
||||||
}, 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_hp(hp: number=0){
|
|
||||||
this.heathed()
|
|
||||||
this.hp+=hp;
|
|
||||||
if(this.hp > this.hp_max){
|
|
||||||
this.hp = this.hp_max;
|
|
||||||
}
|
|
||||||
this.tooltip(2,hp.toString());
|
|
||||||
let hp_progress= this.hp/this.hp_max;
|
|
||||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
|
||||||
}
|
|
||||||
heathed(){
|
|
||||||
this.node.getChildByName("heathed").active=true
|
|
||||||
}
|
|
||||||
|
|
||||||
add_atk(atk: number,time:number=0){
|
|
||||||
if(time > 0){
|
|
||||||
let buff={atk:atk,time:time}
|
|
||||||
this.buff_atks.push(buff);
|
|
||||||
}else{
|
|
||||||
this.atk += atk;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
check_buff_atks(dt: number){
|
|
||||||
for(let i=0;i<this.buff_atks.length;i++){
|
|
||||||
let buff=this.buff_atks[i];
|
|
||||||
buff.time -= dt;
|
|
||||||
if(buff.time <= 0){
|
|
||||||
if(buff.atk > 0)this.atk -= buff.atk;
|
|
||||||
this.buff_atks.splice(i,1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_shield(shield: number,time:number=0){
|
|
||||||
this.shield =this.shield_max=shield
|
|
||||||
this.shield_time = time;
|
|
||||||
}
|
|
||||||
shield_change(hp: number){
|
|
||||||
let ls=this.shield - hp;
|
|
||||||
if(ls <= 0){
|
|
||||||
this.shield = 0;
|
|
||||||
return ls;
|
|
||||||
}else{
|
|
||||||
this.shield = ls;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in_shield(dt){
|
|
||||||
if(this.shield_time <= 0){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if(this.shield_time > 0){
|
|
||||||
this.shield_time -= dt;
|
|
||||||
if(this.shield_time <= 0){
|
|
||||||
this.shield_time = 0;
|
|
||||||
this.shield = this.shield_max=0;
|
|
||||||
// this.node.getChildByName("top").getChildByName("shield").active=false
|
|
||||||
}
|
|
||||||
// let shield_progress= this.shield/this.shield_max;
|
|
||||||
// this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
|
|
||||||
}
|
|
||||||
if(this.shield <= 0){
|
|
||||||
this.shield_time=0
|
|
||||||
// this.node.getChildByName("top").getChildByName("shield").active=false
|
|
||||||
}else{
|
|
||||||
// this.node.getChildByName("top").getChildByName("shield").active=true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tooltip(type:number=1,value:string="",s_uuid:number=1001){
|
|
||||||
// console.log("tooltip",type);
|
|
||||||
let tip =ecs.getEntity<Tooltip>(Tooltip);
|
|
||||||
let pos = this.node.getPosition();
|
|
||||||
let node =this.node.parent
|
|
||||||
pos.y=pos.y+50;
|
|
||||||
tip.load(pos,type,value,s_uuid,node);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** 静止时间 */
|
|
||||||
in_stop (dt: number) {
|
|
||||||
if(this.stop_cd > 0){
|
|
||||||
this.stop_cd -= dt;
|
|
||||||
if(this.stop_cd <= 0){
|
|
||||||
this.stop_cd = 0;
|
|
||||||
this.is_atking = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in_destroy(){
|
|
||||||
// switch (this.scale) {
|
|
||||||
// case -1:
|
|
||||||
// if(this.node.position.x < BoxSet.LETF_END){
|
|
||||||
// this.toDestroy();
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case 1:
|
|
||||||
// if(this.node.position.x > BoxSet.RIGHT_END){
|
|
||||||
// this.toDestroy();
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
in_atked() {
|
|
||||||
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
|
||||||
this.scheduleOnce(() => {
|
|
||||||
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
|
|
||||||
}, 0.1);
|
|
||||||
|
|
||||||
}
|
|
||||||
dead(){
|
|
||||||
|
|
||||||
oops.message.dispatchEvent("mon_dead");
|
|
||||||
var path = "game/skills/dead";
|
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
var node = instantiate(prefab);
|
|
||||||
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
|
|
||||||
node.parent = this.node.parent;
|
|
||||||
|
|
||||||
}
|
|
||||||
toDestroy(){
|
|
||||||
|
|
||||||
}
|
|
||||||
reset() {
|
|
||||||
this.is_dead = false;
|
|
||||||
this.node.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"18359c9e-1232-4a7b-aebd-5cd49e882d86","files":[],"subMetas":{},"userData":{}}
|
|
||||||
Reference in New Issue
Block a user