Commit 4390c20f authored by wildfirecode's avatar wildfirecode

1

parent 6f9b43fa
No preview for this file type
{"currentScene":"assets/scenes/main.scene"}
\ No newline at end of file
# shuijf # 环境
## manifest.json - scilla editor v0.0.30
- fps改成63,提升fps # 步骤
- 使用fixedWidth - 使用v0.0.30的create模板hello-scilla
- webServiceUrl - 使用scilla editor 打开
- preview上的虫子按钮编译
- 运行成功
# livereload
- index.html 增加
```js
<script>
document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] +
':35729/livereload.js?snipver=1"></' + 'script>')
</script>
```
- sudo npm install -g livereload
- livereload ./debug
# mock
- npm run mock
# 配置
- "scaleMode": "fixedWidth",
- "webServiceUrl": "http://localhost:4001"
- dataCenterConfig - dataCenterConfig
## loading.gif # 流程
- main controller
- webservice,SampleApi,SamplePollingApi
- toast
- net和data
- scene&popup
## # 日报
\ No newline at end of file - 5.28 跑新的demo,运行成功
- 5.28
# 换皮
- 换皮可能会超级麻烦
# 可以优化的点
- 分离单个UI配置文件,方便复制
- editor内即时刷新组件属性
- http://localhost:52751/ port能固定不
- 改了图要退出editor才会刷新
- 筛选图的方法
# 优先级
1.增加编译的快捷键
2.方便换皮
# todo
- 排行榜
\ No newline at end of file
No preview for this file type
{"ver":"1.0.1","uuid":"6b4347e6-fc1a-47aa-94b1-0a88302437bd","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"e22b4566-ecdf-47e4-9620-36f1964733b7","subMetas":{},"isGroup":true}
{ {
"name": "i1", "name": "BallItem",
"root": { "root": {
"uuid": "20190301114308", "uuid": "20190301114308",
"components": [ "components": [
{ {
"script": "components/base/Transform" "script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
} }
], ],
"children": [ "children": [
{ {
"uuid": "20190301114245", "uuid": "20190301114245",
"name": "i1", "name": "BallItem",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
"properties": {} "properties": {}
}, },
{ {
"script": "./scripts/Icon", "script": "./scripts/scenes/BallItem",
"properties": {} "properties": {
"scoreTxt": "entity|8abfc716-7017-4834-a7fa-5ca6c2ce4b3e"
}
} }
], ],
"children": [ "children": [
{ {
"name": "Image", "name": "pic",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
"properties": {} "properties": {
"alpha": 0
}
}, },
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|5ea53bf0-8a58-420c-8c25-fc1724e4865b" "texture": "res|5367ae30-00ee-4296-8779-158f8fbd68f2"
} }
} }
], ],
"uuid": "3348f059-ffca-4670-9cbc-d9fdd014a17f" "uuid": "fb53fa37-a942-4474-901a-582dccd14c93"
}, },
{ {
"name": "Image", "name": "blue",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
...@@ -48,14 +55,14 @@ ...@@ -48,14 +55,14 @@
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|c2836212-2459-4c1d-a294-1ed49e197229" "texture": "res|5367ae30-00ee-4296-8779-158f8fbd68f2"
} }
} }
], ],
"uuid": "b083dc1a-32c1-4223-bd92-6a5a08d61761" "uuid": "bd5eee18-b584-4e7b-817f-17924c204a24"
}, },
{ {
"name": "Image", "name": "purple",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
...@@ -64,14 +71,14 @@ ...@@ -64,14 +71,14 @@
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|c9272a2e-6151-4b87-a700-32ac4a12caee" "texture": "res|3aad1b7b-89ec-4565-afa2-a16d36d7b721"
} }
} }
], ],
"uuid": "7f878b93-5f00-4087-aa94-522d6b1fdd8d" "uuid": "23ad1a6b-0041-472e-b2b4-b6d615f6d6f9"
}, },
{ {
"name": "Image", "name": "red",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
...@@ -80,14 +87,14 @@ ...@@ -80,14 +87,14 @@
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|fb22f965-457d-4514-a322-95149ecdee79" "texture": "res|e624e863-53d4-41f7-bc95-924579fe8025"
} }
} }
], ],
"uuid": "7c640bd9-d699-4fca-9d96-2e75f4f927b1" "uuid": "5adf946c-1307-443a-9c4b-73e1ce864a69"
}, },
{ {
"name": "Image", "name": "green",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
...@@ -96,14 +103,14 @@ ...@@ -96,14 +103,14 @@
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|e143dfc7-324e-4635-a776-2f6c0d1ce845" "texture": "res|853cc248-89dc-40f1-8f16-48007e6d8ef3"
} }
} }
], ],
"uuid": "2aa87abd-5f1a-469e-9461-eb7e12779e04" "uuid": "023cb819-56e2-4ba7-b052-786e0766d255"
}, },
{ {
"name": "Image", "name": "darkBlue",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
...@@ -112,59 +119,54 @@ ...@@ -112,59 +119,54 @@
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|511ce403-5c36-48e6-9b5c-b3bbfd9b210d" "texture": "res|9cc48379-a01c-4cd1-9196-220016eb9797"
} }
} }
], ],
"uuid": "58db0986-92aa-4828-9f2c-064174addb21" "uuid": "8cd279f5-9c19-4179-9b93-fdb0b8a7dcca"
}, },
{ {
"name": "Image", "name": "yellow",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|04ae0a39-6624-488e-b52d-97f7a03baf8f" "position": {
"_hashCode": 44907,
"_x": 0,
"_y": 0
} }
} }
],
"uuid": "7b51b9ce-7f6e-4fc2-8ddc-bcd3e619e773"
},
{
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {}
}, },
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextureRenderer",
"properties": { "properties": {
"texture": "res|12e9e984-20c2-4930-aae7-296cee113462" "texture": "res|24c66e95-12ff-4bea-b4be-aa8554eea39f"
} }
} }
], ],
"uuid": "d05c4a07-1471-43a9-b369-c90a497c2c79" "uuid": "47a489b3-037f-4f2d-87bb-58e1b962afb0",
"disabled": false
}, },
{ {
"name": "Image", "name": "txt",
"components": [ "components": [
{ {
"script": "components/base/Transform", "script": "components/base/Transform",
"properties": {} "properties": {}
}, },
{ {
"script": "components/renderer/TextureRenderer", "script": "components/renderer/TextRenderer",
"properties": { "properties": {
"texture": "res|c3361b0e-b03a-4fff-a4b3-b20adde85547" "text": "1111",
"fillColor": "rgba(255, 255, 255, 1)",
"textStyle": {
"fontSize": 100
}
} }
} }
], ],
"uuid": "cca2f2c2-6226-4dcc-bfcc-2e6824ee2cd8" "uuid": "8abfc716-7017-4834-a7fa-5ca6c2ce4b3e"
} }
] ]
} }
......
{"ver":"1.0.1","uuid":"d6c6eb9d-b2bf-4da7-9017-1fdde2766886","subMetas":{},"type":"prefab"} {"ver":"1.0.1","uuid":"1de471d9-75ca-4549-aca9-ff3cca9aac08","subMetas":{},"type":"prefab"}
{
"name": "BlueRocket",
"root": {
"uuid": "20190301114308",
"components": [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
}
],
"children": [
{
"uuid": "20190301114245",
"name": "BlueRocket",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "./scripts/scenes/RocketItem",
"properties": {
"type": "blue",
"text": "entity|b15d2107-ed6f-4784-a704-7852968d9baa"
}
}
],
"children": [
{
"name": "pic",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|b08e8d70-e3cd-48b4-81b5-61196aafdc7b"
}
}
],
"uuid": "8880bafc-d2cd-4e48-bd4d-4b0db91e23c8"
},
{
"name": "Label",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 46,
"y": 0
}
}
},
{
"script": "components/renderer/TextRenderer",
"properties": {
"text": "+1",
"fillColor": "rgba(102, 202, 235, 1)",
"textStyle": {
"fontSize": 35,
"fontWeight": "bold"
}
}
}
],
"uuid": "b15d2107-ed6f-4784-a704-7852968d9baa"
}
]
}
]
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"681aaec9-4063-4399-b56f-2a88de1a902e","subMetas":{},"type":"prefab"} {"ver":"1.0.1","uuid":"b5185698-ef74-4855-95b9-813e187f6ee7","subMetas":{},"type":"prefab"}
{
"name": "PurepleFire",
"root": {
"uuid": "20190301114308",
"components": [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
}
],
"children": [
{
"uuid": "20190301114245",
"name": "PurepleFire",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "./scripts/scenes/RocketItem",
"properties": {
"text": "entity|f5c662d6-44c8-4cb3-9871-47f9b1174a29",
"type": "purple"
}
}
],
"children": [
{
"name": "pic",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|18af58d7-34ef-469b-a769-dec15fb0e908"
}
}
],
"uuid": "18ac6b51-b4ef-4144-94f1-d9ff09bad4d2"
},
{
"name": "Label",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 58,
"y": 0
}
}
},
{
"script": "components/renderer/TextRenderer",
"properties": {
"text": "20%",
"fillColor": "rgba(179, 66, 228, 1)",
"textStyle": {
"fontSize": 35,
"fontStyle": "normal",
"fontWeight": "bold",
"fontVariant": "normal"
}
}
}
],
"uuid": "f5c662d6-44c8-4cb3-9871-47f9b1174a29"
}
]
}
]
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"2be6a616-f50b-402e-b10f-8aacca0b3a9f","subMetas":{},"type":"prefab"}
{
"name": "RedFire",
"root": {
"uuid": "20190301114308",
"components": [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
}
],
"children": [
{
"uuid": "20190301114245",
"name": "RedFire",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "./scripts/scenes/RocketItem",
"properties": {
"type": "red",
"text": "entity|8146b5f9-8c56-4edb-9dbb-93bd44951fcd"
}
}
],
"children": [
{
"name": "pic",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|86bf904f-c870-44c5-b2e1-16e511c63eff"
}
}
],
"uuid": "35827ccd-03af-42fd-868b-5ba42f8ee992"
},
{
"name": "Label",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 64,
"y": 0
}
}
},
{
"script": "components/renderer/TextRenderer",
"properties": {
"text": "30%",
"fillColor": "rgba(242, 106, 57, 1)",
"textStyle": {
"fontSize": 35,
"fontWeight": "bold"
}
}
}
],
"uuid": "8146b5f9-8c56-4edb-9dbb-93bd44951fcd"
}
]
}
]
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"8a61e34c-bdba-4dbe-813a-68c562e7ecbd","subMetas":{},"type":"prefab"}
{
"name": "YellowFire",
"root": {
"uuid": "20190301114308",
"components": [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
}
],
"children": [
{
"uuid": "20190301114245",
"name": "YellowFire",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "./scripts/scenes/RocketItem",
"properties": {
"type": "yellow",
"text": "entity|cb2bcda7-70e8-494e-a23a-ad65ee024e79"
}
}
],
"children": [
{
"name": "pic",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|12a92a67-b5b7-472c-8c4c-95d8eefa1c82"
}
}
],
"uuid": "76605a9b-9864-4e67-be3a-a223039f4aa5"
},
{
"name": "Label",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 58,
"y": 0
}
}
},
{
"script": "components/renderer/TextRenderer",
"properties": {
"text": "10%",
"fillColor": "rgba(255, 234, 0, 1)",
"textStyle": {
"fontSize": 35
}
}
}
],
"uuid": "cb2bcda7-70e8-494e-a23a-ad65ee024e79"
}
]
}
]
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"51834a6b-5880-41df-81d9-beaef804a919","subMetas":{},"type":"prefab"}
{
"name": "bullet",
"root": {
"uuid": "20190301114308",
"components": [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
}
],
"children": [
{
"uuid": "20190301114245",
"name": "bullet",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "./scripts/scenes/BulletItem",
"properties": {},
"disabled": false
}
],
"children": [
{
"name": "pic",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|a0310a43-fc21-44d6-b32b-a8406fe10e03"
}
}
],
"uuid": "bd27ee5e-6f76-49cb-8e10-5ae807e0d000"
}
]
}
]
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"df59e078-e7b7-4fbb-a1aa-8b291284c39f","subMetas":{},"type":"prefab"}
{
"name": "rankItem",
"root": {
"uuid": "20190301114308",
"components": [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
}
],
"children": [
{
"uuid": "20190301114245",
"name": "rankItem",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "./scripts/scenes/result/RankItem",
"properties": {
"avatar": "entity|922f8140-959a-4d58-ad74-fbaa0f0ba3e4",
"rank": "entity|ec0185d3-ce9d-4929-b8bd-a44531efe131",
"score": "entity|723b6f9f-ed88-4e03-ae63-9b5efc3990c6",
"name": "entity|6cee4655-01a5-49ea-b21b-bc269f9a7572"
}
}
],
"children": [
{
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|71e44311-e161-4503-8f98-61e49083fbc4"
}
}
],
"uuid": "f80351a3-2f07-4797-884a-ffc68372547c",
"disabled": true
},
{
"name": "bg",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 0,
"y": 24.392156862745097
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|1c417086-3713-4fc1-94fa-2f29f3a34f09"
}
}
],
"uuid": "f7797dd2-ce00-4226-9568-22702807f1b8"
},
{
"name": "score",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 269.4117647058823,
"y": -4.705882352941177
}
}
},
{
"script": "components/renderer/TextRenderer",
"properties": {
"text": "100颗",
"fillColor": "rgba(255, 247, 224, 1)",
"textStyle": {
"fontSize": 20
}
}
}
],
"uuid": "723b6f9f-ed88-4e03-ae63-9b5efc3990c6"
},
{
"name": "name",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": -125.88235294117649,
"y": -4.705882352941177
}
}
},
{
"script": "components/renderer/TextRenderer",
"properties": {
"text": "隔壁老王",
"fillColor": "rgba(255, 247, 224, 1)",
"textStyle": {
"fontSize": 20
}
}
}
],
"uuid": "6cee4655-01a5-49ea-b21b-bc269f9a7572"
},
{
"name": "rank",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": -283.5294117647059,
"y": -5.882352941176471
}
}
},
{
"script": "components/renderer/TextRenderer",
"properties": {
"text": "44",
"fillColor": "rgba(255, 247, 224, 1)",
"textStyle": {
"fontSize": 20
}
}
}
],
"uuid": "ec0185d3-ce9d-4929-b8bd-a44531efe131"
},
{
"name": "imgWrap",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": -229.41176470588235,
"y": -5.882352941176471,
"_type_": "scilla/support/Vector2D"
}
}
},
{
"script": "components/renderer/RectRenderer",
"properties": {
"width": 40,
"height": 40,
"cornerRadius": 20,
"useCacheMode": false,
"maskVisible": false,
"isMask": true
}
}
],
"uuid": "f2de6959-6413-4218-9694-9f4f0a374f41",
"children": [
{
"name": "avatar",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 0,
"y": 0,
"_type_": "scilla/support/Vector2D"
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|8ad59445-0ff2-4382-bb1c-9f7a07845e48"
}
}
],
"uuid": "922f8140-959a-4d58-ad74-fbaa0f0ba3e4"
}
]
}
]
}
]
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* Created by rockyl on 2019-01-03.
*
* 砖块动画单体
*/
import {Entity,} from "scilla";
import TextRenderer from 'components/renderer/TextRenderer'
import Wave from 'components/animation/Wave'
import ScillaComponent from 'components/base/ScillaComponent';
export default class HelloScilla extends ScillaComponent {
name: string = 'scilla';
logo: Entity;
label: Entity;
private labelRenderer: TextRenderer;
private logoAnimation: Wave;
onAwake() {
super.onAwake();
console.log('fuck11')
this.labelRenderer = this.label.getComponent(TextRenderer);
this.logoAnimation = this.logo.getComponent(Wave);
}
tapMe(){
this.labelRenderer.text = 'Hello ' + this.name;
this.logoAnimation.play();
}
}
import ScillaComponent from 'components/base/ScillaComponent';
import { getX, getY, setXY } from './transformUtils';
export default class Icon extends ScillaComponent {
private GRAVITY = .7;
private _vx = 0;
private _vy = 0;
onAwake() {
super.onAwake();
const children = this.entity.children;
const index = Math.floor(children.length * Math.random());
children.forEach((v, i) => v.enabled = index == i);
const baseY = -100;
const offsetX = 150;
const offsetY = -100;
const randomXoffset = Math.random() * offsetX * 2 - offsetX;
const randomYoffset = Math.random() * offsetY;
setXY(this.entity, randomXoffset, baseY + randomYoffset);
//初始vy小于0
this._vy = (-Math.random() * 3 - 10) * 2;
this._vx = (Math.random() * 5 + 5) * (Math.random() > 0.5 ? 1 : -1) * 1;
}
onUpdate(t) {
this._vy += this.GRAVITY;
super.onUpdate(t);
const x = getX(this) + this._vx;
const y = getY(this) + this._vy;
setXY(this, x, y)
}
}
import ScillaComponent from "scilla-components/src/base/ScillaComponent"; import ScillaComponent from "scilla-components/src/base/ScillaComponent";
import { engine, Entity } from "scilla/src"; import { dynamic, engine, Entity } from "scilla/src";
import { initEnv } from "./common/BuriedPoint";
import Toast from "./common/Toast"; import Toast from "./common/Toast";
import { initEnv } from "./common/BuriedPoint";
import Popup from "./popup/Popup"; import Popup from "./popup/Popup";
export default class MainController extends ScillaComponent { export default class MainController extends ScillaComponent {
Popup: Entity;//PopupContainer 弹窗容器 Popup: Entity;//PopupContainer 弹窗容器
Toast: Entity;//toast 实体 Toast: Entity;//toast 实体
hdToolId: dynamic;
actId: dynamic;
private _toast: Toast; private _toast: Toast;
private _popup: Popup; private _popup: Popup;
// fuckNavigator(p) {
// console.log('fuckNavigator from MainController', p)
// }
onAwake() { onAwake() {
super.onAwake(); super.onAwake();
...@@ -21,47 +26,42 @@ export default class MainController extends ScillaComponent { ...@@ -21,47 +26,42 @@ export default class MainController extends ScillaComponent {
initEnv(); initEnv();
console.log('游戏刷新了...'); this.broadcast('callApi', 1, 'ajaxElement', { duibaId: this.hdToolId, activityId: this.actId })
// const limit = localStorage.getItem('')
} }
onGotAjaxElement() {
this.broadcast('initGameStage');
}
onGotAjaxElementError(e) {
console.log(e);
// onGotAjaxElement() { // if (typeof e === 'string') {
// setTimeout(() => { // switch (e) {
// this.broadcast('initGameStage'); // case '0100016': //活动未开始
// }, 1000); // case '0100014': //活动已结束
// case '0100017': //活动已关闭
// this.showErrorToast(e);
// break;
// default:
// this.showNetError();
// } // }
// } else {
// onGotAjaxElementError(e) { // this.showNetError();
// console.log(e);
// // if (typeof e === 'string') {
// // switch (e) {
// // case '0100016': //活动未开始
// // case '0100014': //活动已结束
// // case '0100017': //活动已关闭
// // this.showErrorToast(e);
// // break;
// // default:
// // this.showNetError();
// // }
// // } else {
// // this.showNetError();
// // }
// } // }
}
// showErrorToast(e) { showErrorToast(e) {
// // switch (e) { // switch (e) {
// // case '0100016': //活动未开始 // case '0100016': //活动未开始
// // this.showToast('活动未开始,暂时无法参与'); // this.showToast('活动未开始,暂时无法参与');
// // break; // break;
// // case '0100014': //活动已结束 // case '0100014': //活动已结束
// // case '0100017': //活动已关闭 // case '0100017': //活动已关闭
// // this.showToast('活动已结束,无法参与'); // this.showToast('活动已结束,无法参与');
// // break; // break;
// // }
// } // }
}
showToast(content, duration?) { showToast(content, duration?) {
this._toast.show({ this._toast.show({
......
{"ver":"1.0.1","uuid":"6264e54e-3a4e-4bb8-baed-91b9a0c6b85d","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"3bc8690b-e80e-4239-849d-41d99f249f5d","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"9abb2447-83bb-49e0-8912-39814676b8a4","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"9d563731-a25f-423f-bab9-e77c10fa8b53","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"de65cf24-dfc0-4728-8ef5-83c97dca9b15","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"976a2dda-db9b-4ca8-b781-51c98b2a6e4a","subMetas":{},"type":"script"}
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
* 简单的api组件 * 简单的api组件
*/ */
import { utils, } from 'scilla/src' import {utils, } from 'scilla/src'
import ApiComponent from "./ApiComponent"; import ApiComponent from "./ApiComponent";
import { callApi } from "../net/webService"; import {callApi} from "../net/webService";
export default class SampleApi extends ApiComponent { export default class SampleApi extends ApiComponent {
uri: string; uri: string;
ignoreSuccessField = false; ignoreSuccessField = false;
async callApi(name, paramsInput, ...args) { async callApi(name, paramsInput, ...args){
if (this.name == name) { if(this.name == name){
await this.execute(paramsInput, ...args); await this.execute(paramsInput, ...args);
} }
} }
...@@ -23,22 +23,20 @@ export default class SampleApi extends ApiComponent { ...@@ -23,22 +23,20 @@ export default class SampleApi extends ApiComponent {
const params = {}; const params = {};
if (this.params) { if(this.params){
utils.injectProp(params, this.params); utils.injectProp(params, this.params);
} }
if (paramsInput) { if(paramsInput){
utils.injectProp(params, paramsInput); utils.injectProp(params, paramsInput);
} }
const { uri, method } = this; const {uri, method} = this;
try { try {
console.log(`${uri}==>${JSON.stringify(params)}`);
const response = await callApi(uri, params, method, 'json', this.ignoreSuccessField); const response = await callApi(uri, params, method, 'json', this.ignoreSuccessField);
this.onGotResponse(response); this.onGotResponse(response);
console.log(`${uri}<<==${JSON.stringify(response)}`);
return response.data; return response.data;
} catch (e) { } catch (e) {
......
{"ver":"1.0.1","uuid":"02450709-0578-4315-82d3-b6676111fc8f","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"2a07e71a-fedb-4bfe-9ea2-771be76404ee","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"92de3cc4-8222-4f87-baca-5d84079f4537","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"a0ccb513-37cc-4bae-920d-334b30dfea62","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"d5df52ff-573f-4fae-a1eb-69fe4062e1ce","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"9f08d900-47ca-4705-941d-5d62c7522867","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"621fdc18-2185-4d12-b199-0d650c2cca94","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"5a56d291-4baf-492f-9528-2c579e7f8c56","subMetas":{},"type":"script"}
...@@ -11,8 +11,7 @@ import Transform from "scilla-components/src/base/Transform"; ...@@ -11,8 +11,7 @@ import Transform from "scilla-components/src/base/Transform";
export default class Toast extends ScillaComponent { export default class Toast extends ScillaComponent {
Label: Entity; Label: Entity;
ypadding = 20; padding = 20;
xpadding = 50;
offsetY = 0; offsetY = 0;
showDuration = 300; showDuration = 300;
hideDuration = 300; hideDuration = 300;
...@@ -51,13 +50,13 @@ export default class Toast extends ScillaComponent { ...@@ -51,13 +50,13 @@ export default class Toast extends ScillaComponent {
show({content, duration = 1000}) { show({content, duration = 1000}) {
this.entity.enabled = true; this.entity.enabled = true;
const {_bgTransform, _labelRenderer, _labelTransform, xpadding,ypadding} = this; const {_bgTransform, _labelRenderer, _labelTransform, padding} = this;
_labelRenderer.text = content; _labelRenderer.text = content;
_labelRenderer.measureBounds(); _labelRenderer.measureBounds();
_bgTransform.width = _labelTransform.width + xpadding * 2; _bgTransform.width = _labelTransform.width + padding * 2;
_bgTransform.height = _labelTransform.height + ypadding * 2; _bgTransform.height = _labelTransform.height + padding * 2;
this._tweenOut.queue[0].props.position.y = this.outPos; this._tweenOut.queue[0].props.position.y = this.outPos;
......
{"ver":"1.0.1","uuid":"e67c7e07-1a4a-44eb-a56e-74fba7534c1a","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"ffe40fb1-962f-4b21-9833-c66d31de4b4c","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"cf6a3b27-3203-4229-9d0b-6e0c9132b754","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"997b374c-347d-466a-af4f-50f115d294cd","subMetas":{},"isGroup":true}
...@@ -5,19 +5,17 @@ ...@@ -5,19 +5,17 @@
*/ */
import DialogContent from "../popup/DialogContent"; import DialogContent from "../popup/DialogContent";
import { Entity } from "scilla/src";
import { setText } from "../entityUtils";
export default class AlertDialogContent extends DialogContent { export default class AlertDialogContent extends DialogContent {
content: Entity;
onAwake() { onAwake() {
super.onAwake(); super.onAwake();
} }
protected onTapCloseButton() {
super.onTapCloseButton();
this.bubbling('fuckNavigator', 'start');
}
setup(data: any = {}) { setup(data: any = {}) {
setText(this.content, data);
}
onClickConfirmButton() {
this.hide('confirm')
} }
} }
{"ver":"1.0.1","uuid":"222398f9-001b-4213-b2d0-0484f49da18f","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"be102305-c06e-4717-9148-a59fccddef73","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"27a4ad71-7fcb-4509-9b6e-d2eb4624a07c","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"b7be6577-399f-47f2-ac0e-b07e03f336e8","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2019-04-10.
*
* 警告对话框内容
*/
import { TextureRenderer } from "scilla-components/src";
import { AssetsManager, createTexture, EngineConfig, Entity, Texture, dynamic } from "scilla/src";
import DialogContent from "../popup/DialogContent";
import { setScale, setText } from "../transformUtils";
import { getRecordURL } from "./ScoreDialogContent";
export default class PrizeDialogContent extends DialogContent {
pic: Entity;
name: Entity;
title: Entity;
private loadImage = (url: string): Promise<HTMLImageElement> => {
return new Promise<HTMLImageElement>((resolve, reject) => {
let img = new Image();
if (EngineConfig.imgCrossOrigin) {
img.setAttribute('crossOrigin', 'anonymous');
}
img.onload = function (e) {
resolve(img);
};
img.onerror = function (e) {
reject(e);
};
img.src = url;
});
}
private loadTexture = async (url: string): Promise<Texture> => {
const img = await this.loadImage(url);
const texture = createTexture(img);
return texture;
}
onClick_usebtn() {
// window.location.href=this.getOrderStatus.lottery.link
window.location.href = getRecordURL();
}
onAwake() {
super.onAwake();
}
async setup(data: any = {}) {
setText(this.name, data.prizeName);
setText(this.title, this.getTypeStr(data.prizeType))
const texRender = this.pic.getComponent(TextureRenderer);
const texture = await this.loadTexture(data.prizeImage);
texRender.texture = texture;
if (texture.bounds.width > texture.bounds.height) {
const maxwidth = 250;
setScale(this.pic, maxwidth / texture.bounds.width)
} else {
const maxheight = 250;
setScale(this.pic, maxheight / texture.bounds.height)
}
}
private getTypeStr(type: number) {
if (type == 1) {
return `获得一等奖`
}
if (type == 2) {
return `获得二等奖`
}
if (type == 3) {
return `获得三等奖`
}
if (type == 4) {
return `获得四等奖`
}
}
}
...@@ -20,7 +20,7 @@ export default class RuleDialogContent extends DialogContent { ...@@ -20,7 +20,7 @@ export default class RuleDialogContent extends DialogContent {
} }
setup(data) { setup(data) {
this._contentRenderer.htmlText = window['ruleContent']; this._contentRenderer.htmlText = this.ajaxElement.rule;
} }
} }
{"ver":"1.0.1","uuid":"20e51d98-2b67-455d-b86f-b238d80fef2c","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"f4ad775b-3c0d-4d15-8f28-4fc7ed078dea","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2019-04-10.
*
* 警告对话框内容
*/
import { Entity } from "scilla/src";
import { setText } from "../entityUtils";
import DialogContent from "../popup/DialogContent";
export default class ScoreDialogContent extends DialogContent {
content: Entity;
rankbtn: Entity;
onAwake() {
super.onAwake();
}
setup(data: any = {}) {
setText(this.content, `恭喜你共摇出${data}颗糖果`)
}
protected onTapCloseButton() {
super.onTapCloseButton();
this.bubbling('fuckNavigator', 'start');
}
onclick_ranbtn() {
this.hide();
// this.broadcast('callApi', 1, 'rankInfo', {
// weddingId: window['CFG'].weddingId,
// activityId: window['CFG'].activityId
// })
this.bubbling('fuckNavigator', 'start');
window.location.href = getRankURL();
}
// onResponse_rank1() {
// console.log('score dialog content,onResponse_rank')
// this.bubbling('fuckNavigator', 'result');
// }
}
export const getRankURL = () => {
return `/customActivity/sjf/activity/recordIndex?weddingId=${window['CFG'].weddingId}&activityId=${window['CFG'].activityId}&brickType=7`
}
export const getURL = () => {
//`/customActivity/sjf/mainIndex?weddingId=2
return `/customActivity/sjf/mainIndex?weddingId=${window['CFG'].weddingId}`;
}
export const getRecordURL = () => {
return `/customActivity/sjf/activity/recordIndex?weddingId=${window['CFG'].weddingId}&activityId=${window['CFG'].activityId}&brickType=6`;
}
...@@ -2,5 +2,5 @@ import { TextRenderer } from "scilla-components/src"; ...@@ -2,5 +2,5 @@ import { TextRenderer } from "scilla-components/src";
import { Entity } from "scilla/src"; import { Entity } from "scilla/src";
export const setText = (entity: Entity, text) => { export const setText = (entity: Entity, text) => {
entity.getComponent(TextRenderer).text = text + ''; entity.getComponent(TextRenderer).text = text;
} }
\ No newline at end of file
{"ver":"1.0.1","uuid":"f4a580ec-d00d-4bb0-8cb1-cc955f990e22","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"23d10a11-6459-4e3b-b73e-a00e1967ad0a","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"c59f7148-9a03-47ab-a146-693028d37bee","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"62c77f0e-0d2a-45ba-95d8-8f6bd922a8a0","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"f852cfa3-ccbf-4989-a807-65368a72b129","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"74c1fe4d-621a-4908-aaf7-0934901d3c1e","subMetas":{},"type":"script"}
...@@ -17,19 +17,7 @@ export const getTween = (context, val: Transform | Entity | ScillaComponent, obj ...@@ -17,19 +17,7 @@ export const getTween = (context, val: Transform | Entity | ScillaComponent, obj
delete obj[key]; delete obj[key];
} }
} }
const scaleObj = {};
for (const key in obj) {
if (key == 'scalex') {
scaleObj['x'] = obj[key];
delete obj[key];
}
if (key == 'scaley') {
scaleObj['y'] = obj[key];
delete obj[key];
}
}
createTween(context, target.position, true).to(postionObj, duration, ease); createTween(context, target.position, true).to(postionObj, duration, ease);
createTween(context, target.scale, true).to(scaleObj, duration, ease);
createTween(context, target, true).to(obj, duration, ease).call(r); createTween(context, target, true).to(obj, duration, ease).call(r);
}); });
} }
\ No newline at end of file
{"ver":"1.0.1","uuid":"4d662288-5dcb-4f4f-af88-0b1233d96770","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"6819e675-030f-4df9-8f49-d662a434d7cf","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"ead52dd1-f4cf-4869-b471-0f820c005d69","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"c0c3cf56-be33-4264-8613-5f2e8f8ebb33","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"23c9a081-bf70-4728-adfc-b95143c2bd18","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"636ee90d-508d-4b65-9605-f7352d0b2466","subMetas":{},"type":"script"}
...@@ -5,12 +5,8 @@ ...@@ -5,12 +5,8 @@
*/ */
import ScillaComponent from "scilla-components/src/base/ScillaComponent"; import ScillaComponent from "scilla-components/src/base/ScillaComponent";
import { ScenePlay, SceneStart } from "../scenes";
import { VirtualNavigator } from "./VirtualNavigator"; import { VirtualNavigator } from "./VirtualNavigator";
import SceneStart from "../scenes/SceneStart";
import ScenePlay from "../scenes/ScenePlay";
import SceneGuide from "../scenes/SceneGuide";
import SceneResult from "../scenes/SceneResult";
import { Button } from "scilla-components/src";
export default class SingleSceneNavigator extends ScillaComponent { export default class SingleSceneNavigator extends ScillaComponent {
_navigator: VirtualNavigator; _navigator: VirtualNavigator;
...@@ -20,8 +16,6 @@ export default class SingleSceneNavigator extends ScillaComponent { ...@@ -20,8 +16,6 @@ export default class SingleSceneNavigator extends ScillaComponent {
this._navigator = new VirtualNavigator(this.entity); this._navigator = new VirtualNavigator(this.entity);
this._navigator.register('start', 'SceneStart', SceneStart); this._navigator.register('start', 'SceneStart', SceneStart);
this._navigator.register('play', 'ScenePlay', ScenePlay); this._navigator.register('play', 'ScenePlay', ScenePlay);
this._navigator.register('guide', 'SceneGuide', SceneGuide);
this._navigator.register('result', 'SceneResult', SceneResult);
} }
onAwake() { onAwake() {
......
{"ver":"1.0.1","uuid":"1baca7a6-0db8-4109-8b3c-a13459a83ff5","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"4b5a29f1-88af-47d5-8949-cfc2c1f8f861","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"60f88e76-e1dc-43a4-a74b-75f71a2f6eef","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"c787ec07-0e47-4ac2-8f55-d4195acbcddc","subMetas":{},"type":"script"}
...@@ -117,6 +117,6 @@ export class VirtualNavigator extends EventEmitter implements INavigatorDelegate ...@@ -117,6 +117,6 @@ export class VirtualNavigator extends EventEmitter implements INavigatorDelegate
* @param error * @param error
*/ */
onError(error: Error) { onError(error: Error) {
console.log(error)
} }
} }
{"ver":"1.0.1","uuid":"4ae843bd-25a7-4979-a39d-59486f4cbc55","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"cca81914-b73a-42e1-8c20-273329a24220","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"af630d2e-acd0-4369-bc02-032a640853da","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"3c970fd0-fe5d-4bdd-aeaa-f291dd26462c","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"9c37b4b7-6565-4d46-ad28-7ad17dbcf7dc","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"d6c61478-e547-4ab5-8c4c-c0b40f34596a","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"aa006aad-50a3-49b2-ae49-6b031b154793","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"412d270b-6e82-4b42-baf9-7fbc976c79e7","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"0657cdf0-0b97-4286-ae87-8f356140e662","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"82058157-b884-4040-b0cd-4dc5289098e0","subMetas":{},"type":"script"}
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
* 弹层 * 弹层
*/ */
import TouchInterrupt from "components/base/TouchInterrupt";
import ScillaComponent from "scilla-components/src/base/ScillaComponent";
import Transform from "scilla-components/src/base/Transform";
import RectRenderer from "scilla-components/src/renderer/RectRenderer";
import { Entity } from "scilla/src";
import SingleSceneNavigator from "../navigator/SingleSceneNavigator";
import DialogContent from "./DialogContent"; import DialogContent from "./DialogContent";
import RectRenderer from "scilla-components/src/renderer/RectRenderer";
import TouchInterrupt from "scilla-components/src/base/TouchInterrupt";
import Transform from "scilla-components/src/base/Transform";
import ScillaComponent from "scilla-components/src/base/ScillaComponent";
import { none } from "./PopupEffect"; import { none } from "./PopupEffect";
import { createTween, Entity } from "scilla/src";
import SingleSceneNavigator from "../navigator/SingleSceneNavigator";
export default class Popup extends ScillaComponent { export default class Popup extends ScillaComponent {
blackLayerDuration = 300; blackLayerDuration = 300;
bgRenderer: Entity; private _bgRenderer: RectRenderer;
private _touchInterrupt: TouchInterrupt; private _touchInterrupt: TouchInterrupt;
private _dialogStack = []; private _dialogStack = [];
...@@ -28,11 +28,10 @@ export default class Popup extends ScillaComponent { ...@@ -28,11 +28,10 @@ export default class Popup extends ScillaComponent {
this._touchInterrupt = this.getComponent(TouchInterrupt); this._touchInterrupt = this.getComponent(TouchInterrupt);
this._touchInterrupt.enabled = false; this._touchInterrupt.enabled = false;
// this.bgRenderer.enabled = false; const bgRenderer = this._bgRenderer = this.getComponent(RectRenderer);
bgRenderer.enabled = false;
this._navigator = this.sceneContainer.getComponent(SingleSceneNavigator);
this.entity.children.forEach(child => child.enabled = false); this._navigator = this.sceneContainer.getComponent(SingleSceneNavigator)
} }
fuckNavigator(p) { fuckNavigator(p) {
...@@ -53,18 +52,17 @@ export default class Popup extends ScillaComponent { ...@@ -53,18 +52,17 @@ export default class Popup extends ScillaComponent {
} }
setBgVisible(visible) { setBgVisible(visible) {
this.bgRenderer.enabled = visible; if (visible) {
// if (visible) { this._bgRenderer.enabled = true;
// this._bgRenderer.enabled = true; }
// } this._bgRenderer.alpha = visible ? 0 : 1;
// this._bgRenderer.alpha = visible ? 0 : 1; createTween(this, this._bgRenderer, true)
// createTween(this, this._bgRenderer, true) .to({ alpha: visible ? 1 : 0 }, this.blackLayerDuration)
// .to({ alpha: visible ? 1 : 0 }, this.blackLayerDuration) .call(() => {
// .call(() => { if (!visible) {
// if (!visible) { this._bgRenderer.enabled = false;
// this._bgRenderer.enabled = false; }
// } });
// });
} }
getDialogInStack(name) { getDialogInStack(name) {
...@@ -120,7 +118,7 @@ export default class Popup extends ScillaComponent { ...@@ -120,7 +118,7 @@ export default class Popup extends ScillaComponent {
const effect = content ? content.effectImpl : none; const effect = content ? content.effectImpl : none;
const effectOptions = content ? content.showEffectOptions : null; const effectOptions = content ? content.showEffectOptions : null;
// await effect.show(transform, effectOptions); await effect.show(transform, effectOptions);
} }
async hideDialog(name, action?: string, data?) { async hideDialog(name, action?: string, data?) {
...@@ -145,7 +143,7 @@ export default class Popup extends ScillaComponent { ...@@ -145,7 +143,7 @@ export default class Popup extends ScillaComponent {
const effect = content ? content.effectImpl : none; const effect = content ? content.effectImpl : none;
const effectOptions = content ? content.hideEffectOptions : null; const effectOptions = content ? content.hideEffectOptions : null;
// await effect.hide(transform, effectOptions); await effect.hide(transform, effectOptions);
dialog.enabled = false; dialog.enabled = false;
if (dialogConfig.callback) { if (dialogConfig.callback) {
......
{"ver":"1.0.1","uuid":"b6b6a4f7-1aa0-4aa8-a325-1184927abd90","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"794b113e-ee7a-46d8-b9cc-6755fc76f839","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"03597fde-0a6d-4c4f-b0f6-d1079ddb777d","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"d1ea2c31-d3f6-4c18-99bc-1d8390553501","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"9b5487b8-a2a7-44ea-a370-ab8e3ea7ba93","subMetas":{},"isGroup":true} {"ver":"1.0.1","uuid":"45d473b1-a874-47aa-8c1a-9323b6720a82","subMetas":{},"isGroup":true}
import { TextRenderer } from 'scilla-components/src';
import { Entity } from 'scilla/src';
import Body from './Body';
import { calNextColor } from './scenePlay/colors';
export default class BallItem extends Body {
private _storedScore;
private _currentScore = 0;
scoreTxt: Entity;
isBig = true;
size: BallSizeType;
colorIndex: number;
nextColorIndex: number;
ID: number;
parentID: number;
constructor() {
super();
this.gravity = 0.225;
this.rotationSpeed = 0.5;
}
onAwake() {
super.onAwake();
}
reduceScore(score: number) {
let result = 0;
if (this._currentScore <= score)
result = this._currentScore;
else
result = score;
this._currentScore -= score;
if (this._currentScore < 0)
this._currentScore = 0;
this.updateScoreTxt();
return result;
}
resetScore(score) {
this._currentScore = score;
this._storedScore = score;
this.updateScoreTxt();
this.nextColorIndex = calNextColor(this.colorIndex);
}
updateScoreTxt() {
const tr = this.scoreTxt.getComponent(TextRenderer);
tr.text = this._currentScore.toString();
}
childNames = [BallType.yellow, BallType.green, BallType.blue, BallType.darkBlue, BallType.purple, BallType.red];
color: BallType;
updateColor(color: BallType) {
this.color = color;
this.childNames.forEach(name => {
const child = this.entity.getChildrenByName(name)[0];
if (name != color)
child.enabled = false;
});
const child = this.entity.getChildrenByName(color)[0];
child.enabled = true;
}
get currentScore() { return this._currentScore }
get storedScore() { return this._storedScore }
}
export enum BallSizeType {
min = 0,
size1 = 1,
size2 = 2,
max = 3,
}
export enum BallType {
blue = 'blue',
purple = 'purple',
red = 'red',
green = 'green',
darkBlue = 'darkBlue',
yellow = 'yellow',
}
export const BallSizeTypeList = [74, 126, 165, 227];
\ No newline at end of file
{"ver":"1.0.1","uuid":"bd9a9589-4961-44b9-ae8c-263297eb9a35","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"99d3002b-6f74-412d-8af0-b144d58bb054","subMetas":{},"type":"script"}
import ScillaComponent from 'components/base/ScillaComponent';
import { Transform } from 'scilla-components/src';
export default class Body extends ScillaComponent {
bounceY = 1;
bounceX = 1;
velocityY = 0;
velocityX = 0;
rotationSpeed = 0.5;
gravity = 0;
private _counter = 0;
onUpdate() {
this._counter++;
const { entity } = this;
this.velocityY += this.gravity;
entity.getComponent(Transform).position.y += this.velocityY;
entity.getComponent(Transform).position.x += this.velocityX;
// console.log(entity.getComponent(Transform).position.y)
entity.getComponent(Transform).rotation = this._counter * .7 * this.rotationSpeed;
}
reset() {
const { entity } = this;
this.velocityY = 0;
this.velocityX = 0;
entity.getComponent(Transform).rotation = 0;
this._counter = 0;
}
revertY() {
this.velocityY *= -1 * this.bounceY;
}
revertX() {
this.velocityX *= -1 * this.bounceX;
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"7846da82-f6e3-4ab7-aadb-064d4b3672b5","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"216f7c25-499f-4bee-9ead-5cdf94411265","subMetas":{},"type":"script"}
import Body from './Body';
import { Transform } from 'scilla-components/src';
export default class BulletItem extends Body {
constructor() {
super();
this.gravity = 0;
this.velocityY = -20;
this.rotationSpeed= 0;
}
onUpdate() {
const { entity } = this;
entity.getComponent(Transform).position.y += this.velocityY;
entity.getComponent(Transform).position.x += this.velocityX;
}
reset() {}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"3321fa44-dadf-4d67-8e26-04ba5fb8bac7","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"9b500f7e-7d23-46bd-8d3f-b3b076ebee5c","subMetas":{},"type":"script"}
import Body from './Body';
import { Entity } from 'scilla/src';
import { DropType } from './scenePlay/DropType';
export default class RocketItem extends Body {
type: DropType;
text: Entity;
constructor() {
super();
this.gravity = .5;
this.bounceY = 0.4;
this.rotationSpeed = 0;
}
onAwake() {
super.onAwake();
this.text.enabled = false;
}
reset() {
super.reset();
this.rotationSpeed = 0;
}
getCarFire() {
if (this.type == DropType.red) return 30;
if (this.type == DropType.yellow) return 10;
if (this.type == DropType.purple) return 20;
return 0;
}
getCarBullet() {
if (this.type == DropType.blue) return 1;
return 0;
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"3a09e137-303f-434e-a26e-6f19216e962f","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"0325040d-e190-4b38-834d-362abc071117","subMetas":{},"type":"script"}
...@@ -8,6 +8,7 @@ export default class SceneController extends ScillaComponent { ...@@ -8,6 +8,7 @@ export default class SceneController extends ScillaComponent {
} }
fuck(p) { fuck(p) {
// console.log('fuck',p)
const nav = this.entity.getComponent(SingleSceneNavigator); const nav = this.entity.getComponent(SingleSceneNavigator);
nav.push(p) nav.push(p)
} }
......
{"ver":"1.0.1","uuid":"fd411e04-be60-45d3-aabb-40a76cf4ad25","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"bc96d141-6270-4cc8-8638-9c05cbaaa271","subMetas":{},"type":"script"}
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { Button, InteractComponent } from "scilla-components/src";
export default class SceneGuide extends InteractComponent implements INavigatorViewBase {
onAwake() {
super.onAwake();
}
onGlobalTouchBegin(e) {
super.onGlobalTouchBegin(e);
this.onNextScene();
return false;
}
onNextScene() {
this.bubbling('fuck', 'play');
}
// _timer
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
async onWillEnter(last: string, action: alien.NavigatorAction, parameters: any) {
}
async onWillLeave(next: string, action: alien.NavigatorAction, parameters: any) {
}
onWillMount(last: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
onWillUnMount(next: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
}
{"ver":"1.0.1","uuid":"9b858404-d4f3-49a0-a174-6947fc5e52ec","subMetas":{},"type":"script"}
This diff is collapsed.
{"ver":"1.0.1","uuid":"848eeea5-4afe-4725-bb21-7d1d01a309ef","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"4c940094-0966-44b4-9875-0c7deb522cb5","subMetas":{},"type":"script"}
import ScillaComponent from "scilla-components/src/base/ScillaComponent";
import { createTexture, EngineConfig, Entity, Texture, dynamic } from "scilla/src";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { TextureRenderer } from "scilla-components/src";
import { setScale, setText } from "../transformUtils";
export default class SceneResult extends ScillaComponent implements INavigatorViewBase {
onAwake() {
super.onAwake();
// console.log(this.rankInfo);
this.onResponse(this.rankInfo);
}
rankInfo: dynamic;
onResponse(data) {
//设置我的信息
setText(this.myname, data.nickName);
if (data.rank > 500)
setText(this.myrank, '未上榜');
else
setText(this.myrank, data.rank + '');
setText(this.myscore, data.score);
this.loadAvatar(this.myavatar, data.avatar, 78);
//设置前三名的信息
const [rankinfo1, rankinfo2, rankinfo3] = data.list;
// console.log(rankinfo1, rankinfo2, rankinfo3, last);
if (rankinfo1) {
this.loadAvatar(this.avatar1, rankinfo1.avatar, 78);
setText(this.name1, rankinfo1.nickName);
setText(this.score1, rankinfo1.score);
}
if (rankinfo2) {
this.loadAvatar(this.avatar2, rankinfo2.avatar, 64);
setText(this.name2, rankinfo2.nickName);
setText(this.score2, rankinfo2.score);
}
if (rankinfo3) {
this.loadAvatar(this.avatar3, rankinfo3.avatar, 64);
setText(this.name3, rankinfo3.nickName);
setText(this.score3, rankinfo3.score);
}
}
onTapCloseButton() {
this.bubbling('fuck', 'start');
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
async onWillEnter(last: string, action: alien.NavigatorAction, parameters: any) {
}
async onWillLeave(next: string, action: alien.NavigatorAction, parameters: any) {
}
onWillMount(last: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
onWillUnMount(next: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
async loadAvatar(avatar: Entity, url: string, width: number) {
const texRender = avatar.getComponent(TextureRenderer);
const texture = await this.loadTexture(url);
texRender.texture = texture;
setScale(avatar, width / texture.bounds.width);
}
private loadImage = (url: string): Promise<HTMLImageElement> => {
return new Promise<HTMLImageElement>((resolve, reject) => {
let img = new Image();
if (EngineConfig.imgCrossOrigin) {
img.setAttribute('crossOrigin', 'anonymous');
}
img.onload = function (e) {
resolve(img);
};
img.onerror = function (e) {
reject(e);
};
img.src = url;
});
}
private loadTexture = async (url: string): Promise<Texture> => {
const img = await this.loadImage(url);
const texture = createTexture(img);
return texture;
}
avatar1: Entity;
myavatar: Entity;
avatar2: Entity;
avatar3: Entity;
name2: Entity;
name1: Entity;
name3: Entity;
myname: Entity;
myscore: Entity;
score2: Entity;
score1: Entity;
score3: Entity;
myrank: Entity;
}
{"ver":"1.0.1","uuid":"83555ffb-9b5c-47af-a811-b9315ca88211","subMetas":{},"type":"script"}
...@@ -2,192 +2,76 @@ ...@@ -2,192 +2,76 @@
* Created by rockyl on 2019-04-09. * Created by rockyl on 2019-04-09.
*/ */
import { Button } from "scilla-components/src";
import ScillaComponent from "scilla-components/src/base/ScillaComponent"; import ScillaComponent from "scilla-components/src/base/ScillaComponent";
import { dynamic, Entity } from "scilla/src"; import { dynamic, Entity } from "scilla/src";
import { setText } from "../entityUtils";
import { alien } from "../navigator/StackNavigator"; import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator"; import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { setText, setRotation, getRotation } from "../transformUtils";
import { getRankURL, getRecordURL, getURL } from "../dialogs/ScoreDialogContent";
export default class SceneStart extends ScillaComponent implements INavigatorViewBase { export default class SceneStart extends ScillaComponent implements INavigatorViewBase {
ajaxElement: dynamic;
doJoin: dynamic; doJoin: dynamic;
getOrderStatus: dynamic; // getNgameStartStatus: dynamic;
countTxt: Entity; countTxt: Entity;
startbtn: Entity; startbtn: Entity;
rankbtn: Entity; rankbtn: Entity;
rulebtn: Entity; rulebtn: Entity;
box: Entity;
musiconbtn: Entity;
musicoffbtn: Entity;
onclick_music() {
this.musicoffbtn.enabled = !this.musicoffbtn.enabled;
this.musiconbtn.enabled = !this.musiconbtn.enabled;
if (this.musiconbtn.enabled) {
document.getElementById('bgmusic')['play']();
} else {
document.getElementById('bgmusic')['pause']();
}
}
private INTERVAL = 3000;
private STREN = 3;
private FREQ = 5;
private SHAK_TIMERS = 10;
private _shakeTimes = -1;
private _counter = -1;
private _lastTime = -1;
onUpdate() {
if (Date.now() - this._lastTime > this.INTERVAL) {
this._lastTime = Date.now();
setRotation(this.box, this.STREN);
this._shakeTimes = this.SHAK_TIMERS;
this._counter = 0;
}
if (this._shakeTimes > 0) {
if (this._counter <= 0) {
this._shakeTimes--;
setRotation(this.box, -getRotation(this.box))
if (this._shakeTimes <= 0) {
setRotation(this.box, 0);
}
this._counter = this.FREQ;
} else {
this._counter--;
}
}
}
updateCountFromNet(limit: number) {
if (limit < 0)
limit = 0;
setText(this.countTxt, `剩余次数:${limit}`);
console.log('updateCountFromNet', `剩余次数:${limit}`)
}
onErrorLimitFree(data) {
console.log('onErrorLimitFree', data);
if (data == '400005')
setText(this.countTxt, `剩余次数:${window['CFG'].freeLimit}`);
else
setText(this.countTxt, `剩余次数:0`);
}
updateCountTxtFromDojoin() {
let limit = 0;
if (this.doJoin) {
limit = this.doJoin.freeLimit;
}
if (limit < 0)
limit = 0;
setText(this.countTxt, `剩余次数:${limit}`);
console.log('updateCountTxtFromDojoin', `剩余次数:${limit}`)
}
onAwake() { onAwake() {
super.onAwake(); super.onAwake();
this.broadcast('callApi', 1, 'rankInfo2', { this.setCountText('');
weddingId: window['CFG'].weddingId, // SingleSceneNavigator
activityId: window['CFG'].activityId console.log('fuck start scene')
});
this.broadcast('callApi', 1, 'limitTimes', {
weddingId: window['CFG'].weddingId,
activityId: window['CFG'].activityId
});
this._shakeTimes = 0;
this._counter = 0;
this._lastTime = -1;
setRotation(this.box, 0);
} }
onResponse_rankInfo2(data) { private setCountText(text: string) {
if (data.openPrize && data.score > 0) {//开奖了,都是线下奖品 setText(this.countTxt, text);
console.log('开奖了....');
console.log('prizelist', JSON.stringify(window['CFG'].activity.prizeList));
let prize;
window['CFG'].activity.prizeList.forEach(p => {
if (p.prizeType == data.prizeType)
prize = p;
});
if (prize)
console.log('中奖了', JSON.stringify(prize))
else
console.log('没有中奖')
if (!window.localStorage.getItem(this.getKey())) {
if (prize) //中奖了
this.bubbling('showDialog', 'Prize', prize);
else
this.bubbling('showDialog', 'Alert', '您与奖品擦肩而过~');
} else {
console.log('已经弹窗过了', this.getKey())
}
window.localStorage.setItem(this.getKey(), '1')
}
}
getKey() {
return 'prizeShowed-' + window['CFG'].weixinUid + '-' + window['CFG'].weddingId + '-' + window['CFG'].activityId
} }
initGameStage() { initGameStage() {
console.log('initGameStage') this.updateCountText();
} }
onClick_startbtn() { updateCountText() {
this.startbtn.getComponent(Button).enabled = false; const { element } = this.ajaxElement;
this.sendDojoin(); let text = ''
if (element.freeLimit > 0) {
text = `今日剩余免费次数:${element.freeLimit}次`;
} else {
text = `${element.needCredits}${window['CFG'].unitName}/次`
} }
this.setCountText(text);
sendDojoin() {
// if (window['getDuibaToken']) {
// window['getDuibaToken']((tokenObj: any) => {
// this.dojoinFunc(tokenObj.token);
// }, (key: string, messageObj: any) => {
// // this.onError(net);
// });
// } else {
this.dojoinFunc();
// }
} }
dojoinFunc(token?) { onClick_startbtn() {
this.broadcast('callApi', 1, 'doJoin', { this.broadcast('callApi', 1, 'doJoin', {
activityId: window['CFG'].activityId, activityId: window['CFG'].actId,
weddingId: window['CFG'].weddingId, activityType: 'hdtool',
consumerId: window['CFG'].consumerId
}); });
// globalEvent.emit('popup', { name: 'RulePanel', params: {} }, this.onAlertClose);
} }
onGotDojoin() { onGotDojoin() {
console.log('onGotDojoin', this.doJoin); console.log('onGotDojoin', this.doJoin);
this.startbtn.getComponent(Button).enabled = true; this.broadcast('callApi', 1, 'getNgameStartStatus', {
this.updateCountTxtFromDojoin(); orderId: this.doJoin
setTimeout(() => { });
this.bubbling('fuck', 'guide');
}, 50);
} }
onGotDojoinError(error) { onGotDojoinError() {
this.startbtn.getComponent(Button).enabled = true; console.log('onGotDojoinError')
if (error === '400005') {
this.bubbling('showToast', '活动还未开始\n敬请期待~');
} else if (error === '400006') {
this.bubbling('showToast', '活动已结束\n下次早点来哦~');
} else if (error === '400002') {
this.bubbling('showDialog', 'Alert', '您已经没有抽奖机会了');
} }
else {
this.bubbling('showDialog', 'Alert', '网络异常,请稍后再试~'); onGot_getNgameStartStatus() {
// console.log('onGot_getNgameStartStatus', this.getNgameStartStatus);
//fuck 不可以循环引用
this.bubbling('fuck', 'play');
} }
console.log('onGotDojoinError', error);
onGotError_getNgameStartStatus() {
console.log('onGotError_getNgameStartStatus');
} }
onClick_rulebtn() { onClick_rulebtn() {
...@@ -196,22 +80,7 @@ export default class SceneStart extends ScillaComponent implements INavigatorVie ...@@ -196,22 +80,7 @@ export default class SceneStart extends ScillaComponent implements INavigatorVie
} }
onClick_rankbtn() { onClick_rankbtn() {
window.location.href = getRankURL(); alert('onClick_rankbtn')
}
onClick_backbtn() {
// console.log('onClick_backbtn');
window.location.href = getURL()
}
onResponse_rank() {
this.bubbling('fuck', 'result');
this.rankbtn.getComponent(Button).enabled = true;
}
onClick_recordbtn() {
// alert('onClick_recordbtn')
window.location.href = getRecordURL();
// globalEvent.emit('alert', {title: 'Success', content: 'You complete this puzzle', button: 'Next level'}, this.onAlertClose); // globalEvent.emit('alert', {title: 'Success', content: 'You complete this puzzle', button: 'Next level'}, this.onAlertClose);
} }
......
{"ver":"1.0.1","uuid":"a6fb727e-d71c-484f-b3eb-480b3a5f3e42","subMetas":{},"type":"script"} {"ver":"1.0.1","uuid":"9b17ef27-60b5-46b4-b9d2-735a2861e5f6","subMetas":{},"type":"script"}
export const removeFromList = (item, list: any[]) => {
const index = list.indexOf(item);
if (index != -1) {
list.splice(index, 1);
}
return item;
}
export const pickFromList = (list: any[]) => {
const index = Math.floor(Math.random() * list.length);
return list[index]
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"82324ada-6ea3-480d-ad2d-229339fd7df4","subMetas":{},"type":"script"}
export const gravityY= .5;
\ No newline at end of file
{"ver":"1.0.1","uuid":"49d89b23-4cb4-4536-9f9e-c83130909711","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2019-04-09.
*/
export {default as SceneStart} from "./SceneStart";
export {default as ScenePlay} from "./ScenePlay";
{"ver":"1.0.1","uuid":"f5c11db4-1b48-4d86-8433-e4afda5d9a8d","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"8de41bf2-0b03-42d7-bbb9-8d01f3cad181","subMetas":{},"isGroup":true}
import { setText } from 'assets/scripts/entityUtils';
import { setScale } from 'assets/scripts/transformUtils';
import ScillaComponent from 'components/base/ScillaComponent';
import { TextureRenderer } from 'scilla-components/src';
import { createTexture, EngineConfig, Entity, Texture } from 'scilla/src';
export default class RankItem extends ScillaComponent {
score: Entity;
rank: Entity;
name: Entity;
avatar: Entity;
onAwake() {
super.onAwake();
}
async setdata(data) {
// console.log(data);
setText(this.score, data.score + '');
setText(this.rank, data.rank);
setText(this.name, data.nickName);
const texRender = this.avatar.getComponent(TextureRenderer);
const texture = await this.loadTexture(data.avatar);
texRender.texture = texture;
setScale(this.avatar, 40 / texture.bounds.width)
}
onUpdate(t) {
super.onUpdate(t);
}
private loadImage = (url: string): Promise<HTMLImageElement> => {
return new Promise<HTMLImageElement>((resolve, reject) => {
let img = new Image();
if (EngineConfig.imgCrossOrigin) {
img.setAttribute('crossOrigin', 'anonymous');
}
img.onload = function (e) {
resolve(img);
};
img.onerror = function (e) {
reject(e);
};
img.src = url;
});
}
private loadTexture = async (url: string): Promise<Texture> => {
const img = await this.loadImage(url);
const texture = createTexture(img);
return texture;
}
}
{"ver":"1.0.1","uuid":"ea6e2329-3083-471f-b71a-a9bdbe9f3cb2","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2019-01-03.
*
* 砖块动画单体
*/
import ScillaComponent from 'components/base/ScillaComponent';
import { RectRenderer, Transform } from 'scilla-components/src';
import { Entity, resource, instantiate, dynamic } from 'scilla/src';
import RankItem from './RankItem';
export default class RankList extends ScillaComponent {
item: resource;
content: Entity;
private _list: Entity[];
private _bg: RectRenderer;
rankInfo: dynamic;
onAwake() {
super.onAwake();
// console.log('RankList onAwake')
this.updateRankList(this.rankInfo);
}
updateRankList(rankInfo) {
const [, , , ...data] = rankInfo.list;
this._bg = this.content.getComponent(RectRenderer);
if (this._list) {
this._list.forEach(item => {
this.content.removeChild(item);
})
}
const itemHeight = 73;
const totalHeight = itemHeight * data.length;
this._list = [];
this._bg.height = totalHeight;
data.forEach((item, index) => {
const rank = instantiate(this.item);
rank.getComponent(RankItem).setdata(item);
this.content.addChild(rank);
// rank.getComponent(Transform).position.y = index * itemHeight;
rank.getComponent(Transform).position.y = index * itemHeight - totalHeight / 2 + itemHeight / 2 + 10;
this._list.push(rank);
});
}
}
{"ver":"1.0.1","uuid":"8960d977-3ca8-482b-b15a-9dac7438d253","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"78241f13-a5ce-4eb9-8455-97ff2004f0e2","subMetas":{},"isGroup":true}
import { getTween } from 'assets/scripts/getTween';
import { getX, getY, setScale, setXY } from 'assets/scripts/transformUtils';
import ScillaComponent from 'components/base/ScillaComponent';
import { Transform } from 'scilla-components/src';
import { Entity, instantiate, resource } from 'scilla/src';
import BallItem, { BallSizeType, BallSizeTypeList } from '../BallItem';
import { removeFromList } from '../_';
import { getBallScore, getBallScoreRange } from './ballScore';
import { randomColorIndex } from './colors';
import { getNextScore } from './getNextScore';
const getN = (carBullet) => {
if (carBullet <= 20) return 1;
if (carBullet <= 60) return 2;
if (carBullet <= 100) return 3
if (carBullet <= 130) return 4;
if (Math.random() < 0.3) return 6;
return 7;
}
export default class BallManager extends ScillaComponent {
private _idCounter = 1;
/** 所有父亲球的id */
private _ballIDs: number[] = [];
private checkAddBall(carBullet, carFire) {
if (this._ballIDs.length < getN(carBullet)) {
this.addBall(carBullet, carFire)
}
}
onBallDestroyedCheckBallIDs(carBullet, carFire) {
for (let i = 0; i < this._ballIDs.length; i++) {
const id = this._ballIDs[i];
const ballIsNotDestroy = this.ballList.some(ball => ball.ID == id);
if (this.ballList.every(ball => ball.parentID != id) && !ballIsNotDestroy) {
this._ballIDs.splice(i, 1);
i--;
}
}
this.checkAddBall(carBullet, carFire);
}
addBall(carBullet, carFire) {
let size = Math.floor(Math.random() * 4); //随机size,0-3
let colorIndex = randomColorIndex(size); //根据size随机颜色
let scorerange = getBallScoreRange(carBullet, carFire);
scorerange = scorerange.map(val => Math.ceil(val * (window['ballscore-p'] || 1)));
const score = getBallScore(scorerange, colorIndex);// [1, 100];
let dir = Math.random() > 0.5 ? -1 : 1;
// this.createBigBall(20, dir, colorIndex, size);
this.createBigBall(score, dir, colorIndex, size);
}
onGameOver() {
this.disableBalls();
}
disableBalls() {
this.ballList.forEach(item => item.enabled = false);
}
_onDidLeave() {
//删除所有的球
this.ballList.forEach(
ball => {
ball.enabled = false;
this.entity.removeChild(ball.entity);
this._freeBallList.push(ball);
}
);
this.ballList = [];
this._ballIDs = [];
this._idCounter = 1;
}
checkBallSplit(ball: BallItem,bullet,fire) {
//移除ball
ball.enabled = false;
removeFromList(ball, this.ballList);
this.entity.removeChild(ball.entity);
this._freeBallList.push(ball);
// console.log('this.ballList', this.ballList.length, 'this._freeBallList', this._freeBallList.length);
if (ball.size > BallSizeType.min) {//开始分裂
const nextSizeType = ball.size - 1;
const nextScore = getNextScore(ball.storedScore);
const nextColorIndex = ball.nextColorIndex;
const ball1 = this.createSplitedBall(ball, nextSizeType, nextScore, nextColorIndex);
const ball2 = this.createSplitedBall(ball, nextSizeType, nextScore, nextColorIndex);
ball1.velocityX = -5;
ball2.velocityX = 5;
} else {//掉落
this.broadcast('createDrop', 1, ball,bullet,fire)
}
}
BallItemPrefab: resource;
topline: Entity;
ballList: BallItem[] = [];
private _freeBallList: BallItem[] = [];
createSplitedBall(parentBall: BallItem, size, score, nextColorIndex) {
const ball = this.getBall();
ball.reset();
ball.resetScore(score);
ball.size = size;
// console.log(size)
ball.updateColor(ball.childNames[nextColorIndex]);
setScale(ball, BallSizeTypeList[size] / BallSizeTypeList[BallSizeTypeList.length - 1]);
setXY(ball, getX(parentBall), getY(parentBall));
this.ballList.push(ball);
this.entity.addChild(ball.entity);
ball.enabled = true;
ball.velocityY = -5;
ball.parentID = parentBall.ID == -1 ? parentBall.parentID : parentBall.ID; //parentBall.ID = -1 表示是父球,不是祖宗求。否则是祖宗求
ball.ID = -1;
return ball;
}
private async createBigBall(score, dir, colorIndex, size: BallSizeType) {
const ball = this.getBall();
ball.reset();
ball.resetScore(score);
ball.updateColor(ball.childNames[colorIndex])
setScale(ball, 1);
ball.enabled = false;
this.ballList.push(ball);
this.entity.addChild(ball.entity);
ball.size = size;
ball.parentID = -1;
ball.ID = ++this._idCounter;
this._ballIDs.push(this._idCounter);
setScale(ball, BallSizeTypeList[size] / BallSizeTypeList[BallSizeTypeList.length - 1]);
if (dir == 1) {
setXY(ball.entity, -375, getY(this.topline));
await getTween(this, ball.getComponent(Transform), { x: -375 + 200 }, 700);
ball.velocityX = 5;
}
else {
setXY(ball.entity, 375, getY(this.topline));
await getTween(this, ball.getComponent(Transform), { x: 375 - 200 }, 700);
ball.velocityX = -5;
}
ball.enabled = true;
}
getBall() {
let ball: BallItem;
if (this._freeBallList.length > 0) {
ball = this._freeBallList.pop();
} else {
ball = this.createBall();
}
return ball;
}
createBall() {
const ball = instantiate(this.BallItemPrefab);
const body = ball.getComponent(BallItem);
return body;
}
}
{"ver":"1.0.1","uuid":"1e2f418c-2d41-4d72-8a40-34cb834e99f6","subMetas":{},"type":"script"}
import { getTween } from 'assets/scripts/getTween';
import { getX, getY, setXY } from 'assets/scripts/transformUtils';
import ScillaComponent from 'components/base/ScillaComponent';
import { Transform } from 'scilla-components/src';
import { Entity, instantiate, resource } from 'scilla/src';
import Body from '../Body';
const getLines = (X) => {
if (X <= 20) return 1
if (X <= 40) return 2
if (X <= 60) return 3
if (X <= 80) return 4
if (X <= 100) return 5
if (X <= 120) return 6
if (X <= 140) return 7
return 7
}
export default class CarBulletAni extends ScillaComponent {
BulletItemPrefab: resource;
scenePlay: Entity;
private _interval = 10;
//等级1 2 3 4
private _lines = 1;
private _offsetList: number[][] = [];
bullets: Body[] = [];
private _freeBullets: Body[];
private _pause = false;
onGameOver() {
this._pause = true;
this.disableBullets();
}
disableBullets() {
this.bullets.forEach(item => item.enabled = false);
}
_onDidLeave() {
this.bullets.forEach(bullet => {
this.scenePlay.removeChild(bullet.entity);
bullet.enabled = false;
this._freeBullets.push(bullet);
});
this.bullets = [];
}
onAwake() {
super.onAwake();
if (!this._freeBullets) {
this._freeBullets = [];
this._offsetList.push([0]);
this._offsetList.push([-9, 9]);
this._offsetList.push([-18, 0, 18]);
this._offsetList.push([-27, -9, 9, 27]);
this._offsetList.push([-36, -18, 0, 18, 36]);
this._offsetList.push([-45, -27, -9, 9, 27, 45]);
this._offsetList.push([-54, -36, -18, 0, 18, 36, 54]);
}
this._pause = false;
this._interval = 10;
}
updateLines(carbullet) {
if (carbullet >= 20)
this._interval = 3;
else
this._interval = 10 - (carbullet / 20) * 7;
this._lines = getLines(carbullet);
}
_counter = 0;
onUpdate(t) {
super.onUpdate(t);
if (this._pause) return;
this._counter++;
if (this._counter >= this._interval) {
this._counter = 0;
this.createBullet();
}
this.checkRemoveBullets();
}
removeBullet(bullet: Body) {
this.scenePlay.removeChild(bullet.entity);
bullet.enabled = false;
this._freeBullets.push(bullet);
}
checkRemoveBullets() {
for (let i = 0; i < this.bullets.length; i++) {
const bullet = this.bullets[i];
const y = getY(bullet)
if (y < -1624 / 2) { //子弹失效
this.removeBullet(bullet);
this.bullets.splice(i, 1);
i--;
}
}
}
createBullet() {
const tweens = [];
const list: Body[] = [];
const offsets = this._offsetList[this._lines - 1];
for (let i = 0; i < this._lines; i++) {
let bullet: Body;
let item: Entity;
if (this._freeBullets.length > 0) {
bullet = this._freeBullets.pop();
item = bullet.entity;
} else {
item = instantiate(this.BulletItemPrefab);
bullet = item.getComponent(Body);
}
bullet.enabled = false;
list.push(bullet);
const targetX = getX(this.entity);
const targetY = getY(this.entity) - 80;
setXY(item, targetX, targetY);
const tween = getTween(this, item.getComponent(Transform), { y: targetY - 50, x: targetX + offsets[i] }, 100);
tweens.push(tween);
}
Promise.all(tweens).then(() => {
list.forEach(bullet => {
if (this._pause) { //暂停了之后再结束的tween
this.bullets.push(bullet);
} else {
bullet.enabled = true;
this.bullets.push(bullet);
}
});
});
list.forEach(bullet => {
this.scenePlay.addChild(bullet.entity);
});
}
}
{"ver":"1.0.1","uuid":"8525cc2b-6dbc-4f0e-9fe1-256a2811c705","subMetas":{},"type":"script"}
import ScillaComponent from 'components/base/ScillaComponent';
import { Entity } from 'scilla/src';
import { getY, setY } from 'assets/scripts/transformUtils';
export default class CarShootAni extends ScillaComponent {
body: Entity;
smoke: Entity;
_bodyY: number;
onAwake() {
super.onAwake();
this._bodyY = getY(this.body);
}
_counter = 0;
onUpdate(t) {
super.onUpdate(t);
this._counter++;
if (this._counter > 1) {
this._counter = 0;
const bodyY = getY(this.body);
const targetY = bodyY == this._bodyY ? this._bodyY - 3 : this._bodyY;
setY(this.body, targetY);
this.smoke.enabled = !this.smoke.enabled;
}
}
}
{"ver":"1.0.1","uuid":"e78ad988-e1f0-4505-a1c7-8d40b26790c2","subMetas":{},"type":"script"}
import { getTween } from 'assets/scripts/getTween';
import { getX, getY, setAlpha, setXY } from 'assets/scripts/transformUtils';
import ScillaComponent from 'components/base/ScillaComponent';
import { instantiate, resource } from 'scilla/src';
import Body from '../Body';
import RocketItem from '../RocketItem';
import { removeFromList } from '../_';
import { DropType } from './DropType';
import { initEnv } from 'assets/scripts/common/BuriedPoint';
import { getProp, dropsCls } from './drops';
import getPropItem from './getPropItem';
export default class DropManager extends ScillaComponent {
RedFirePrefab: resource;
BlueRocketPrefab: resource;
YellowRocketPrefab: resource;
PurpleRocketPrefab: resource;
onGameOver() {
this.disableBalls();
}
disableBalls() {
this._dropList.forEach(item => item.enabled = false);
}
_onDidLeave() {
//删除所有的球
this._dropList.forEach(
drop => {
drop.enabled = false;
this.entity.removeChild(drop.entity);
const frees = this._freeDic[drop.type];
frees.push(drop);
}
);
this._dropList = [];
}
async removeDrop(drop: RocketItem) {
drop.enabled = false;
drop.text.enabled = true;
removeFromList(drop, this._dropList);
const frees = this._freeDic[drop.type];
const y = getY(drop);
await getTween(this, drop, { y: y - 200, alpha: 0 }, 1000);
frees.push(drop);
this.entity.removeChild(drop.entity);
setAlpha(drop, 1);
}
createDrop(ball: Body, carbullet, fire) {
const dropinfo = getProp(carbullet);
const dropsData: DropType[] = getPropItem(dropsCls, dropinfo.p, dropinfo.n);
const [d1, d2, d3] = dropsData;
let n = dropsData.length;
// console.log(dropsData)
const p = 30;
let dir = 1;
if (getX(ball) > 0)
dir = -1;
const x = getX(ball), y = getY(ball);
const baseVx = dir * 1;
if (n == 3) {
const item1 = this.createDropItem(d1, ball, x, y, baseVx - dir);
const item2 = this.createDropItem(d2, ball, x + dir * p, y - p, baseVx);
const item3 = this.createDropItem(d3, ball, x + dir * p * 2, y - p * 2, baseVx + dir);
} else if (n == 2) {
const item1 = this.createDropItem(d1, ball, x, y, baseVx);
const item2 = this.createDropItem(d2, ball, x + dir * p, y - p, baseVx + dir);
} else {
const item1 = this.createDropItem(d1, ball, x, y, baseVx);
}
}
getPrefab(dropType: DropType) {
if (dropType == DropType.blue) return this.BlueRocketPrefab;
if (dropType == DropType.purple) return this.PurpleRocketPrefab;
if (dropType == DropType.red) return this.RedFirePrefab;
if (dropType == DropType.yellow) return this.YellowRocketPrefab;
}
private createDropItem(dropType: DropType, ball: Body, x: number, y: number, vx) {
let item: Body;
item = this.getFireItem(this.getPrefab(dropType), dropType);
setXY(item, getX(ball), getY(ball));
item.velocityY = -Math.abs(vx) * 3 * 2;
item.velocityX = vx * 3;
return item;
}
getFireItem(res: resource, type: DropType) {
const frees = this._freeDic[type];
let body: RocketItem;
if (frees.length > 0) {
body = frees.pop();
body.enabled = true;
body.reset();
} else {
const item = instantiate(res);
body = item.getComponent(RocketItem);
}
this.entity.addChild(body.entity);
this._dropList.push(body);
return body;
}
private _dropList: RocketItem[] = [];
get dropList() { return this._dropList }
private _freeDic: { [key: string]: RocketItem[]; } = {
'red': [], 'blue': [], 'purple': [], 'yellow': []
};
oncreate() {
super.onCreate();
}
onAwake() {
super.onAwake();
}
onUpdate(t) {
super.onUpdate(t);
}
}
{"ver":"1.0.1","uuid":"7dbbaba5-b07a-4e4e-a598-dc1de3aca547","subMetas":{},"type":"script"}
export enum DropType {
red = 'red', blue = 'blue', yellow = 'yellow', purple = 'purple'
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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