Commit 01867d9b authored by wildfirecode's avatar wildfirecode

1

parent 332535bf
{"currentScene":"assets/prefabs/BallItem.pfb"}
\ No newline at end of file
{"currentScene":"assets/scenes/main.scene"}
\ No newline at end of file
......@@ -396,6 +396,35 @@
"bottomline": "entity|791444c1-84e8-4455-9fb1-c1b2691c6cc0",
"topline": "entity|9f9bfbf2-4f77-4a1b-b1b5-42b6784e0c8c"
}
},
{
"script": "./scripts/scenes/scenePlay/ngameSubmit",
"properties": {
"doJoin": "dynamic|API|doJoin",
"getNgameStartStatus": "dynamic|API|ngameSubmit"
}
},
{
"script": "./scripts/api/SampleApi",
"properties": {
"method": "POST",
"uri": "/hdtool/recon/ngame/ngameSubmit",
"name": "ngameSubmit",
"onError": [
{
"entity": "entity|1265b761-1b67-4d76-9526-78c457a8d113",
"component": 3,
"method": "onError_ngameSubmit"
}
],
"onResponse": [
{
"entity": "entity|1265b761-1b67-4d76-9526-78c457a8d113",
"component": 3,
"method": "onResponse_ngameSubmit"
}
]
}
}
],
"uuid": "1265b761-1b67-4d76-9526-78c457a8d113",
......
......@@ -9,7 +9,7 @@ export default class BallItem extends Body {
constructor() {
super();
this.gravity = 0.225;
this.rotationSpeed = 0.5;s
this.rotationSpeed = 0.5;
}
onAwake() {
......
......@@ -11,10 +11,10 @@ import Body from "./Body";
import CarBulletAni from "./scenePlay/CarBulletAni";
import CarShootAni from "./scenePlay/CarShootAni";
import { removeFromList } from "./_";
import ngameSubmit from "./scenePlay/ngameSubmit";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
BallItemPrefab: resource;
// BulletItemPrefab: resource;
RedFirePrefab: resource;
BlueRocketPrefab: resource;
YellowRocketPrefab: resource;
......@@ -25,18 +25,18 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
topline: Entity;
bottomline: Entity;
doJoinData: dynamic;
getNgameStartStatus: dynamic;
score = 0;
bodys: Body[];
ballList: Body[];
ballList: BallItem[];
drops: Body[];
_carShootAni: CarShootAni;
_carBulletAni: CarBulletAni;
private _ngameSubmitApi: ngameSubmit;
onGlobalTouchBegin(e): any {
this._lastTouchMoveX=-1;
this._lastTouchMoveX = -1;
return super.onGlobalTouchBegin(e);
}
......@@ -58,6 +58,36 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
onUpdate() {
this.checkBallCollideGroud();
this.checkBulletCollideBall();
}
checkBulletCollideBall() {
for (let i = 0; i < this._carBulletAni.bullets.length; i++) {
const bullet = this._carBulletAni.bullets[i];
const { width: bulletWidth, height: bulletHeight } = bullet.entity.getComponent(Transform);
for (let j = 0; j < this.ballList.length; j++) {
const ball = this.ballList[j];
const x0 = Math.abs(getX(ball.entity) - getX(bullet.entity));
const y0 = Math.abs(getY(ball.entity) - getY(bullet.entity));
const { scale: ballScale } = ball.getComponent(Transform);
const { height: ballH } = ball.entity.getChildrenByName('blue')[0].getComponent(Transform);
const x1 = bulletWidth / 2 + ballH / 2 * ballScale.x;
const y1 = bulletHeight / 2 + ballH / 2 * ballScale.x;
if (x0 < x1 && y0 < y1) { //子弹和球碰撞了,不再便利其他球
this._carBulletAni.removeBullet(bullet);
i--;
if (ball.reduceScore() == 0) { //破裂
this.onBallSplit(ball);
}
break;
}
}
}
}
onBallSplit(ball: BallItem) {
removeFromList(ball, this.ballList);
this.entity.removeChild(ball.entity);
}
checkBallCollideGroud() {
......@@ -119,7 +149,7 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
async createBigBall() {
let dir = Math.random() > 0.5 ? -1 : 1;
const ball = this.getBallItem(20);
setXY(ball.entity, -375, getY(this.topline) +400);
setXY(ball.entity, -375, getY(this.topline));
const body = ball.getComponent(Body);
body.enabled = false;
await getTween(this, ball.getComponent(Transform), { x: -375 + 200 }, 700);
......@@ -130,7 +160,7 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
getBallItem(score: number) {
const ball = instantiate(this.BallItemPrefab);
ball.getComponent(BallItem).score = score;
const body = ball.getComponent(Body);
const body = ball.getComponent(BallItem);
this.bodys.push(body);
this.ballList.push(body);
this.entity.addChild(ball);
......@@ -144,6 +174,7 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
this.drops = [];
this._carShootAni = this.car.getComponent(CarShootAni);
this._carBulletAni = this.car.getComponent(CarBulletAni);
this._ngameSubmitApi = this.getComponent(ngameSubmit);
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
......@@ -155,32 +186,11 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
setInterval(() => {
this.createBigBall();
}, 2000);
}, 10 * 1000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
onError_ngameSubmit() {
this._ngameSubmitApi.ngameSubmit(this.score);
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
......
......@@ -23,7 +23,7 @@ export default class CarBulletAni extends ScillaComponent {
private _interval = 3;
//等级1 2 3 4
private _lines = 7;
private _lines = 1;
private _offsetList: number[][] = [];
bullets: Body[] = [];
private _freeBullets: Body[];
......@@ -57,12 +57,12 @@ export default class CarBulletAni extends ScillaComponent {
this.checkRemoveBullets();
}
removeBullet(body: Body) {
body.entity.enabled = false;
this._playScene.removeChild(body.entity);
removeFromList(body, this.bullets);
this._freeBullets.push(body);
this.bubbling('bulletRemoved', body);
removeBullet(bullet: Body) {
bullet.entity.enabled = false;
this._playScene.removeChild(bullet.entity);
removeFromList(bullet, this.bullets);
this._freeBullets.push(bullet);
this.bubbling('bulletRemoved', bullet);
// console.log(this._freeBullets.length, this._bullets.length);
}
......
import ScillaComponent from 'components/base/ScillaComponent';
import { createSgin } from 'assets/scripts/net/webService';
import { dynamic } from 'scilla/src';
export default class ngameSubmit extends ScillaComponent {
onAwake() {
super.onAwake();
}
onUpdate(t) {
super.onUpdate(t);
}
doJoin: dynamic;
getNgameStartStatus: dynamic;
ngameSubmit(score: number) {
console.log('createSgin', this.doJoin, score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoin, score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoin,
score: score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
onError_ngameSubmit() {
}
}
{"ver":"1.0.1","uuid":"c7ed7528-bfa7-40c2-a502-e01500fd21dd","subMetas":{},"type":"script"}
......@@ -5,8 +5,8 @@
import {registerDef} from 'scilla'
import component0 from 'components/renderer/RectRenderer';
registerDef('components/renderer/RectRenderer', component0);
import component0 from 'components/other/RelativeLayout';
registerDef('components/other/RelativeLayout', component0);
import component1 from 'components/base/Transform';
registerDef('components/base/Transform', component1);
......@@ -23,11 +23,11 @@ registerDef('components/other/FullStageSize', component4);
import component5 from 'components/base/TouchInterrupt';
registerDef('components/base/TouchInterrupt', component5);
import component6 from 'components/other/CameraController';
registerDef('components/other/CameraController', component6);
import component6 from 'components/renderer/RectRenderer';
registerDef('components/renderer/RectRenderer', component6);
import component7 from 'components/other/RelativeLayout';
registerDef('components/other/RelativeLayout', component7);
import component7 from 'components/other/CameraController';
registerDef('components/other/CameraController', component7);
import component8 from 'components/renderer/TextureRenderer';
registerDef('components/renderer/TextureRenderer', component8);
......@@ -41,56 +41,59 @@ registerDef('components/animation/TouchZoom', component10);
import component11 from 'components/ui/Button';
registerDef('components/ui/Button', component11);
import component12 from '../../assets/scripts/dialogs/RuleDialogContent';
registerDef('./scripts/dialogs/RuleDialogContent', component12);
import component12 from '../../assets/scripts/dialogs/AlertDialogContent';
registerDef('./scripts/dialogs/AlertDialogContent', component12);
import component13 from '../../assets/scripts/api/SamplePollingApi';
registerDef('./scripts/api/SamplePollingApi', component13);
import component14 from '../../assets/scripts/scenes/SceneStart';
registerDef('./scripts/scenes/SceneStart', component14);
import component14 from '../../assets/scripts/scenes/scenePlay/ngameSubmit';
registerDef('./scripts/scenes/scenePlay/ngameSubmit', component14);
import component15 from '../../assets/scripts/scenes/SceneController';
registerDef('./scripts/scenes/SceneController', component15);
import component15 from '../../assets/scripts/scenes/SceneStart';
registerDef('./scripts/scenes/SceneStart', component15);
import component16 from '../../assets/scripts/scenes/scenePlay/CarBulletAni';
registerDef('./scripts/scenes/scenePlay/CarBulletAni', component16);
import component16 from '../../assets/scripts/scenes/SceneController';
registerDef('./scripts/scenes/SceneController', component16);
import component17 from '../../assets/scripts/scenes/scenePlay/CarShootAni';
registerDef('./scripts/scenes/scenePlay/CarShootAni', component17);
import component17 from '../../assets/scripts/scenes/scenePlay/CarBulletAni';
registerDef('./scripts/scenes/scenePlay/CarBulletAni', component17);
import component18 from '../../assets/scripts/popup/Popup';
registerDef('./scripts/popup/Popup', component18);
import component18 from '../../assets/scripts/scenes/scenePlay/CarShootAni';
registerDef('./scripts/scenes/scenePlay/CarShootAni', component18);
import component19 from '../../assets/scripts/navigator/SingleSceneNavigator';
registerDef('./scripts/navigator/SingleSceneNavigator', component19);
import component19 from '../../assets/scripts/popup/Popup';
registerDef('./scripts/popup/Popup', component19);
import component20 from '../../assets/scripts/dialogs/AlertDialogContent';
registerDef('./scripts/dialogs/AlertDialogContent', component20);
import component20 from '../../assets/scripts/navigator/SingleSceneNavigator';
registerDef('./scripts/navigator/SingleSceneNavigator', component20);
import component21 from '../../assets/scripts/scenes/ScenePlay';
registerDef('./scripts/scenes/ScenePlay', component21);
import component22 from '../../assets/scripts/api/SampleApi';
registerDef('./scripts/api/SampleApi', component22);
import component22 from '../../assets/scripts/dialogs/RuleDialogContent';
registerDef('./scripts/dialogs/RuleDialogContent', component22);
import component23 from '../../assets/scripts/game/CustomTextRenderer';
registerDef('./scripts/game/CustomTextRenderer', component23);
import component23 from '../../assets/scripts/api/SampleApi';
registerDef('./scripts/api/SampleApi', component23);
import component24 from '../../assets/scripts/MainController';
registerDef('./scripts/MainController', component24);
import component24 from '../../assets/scripts/game/CustomTextRenderer';
registerDef('./scripts/game/CustomTextRenderer', component24);
import component25 from '../../assets/scripts/dialogs/GameOverPanel';
registerDef('./scripts/dialogs/GameOverPanel', component25);
import component25 from '../../assets/scripts/MainController';
registerDef('./scripts/MainController', component25);
import component26 from '../../assets/scripts/common/Toast';
registerDef('./scripts/common/Toast', component26);
import component26 from '../../assets/scripts/dialogs/GameOverPanel';
registerDef('./scripts/dialogs/GameOverPanel', component26);
import component27 from '../../assets/scripts/scenes/BallItem';
registerDef('./scripts/scenes/BallItem', component27);
import component27 from '../../assets/scripts/common/Toast';
registerDef('./scripts/common/Toast', component27);
import component28 from '../../assets/scripts/scenes/RocketItem';
registerDef('./scripts/scenes/RocketItem', component28);
import component28 from '../../assets/scripts/scenes/BallItem';
registerDef('./scripts/scenes/BallItem', component28);
import component29 from '../../assets/scripts/scenes/BulletItem';
registerDef('./scripts/scenes/BulletItem', component29);
import component29 from '../../assets/scripts/scenes/RocketItem';
registerDef('./scripts/scenes/RocketItem', component29);
import component30 from '../../assets/scripts/scenes/BulletItem';
registerDef('./scripts/scenes/BulletItem', component30);
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