[add] first
This commit is contained in:
40
assets/scripts/logic/ui/jump-points.ts
Normal file
40
assets/scripts/logic/ui/jump-points.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { _decorator, Component, Node, Label, math } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('JumpPoints')
|
||||
export class JumpPoints extends Component {
|
||||
|
||||
label: Label | null | undefined;
|
||||
real_points = 0;
|
||||
cur_points = 0;
|
||||
|
||||
speed = 0;
|
||||
a = 1;
|
||||
|
||||
str: string = '';
|
||||
|
||||
onEnable () {
|
||||
this.label = this.node.getComponent(Label);
|
||||
if (this.label === null) {
|
||||
throw new Error(`Jump Points not get component Label.`);
|
||||
}
|
||||
this.node.on('set_points', (points: number, str: string = 's') => {
|
||||
this.str = str;
|
||||
this.cur_points = 0;
|
||||
this.real_points = points;
|
||||
this.speed = 0;
|
||||
this.a = 1;
|
||||
})
|
||||
}
|
||||
update (deltaTime: number) {
|
||||
|
||||
if (this.cur_points < this.real_points) {
|
||||
this.speed += this.a;
|
||||
this.cur_points += deltaTime * this.speed;
|
||||
if (this.cur_points > this.real_points) this.cur_points = this.real_points;
|
||||
var show_num = Math.ceil(this.cur_points);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
9
assets/scripts/logic/ui/jump-points.ts.meta
Normal file
9
assets/scripts/logic/ui/jump-points.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "4af39096-6a78-4614-bff1-7ffef22a3d0a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
35
assets/scripts/logic/ui/ui-aim-range.ts
Normal file
35
assets/scripts/logic/ui/ui-aim-range.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { _decorator, Component, Node, SpriteComponent, v3 } from 'cc';
|
||||
import { Msg } from '../../core/msg/msg';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UIAimRange')
|
||||
export class UIAimRange extends Component {
|
||||
|
||||
sprite:SpriteComponent | undefined | null;
|
||||
|
||||
dirs = [[1,0],[0,1],[-1,0],[0,-1]];
|
||||
|
||||
baseSize = 40;
|
||||
|
||||
start() {
|
||||
this.sprite = this.getComponent(SpriteComponent);
|
||||
|
||||
if (this.sprite === undefined) {
|
||||
throw new Error(`${this.node.name} node UIAimRange can not find sprite component.`);
|
||||
}
|
||||
|
||||
Msg.bind('msg_update_aim', this.updateAim, this);
|
||||
this.updateAim(0);
|
||||
}
|
||||
|
||||
updateAim(size:number) {
|
||||
const currentSize = size * this.baseSize;
|
||||
for(let i = 0; i < this.node.children.length; i++) {
|
||||
const child = this.node.children[i];
|
||||
const dir = this.dirs[i];
|
||||
child.setPosition(dir[0] * currentSize, dir[1] * currentSize, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
9
assets/scripts/logic/ui/ui-aim-range.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-aim-range.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "67693545-3c76-49c6-8ce6-74255a871a54",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
23
assets/scripts/logic/ui/ui-animation.ts
Normal file
23
assets/scripts/logic/ui/ui-animation.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { _decorator, Component, Node, animation } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UIAnimation')
|
||||
export class ui_animation extends Component {
|
||||
|
||||
_graph: animation.AnimationController | undefined | null;
|
||||
|
||||
onEnable () {
|
||||
this._graph = this.getComponent(animation.AnimationController);
|
||||
|
||||
if (this._graph === null) {
|
||||
throw new Error(`${this.node.name} node can not find AnimationController.`);
|
||||
}
|
||||
|
||||
this.node.on('set_anim', this.play, this);
|
||||
}
|
||||
|
||||
play (key: string, value: boolean | number) {
|
||||
this._graph!.setValue(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
9
assets/scripts/logic/ui/ui-animation.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-animation.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "351ec0c1-3f44-4c1e-b1b3-d71cebaf4a0a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
33
assets/scripts/logic/ui/ui-fx.ts
Normal file
33
assets/scripts/logic/ui/ui-fx.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { Msg } from '../../core/msg/msg';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UIFx')
|
||||
export class UIFx extends Component {
|
||||
|
||||
map:Record<string, Node> = {};
|
||||
|
||||
start() {
|
||||
|
||||
for(let i = 0; i < this.node.children.length; i++) {
|
||||
const child = this.node.children[i];
|
||||
this.map[child.name] = child;
|
||||
}
|
||||
|
||||
Msg.on('msg_ui_fx_open', this.open.bind(this));
|
||||
Msg.on('msg_ui_fx_close', this.close.bind(this));
|
||||
|
||||
}
|
||||
|
||||
open(name:string) {
|
||||
const effect = this.map[name];
|
||||
if(effect !== undefined) effect.active = true;
|
||||
}
|
||||
|
||||
close(name:string) {
|
||||
const effect = this.map[name];
|
||||
if(effect !== undefined) effect.active = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
9
assets/scripts/logic/ui/ui-fx.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-fx.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "6223e63a-047e-47ae-8e59-2ee0a82643b0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
67
assets/scripts/logic/ui/ui-grp-picked-tips.ts
Normal file
67
assets/scripts/logic/ui/ui-grp-picked-tips.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
// import { _decorator, Node, Label, game } from 'cc';
|
||||
// import { Game } from '../../core/data/game';
|
||||
// import { Local } from '../../core/local/local';
|
||||
// import { Msg } from '../../core/msg/msg';
|
||||
// import { Res } from '../../core/res/res';
|
||||
// import { UICom } from '../../core/ui/ui-base';
|
||||
// import { Queue } from '../../core/util/data-structure';
|
||||
|
||||
// export class GrpPickedTips extends UICom {
|
||||
|
||||
// list:Array<GrpPickedTipsItem>;
|
||||
// msgs:Queue<MsgPicked>;
|
||||
|
||||
// index = 0;
|
||||
|
||||
// constructor (node:Node) {
|
||||
// super(node);
|
||||
// // Init deep default 10.
|
||||
// const count = DataGameInst._data.count_picked_info;
|
||||
|
||||
// this.list = new Array<GrpPickedTipsItem>(count);
|
||||
|
||||
// this.msgs = new Queue(count);
|
||||
|
||||
// const item = this._node.children[0];
|
||||
|
||||
// this.list[0] = new GrpPickedTipsItem(item);
|
||||
|
||||
// for(let i = 1; i < count; i++) {
|
||||
// const newItem = Res.instNode(item, this._node);
|
||||
// this.list[i] = new GrpPickedTipsItem(newItem);
|
||||
// this.list[i].setDisplay(false);
|
||||
// }
|
||||
|
||||
// Msg.on('msg_picked', (info:MsgPicked)=>{
|
||||
// this._node.children[0].setSiblingIndex(count);
|
||||
// this.list[this.index].refresh(info);
|
||||
// })
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// interface MsgPicked {
|
||||
// name:string,
|
||||
// num:number,
|
||||
// time:number,
|
||||
// }
|
||||
|
||||
// class GrpPickedTipsItem {
|
||||
|
||||
// txt_info:Label;
|
||||
// _node:Node;
|
||||
|
||||
// constructor(node:Node) {
|
||||
// this._node = node;
|
||||
// }
|
||||
|
||||
// refresh(info:MsgPicked) {
|
||||
// this.txt_info.string = `${Local.Instance.get('picked')} ${info.name} x${info.num}`;
|
||||
// this.setDisplay(true);
|
||||
// }
|
||||
|
||||
// setDisplay(isShow:boolean) {
|
||||
// this._node.emit('setDisplay', isShow ? 255 : 0);
|
||||
// }
|
||||
|
||||
// }
|
||||
9
assets/scripts/logic/ui/ui-grp-picked-tips.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-grp-picked-tips.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c341fd59-62e6-4720-8db1-874ea8793b6e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
26
assets/scripts/logic/ui/ui-guide-platform.ts
Normal file
26
assets/scripts/logic/ui/ui-guide-platform.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { _decorator, Component, Node, Sprite, SpriteFrame, sys } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UIGuidePlatform')
|
||||
export class UIGuidePlatform extends Component {
|
||||
|
||||
@property( { type:[SpriteFrame] } )
|
||||
guideSprites:SpriteFrame[] = [];
|
||||
|
||||
@property( { type : Sprite } )
|
||||
sprite:Sprite | undefined;
|
||||
|
||||
start() {
|
||||
|
||||
if(sys.platform === sys.Platform.MOBILE_BROWSER ||
|
||||
sys.platform === sys.Platform.ANDROID ||
|
||||
sys.platform === sys.Platform.IOS ) {
|
||||
this.sprite!.spriteFrame = this.guideSprites[1];
|
||||
}else {
|
||||
this.sprite!.spriteFrame = this.guideSprites[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
9
assets/scripts/logic/ui/ui-guide-platform.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-guide-platform.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "afcf262c-a78b-42e1-b72d-c911b5cb6ddd",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
112
assets/scripts/logic/ui/ui-loading.ts
Normal file
112
assets/scripts/logic/ui/ui-loading.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
Copyright (c) 2020-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { _decorator, Component, Node, Label, math, Sprite } from 'cc';
|
||||
import { Msg } from '../../core/msg/msg';
|
||||
import { Game } from '../data/game';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UILoading')
|
||||
export class UILoading extends Component {
|
||||
|
||||
@property(Label)
|
||||
txtLoading: Label | undefined;
|
||||
|
||||
@property(Sprite)
|
||||
img_loading_bar: Sprite | undefined;
|
||||
|
||||
_percent = 0;
|
||||
_realPercent = 0;
|
||||
waitList: Record<number, ILoadMsg> = {};
|
||||
viewNode: Node | undefined;
|
||||
|
||||
count = 0;
|
||||
wait_count = 0;
|
||||
current_msg = '';
|
||||
|
||||
isLoading = false;
|
||||
|
||||
start () {
|
||||
Msg.on('msg_loading', this.onWaitList.bind(this));
|
||||
this.viewNode = this.node.children[0];
|
||||
}
|
||||
|
||||
onWaitList (data: ILoadMsg) {
|
||||
this.waitList[data.id] = data;
|
||||
this.isLoading = true;
|
||||
this.viewNode!.active = true;
|
||||
this._percent = 0;
|
||||
}
|
||||
|
||||
update (deltaTime: number) {
|
||||
|
||||
if (!this.isLoading) return;
|
||||
|
||||
this.calculateLoading();
|
||||
this._percent = math.lerp(this._percent, this._realPercent, deltaTime);
|
||||
this.txtLoading!.string = this.current_msg;
|
||||
this.img_loading_bar!.fillRange = this._percent;
|
||||
|
||||
if (this._percent >= 0.9999) {
|
||||
this.onLoadFinished();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onLoadFinished () {
|
||||
this.isLoading = false;
|
||||
this.viewNode!.active = false;
|
||||
|
||||
// If current is menu replay animation.
|
||||
if (Game.Instance._currentGameNodeName === 'menu')
|
||||
Msg.emit('msg_play_animation');
|
||||
|
||||
}
|
||||
|
||||
calculateLoading () {
|
||||
this.count = 0;
|
||||
this.wait_count = 0;
|
||||
//this.current_msg = '';
|
||||
for (let k in this.waitList) {
|
||||
const waitMsg = this.waitList[k];
|
||||
this.count += waitMsg.count;
|
||||
this.wait_count += waitMsg.wait_count;
|
||||
/*
|
||||
if (this.wait_count > 0) {
|
||||
this.current_msg = `${waitMsg.action} ${waitMsg.current}`;
|
||||
}
|
||||
*/
|
||||
}
|
||||
this._realPercent = (this.count - this.wait_count) / this.count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface ILoadMsg {
|
||||
id: number,
|
||||
action: string,
|
||||
current: string,
|
||||
wait_count: number,
|
||||
count: number,
|
||||
}
|
||||
9
assets/scripts/logic/ui/ui-loading.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-loading.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ece98152-8d22-40b2-9f5a-7536da63b78a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
73
assets/scripts/logic/ui/ui-move-show.ts
Normal file
73
assets/scripts/logic/ui/ui-move-show.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { _decorator, Component, input, Input, EventMouse, SpriteComponent, Color, Button, EventTouch } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UIMoveShow')
|
||||
export class UIMoveShow extends Component {
|
||||
|
||||
@property
|
||||
hiddenTime:number = 1;
|
||||
|
||||
@property
|
||||
showSpeed:number = 0.3;
|
||||
|
||||
@property
|
||||
hiddenSpeed:number = 0.3;
|
||||
|
||||
_curTime = 0;
|
||||
|
||||
_sprite:SpriteComponent | undefined | null;
|
||||
|
||||
_color:Color = new Color(255, 255, 255, 0);
|
||||
|
||||
_a:number = 0;
|
||||
|
||||
_btn:Button | undefined | null;
|
||||
|
||||
start() {
|
||||
|
||||
input.on(Input.EventType.MOUSE_MOVE, this.onMouseMove, this);
|
||||
input.on(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||
|
||||
this._sprite = this.getComponent(SpriteComponent);
|
||||
this._sprite!.color = this._color;
|
||||
this._curTime = this.hiddenTime;
|
||||
this._btn = this.getComponent(Button);
|
||||
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
input.off(Input.EventType.MOUSE_MOVE, this.onMouseMove, this);
|
||||
input.off(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||
}
|
||||
|
||||
onMouseMove(event: EventMouse) {
|
||||
this._curTime = 0;
|
||||
}
|
||||
|
||||
onTouchMove(event: EventTouch) {
|
||||
this._curTime = 0;
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
this._curTime += deltaTime;
|
||||
|
||||
if (this._curTime > this.hiddenTime) {
|
||||
if (this._color.a > 0) {
|
||||
var delta = deltaTime * this.hiddenSpeed;
|
||||
this._color.a -= delta;
|
||||
this._sprite!.color = this._color.clone();
|
||||
this._btn!.enabled = false;
|
||||
}
|
||||
}else{
|
||||
if (this._color.a < 255) {
|
||||
var delta = deltaTime * this.showSpeed;
|
||||
this._color.a += delta;
|
||||
this._sprite!.color = this._color.clone();
|
||||
this._btn!.enabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
9
assets/scripts/logic/ui/ui-move-show.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-move-show.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d9580fb9-fb09-498f-b4bd-46d5b36066b8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
22
assets/scripts/logic/ui/ui-svc-reset-pos.ts
Normal file
22
assets/scripts/logic/ui/ui-svc-reset-pos.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { _decorator, Component, Node, UITransform, Layout } from 'cc';
|
||||
import { fun } from '../../core/util/fun';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UIScrollViewResetPos')
|
||||
export class UIScrollViewResetPos extends Component {
|
||||
|
||||
@property
|
||||
delay = 0.3;
|
||||
|
||||
onEnable() {
|
||||
fun.delay(()=>{
|
||||
//var reset_pos = this.node.position.y;
|
||||
|
||||
//this.node.setPosition(0, reset_pos, 0);
|
||||
var layout = this.node.getComponent(Layout);
|
||||
layout.enabled = false;
|
||||
layout.enabled = true;
|
||||
},this.delay);
|
||||
}
|
||||
}
|
||||
|
||||
9
assets/scripts/logic/ui/ui-svc-reset-pos.ts.meta
Normal file
9
assets/scripts/logic/ui/ui-svc-reset-pos.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b37d047d-95e9-4f92-8be8-9d24e427fc31",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user