mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交捕捉
This commit is contained in:
9
JisolGameCocos/assets/script/ui/Consts/Game.meta
Normal file
9
JisolGameCocos/assets/script/ui/Consts/Game.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "a0bd4b57-3c54-4d36-a0b5-20728f53f17b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
54
JisolGameCocos/assets/script/ui/Consts/Game/ModeRender.ts
Normal file
54
JisolGameCocos/assets/script/ui/Consts/Game/ModeRender.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { app } from '../../../App';
|
||||
import GRoleDefault from '../../../battle/base/role/GRoleDefault';
|
||||
import { GData } from '../../../consts/GData';
|
||||
import { v2 } from 'cc';
|
||||
import { Prefab } from 'cc';
|
||||
import { instantiate } from 'cc';
|
||||
import { v3 } from 'cc';
|
||||
import { ModeRenderHitText } from './ModeRenderHitText';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum ModeRenderEvent{
|
||||
//受击
|
||||
HIT = "ModeRenderEvent_HIT"
|
||||
}
|
||||
|
||||
@ccclass('ModeRender')
|
||||
export class ModeRender extends Component {
|
||||
|
||||
//受击预制体
|
||||
@property(Prefab)
|
||||
hitPrefab:Prefab;
|
||||
|
||||
onLoad(){
|
||||
|
||||
app.event.on(ModeRenderEvent.HIT,this.onHit,this);
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
|
||||
app.event.off(ModeRenderEvent.HIT,this.onHit,this);
|
||||
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(role:GRoleDefault,hit:number){
|
||||
|
||||
if(!role.get()) return;
|
||||
|
||||
let rolePos = GData.WorldCanvas.camera.worldToScreen(role.node.worldPosition);
|
||||
|
||||
let hitNode = instantiate(this.hitPrefab);
|
||||
|
||||
this.node.addChild(hitNode);
|
||||
hitNode.position = rolePos.add(v3(0,100,0));
|
||||
|
||||
hitNode.getComponent(ModeRenderHitText).setText(hit);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "00e93335-8301-435f-83b1-b83f29e48e8b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
import { tween } from 'cc';
|
||||
import { v3 } from 'cc';
|
||||
import { Label } from 'cc';
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ModeRenderHitText')
|
||||
export class ModeRenderHitText extends Component {
|
||||
|
||||
@property(Label)
|
||||
hitLabel:Label;
|
||||
|
||||
setText(hit:number){
|
||||
|
||||
this.hitLabel.string = `${hit}`;
|
||||
|
||||
this.setAnimation();
|
||||
|
||||
}
|
||||
|
||||
//设置动画
|
||||
setAnimation(){
|
||||
|
||||
this.node.scale = v3(0,0,0);
|
||||
|
||||
tween(this.node)
|
||||
.to(.5,{position:this.node.position.clone().add(v3(0,100,0)),scale:v3(1,1,1)},{
|
||||
onComplete:() => {
|
||||
this.node.destroy();
|
||||
},
|
||||
easing:"quadInOut"
|
||||
})
|
||||
.start();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fad17282-4ea6-418f-89c6-09bff1b47c62",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
24
JisolGameCocos/assets/script/ui/Consts/Pet/PetIcon.ts
Normal file
24
JisolGameCocos/assets/script/ui/Consts/Pet/PetIcon.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { sp } from 'cc';
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { app } from '../../../App';
|
||||
import { UIPetAnim } from '../../../consts/GData';
|
||||
import { v3 } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PetIcon')
|
||||
export class PetIcon extends Component {
|
||||
|
||||
@property(sp.Skeleton)
|
||||
spine:sp.Skeleton;
|
||||
|
||||
//设置icon
|
||||
setIcon(petTbId:number){
|
||||
|
||||
this.spine.skeletonData = app.battleRes.roleSpine[petTbId];
|
||||
this.spine.setAnimation(0,UIPetAnim.std,true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b380916e-5ab8-41da-8bc4-08376a3133ac",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
62
JisolGameCocos/assets/script/ui/Consts/Pet/PetIconSelect.ts
Normal file
62
JisolGameCocos/assets/script/ui/Consts/Pet/PetIconSelect.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { PetIcon } from './PetIcon';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PetIconSelect')
|
||||
export class PetIconSelect extends Component {
|
||||
|
||||
@property(PetIcon)
|
||||
petIcon:PetIcon;
|
||||
|
||||
//选中节点
|
||||
@property(Node)
|
||||
select:Node;
|
||||
|
||||
//不可选中节点
|
||||
@property(Node)
|
||||
noselect:Node;
|
||||
|
||||
//是否被选中
|
||||
_isSelect:boolean = false;
|
||||
get isSelect(){
|
||||
return this._isSelect;
|
||||
}
|
||||
set isSelect(data:boolean){
|
||||
this._isSelect = data;
|
||||
this.onUpdateSelect();
|
||||
}
|
||||
|
||||
//是否不可选中
|
||||
_isNoSelect:boolean = false;
|
||||
get isNoSelect(){
|
||||
return this._isNoSelect;
|
||||
}
|
||||
set isNoSelect(data:boolean){
|
||||
this._isNoSelect = data;
|
||||
this.onUpdateSelect();
|
||||
}
|
||||
|
||||
onLoad(){
|
||||
this.onUpdateSelect();
|
||||
this.noselect.active = false;
|
||||
this.select.active = false;
|
||||
}
|
||||
|
||||
|
||||
//设置icon
|
||||
setIcon(petTbId:number){
|
||||
|
||||
this.petIcon.setIcon(petTbId);
|
||||
|
||||
}
|
||||
|
||||
onUpdateSelect(){
|
||||
|
||||
this.select.active = this.isSelect;
|
||||
this.noselect.active = this.isNoSelect;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7c6657dc-bcb4-460e-ace3-860bd4238a0d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -24,6 +24,7 @@ export class MainView extends JNGLayerBase {
|
||||
});
|
||||
|
||||
this.onUpdateView();
|
||||
|
||||
}
|
||||
|
||||
//更新UI界面
|
||||
|
9
JisolGameCocos/assets/script/ui/Home/Sreeps.meta
Normal file
9
JisolGameCocos/assets/script/ui/Home/Sreeps.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "45b68a51-740e-4ff5-91b1-ba79c76ede3d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNScrollViewItem from '../../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||
import { GOnHookPet } from '../../../../../extensions/ngame/assets/ngame/message/proto';
|
||||
import { PetIcon } from '../../Consts/Pet/PetIcon';
|
||||
import { PetIconSelect } from '../../Consts/Pet/PetIconSelect';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('MainSreepsIcon')
|
||||
export class MainSreepsIcon extends JNScrollViewItem<GOnHookPet> {
|
||||
|
||||
@property(PetIconSelect)
|
||||
icon:PetIconSelect;
|
||||
|
||||
start(){
|
||||
this.icon.setIcon(this.data.petTbId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "590f92c6-d3f3-4143-9de4-e47a1257257a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNScrollView from '../../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import { app } from '../../../App';
|
||||
import GOnHookManager, { GOnHookManagerEvent } from '../../../manager/battle/mode/GOnHookManager';
|
||||
import { GOnHookPet } from '../../../../../extensions/ngame/assets/ngame/message/proto';
|
||||
import { MainSreepsIcon } from './MainSreepsIcon';
|
||||
import { NodeEventType } from 'cc';
|
||||
import { GUI } from '../../UIConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('MainSreepsList')
|
||||
export class MainSreepsList extends Component {
|
||||
|
||||
//野怪列表
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView;
|
||||
|
||||
//默认选择
|
||||
index:number = 0;
|
||||
|
||||
onLoad(){
|
||||
|
||||
//监听 野怪死亡
|
||||
app.event.on(GOnHookManagerEvent.ADD_KILL_SREEP,this.onAddSreep,this);
|
||||
//监听 野怪删除
|
||||
app.event.on(GOnHookManagerEvent.DEL_KILL_SREEP,this.onDelSreep,this);
|
||||
|
||||
//添加子节点事件
|
||||
this.views.addItemEvent(NodeEventType.TOUCH_END,this.onClickItem.bind(this));
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
|
||||
//取消监听
|
||||
app.event.off(GOnHookManagerEvent.ADD_KILL_SREEP,this.onAddSreep,this);
|
||||
app.event.on(GOnHookManagerEvent.DEL_KILL_SREEP,this.onDelSreep,this);
|
||||
}
|
||||
|
||||
|
||||
//添加野怪
|
||||
onAddSreep(sreep:GOnHookPet){
|
||||
this.views.addData(sreep);
|
||||
}
|
||||
|
||||
//删除野怪
|
||||
onDelSreep(sreep:GOnHookPet){
|
||||
this.views.delData(sreep);
|
||||
}
|
||||
|
||||
//刷新
|
||||
onUpdateView(){
|
||||
|
||||
let items = this.views.getItems<MainSreepsIcon>();
|
||||
|
||||
if(items.length <= 0) return;
|
||||
|
||||
//取消选中
|
||||
items.forEach(item => item.icon.isSelect = false)
|
||||
|
||||
//选中index
|
||||
if(items[this.index]) items[this.index].icon.isSelect = true;
|
||||
|
||||
}
|
||||
|
||||
//点击子节点
|
||||
onClickItem(index:number){
|
||||
|
||||
this.index = index;
|
||||
this.onUpdateView();
|
||||
|
||||
}
|
||||
|
||||
//捕捉野怪
|
||||
async onClickCatch(){
|
||||
|
||||
//获取选中的野怪
|
||||
let item = this.views.getItems<MainSreepsIcon>()[this.index];
|
||||
|
||||
if(!item){
|
||||
app.layer.Open(GUI.Tips,{text:"请选择需要捕捉的宠物"});
|
||||
return;
|
||||
}
|
||||
|
||||
if(await GOnHookManager.getIns().onCatchCreeps(item.data))
|
||||
app.layer.Open(GUI.Tips,{text:"捕捉成功!"});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fe2ad307-ecc6-45e4-a5e0-4782b0bf0257",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,50 +1,17 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNScrollViewItem from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||
import { PlayerPetOV } from '../../consts/API';
|
||||
import { sp } from 'cc';
|
||||
import { app } from '../../App';
|
||||
import { UIPetAnim } from '../../consts/GData';
|
||||
import JNScrollViewItem from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||
import { PetIconSelect } from '../Consts/Pet/PetIconSelect';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('IntoBattlePetIcon')
|
||||
export class IntoBattlePetIcon extends JNScrollViewItem<PlayerPetOV> {
|
||||
|
||||
@property(sp.Skeleton)
|
||||
spine:sp.Skeleton;
|
||||
|
||||
//选中节点
|
||||
@property(Node)
|
||||
select:Node;
|
||||
|
||||
//不可选中节点
|
||||
@property(Node)
|
||||
noselect:Node;
|
||||
|
||||
//是否被选中
|
||||
isSelect:boolean = false;
|
||||
|
||||
//是否不可选中
|
||||
isNoSelect:boolean = false;
|
||||
|
||||
onLoad(){
|
||||
this.onUpdateSelect();
|
||||
this.noselect.active = false;
|
||||
this.select.active = false;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
|
||||
//显示角色
|
||||
this.spine.skeletonData = app.battleRes.roleSpine[this.data.petTbId];
|
||||
this.spine.setAnimation(0,UIPetAnim.std,true);
|
||||
|
||||
}
|
||||
|
||||
onUpdateSelect(){
|
||||
|
||||
this.select.active = this.isSelect;
|
||||
this.noselect.active = this.isNoSelect;
|
||||
@property(PetIconSelect)
|
||||
select:PetIconSelect;
|
||||
|
||||
protected start(): void {
|
||||
this.select.setIcon(this.data.petTbId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7c6657dc-bcb4-460e-ace3-860bd4238a0d",
|
||||
"uuid": "0d7f0c4b-80b2-49fb-baab-f4c7131b9dda",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
|
@@ -21,9 +21,6 @@ export class IntoBattleView extends JNLayerBase {
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView; //宠物列表
|
||||
|
||||
@property(Prefab)
|
||||
petIconPrefab; //宠物Icon预制体
|
||||
|
||||
@property(sp.Skeleton)
|
||||
spine:sp.Skeleton; //当前选中的宠物
|
||||
|
||||
@@ -58,7 +55,7 @@ export class IntoBattleView extends JNLayerBase {
|
||||
//设置不可选中
|
||||
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
|
||||
if(PlayerTacticalData.getIns().getTacticalInfo().indexOf(item.data.petId) != -1)
|
||||
item.isNoSelect = true; //如果在阵法里则不可选中
|
||||
item.select.isNoSelect = true; //如果在阵法里则不可选中
|
||||
})
|
||||
|
||||
//向子节点添加点击事件
|
||||
@@ -73,15 +70,13 @@ export class IntoBattleView extends JNLayerBase {
|
||||
|
||||
//默认都不选中
|
||||
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
|
||||
item.isSelect = false;
|
||||
item.onUpdateSelect();
|
||||
item.select.isSelect = false;
|
||||
})
|
||||
|
||||
//设置选中
|
||||
if(this.index != -1){
|
||||
let current = this.views.getItems<IntoBattlePetIcon>()[this.index]
|
||||
current.isSelect = true;
|
||||
current.onUpdateSelect();
|
||||
current.select.isSelect = true;
|
||||
|
||||
//显示选中宠物
|
||||
this.spine.skeletonData = app.battleRes.roleSpine[this.pets[this.index].petTbId];
|
||||
@@ -94,7 +89,7 @@ export class IntoBattleView extends JNLayerBase {
|
||||
onClickItem(index:number){
|
||||
|
||||
//判断是否不可选中
|
||||
if(this.views.getItems<IntoBattlePetIcon>()[index].isNoSelect) {
|
||||
if(this.views.getItems<IntoBattlePetIcon>()[index].select.isNoSelect) {
|
||||
app.layer.Open(GUI.Tips,{text:"当前宠物已上阵"})
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user