Commit c1a22af1 authored by rockyl's avatar rockyl

curse 模板修改

parent e32a1b1a
......@@ -31,9 +31,5 @@
{
"name": "promise"
}
],
"version": {
"main": "1.0.0",
"build": 588
}
]
}
\ No newline at end of file
......@@ -25,7 +25,7 @@
"target": "this",
"components": [
{
"script": "components/SceneMenu",
"script": "game/components/SceneMenu",
"enabled": true,
"injection": {
"type": "1"
......@@ -37,7 +37,7 @@
"target": "badgeChance",
"components": [
{
"script": "components/Badge",
"script": "game/components/Badge",
"enabled": true,
"injection": {
"name": "chance"
......@@ -49,7 +49,7 @@
"target": "btnStart",
"components": [
{
"script": "components/ButtonStart",
"script": "game/components/ButtonStart",
"enabled": true,
"injection": {
"type": {
......@@ -61,7 +61,7 @@
}
},
{
"script": "components/BuriedPointButton",
"script": "game/components/BuriedPointButton",
"enabled": true,
"injection": {
"dpm": "app_id.202.7.1",
......@@ -69,7 +69,7 @@
}
},
{
"script": "components/Breath",
"script": "game/components/Breath",
"injection": {
"duration": 3000,
"scaleOffset": 0.1
......@@ -82,14 +82,14 @@
"target": "btnRule",
"components": [
{
"script": "components/ButtonRule",
"script": "game/components/ButtonRule",
"injection": {
"type": 2
},
"enabled": true
},
{
"script": "components/BuriedPointButton",
"script": "game/components/BuriedPointButton",
"injection": {
"dpm": "app_id.202.7.2",
"dcm": "213.oaid.0.0"
......@@ -110,7 +110,7 @@
"target": "this",
"components": [
{
"script": "components/ScenePlay",
"script": "game/components/ScenePlay",
"injection": {}
}
]
......@@ -119,7 +119,7 @@
"target": "btnBack",
"components": [
{
"script": "components/ButtonBack",
"script": "game/components/ButtonBack",
"enabled": true
}
]
......@@ -128,7 +128,7 @@
"target": "gameView.labelInGameView",
"components": [
{
"script": "components/GameViewLabel",
"script": "game/components/GameViewLabel",
"enabled": true,
"injection": {}
}
......@@ -146,7 +146,7 @@
"target": "this",
"components": [
{
"script": "components/PanelRule",
"script": "game/components/PanelRule",
"injection": {
"content": "一个弹窗哟!\\n换行",
"button": "确定"
......
......@@ -29,7 +29,7 @@ export class GenerateDependencePlugin implements plugins.Command {
for (let component of binding.components) {
const name = component.script;
content += `import '../game/${name}'\n`;
content += `import '../${name}'\n`;
}
}
}
......
......@@ -3,10 +3,16 @@
*/
import lang from "./lang";
import Toast from "@core/view/Toast";
export function showErrorAlert(e = null, callback?){
let text = !e || e instanceof Error ? lang.net_error : e;
/*Alert.show(text, function(){
let content = !e || e instanceof Error ? lang.net_error : e;
Toast.show({
content
});
/*PanelController.instance.show(PANEL_ALERT, {content}, function(){
if(callback){
callback();
}else{
......
......@@ -6,7 +6,7 @@
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 {
/**
......
......@@ -28,7 +28,7 @@ export default class CurseComponent extends egret.HashObject{
/**
* 初始化
*/
protected reset() {
protected onCreate() {
}
......
......@@ -6,10 +6,11 @@
import {Flew} from "@alienlib/popup/PopupEffect";
import {PopupBase} from "@alienlib/popup/PopupBase";
import {awakeView, mountScene, sleepView} from "./Manager";
import {awakeView, mountView, sleepView} from "./Manager";
export default class CursePanel extends PopupBase {
options: any;
data: any;
constructor(name, options) {
super(
......@@ -28,11 +29,12 @@ export default class CursePanel extends PopupBase {
protected childrenCreated(): void {
super.childrenCreated();
mountScene(this, this.name);
mountView(this, this.name);
//unmountScene(this, this.name);
}
async show(data, callback) {
this.data = data;
this._callback = callback;
await this.popup();
......
......@@ -6,7 +6,7 @@
import {NavigatorAction} from "@alienlib/navigator/StackNavigator";
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 {
options: any;
......@@ -27,6 +27,7 @@ export default class CurseScene extends Scene {
}
async onWillEnter(last: string, action: NavigatorAction, parameters: any): Promise<any> {
setCurrentGroup(this.name);
awakeView(this, this.name);
return super.onWillEnter(last, action, parameters);
......@@ -51,7 +52,8 @@ export default class CurseScene extends Scene {
childrenCreated(): void {
super.childrenCreated();
mountScene(this, this.name);
setCurrentGroup(this.name);
mountView(this, this.name);
//unmountScene(this, this.name);
}
}
......@@ -8,6 +8,8 @@ const componentDefinitions = {};
const components = [];
const bindingsMap = {};
let currentGroup;
let bindingConfig: {
name: string,
skin: string,
......@@ -59,10 +61,15 @@ function getBindingByName(name){
}
export function getComponents(host, createWhenNotExist = false) {
let group = bindingsMap[currentGroup];
if(!group){
group = bindingsMap[currentGroup] = {};
}
const key = getHostKey(host);
let bindings = bindingsMap[key];
let bindings = group[key];
if (!bindings && createWhenNotExist) {
bindings = bindingsMap[key] = [];
bindings = group[key] = [];
}
return bindings;
......@@ -71,10 +78,12 @@ export function getComponents(host, createWhenNotExist = false) {
export function getComponent(host, nameOrDef){
let target;
const components = getComponents(host);
for(let component of components){
if(components['__class__'] == nameOrDef || component instanceof nameOrDef){
target = component;
break;
if(components){
for(let component of components){
if(components['__class__'] == nameOrDef || component instanceof nameOrDef){
target = component;
break;
}
}
}
......@@ -83,12 +92,23 @@ export function getComponent(host, nameOrDef){
function transData(data){
for(let key in data){
const child = data[key];
let child = data[key];
const type = typeof child;
if(type == 'object'){
transData(child);
}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) {
}
}
export function mountScene(sceneView, name) {
export function setCurrentGroup(name){
currentGroup = name;
}
export function mountView(sceneView, name) {
forEachBindings(sceneView, name, function (targetView, binding) {
for (let component of binding.components) {
const {script, injection, enabled} = component;
......@@ -168,7 +192,7 @@ export function mountScene(sceneView, name) {
if (instance) {
bindComponent(targetView, instance, injection);
instance.reset();
instance.onCreate();
} else {
console.warn('script is not exist:', 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 {
return instance;
}
dealAction(name, action?, data?){
let instance: CursePanel = this._instanceMap[name];
if(!instance){
return ;
}
instance.dealAction(action, data)
}
close(name){
let instance: CursePanel = this._instanceMap[name];
if(!instance){
return ;
}
instance.close();
instance.close()
}
}
......@@ -39,7 +39,7 @@ export default class Toast extends VisualEventComponent {
if(data && this._queue.length == 0 && !this._tween){
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);
}
......@@ -49,9 +49,9 @@ export default class Toast extends VisualEventComponent {
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._tween = egret.Tween.get(this.grp, null, null, true)
......
......@@ -4,7 +4,7 @@
* 角标
*/
import CurseComponent from "../../core/curse/CurseComponent";
import CurseComponent from "@core/curse/CurseComponent";
import badgeService from "../services/BadgeService";
import {BADGE_CHANGED} from "../model/events";
......
......@@ -2,7 +2,7 @@
* 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 {anchorCenter} from "@alienlib/tools/Utils";
......
......@@ -2,7 +2,7 @@
* Created by rockyl on 2018/10/10.
*/
import CurseComponent from "../../core/curse/CurseComponent";
import CurseComponent from "@core/curse/CurseComponent";
import buriedPointService from "../services/BuriedPointService";
export default class BuriedPointButton extends CurseComponent {
......
......@@ -2,8 +2,8 @@
* Created by rockyl on 2018/10/10.
*/
import CurseComponent from "../../core/curse/CurseComponent";
import SceneController from "../../core/view/SceneController";
import CurseComponent from "@core/curse/CurseComponent";
import SceneController from "@core/view/SceneController";
export default class ButtonBack extends CurseComponent{
type: number;
......
......@@ -2,9 +2,9 @@
* 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 PanelController from "../../core/view/PanelController";
export default class ButtonRule extends CurseComponent{
type: number;
......
......@@ -2,9 +2,9 @@
* 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 SceneController from "../../core/view/SceneController";
export default class ButtonStart extends CurseComponent{
type: number;
......
......@@ -4,7 +4,7 @@
*
*/
import CurseComponent from "../../core/curse/CurseComponent";
import CurseComponent from "@core/curse/CurseComponent";
export default class GameViewLabel extends CurseComponent {
protected reset() {
......
......@@ -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 PanelController from "../../core/view/PanelController";
export default class PanelRule extends CurseComponent {
content: string;
......
......@@ -2,7 +2,7 @@
* 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 {delayLoad} from "../Utils";
......
......@@ -2,7 +2,7 @@
* Created by rockyl on 2018/10/10.
*/
import CurseComponent from "../../core/curse/CurseComponent";
import CurseComponent from "@core/curse/CurseComponent";
import {delayLoad} from "../Utils";
import defenseService from "../services/DefenseService";
......
......@@ -15,7 +15,8 @@
],
"baseUrl": "./",
"paths": {
"@alienlib/*": ["/Users/rockyl/WorkSpaces/alienlib/src/*"]
"@alienlib/*": ["/Users/rockyl/WorkSpaces/alienlib/src/*"],
"@core/*": ["src/core/*"]
}
},
"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