Skip to content
This repository has been archived by the owner on Jan 30, 2022. It is now read-only.

Commit

Permalink
Version 0.2.0 修复偶尔无法进入下一关的 BUG;修复其他小错误
Browse files Browse the repository at this point in the history
  • Loading branch information
feichao93 committed Apr 15, 2018
1 parent ed15fd5 commit 972f8b5
Show file tree
Hide file tree
Showing 9 changed files with 533 additions and 46 deletions.
2 changes: 1 addition & 1 deletion app/components/StatisticsScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class StatisticsScene extends React.PureComponent<{ game: GameRecord }> {
<Screen>
<rect fill="#000000" x={0} y={0} width={16 * B} height={16 * B} />
<StatisticsSceneContent game={game} />
{game.paused ? <PauseIndicator /> : null}
{game.paused ? <PauseIndicator x={6.25 * B} y={8 * B} /> : null}
</Screen>
)
}
Expand Down
18 changes: 4 additions & 14 deletions app/sagas/common/destroyTanks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { all, put } from 'redux-saga/effects'
import { ExplosionRecord, ScoreRecord, TankRecord, TanksMap } from '../../types'
import { put } from 'redux-saga/effects'
import { ExplosionRecord, ScoreRecord, TankRecord } from '../../types'
import { frame as f, getNextId } from '../../utils/common'
import { TANK_KILL_SCORE_MAP } from '../../utils/constants'
import Timing from '../../utils/Timing'
Expand Down Expand Up @@ -60,18 +60,8 @@ export function* destroyTank(tank: TankRecord) {
yield put<Action>({ type: 'DEACTIVATE_TANK', tankId: tank.tankId })

// 产生坦克爆炸效果
yield* explosionFromTank(tank)
yield explosionFromTank(tank)
if (tank.side === 'ai') {
yield* scoreFromKillTank(tank)
yield scoreFromKillTank(tank)
}
}

// 移除坦克 & 产生爆炸效果 & 显示击杀得分信息
export default function* destroyTanks(tanks: TanksMap) {
yield all(
tanks
.valueSeq()
.map(destroyTank)
.toArray(),
)
}
1 change: 0 additions & 1 deletion app/sagas/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as spawnTank } from './spawnTank'
export { default as destroyBullets } from './destroyBullets'
export { default as destroyTanks } from './destroyTanks'
export { default as flickerSaga } from './flickerSaga'
38 changes: 18 additions & 20 deletions app/sagas/powerUpManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { BLOCK_SIZE, N_MAP, POWER_UP_NAMES } from '../utils/constants'
import IndexHelper from '../utils/IndexHelper'
import * as selectors from '../utils/selectors'
import Timing from '../utils/Timing'
import { destroyTanks } from './common'
import powerUpLifecycle from './powerUpLifecycle'
import { destroyTank } from './common/destroyTanks'

function convertToBricks(map: MapRecord) {
const { eagle, steels, bricks } = map
Expand Down Expand Up @@ -117,20 +117,18 @@ function* grenade(action: Action.PickPowerUpAction) {
const { tanks: allTanks, players }: State = yield select()
const activeAITanks = allTanks.filter(t => t.active && t.side === 'ai')

yield* activeAITanks
.map(targetTank =>
put<Action.Kill>({
type: 'KILL',
sourcePlayer: action.player,
sourceTank: action.tank,
targetPlayer: players.find(p => p.activeTankId === targetTank.tankId),
targetTank,
method: 'grenade',
}),
)
.values()
for (const targetTank of activeAITanks.values()) {
yield put<Action.Kill>({
type: 'KILL',
sourcePlayer: action.player,
sourceTank: action.tank,
targetPlayer: players.find(p => p.activeTankId === targetTank.tankId),
targetTank,
method: 'grenade',
})

yield* destroyTanks(activeAITanks)
yield fork(destroyTank, targetTank)
}
}

function* star({ tank }: Action.PickPowerUpAction) {
Expand Down Expand Up @@ -227,15 +225,15 @@ function* spawnPowerUpIfNeccessary(action: Action.Hit) {
x: randint(0, 25) / 2 * BLOCK_SIZE,
y: randint(0, 25) / 2 * BLOCK_SIZE,
}
yield powerUpLifecycle(
new PowerUpRecord({
powerUpId: getNextId('power-up'),
yield powerUpLifecycle(
new PowerUpRecord({
powerUpId: getNextId('power-up'),
powerUpName,
visible: true,
visible: true,
x: position.x,
y: position.y,
}),
)
}),
)
}
}

Expand Down
13 changes: 4 additions & 9 deletions app/sagas/stageSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,8 @@ export default function* stageSaga(stage: StageConfig) {
)
if (remainingEnemies.isEmpty() && otherActiveAITanks.isEmpty()) {
// 剩余enemy数量为0, 且场上已经没有ai tank了
yield Timing.delay(3000)
const { powerUps }: State = yield select()
if (!powerUps.isEmpty()) {
// 如果场上有powerup, 则适当延长结束时间
yield Timing.delay(3000)
}
yield* statistics()
yield Timing.delay(DEV.FAST ? 1000 : 3000)
yield statistics()
yield put<Action>({ type: 'BEFORE_END_STAGE' })
yield put<Action>({ type: 'END_STAGE' })
return { pass: true } as StageResult
Expand All @@ -103,8 +98,8 @@ export default function* stageSaga(stage: StageConfig) {
// ai击杀human
if (!players.some(ply => ply.side === 'human' && ply.lives > 0)) {
// 所有的human player都挂了
yield Timing.delay(3000)
yield* statistics()
yield Timing.delay(DEV.FAST ? 1000 : 3000)
yield statistics()
// 因为 gameSaga 会 put END_GAME 所以这里不需要 put END_STAGE
return { pass: false, reason: 'dead' } as StageResult
}
Expand Down
56 changes: 56 additions & 0 deletions build/0.2.0/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 972f8b5

Please sign in to comment.