Commit c1a22af1 authored by rockyl's avatar rockyl

curse 模板修改

parent e32a1b1a
...@@ -31,9 +31,5 @@ ...@@ -31,9 +31,5 @@
{ {
"name": "promise" "name": "promise"
} }
], ]
"version": {
"main": "1.0.0",
"build": 588
}
} }
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"target": "this", "target": "this",
"components": [ "components": [
{ {
"script": "components/SceneMenu", "script": "game/components/SceneMenu",
"enabled": true, "enabled": true,
"injection": { "injection": {
"type": "1" "type": "1"
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"target": "badgeChance", "target": "badgeChance",
"components": [ "components": [
{ {
"script": "components/Badge", "script": "game/components/Badge",
"enabled": true, "enabled": true,
"injection": { "injection": {
"name": "chance" "name": "chance"
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
"target": "btnStart", "target": "btnStart",
"components": [ "components": [
{ {
"script": "components/ButtonStart", "script": "game/components/ButtonStart",
"enabled": true, "enabled": true,
"injection": { "injection": {
"type": { "type": {
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
} }
}, },
{ {
"script": "components/BuriedPointButton", "script": "game/components/BuriedPointButton",
"enabled": true, "enabled": true,
"injection": { "injection": {
"dpm": "app_id.202.7.1", "dpm": "app_id.202.7.1",
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
} }
}, },
{ {
"script": "components/Breath", "script": "game/components/Breath",
"injection": { "injection": {
"duration": 3000, "duration": 3000,
"scaleOffset": 0.1 "scaleOffset": 0.1
...@@ -82,14 +82,14 @@ ...@@ -82,14 +82,14 @@
"target": "btnRule", "target": "btnRule",
"components": [ "components": [
{ {
"script": "components/ButtonRule", "script": "game/components/ButtonRule",
"injection": { "injection": {
"type": 2 "type": 2
}, },
"enabled": true "enabled": true
}, },
{ {
"script": "components/BuriedPointButton", "script": "game/components/BuriedPointButton",
"injection": { "injection": {
"dpm": "app_id.202.7.2", "dpm": "app_id.202.7.2",
"dcm": "213.oaid.0.0" "dcm": "213.oaid.0.0"
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
"target": "this", "target": "this",
"components": [ "components": [
{ {
"script": "components/ScenePlay", "script": "game/components/ScenePlay",
"injection": {} "injection": {}
} }
] ]
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
"target": "btnBack", "target": "btnBack",
"components": [ "components": [
{ {
"script": "components/ButtonBack", "script": "game/components/ButtonBack",
"enabled": true "enabled": true
} }
] ]
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
"target": "gameView.labelInGameView", "target": "gameView.labelInGameView",
"components": [ "components": [
{ {
"script": "components/GameViewLabel", "script": "game/components/GameViewLabel",
"enabled": true, "enabled": true,
"injection": {} "injection": {}
} }
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
"target": "this", "target": "this",
"components": [ "components": [
{ {
"script": "components/PanelRule", "script": "game/components/PanelRule",
"injection": { "injection": {
"content": "一个弹窗哟!\\n换行", "content": "一个弹窗哟!\\n换行",
"button": "确定" "button": "确定"
......
...@@ -29,7 +29,7 @@ export class GenerateDependencePlugin implements plugins.Command { ...@@ -29,7 +29,7 @@ export class GenerateDependencePlugin implements plugins.Command {
for (let component of binding.components) { for (let component of binding.components) {
const name = component.script; const name = component.script;
content += `import '../game/${name}'\n`; content += `import '../${name}'\n`;
} }
} }
} }
......
...@@ -3,10 +3,16 @@ ...@@ -3,10 +3,16 @@
*/ */
import lang from "./lang"; import lang from "./lang";
import Toast from "@core/view/Toast";
export function showErrorAlert(e = null, callback?){ export function showErrorAlert(e = null, callback?){
let text = !e || e instanceof Error ? lang.net_error : e; let content = !e || e instanceof Error ? lang.net_error : e;
/*Alert.show(text, function(){
Toast.show({
content
});
/*PanelController.instance.show(PANEL_ALERT, {content}, function(){
if(callback){ if(callback){
callback(); callback();
}else{ }else{
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import {Ajax, EgretUtils} from "@alienlib/tools"; import {Ajax, EgretUtils} from "@alienlib/tools";
const WEB_SERVICE_URL: string = DEBUG ? 'http://localhost:3000' : ''; const WEB_SERVICE_URL: string = DEBUG ? 'https://172.31.51.89:3000' : '';
class WebService { class WebService {
/** /**
......
...@@ -28,7 +28,7 @@ export default class CurseComponent extends egret.HashObject{ ...@@ -28,7 +28,7 @@ export default class CurseComponent extends egret.HashObject{
/** /**
* 初始化 * 初始化
*/ */
protected reset() { protected onCreate() {
} }
......
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
import {Flew} from "@alienlib/popup/PopupEffect"; import {Flew} from "@alienlib/popup/PopupEffect";
import {PopupBase} from "@alienlib/popup/PopupBase"; import {PopupBase} from "@alienlib/popup/PopupBase";
import {awakeView, mountScene, sleepView} from "./Manager"; import {awakeView, mountView, sleepView} from "./Manager";
export default class CursePanel extends PopupBase { export default class CursePanel extends PopupBase {
options: any; options: any;
data: any;
constructor(name, options) { constructor(name, options) {
super( super(
...@@ -28,11 +29,12 @@ export default class CursePanel extends PopupBase { ...@@ -28,11 +29,12 @@ export default class CursePanel extends PopupBase {
protected childrenCreated(): void { protected childrenCreated(): void {
super.childrenCreated(); super.childrenCreated();
mountScene(this, this.name); mountView(this, this.name);
//unmountScene(this, this.name); //unmountScene(this, this.name);
} }
async show(data, callback) { async show(data, callback) {
this.data = data;
this._callback = callback; this._callback = callback;
await this.popup(); await this.popup();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import {NavigatorAction} from "@alienlib/navigator/StackNavigator"; import {NavigatorAction} from "@alienlib/navigator/StackNavigator";
import Scene from "./Scene"; import Scene from "./Scene";
import {awakeView, mountScene, sleepView, unMountView} from "./Manager"; import {awakeView, mountView, setCurrentGroup, sleepView, unMountView} from "./Manager";
export default class CurseScene extends Scene { export default class CurseScene extends Scene {
options: any; options: any;
...@@ -27,6 +27,7 @@ export default class CurseScene extends Scene { ...@@ -27,6 +27,7 @@ export default class CurseScene extends Scene {
} }
async onWillEnter(last: string, action: NavigatorAction, parameters: any): Promise<any> { async onWillEnter(last: string, action: NavigatorAction, parameters: any): Promise<any> {
setCurrentGroup(this.name);
awakeView(this, this.name); awakeView(this, this.name);
return super.onWillEnter(last, action, parameters); return super.onWillEnter(last, action, parameters);
...@@ -51,7 +52,8 @@ export default class CurseScene extends Scene { ...@@ -51,7 +52,8 @@ export default class CurseScene extends Scene {
childrenCreated(): void { childrenCreated(): void {
super.childrenCreated(); super.childrenCreated();
mountScene(this, this.name); setCurrentGroup(this.name);
mountView(this, this.name);
//unmountScene(this, this.name); //unmountScene(this, this.name);
} }
} }
...@@ -8,6 +8,8 @@ const componentDefinitions = {}; ...@@ -8,6 +8,8 @@ const componentDefinitions = {};
const components = []; const components = [];
const bindingsMap = {}; const bindingsMap = {};
let currentGroup;
let bindingConfig: { let bindingConfig: {
name: string, name: string,
skin: string, skin: string,
...@@ -59,10 +61,15 @@ function getBindingByName(name){ ...@@ -59,10 +61,15 @@ function getBindingByName(name){
} }
export function getComponents(host, createWhenNotExist = false) { export function getComponents(host, createWhenNotExist = false) {
let group = bindingsMap[currentGroup];
if(!group){
group = bindingsMap[currentGroup] = {};
}
const key = getHostKey(host); const key = getHostKey(host);
let bindings = bindingsMap[key]; let bindings = group[key];
if (!bindings && createWhenNotExist) { if (!bindings && createWhenNotExist) {
bindings = bindingsMap[key] = []; bindings = group[key] = [];
} }
return bindings; return bindings;
...@@ -71,10 +78,12 @@ export function getComponents(host, createWhenNotExist = false) { ...@@ -71,10 +78,12 @@ export function getComponents(host, createWhenNotExist = false) {
export function getComponent(host, nameOrDef){ export function getComponent(host, nameOrDef){
let target; let target;
const components = getComponents(host); const components = getComponents(host);
for(let component of components){ if(components){
if(components['__class__'] == nameOrDef || component instanceof nameOrDef){ for(let component of components){
target = component; if(components['__class__'] == nameOrDef || component instanceof nameOrDef){
break; target = component;
break;
}
} }
} }
...@@ -83,12 +92,23 @@ export function getComponent(host, nameOrDef){ ...@@ -83,12 +92,23 @@ export function getComponent(host, nameOrDef){
function transData(data){ function transData(data){
for(let key in data){ for(let key in data){
const child = data[key]; let child = data[key];
const type = typeof child; const type = typeof child;
if(type == 'object'){ if(type == 'object'){
transData(child); transData(child);
}else if(type == 'string'){ }else if(type == 'string'){
data[key] = child.replace(/\\n/g, '\n'); child = child.replace(/\\n/g, '\n');
if(child.indexOf('${') >= 0){
const result = child.match(/\${[.|\w]+}/g);
if(result){
for(let item of result){
const code = item.substr(2, item.length - 3);
const ret = devil(code);
child = child.replace(item, ret);
}
}
}
data[key] = child;
} }
} }
} }
...@@ -156,7 +176,11 @@ function forEachBindings(sceneView, name, func) { ...@@ -156,7 +176,11 @@ function forEachBindings(sceneView, name, func) {
} }
} }
export function mountScene(sceneView, name) { export function setCurrentGroup(name){
currentGroup = name;
}
export function mountView(sceneView, name) {
forEachBindings(sceneView, name, function (targetView, binding) { forEachBindings(sceneView, name, function (targetView, binding) {
for (let component of binding.components) { for (let component of binding.components) {
const {script, injection, enabled} = component; const {script, injection, enabled} = component;
...@@ -168,7 +192,7 @@ export function mountScene(sceneView, name) { ...@@ -168,7 +192,7 @@ export function mountScene(sceneView, name) {
if (instance) { if (instance) {
bindComponent(targetView, instance, injection); bindComponent(targetView, instance, injection);
instance.reset(); instance.onCreate();
} else { } else {
console.warn('script is not exist:', name); console.warn('script is not exist:', name);
} }
...@@ -203,3 +227,20 @@ export function sleepView(view, name) { ...@@ -203,3 +227,20 @@ export function sleepView(view, name) {
} }
}); });
} }
export function broadcast(method, ...params){
let group = bindingsMap[currentGroup];
if(!group){
return;
}
for(let key in group){
const bindings = group[key];
for(let binding of bindings){
const m: any = binding[method];
if(m){
m.apply(binding, params);
}
}
}
}
...@@ -50,12 +50,21 @@ export default class PanelController { ...@@ -50,12 +50,21 @@ export default class PanelController {
return instance; return instance;
} }
dealAction(name, action?, data?){
let instance: CursePanel = this._instanceMap[name];
if(!instance){
return ;
}
instance.dealAction(action, data)
}
close(name){ close(name){
let instance: CursePanel = this._instanceMap[name]; let instance: CursePanel = this._instanceMap[name];
if(!instance){ if(!instance){
return ; return ;
} }
instance.close(); instance.close()
} }
} }
...@@ -39,7 +39,7 @@ export default class Toast extends VisualEventComponent { ...@@ -39,7 +39,7 @@ export default class Toast extends VisualEventComponent {
if(data && this._queue.length == 0 && !this._tween){ if(data && this._queue.length == 0 && !this._tween){
this._queue.push(data); this._queue.push(data);
} }
else if(data && this._queue.length > 0 && data.text != this._queue[this._queue.length-1].text){ else if(data && this._queue.length > 0 && data.content != this._queue[this._queue.length-1].text){
this._queue.push(data); this._queue.push(data);
} }
...@@ -49,9 +49,9 @@ export default class Toast extends VisualEventComponent { ...@@ -49,9 +49,9 @@ export default class Toast extends VisualEventComponent {
let item = this._queue.shift(); let item = this._queue.shift();
let {text, color = 0xfff1d3, duration = 1000} = item; let {content, color = 0xfff1d3, duration = 1000} = item;
this.labContent.text = text; this.labContent.text = content;
this.labContent.textColor = color; this.labContent.textColor = color;
this._tween = egret.Tween.get(this.grp, null, null, true) this._tween = egret.Tween.get(this.grp, null, null, true)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* 角标 * 角标
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import badgeService from "../services/BadgeService"; import badgeService from "../services/BadgeService";
import {BADGE_CHANGED} from "../model/events"; import {BADGE_CHANGED} from "../model/events";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by rockyl on 2018/10/10. * Created by rockyl on 2018/10/10.
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import {breath, Wave} from "@alienlib/animation/wave"; import {breath, Wave} from "@alienlib/animation/wave";
import {anchorCenter} from "@alienlib/tools/Utils"; import {anchorCenter} from "@alienlib/tools/Utils";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by rockyl on 2018/10/10. * Created by rockyl on 2018/10/10.
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import buriedPointService from "../services/BuriedPointService"; import buriedPointService from "../services/BuriedPointService";
export default class BuriedPointButton extends CurseComponent { export default class BuriedPointButton extends CurseComponent {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* Created by rockyl on 2018/10/10. * Created by rockyl on 2018/10/10.
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import SceneController from "../../core/view/SceneController"; import SceneController from "@core/view/SceneController";
export default class ButtonBack extends CurseComponent{ export default class ButtonBack extends CurseComponent{
type: number; type: number;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* Created by rockyl on 2018/10/10. * Created by rockyl on 2018/10/10.
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import PanelController from "@core/view/PanelController";
import {PANEL_RULE} from "../model/constants"; import {PANEL_RULE} from "../model/constants";
import PanelController from "../../core/view/PanelController";
export default class ButtonRule extends CurseComponent{ export default class ButtonRule extends CurseComponent{
type: number; type: number;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* Created by rockyl on 2018/10/10. * Created by rockyl on 2018/10/10.
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import SceneController from "@core/view/SceneController";
import {SCENE_PLAY} from "../model/constants"; import {SCENE_PLAY} from "../model/constants";
import SceneController from "../../core/view/SceneController";
export default class ButtonStart extends CurseComponent{ export default class ButtonStart extends CurseComponent{
type: number; type: number;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
export default class GameViewLabel extends CurseComponent { export default class GameViewLabel extends CurseComponent {
protected reset() { protected reset() {
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* 规则弹窗 * 规则弹窗
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import PanelController from "@core/view/PanelController";
import {PANEL_RULE} from "../model/constants"; import {PANEL_RULE} from "../model/constants";
import PanelController from "../../core/view/PanelController";
export default class PanelRule extends CurseComponent { export default class PanelRule extends CurseComponent {
content: string; content: string;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by rockyl on 2018/10/10. * Created by rockyl on 2018/10/10.
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import {sin, Wave} from "@alienlib/animation/wave"; import {sin, Wave} from "@alienlib/animation/wave";
import {delayLoad} from "../Utils"; import {delayLoad} from "../Utils";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by rockyl on 2018/10/10. * Created by rockyl on 2018/10/10.
*/ */
import CurseComponent from "../../core/curse/CurseComponent"; import CurseComponent from "@core/curse/CurseComponent";
import {delayLoad} from "../Utils"; import {delayLoad} from "../Utils";
import defenseService from "../services/DefenseService"; import defenseService from "../services/DefenseService";
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
], ],
"baseUrl": "./", "baseUrl": "./",
"paths": { "paths": {
"@alienlib/*": ["/Users/rockyl/WorkSpaces/alienlib/src/*"] "@alienlib/*": ["/Users/rockyl/WorkSpaces/alienlib/src/*"],
"@core/*": ["src/core/*"]
} }
}, },
"exclude": [ "exclude": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment