Commit cefdabe2 authored by wildfirecode's avatar wildfirecode

1

parent ae125ad5
{"currentScene":"assets/scenes/main.scene"}
\ No newline at end of file
{"currentScene":"assets/prefabs/BlueRocket.pfb"}
\ No newline at end of file
......@@ -7,9 +7,9 @@ export default class RocketItem extends Body {
text: Entity;
constructor() {
super();
this.gravity = 1.5;
this.bounceY = 0.6;
this.velocityX = 1; this.rotationSpeed = 0;
this.gravity = .5;
this.bounceY = 0.4;
this.rotationSpeed = 0;
}
onAwake() {
......@@ -19,7 +19,6 @@ export default class RocketItem extends Body {
reset() {
super.reset();
this.velocityX = 1;
this.rotationSpeed = 0;
}
......
......@@ -141,7 +141,7 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
getBulletStren() { return Math.floor(this._carFire / 100); }
checkBallSplit(ball: BallItem) {
this._ballManager.checkBallSplit(ball);
this._ballManager.checkBallSplit(ball,this._carBullet,this._carFire);
}
checkBallCollideGroud() {
......@@ -203,8 +203,7 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
this._dropManager = this.getComponent(DropManager);
}
this.score = 0;
this._carBullet = 15;
// this._carBullet = 0;
this._carBullet = 0;
this._carFire = 100;
this._bulletManager.updateLines(this._carBullet);
this.updateScoreTxt();
......
......@@ -2,11 +2,11 @@ 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, createTween, ease, ColorMatrixFilter } from 'scilla/src';
import { Entity, instantiate, resource } from 'scilla/src';
import BallItem, { BallSizeType, BallSizeTypeList } from '../BallItem';
import { pickFromList, removeFromList } from '../_';
import { removeFromList } from '../_';
import { getBallScore, getBallScoreRange } from './ballScore';
import { randomColorIndex } from './colors';
import { getBallScoreRange, getBallScore } from './ballScore';
import { getNextScore } from './getNextScore';
const getN = (carBullet) => {
......@@ -73,7 +73,7 @@ export default class BallManager extends ScillaComponent {
this._idCounter = 1;
}
checkBallSplit(ball: BallItem) {
checkBallSplit(ball: BallItem,bullet,fire) {
//移除ball
ball.enabled = false;
removeFromList(ball, this.ballList);
......@@ -89,7 +89,7 @@ export default class BallManager extends ScillaComponent {
ball1.velocityX = -5;
ball2.velocityX = 5;
} else {//掉落
this.broadcast('createDrop', 1, ball)
this.broadcast('createDrop', 1, ball,bullet,fire)
}
}
......
......@@ -7,6 +7,9 @@ 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;
......@@ -46,19 +49,44 @@ export default class DropManager extends ScillaComponent {
setAlpha(drop, 1);
}
createDrop(ball: Body) {
let item: Body;
if (Math.random() > 0.7) {
item = this.getFireItem(this.BlueRocketPrefab, DropType.blue);
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 {
if (Math.random() > 0.7)
item = this.getFireItem(this.RedFirePrefab, DropType.red);
else if (Math.random() > 0.3)
item = this.getFireItem(this.YellowRocketPrefab, DropType.yellow);
else
item = this.getFireItem(this.PurpleRocketPrefab, DropType.purple);
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;
}
......@@ -82,7 +110,7 @@ export default class DropManager extends ScillaComponent {
private _dropList: RocketItem[] = [];
get dropList() { return this._dropList }
private _freeDic: { [key: string]: RocketItem[]; } = {
'red': [], 'blue': [],'purple': [], 'yellow': []
'red': [], 'blue': [], 'purple': [], 'yellow': []
};
oncreate() {
......
import { DropType } from "./DropType";
//////////////////////// 1 30% 20% 10%
export const dropsCls = [DropType.blue, DropType.red, DropType.purple, DropType.yellow];
export const dropsData = [{ bullet: 1 }, { fire: 30 }, { fire: 20 }, { fire: 10 }];
export const getIndex = (cls) => dropsCls.indexOf(cls);
export const getProp = (X: number) => {
if (X <= 30) {
return {
n: 3,
p: window['drop-p-30'] || [40, 0, 15, 50]
}
}
if (X > 30 && X < 70) {
return {
n: 2,
p: window['drop-p-30-70'] || [40, 5, 15, 50]
}
}
if (X >= 70) {
return {
n: 1,
p: window['drop-p-70'] || [40, 5, 15, 50]
}
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"2648271f-74ba-485c-96c8-24cd46fac8dc","subMetas":{},"type":"script"}
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