开箱完成,开箱设定为只获得英雄碎片

This commit is contained in:
2024-12-20 11:00:16 +08:00
parent ee2eb55442
commit c4e1f55d12
21 changed files with 541 additions and 2112 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
{"ver":"1.2.0","importer":"directory","imported":true,"uuid":"59681a02-4a5e-464a-a391-21c0ad9a20e7","files":[],"subMetas":{},"userData":{}}

View File

@@ -1,95 +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 { BossModelComp } from "./BossModelComp";
import { BossSpine } from "./BossSpine";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BossViewComp } from "./BossViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { MonSet } from "../common/config/heroSet";
/** 角色实体 */
@ecs.register(`Boss`)
export class Boss extends ecs.Entity {
// 数据层
BossModel!: BossModelComp;
BossMoveTo!: MoveToComp; // 移动
// 视图层
BossView!: BossViewComp;
protected init() {
this.addComponents<ecs.Comp>(
BossModelComp);
}
destroy(): void {
this.remove(BossViewComp);
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 bs = node.getComponent(BossViewComp)!;
// console.log("hero_init",buff)
bs.speed =bs.ospeed = MonSet[uuid].speed;
bs.boos_name= MonSet[uuid].name;
bs.hp= bs.hp_max = MonSet[uuid].hp;
bs.level = MonSet[uuid].level;
bs.atk = MonSet[uuid].atk;
bs.atk_cd = MonSet[uuid].atk_cd;
bs.atk_dis = MonSet[uuid].atk_dis;
bs.power = MonSet[uuid].power;
bs.power_max = MonSet[uuid].power_max;
bs.skill = MonSet[uuid].skill_uuid;
bs.type = MonSet[uuid].type;
bs.box_group = BoxSet.MONSTER;
bs.scale = -1;
bs.Tpos = v3(0,0,0);
this.add(bs);
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"dc2a1db4-c531-4d4b-8de4-318efb5dbf58","files":[],"subMetas":{},"userData":{}}

View File

@@ -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('BossModel')
export class BossModelComp extends ecs.Comp {
/** 角色编号 */
id: number = -1;
/** 角色名 */
name: string = "Boss";
/** 动画名资源 */
anim: string = "Boss";
reset() {
this.id = -1;
this.name = "";
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"258ce138-d7ba-4393-ad1c-fc037fb912e1","files":[],"subMetas":{},"userData":{}}

View File

@@ -1,56 +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";
const { ccclass, property } = _decorator;
/**
* SPINE角色模型
*/
@ccclass('BossSpine')
export class BossSpine 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 = "atk";
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.spine.setAnimation(0, this.idel_name, true);
}
move(){
this.spine.setAnimation(0, this.move_name, true);
}
max(){
this.spine.setAnimation(0, this.max_name, false);
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"3a58952a-5c4c-4f38-a65c-e82553ff7fcd","files":[],"subMetas":{},"userData":{}}

View File

@@ -1,445 +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 { BossSpine } from "./BossSpine";
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 { Tooltip } from "../skills/Tooltip";
import { HeroViewComp } from "../hero/HeroViewComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@ccclass('BossViewComp') // 定义为 Cocos Creator 组件
@ecs.register('BossView', false) // 定义为 ECS 组件
export class BossViewComp extends CCComp {
sprite: Sprite;
/** 角色动画 */
as:BossSpine =null!;
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
atk_enemy:any=null!;
neraster_enemy:any=null!;
/** 角色动画 */
boos_uuid:number = 1001;
boos_name : string = "role";
level:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :monster */
state: number = 1; /** 状态 1move ,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:{
1:{uuid:8001,cd:2,alive:true },
2:{uuid:8001,cd:2,alive:false},
3:{uuid:8001,cd:2,alive:false},
4:{uuid:8001,cd:2,alive:false},
5:{uuid:8001,cd:2,alive:false},
}
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; /*停止倒计时*/
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(0.1); //计时器
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
type:number = 0;
onLoad() {
// this.BoxRang = this.node.getChildByName("range_box");
this.as = this.node.getComponent(BossSpine);
// console.log(this.as)
}
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);
// this.node.setSiblingIndex(100)
// 注册单个碰撞体的回调函数
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);
}
}
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.ap);
}
}
}
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());
}
}
}
}
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.game_over||smc.vmdata.game_pause){
return
}
if (this.timer.update(dt)) {
}
this.in_destroy();
this.check_buff_atks(dt)
this.in_shield(dt);
this.in_stop(dt);
this.atk_time += dt;
this.in_atk();
this.move(dt);
this.check_enemy_alive()
}
check_enemy_alive(){
let dir = 320
for (let i = 0; i < GameSet.ATK_LINES; i++) {
let hero:any = smc.hero_pos[i];
let x=Math.abs(hero.x-this.node.position.x)
let y = Math.abs(hero.y-this.node.position.y)
let squaredDistance =x*x+y*y
let distance = Math.sqrt(squaredDistance);
if(distance < dir){
dir = distance
this.enemy = hero
}
}
if(dir < this.atk_dis){
this.is_atking=true
}else{
this.is_atking=false
}
}
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, this.node.position.z);
}
move_to(enemy:Vec3){
// console.log("move to ",enemy);
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(enemy.x-100,enemy.y);
move.node = this.node;
move.speed = this.ospeed;
if(enemy.x < this.node.position.x){
this.node.setScale(-1,1);
}else{
this.node.setScale(1,1);
}
}
shoot(skill_uuid:number,y:number=0,x:number=0){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
let atk = SkillSet[skill_uuid].atk+this.atk+this.buff_atk;
let {pos,t_pos}=this.get_enemy_pos()
pos.y=pos.y + y
pos.x=pos.x + x
skill.load(pos,this.box_group,this.node,skill_uuid,atk,t_pos);
// this.tooltip(3,SkillSet[skill_uuid].name,this.skill_uuid);
}
//使用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}
}
in_atk() {
if(this.atk_time >= this.atk_cd){
// if(this.is_atking&&this.check_enemy_alive()){
// this.atk_time = 0;
// // console.log("atk_cd:"+this.atk_cd);
// this.as.atk();
// this.scheduleOnce(()=>{
// this.shoot(this.skill,-30);
// },0.4)
// }
this.atk_time = 0;
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill,-30);
},0.2)
}
}
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)
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
heathed(){
this.node.getChildByName("heathed").active=true
}
add_hp(hp: number=0){
this.heathed();
this.tooltip(2,hp.toString());
let hp_progress= 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,60)
node.setPosition(pos)
node.parent = this.node;
// this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
// this.scheduleOnce(() => {
// this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
// }, 0.1);
}
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;
// director.pause();
this.node.destroy();
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"2e4e5f05-fb79-401b-9376-7e006b9c8247","files":[],"subMetas":{},"userData":{}}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"d07463ae-fffe-4c3b-af60-c40a1253e9a3","files":[],"subMetas":{},"userData":{}}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"34c56beb-469d-4134-a4bb-e0e79fef03e3","files":[],"subMetas":{},"userData":{}}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"16ff69cd-f95d-4898-acdf-8d53e61e2f89","files":[],"subMetas":{},"userData":{}}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"243e34fa-bcfe-4b88-83c4-bda211a7abaf","files":[],"subMetas":{},"userData":{}}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"880fb02e-7bb2-4ee8-9a8a-f7c161eca401","files":[],"subMetas":{},"userData":{}}

