角色动画 确定
This commit is contained in:
@@ -5,13 +5,18 @@
|
||||
* @LastEditTime: 2022-08-17 12:36:18
|
||||
*/
|
||||
|
||||
import { Vec3, v3,_decorator ,Collider2D,Contact2DType,IPhysics2DContact,Material,Sprite,ProgressBar} from "cc";
|
||||
import { Vec3, v3,_decorator ,Collider2D,Contact2DType,IPhysics2DContact,Material,Sprite,ProgressBar, Prefab, instantiate} 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} 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";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 角色显示组件 */
|
||||
@@ -29,24 +34,27 @@ export class RoleViewComp extends CCComp {
|
||||
hp_max:number = 1000;
|
||||
power: number = 0;
|
||||
stop_cd:number = 0;
|
||||
atk_cd:number = 0;
|
||||
atk:number = 2;
|
||||
atk_cd:number = 20;
|
||||
atk:number = 10;
|
||||
skill_uuid:number = 9003;
|
||||
max_skill_uuid:number = 1001;
|
||||
skin="Character01";
|
||||
private atk_time:Timer = new Timer(1);
|
||||
|
||||
onLoad() {
|
||||
onLoad() {
|
||||
this.as = this.getComponent(RoleSpine);
|
||||
|
||||
}
|
||||
start () {
|
||||
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
|
||||
|
||||
// let x = RandomManager.instance.getRandomInt(1,9,2)
|
||||
// this.as.setSkin("Character0"+x);
|
||||
this.atk_time = new Timer(this.atk_cd);
|
||||
// this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
// this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
|
||||
console.log("Role view start")
|
||||
|
||||
let collider = this.getComponent(Collider2D);
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
|
||||
}
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(otherCollider.tag==BoxSet.SKILL_TAG){
|
||||
@@ -61,46 +69,53 @@ export class RoleViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
}
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
|
||||
}
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag != BoxSet.ATK_RANGE){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
|
||||
if(selfCollider.group == otherCollider.group){
|
||||
// console.log('monster view group 相同');
|
||||
|
||||
}else{
|
||||
// console.log('monster onPostSolve'+selfCollider.group+"|"+otherCollider.group);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {}
|
||||
// onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {}
|
||||
// onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {}
|
||||
|
||||
update(dt: number){
|
||||
|
||||
if (this.atk_time.update(dt)) {
|
||||
this.toAtk(this.skill_uuid);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setSkin(){
|
||||
this.as.setSkin(this.skin);
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
toAtk(uuid) {
|
||||
this.as.atk();
|
||||
this.scheduleOnce(()=>{
|
||||
this.shoot(this.skill_uuid);
|
||||
},0.5)
|
||||
}
|
||||
|
||||
|
||||
shoot(skill_uuid:number){
|
||||
// console.log("monster shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let pos = v3(35,55)
|
||||
let scale = 1
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let dis = SkillSet[skill_uuid].dis;
|
||||
let atk = SkillSet[skill_uuid].atk+this.atk;
|
||||
let uuid = skill_uuid;
|
||||
skill.load(pos,speed,dis,scale,this.node,uuid,atk,2);
|
||||
}
|
||||
|
||||
in_atked() {
|
||||
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
||||
this.scheduleOnce(() => {
|
||||
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
|
||||
}, 0.1);
|
||||
// this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
||||
// this.scheduleOnce(() => {
|
||||
// this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
|
||||
// }, 0.1);
|
||||
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;
|
||||
}
|
||||
hp_change(hp: number){
|
||||
this.hp -= hp;
|
||||
@@ -110,8 +125,8 @@ export class RoleViewComp extends CCComp {
|
||||
let hp_progress= this.hp/this.hp_max;
|
||||
this.node.getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
if(this.hp <= 0){
|
||||
console.log("dead");
|
||||
console.log("dead");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user