Skip to content

Commit

Permalink
更换素材,增加游戏模式
Browse files Browse the repository at this point in the history
  • Loading branch information
HK-SHAO committed Jul 26, 2022
1 parent 77aabe5 commit ce0a961
Show file tree
Hide file tree
Showing 29 changed files with 118 additions and 55 deletions.
Binary file modified assets/res/audio/end.mp3
Binary file not shown.
Binary file modified assets/res/audio/err.mp3
Binary file not shown.
Binary file modified assets/res/audio/tap.mp3
Binary file not shown.
4 changes: 2 additions & 2 deletions assets/res/image/ball.png.meta
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"userData": {
"wrapModeS": "mirrored-repeat",
"wrapModeT": "mirrored-repeat",
"minfilter": "linear",
"magfilter": "linear",
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
Expand Down
8 changes: 4 additions & 4 deletions assets/res/image/gongji.png.meta
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"minfilter": "linear",
"magfilter": "linear",
"wrapModeS": "mirrored-repeat",
"wrapModeT": "mirrored-repeat",
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
Expand Down
Binary file modified assets/res/image/kun-sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion assets/res/image/kun-sprite.png.meta
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
"type": "sprite-frame",
"fixAlphaTransparencyArtifacts": true,
"hasAlpha": false,
"redirect": "b43569c8-9493-4355-92c1-67f3d4ba96d4@f9941"
"redirect": "b43569c8-9493-4355-92c1-67f3d4ba96d4@f9941",
"compressSettings": {
"useCompressTexture": false
}
}
}
Binary file modified assets/res/image/kun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions assets/res/image/kun.png.meta
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"userData": {
"wrapModeS": "mirrored-repeat",
"wrapModeT": "mirrored-repeat",
"minfilter": "linear",
"magfilter": "linear",
"minfilter": "nearest",
"magfilter": "nearest",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
Expand All @@ -35,7 +35,7 @@
"userData": {
"type": "texture",
"fixAlphaTransparencyArtifacts": true,
"hasAlpha": false,
"hasAlpha": true,
"redirect": "2179c916-7da1-4a48-bf40-70c0b654f9d9@6c48a"
}
}
10 changes: 5 additions & 5 deletions assets/res/material/cube-material.mtl
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@
{
"mainColor": {
"__type__": "cc.Color",
"r": 255,
"g": 193,
"b": 158,
"r": 42,
"g": 42,
"b": 42,
"a": 255
},
"roughness": 0.715,
"metallic": 0.513,
"specularIntensity": 0.68,
"emissive": {
"__type__": "cc.Color",
"r": 201,
"g": 89,
"r": 31,
"g": 18,
"b": 0,
"a": 255
}
Expand Down
2 changes: 1 addition & 1 deletion assets/res/material/cube-physics-material.pmtl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"_name": "",
"_objFlags": 0,
"_native": "",
"_friction": 0.8,
"_friction": 0.7,
"_rollingFriction": 0,
"_spinningFriction": 0,
"_restitution": 0.1
Expand Down
36 changes: 32 additions & 4 deletions assets/res/material/kun-material.mtl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,38 @@
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "bf4078d6-d2d7-4073-83bb-cd6f1802e880",
"__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": "0",
"_defines": [
{
"USE_TEXTURE": true
}
"USE_ALBEDO_MAP": true,
"USE_EMISSIVE_MAP": true,
"USE_ALPHA_TEST": true
},
{},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
Expand All @@ -29,7 +51,13 @@
"mainTexture": {
"__uuid__": "2179c916-7da1-4a48-bf40-70c0b654f9d9@6c48a",
"__expectedType__": "cc.Texture2D"
},
"emissiveMap": {
"__uuid__": "2179c916-7da1-4a48-bf40-70c0b654f9d9@6c48a",
"__expectedType__": "cc.Texture2D"
}
}
},
{},
{}
]
}
12 changes: 6 additions & 6 deletions assets/scene/Main.scene
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": -21.213,
"y": 25.531,
"z": -10.215
"x": -19.332,
"y": 22.134,
"z": -13.072
},
"_lrot": {
"__type__": "cc.Quat",
Expand Down Expand Up @@ -121,7 +121,7 @@
"_shadowFixedArea": true,
"_shadowNear": 0.1,
"_shadowFar": 50,
"_shadowOrthoSize": 30,
"_shadowOrthoSize": 34,
"_id": "597uMYCbhEtJQc0ffJlcgA"
},
{
Expand Down Expand Up @@ -3112,7 +3112,7 @@
"b": 255,
"a": 255
},
"_string": "🐓",
"_string": "♾️",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 120,
Expand Down Expand Up @@ -3546,7 +3546,7 @@
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_isTrimmedMode": false,
"_useGrayscale": false,
"_atlas": null,
"_id": "84Mc7eiV1IyZcyJiAhwDPs"
Expand Down
2 changes: 1 addition & 1 deletion assets/script/game/AudioController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class AudioController extends Component {
audioSource: AudioSource = null;

public static playEffect(audio: AudioClip) {
AudioController.instance.audioSource.playOneShot(audio);
AudioController.instance?.audioSource?.playOneShot(audio);
}

start() {
Expand Down
4 changes: 2 additions & 2 deletions assets/script/game/Character/BallController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export class BallController extends BaseController {
onTouchStart(event: EventTouch) {
// Util.log('球被触摸到');

// 点到球扣一分
GameManager.curScore -= 1;
// 点到球加一分
GameManager.curScore += 1;
// 缓动销毁
Util.tweenDestroy(0.3, this.node, null);

Expand Down
29 changes: 22 additions & 7 deletions assets/script/game/Character/CubeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,31 @@ export class CubeController extends BaseController {
.to(0.3, { scale: v3(1, 1, 1) }, { easing: 'quartOut' })
.start();


// kunkun 掉落扣分
if (this.jiNode.active) {
GameManager.curScore -= 20;
AudioController.playEffect(AudioController.instance.errAudio);
} else {
GameManager.curScore -= 2;
}

if (GameManager.mode = 'inf') {
// 无穷模式掉落一个就死亡
GameManager.gameOver();
}
this.isDead = true;
}

// if (this.node.parent.name === 'Cubes') {
// // 限制最低速度
// let vec3 = v3();
// this.rigidbody.getLinearVelocity(vec3);
// let vel = 5 + 2 * Math.pow(GameManager.time, 0.5);
// if (vec3.z < vel) {
// vec3.z = vel;
// this.rigidbody.setLinearVelocity(vec3);
// }
// }
}

// 向摄像机方向移动
Expand Down Expand Up @@ -94,9 +109,9 @@ export class CubeController extends BaseController {

// 飞天
tween(this.node)
.by(0.4, { position: v3(0, this.node.position.z / 3, 0) }, { easing: 'smooth' })
.by(0.8, { position: v3(0, this.node.position.z / 3, 0) }, { easing: 'smooth' })
.call(() => {
this.node.destroy();
Util.tweenDestroy(0.3, this.node);

if (GameManager.mode === 'taimei') {
// 放一个篮球下去
Expand All @@ -108,8 +123,8 @@ export class CubeController extends BaseController {
}).start();

// 旋转鸡螺旋桨
Util.tweenNumber(0.4, 0, 1, (num: number) => {
this.jiNode?.setRotationFromEuler(v3(0, num * 360 * 4, 0))
Util.tweenNumber(0.8, 0, 1, (num: number) => {
this.jiNode?.setRotationFromEuler(v3(0, num * 360 * 8, 0))
});
}

Expand All @@ -119,12 +134,12 @@ export class CubeController extends BaseController {

onTouchEnd(event: EventTouch) {
// 恢复颜色
this.material.setProperty('albedo', this.initAlbedo);
// this.material.setProperty('albedo', this.initAlbedo);
}

onTouchCancel(event: EventTouch) {
// 恢复颜色
this.material.setProperty('albedo', this.initAlbedo);
// this.material.setProperty('albedo', this.initAlbedo);
}


Expand Down
53 changes: 35 additions & 18 deletions assets/script/game/GameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ export class GameManager extends Component {
private _maxScore: number = 0;
private _minScore: number = 0;

public static hp = Constant.INIT_HP;
public static time = 0;
public static hp = 0;
public static state: 'gameover' | 'normal' | 'idle' = 'normal';
public static mode: 'jini' | 'taimei' = 'jini';
public static mode: 'jini' | 'taimei' | 'inf' = 'inf';


start() {
Expand All @@ -87,7 +88,6 @@ export class GameManager extends Component {
}

// 初始化游戏
GameManager.state = 'normal';
this.gameOverLabel.node.setScale(v3(0, 0, 0));
this.gameOverSprite.node.setScale(v3(0, 0, 0));

Expand All @@ -102,9 +102,15 @@ export class GameManager extends Component {
}

update(deltaTime: number) {
GameManager.time += deltaTime;

// 时间流逝扣血
GameManager.hp -= deltaTime;
if (GameManager.mode === 'inf') {
// 时间流逝加血
GameManager.hp += deltaTime;
} else {
// 时间流逝扣血
GameManager.hp -= deltaTime;
}

// 小于 0 游戏结束
if (GameManager.hp < 0 && GameManager.state === 'normal') {
Expand All @@ -123,11 +129,14 @@ export class GameManager extends Component {
}

public onChangeButtonClick() {

if (GameManager.mode === 'jini') {
GameManager.mode = 'taimei';
GameManager.instance.buttonLabel.string = '🏀';
} else {
} else if (GameManager.mode === 'taimei') {
GameManager.mode = 'inf';
GameManager.instance.buttonLabel.string = '♾️';
}
else if (GameManager.mode === 'inf') {
GameManager.mode = 'jini';
GameManager.instance.buttonLabel.string = '🐓';
}
Expand Down Expand Up @@ -307,19 +316,27 @@ export class GameManager extends Component {

public static touchCubeOnce() {

// 与上次不同的随机选取一个
let index = 0;
for (; ;) {
index = randomRangeInt(0, GameManager.instance.cubesPosNode.children.length);
if (index != this.lastChoiceIndex) {
this.lastChoiceIndex = index;
break;
// 难度曲线
let normalTime = GameManager.time / 100;
let ex = Math.exp(normalTime);
let prob = ex / (1 + ex);

// 生成新砖块的概率
if (Math.random() < prob) {
// 与上次不同的随机选取一个
let index = 0;
for (; ;) {
index = randomRangeInt(0, GameManager.instance.cubesPosNode.children.length);
if (index != this.lastChoiceIndex) {
this.lastChoiceIndex = index;
break;
}
}
// 创建新方块
let cube = instantiate(GameManager.instance.cubesPosNode.children[index]);
cube.worldPosition = cube.position.add(v3(0, 0, cube.scale.z + 1));
GameManager.instance.cubesNode.addChild(cube);
}
// 创建新方块
let cube = instantiate(GameManager.instance.cubesPosNode.children[index]);
cube.worldPosition = cube.position.add(v3(0, 0, cube.scale.z + 1));
GameManager.instance.cubesNode.addChild(cube);

// 移动下一次
GameManager.instance.scheduleOnce(GameManager.moveCubesNext);
Expand Down
2 changes: 1 addition & 1 deletion assets/script/util/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Util {
}

// 缓动销毁
public static tweenDestroy(duration: number, node: Node, callback: () => void) {
public static tweenDestroy(duration: number, node: Node, callback: () => void = null) {
tween(node).to(duration, { scale: v3(0, 0, 0) }, { easing: 'quartOut' }).call(() => {
// Util.log('销毁', node);
node.destroy();
Expand Down
Binary file added doc/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/banner.psd
Binary file not shown.
Binary file added doc/ic_launcher.psd
Binary file not shown.
Binary file modified doc/image/Screenshot_com.shao.ikun.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/image/Screenshot_com.shao.ikun_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/video.psd
Binary file not shown.
Binary file added doc/蔡鸡篮球Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/蔡鸡篮球Icon.psd
Binary file not shown.
Binary file added doc/隐私政策.pdf
Binary file not shown.
Binary file added doc/隐私政策.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce0a961

Please sign in to comment.