mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
Chest and magnet spawning
This commit is contained in:
parent
4b2d35a733
commit
afc9448826
@ -155,7 +155,9 @@
|
||||
"lifetime": -1,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0,
|
||||
"healthPotionRewardChance": 0.05
|
||||
"healthPotionRewardChance": 0.05,
|
||||
"magnetRewardChance": 0.5,
|
||||
"chestRewardChance": 0.5
|
||||
},
|
||||
{
|
||||
"id": "StandardEnemy",
|
||||
@ -167,7 +169,9 @@
|
||||
"lifetime": -1,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0.1,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "FastEnemy",
|
||||
@ -179,7 +183,9 @@
|
||||
"lifetime": -1,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0.1,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "CircleEnemy",
|
||||
@ -191,7 +197,9 @@
|
||||
"lifetime": 29,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "CircleEnemyStandard",
|
||||
@ -203,7 +211,9 @@
|
||||
"lifetime": 27,
|
||||
"xpReward": 1,
|
||||
"goldReward": 2,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "WaveEnemy",
|
||||
@ -215,7 +225,9 @@
|
||||
"lifetime": 20,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0.2,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "WaveEnemyArmor",
|
||||
@ -227,7 +239,9 @@
|
||||
"lifetime": 30,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "WaveEnemyArmorFast",
|
||||
@ -239,7 +253,9 @@
|
||||
"lifetime": 30,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "BasicBoss",
|
||||
@ -251,7 +267,9 @@
|
||||
"lifetime": -1,
|
||||
"xpReward": 1,
|
||||
"goldReward": 3,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "StandardBoss",
|
||||
@ -263,7 +281,9 @@
|
||||
"lifetime": -1,
|
||||
"xpReward": 2,
|
||||
"goldReward": 5,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
},
|
||||
{
|
||||
"id": "BasicCheetah",
|
||||
@ -275,7 +295,9 @@
|
||||
"lifetime": -1,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1,
|
||||
"healthPotionRewardChance": 0
|
||||
"healthPotionRewardChance": 0,
|
||||
"magnetRewardChance": 0,
|
||||
"chestRewardChance": 0
|
||||
}
|
||||
],
|
||||
"periodicFollowMovers": [
|
||||
|
BIN
assets/Media/Audio/Game/Sound/01_chest_open_1.wav
Normal file
BIN
assets/Media/Audio/Game/Sound/01_chest_open_1.wav
Normal file
Binary file not shown.
14
assets/Media/Audio/Game/Sound/01_chest_open_1.wav.meta
Normal file
14
assets/Media/Audio/Game/Sound/01_chest_open_1.wav.meta
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "a26cfab9-1d95-4f99-83bf-297696072f6c",
|
||||
"files": [
|
||||
".json",
|
||||
".wav"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
@ -98,6 +98,14 @@
|
||||
"__uuid__": "b1564752-035d-4989-aed0-2c0684d8a0e9",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"magnetPickup": {
|
||||
"__uuid__": "a26cfab9-1d95-4f99-83bf-297696072f6c",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"chestPickup": {
|
||||
"__uuid__": "a26cfab9-1d95-4f99-83bf-297696072f6c",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"levelUp": {
|
||||
"__uuid__": "4bf29238-2767-4178-a74a-3c2857685265",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
|
@ -27,7 +27,7 @@
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": {
|
||||
"__id__": 116
|
||||
"__id__": 114
|
||||
},
|
||||
"autoReleaseAssets": false,
|
||||
"_globals": {
|
||||
@ -3341,115 +3341,16 @@
|
||||
"modalWindowManager": {
|
||||
"__id__": 96
|
||||
},
|
||||
"gameAudioAdapter": {
|
||||
"__id__": 114
|
||||
},
|
||||
"gameAudioAdapter": null,
|
||||
"_id": "3a9z1bqlFCGL4/WyDwU4L5"
|
||||
},
|
||||
{
|
||||
"__type__": "eb842QdTMFOUJEdwMiA7AJN",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 115
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"music": {
|
||||
"__uuid__": "0faecdcf-e5d6-4cc1-b3cf-3b2873f8ee62",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"enemyHit": {
|
||||
"__uuid__": "efed223f-7b17-47ad-b265-7a951ace6d85",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"playerHit": {
|
||||
"__uuid__": "99fb12ce-b248-4560-85fd-c1a61689adf2",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"playerDeath": {
|
||||
"__uuid__": "68ebed5f-544b-4337-a49c-d4ba32e8e6a2",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"weaponSwing": {
|
||||
"__uuid__": "5ad08e27-4461-464a-ad19-8c933abf5a5d",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"xpPickup": {
|
||||
"__uuid__": "6af287fc-820f-4e12-8b8f-858a5dd41d2c",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"goldPickup": {
|
||||
"__uuid__": "580b2ceb-3daa-409b-b6c4-7d81c7182650",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"healthPotionPickup": {
|
||||
"__uuid__": "b1564752-035d-4989-aed0-2c0684d8a0e9",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"levelUp": {
|
||||
"__uuid__": "4bf29238-2767-4178-a74a-3c2857685265",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"horizontalProjectileLaunch": {
|
||||
"__uuid__": "36c577cb-8a85-40a7-9390-455863dfef8f",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"diagonalProjectileLaunch": {
|
||||
"__uuid__": "adeff7ed-6f7e-471b-8790-d0eb14e048f9",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"haloProjectileLaunch": {
|
||||
"__uuid__": "a7b634e1-7842-402c-a2a9-4007435c9a4a",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"_id": "8fIp3RG7RDK6FMarL5A96h"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "GameAudioAdapter",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 114
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -319.99999999999994,
|
||||
"y": -479.99999999999994,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_layer": 1073741824,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": "62B+OqAzROoon1s4L/Ur4W"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"fileId": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f",
|
||||
"targetOverrides": [
|
||||
{
|
||||
"__id__": 115
|
||||
},
|
||||
{
|
||||
"__id__": 117
|
||||
}
|
||||
@ -3479,7 +3380,7 @@
|
||||
"__id__": 32
|
||||
},
|
||||
"targetInfo": {
|
||||
"__id__": 118
|
||||
"__id__": 116
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -3488,6 +3389,28 @@
|
||||
"73GtzRGABId6PSqMhTW/3T"
|
||||
]
|
||||
},
|
||||
{
|
||||
"__type__": "cc.TargetOverrideInfo",
|
||||
"source": {
|
||||
"__id__": 113
|
||||
},
|
||||
"sourceInfo": null,
|
||||
"propertyPath": [
|
||||
"gameAudioAdapter"
|
||||
],
|
||||
"target": {
|
||||
"__id__": 13
|
||||
},
|
||||
"targetInfo": {
|
||||
"__id__": 118
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.TargetInfo",
|
||||
"localID": [
|
||||
"b2ILEwH8JJmYiJlSWbxV6z"
|
||||
]
|
||||
},
|
||||
{
|
||||
"__type__": "cc.SceneGlobals",
|
||||
"ambient": {
|
||||
|
@ -20,6 +20,8 @@ export class GameAudioAdapter extends Component {
|
||||
@property(AudioClip) private xpPickup: AudioClip;
|
||||
@property(AudioClip) private goldPickup: AudioClip;
|
||||
@property(AudioClip) private healthPotionPickup: AudioClip;
|
||||
@property(AudioClip) private magnetPickup: AudioClip;
|
||||
@property(AudioClip) private chestPickup: AudioClip;
|
||||
@property(AudioClip) private levelUp: AudioClip;
|
||||
@property(AudioClip) private horizontalProjectileLaunch: AudioClip;
|
||||
@property(AudioClip) private diagonalProjectileLaunch: AudioClip;
|
||||
@ -89,6 +91,12 @@ export class GameAudioAdapter extends Component {
|
||||
case ItemType.HealthPotion:
|
||||
clipToPlay = this.healthPotionPickup;
|
||||
break;
|
||||
case ItemType.Magnet:
|
||||
clipToPlay = this.magnetPickup;
|
||||
break;
|
||||
case ItemType.Chest:
|
||||
clipToPlay = this.chestPickup;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -127,6 +127,8 @@ export class EnemySettings {
|
||||
public xpReward = 0;
|
||||
public goldReward = 0;
|
||||
public healthPotionRewardChance = 0;
|
||||
public magnetRewardChance = 0;
|
||||
public chestRewardChance = 0;
|
||||
}
|
||||
|
||||
export class ItemSettings {
|
||||
|
@ -49,6 +49,8 @@ export class ItemManager extends Component {
|
||||
this.itemTypeToAction.set(ItemType.XP, this.addXP.bind(this));
|
||||
this.itemTypeToAction.set(ItemType.Gold, this.addGold.bind(this));
|
||||
this.itemTypeToAction.set(ItemType.HealthPotion, this.useHealthPotion.bind(this));
|
||||
this.itemTypeToAction.set(ItemType.Magnet, this.activateMagnet.bind(this));
|
||||
this.itemTypeToAction.set(ItemType.Chest, this.giveRandomSkill.bind(this));
|
||||
}
|
||||
|
||||
public get PickupEvent(): ISignal<ItemType> {
|
||||
@ -78,6 +80,10 @@ export class ItemManager extends Component {
|
||||
this.player.Health.heal(this.healthPerPotion);
|
||||
}
|
||||
|
||||
private activateMagnet(): void {}
|
||||
|
||||
private giveRandomSkill(): void {}
|
||||
|
||||
private addEnemyListeners(enemy: Enemy): void {
|
||||
enemy.DeathEvent.on(this.trySpawnItems, this);
|
||||
}
|
||||
@ -89,7 +95,9 @@ export class ItemManager extends Component {
|
||||
private trySpawnItems(enemy: Enemy): void {
|
||||
this.trySpawnXP(enemy);
|
||||
this.trySpawnGold(enemy);
|
||||
this.trySpawnHealthPotion(enemy);
|
||||
ItemManager.trySpawnOnce(enemy.HealthPotionRewardChance, this.healthPotionSpawner, this.getRandomPosition(enemy));
|
||||
ItemManager.trySpawnOnce(enemy.MagnetRewardChance, this.magnetSpawner, this.getRandomPosition(enemy));
|
||||
ItemManager.trySpawnOnce(enemy.ChestRewardChance, this.chestSpawner, this.getRandomPosition(enemy));
|
||||
}
|
||||
|
||||
private trySpawnXP(enemy: Enemy): void {
|
||||
@ -112,19 +120,16 @@ export class ItemManager extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
private trySpawnHealthPotion(enemy: Enemy): void {
|
||||
if (enemy.HealthPotionRewardChance <= 0) return;
|
||||
|
||||
console.log("random: " + random() + " chance " + enemy.HealthPotionRewardChance);
|
||||
if (random() < enemy.HealthPotionRewardChance) {
|
||||
this.healthPotionSpawner.spawn(enemy.node.worldPosition);
|
||||
private static trySpawnOnce(chance: number, itemSpawner: ItemSpawner, worldPosition: Vec3): void {
|
||||
if (random() < chance) {
|
||||
itemSpawner.spawn(worldPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private getRandomPosition(enemy: Enemy): Vec3 {
|
||||
const position: Vec3 = enemy.node.worldPosition;
|
||||
position.x += randomRange(-10, 10);
|
||||
position.y += randomRange(-10, 10);
|
||||
position.x += randomRange(-15, 15);
|
||||
position.y += randomRange(-15, 15);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ export class Enemy extends Component {
|
||||
private xpReward: number;
|
||||
private goldReward: number;
|
||||
private healthPotionRewardChance: number;
|
||||
private magnetRewardChance: number;
|
||||
private chestRewardChance: number;
|
||||
|
||||
private endOfLifetimeTriggered = false;
|
||||
|
||||
@ -44,6 +46,8 @@ export class Enemy extends Component {
|
||||
this.xpReward = settings.xpReward;
|
||||
this.goldReward = settings.goldReward;
|
||||
this.healthPotionRewardChance = settings.healthPotionRewardChance;
|
||||
this.magnetRewardChance = settings.magnetRewardChance;
|
||||
this.chestRewardChance = settings.chestRewardChance;
|
||||
|
||||
this.node.setWorldPosition(position);
|
||||
this.node.active = true;
|
||||
@ -88,6 +92,14 @@ export class Enemy extends Component {
|
||||
return this.healthPotionRewardChance;
|
||||
}
|
||||
|
||||
public get MagnetRewardChance(): number {
|
||||
return this.magnetRewardChance;
|
||||
}
|
||||
|
||||
public get ChestRewardChance(): number {
|
||||
return this.chestRewardChance;
|
||||
}
|
||||
|
||||
public get LifetimeEndedEvent(): ISignal<Enemy> {
|
||||
return this.lifetimeEndedEvent;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user