View File

@@ -1,8 +1,25 @@
export const BoxDrop={
1:[
{uuid: 1001,dropRate: 10,num_max: 2},
{uuid: 1002,dropRate: 10,num_max: 2},
{uuid: 9001,dropRate: 10,num_max: 10,type:0},
{uuid: 9002,dropRate: 10,num_max: 10,type:0},
{uuid: 9003,dropRate: 10,num_max: 10,type:0},
],
2:[
{uuid: 9001,dropRate: 10,num_max: 10,type:0},
{uuid: 9002,dropRate: 10,num_max: 10,type:0},
{uuid: 9003,dropRate: 10,num_max: 10,type:0},
],
3:[
{uuid: 9001,dropRate: 10,num_max: 10,type:0},
{uuid: 9002,dropRate: 10,num_max: 10,type:0},
{uuid: 9003,dropRate: 10,num_max: 10,type:0},
],
}
export const BoxDropCount={
1:3,
2:3,
3:3,
}

View File

@@ -6,14 +6,12 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { SkillSet } from "../common/config/SkillSet";
import { HeroModelComp } from "../hero/HeroModelComp";
import { RewardSet } from "../common/config/RewardSet";
import { GameSet } from "../common/config/BoxSet";
import { GameMap } from "./GameMap";
import { MapModelComp } from "./model/MapModelComp";
import { Talent } from "../Role/Talent";
import { Talents } from "../common/config/TalentSet";
import { HeroViewComp } from "../hero/HeroViewComp";
import { BossViewComp } from "../Boss/BossViewComp";
import { Position } from "../../../../extensions/oops-plugin-framework/assets/libs/gui/badge/Badge";
const { ccclass, property } = _decorator;

View File

@@ -1,4 +1,4 @@
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas } from "cc";
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas, Vec3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ItemComp } from "./ItemComp";

View File

@@ -1,8 +1,13 @@
import { _decorator, instantiate, Prefab ,Node, Label, Sprite} from "cc";
import { _decorator, instantiate, Prefab ,Node, Label, Sprite, resources, SpriteAtlas} 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { Item } from "./Item";
import { Items } from "../common/config/Items";
import { HChipComp } from "../hero/HChipComp";
import { BoxDrop } from "../common/config/RewardSet";
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
const { ccclass, property } = _decorator;
@@ -81,28 +86,64 @@ export class LuckHomeCompComp extends CCComp {
}
}
open_sb() {
console.log("open_sb");
smc.items[1001].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
this.get_reward(1)
}, 0.5)
}
open_mb() {
console.log("open_mb");
smc.items[1002].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
this.get_reward(2)
}, 0.5)
}
open_lb() {
console.log("open_lb");
smc.items[1003].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
this.get_reward(3)
}, 0.5)
}
get_reward(reward:number){
let list =BoxDrop[reward];
let chip_uuid= 0
let num =1
let i=0
while (chip_uuid==0) {
for (let x = 0; x < list.length; x++) {
let rate = Math.random()*100
if(rate < list[x].dropRate){
chip_uuid=list[x].uuid;
num =RandomManager.instance.getRandomInt(list[x].num_max/2,list[x].num_max);
break;
}
}
i++;
}
this.show_item(chip_uuid,num)
smc.heros[chip_uuid].num += num
}
show_item(uuid:number,num:number){
let path = "game/gui/hchip";
let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab);
let hc= node.getComponent(HChipComp)
hc.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items");
}, 0.5)
this.scheduleOnce(()=>{
node.destroy();
}, 10)
}
show_bbox() {
var parent = this.node.getChildByName("bbox")
var path = "game/gui/bbox";

View File

@@ -6,17 +6,14 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { MSkillset, MSlist, SkillSet } from "../common/config/SkillSet";
import { HeroModelComp } from "../hero/HeroModelComp";
import { RewardSet } from "../common/config/RewardSet";
import { BoxSet, GameSet } from "../common/config/BoxSet";
import { GameMap } from "./GameMap";
import { MapModelComp } from "./model/MapModelComp";
import { Talent } from "../Role/Talent";
import { Talents } from "../common/config/TalentSet";
import { HeroViewComp } from "../hero/HeroViewComp";
import { BossViewComp } from "../Boss/BossViewComp";
import { Hero } from "../hero/Hero";
import { HeroInfo, HeroSet } from "../common/config/heroSet";
import { Boss } from "../Boss/Boss";
import { MonModelComp } from "../hero/MonModelComp";
import { BossList, MBSet, MissionNum, MissionSet, MonsetList } from "../common/config/MissionSet";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";

View File

@@ -4,7 +4,6 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { BossViewComp } from "../Boss/BossViewComp";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { MissionReward } from "../common/config/MissionSet";
import { Items } from "../common/config/Items";