diff --git a/assets/Data.meta b/assets/Data.meta new file mode 100644 index 0000000..9286473 --- /dev/null +++ b/assets/Data.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "c99ac9fe-c6a9-4142-a419-4d10885c744d", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/assets/Data/GameSettings.json b/assets/Data/GameSettings.json new file mode 100644 index 0000000..fe9477a --- /dev/null +++ b/assets/Data/GameSettings.json @@ -0,0 +1 @@ +{"playerSettings":{"defaultHP":50,"requiredXP":[],"collisionDelay":0},"weaponSettings":{"strikeDelay":0.5,"newTest":33}} \ No newline at end of file diff --git a/assets/Data/GameSettings.json.meta b/assets/Data/GameSettings.json.meta new file mode 100644 index 0000000..8a36066 --- /dev/null +++ b/assets/Data/GameSettings.json.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.0", + "importer": "json", + "imported": true, + "uuid": "6828fb79-0a56-437e-b718-9f43bf234fbc", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scenes/scene.scene b/assets/Scenes/scene.scene index cfdf7f2..f83b630 100644 --- a/assets/Scenes/scene.scene +++ b/assets/Scenes/scene.scene @@ -1070,7 +1070,7 @@ }, { "__type__": "cc.Node", - "_name": "EnemySpawner", + "_name": "XPSpawner", "_objFlags": 0, "_parent": { "__id__": 32 @@ -1109,10 +1109,10 @@ "y": 0, "z": 0 }, - "_id": "936Vpv3ydL8JZMvakVgAP5" + "_id": "b7cM/vyZtNY6PANwPA4aXG" }, { - "__type__": "8aa2aOTzVFLtKl5CV5vzpWp", + "__type__": "ab9e2Br8RpBfIFLB9KcWe1u", "_name": "", "_objFlags": 0, "node": { @@ -1120,17 +1120,15 @@ }, "_enabled": true, "__prefab": null, - "enemies": [ - { - "__uuid__": "fc9a455d-1b5f-460e-96eb-7c0ebf07d3d0", - "__expectedType__": "cc.Prefab" - } - ], - "_id": "0bYOmE6uFKe6bZiYUsXVFn" + "xpPrefab": { + "__uuid__": "b83dbe32-6b43-4ea9-b0e2-5f96c09f459d", + "__expectedType__": "cc.Prefab" + }, + "_id": "cbPY3r6KtPXJ5MuqA3BqfN" }, { "__type__": "cc.Node", - "_name": "XPSpawner", + "_name": "EnemySpawner", "_objFlags": 0, "_parent": { "__id__": 32 @@ -1169,10 +1167,10 @@ "y": 0, "z": 0 }, - "_id": "b7cM/vyZtNY6PANwPA4aXG" + "_id": "936Vpv3ydL8JZMvakVgAP5" }, { - "__type__": "ab9e2Br8RpBfIFLB9KcWe1u", + "__type__": "8aa2aOTzVFLtKl5CV5vzpWp", "_name": "", "_objFlags": 0, "node": { @@ -1180,11 +1178,13 @@ }, "_enabled": true, "__prefab": null, - "xpPrefab": { - "__uuid__": "b83dbe32-6b43-4ea9-b0e2-5f96c09f459d", - "__expectedType__": "cc.Prefab" - }, - "_id": "cbPY3r6KtPXJ5MuqA3BqfN" + "enemies": [ + { + "__uuid__": "fc9a455d-1b5f-460e-96eb-7c0ebf07d3d0", + "__expectedType__": "cc.Prefab" + } + ], + "_id": "0bYOmE6uFKe6bZiYUsXVFn" }, { "__type__": "c5416rtZLFCbpWbvH1cdF52", @@ -1196,10 +1196,10 @@ "_enabled": true, "__prefab": null, "enemySpawner": { - "__id__": 34 + "__id__": 36 }, "xpSpawner": { - "__id__": 36 + "__id__": 34 }, "_id": "389jvXDeVHmanyKnmtceKg" }, @@ -2836,6 +2836,10 @@ "modalWindowManager": { "__id__": 75 }, + "settingsAsset": { + "__uuid__": "6828fb79-0a56-437e-b718-9f43bf234fbc", + "__expectedType__": "cc.JsonAsset" + }, "_id": "3a9z1bqlFCGL4/WyDwU4L5" }, { diff --git a/assets/Scripts/Game/Data.meta b/assets/Scripts/Game/Data.meta new file mode 100644 index 0000000..15748db --- /dev/null +++ b/assets/Scripts/Game/Data.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "0811e8aa-50a1-4cee-8c6f-1ce5e4085e07", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/assets/Scripts/Game/Data/GameSettings.ts b/assets/Scripts/Game/Data/GameSettings.ts new file mode 100644 index 0000000..4da1209 --- /dev/null +++ b/assets/Scripts/Game/Data/GameSettings.ts @@ -0,0 +1,14 @@ +export class GameSettings { + public playerSettings: PlayerSettings = new PlayerSettings(); + public weaponSettings: WeaponSettings = new WeaponSettings(); +} + +export class PlayerSettings { + public defaultHP = 0; + public requiredXP: number[] = []; + public collisionDelay = 0; +} + +export class WeaponSettings { + public strikeDelay = 0; +} diff --git a/assets/Scripts/Game/Data/GameSettings.ts.meta b/assets/Scripts/Game/Data/GameSettings.ts.meta new file mode 100644 index 0000000..c971a4d --- /dev/null +++ b/assets/Scripts/Game/Data/GameSettings.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "5f9b9fda-b2fa-4c93-a328-8699238bdf09", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/Game/GameBootstrapper.ts b/assets/Scripts/Game/GameBootstrapper.ts index 6c2edd2..d91cf35 100644 --- a/assets/Scripts/Game/GameBootstrapper.ts +++ b/assets/Scripts/Game/GameBootstrapper.ts @@ -1,13 +1,16 @@ -import { Camera, CCFloat, CCInteger, Component, director, KeyCode, _decorator } from "cc"; +import { Camera, CCFloat, CCInteger, Component, director, JsonAsset, KeyCode, _decorator } from "cc"; import { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager"; import { PlayerCollisionSystem } from "./Collision/PlayerCollisionSystem"; import { WeaponCollisionSystem } from "./Collision/WeaponCollisionSystem"; +import { GameSettings } from "./Data/GameSettings"; import { EnemyManager } from "./Enemy/EnemyManager"; import { KeyboardInput } from "./Input/KeyboardInput"; import { MultiInput } from "./Input/MultiInput"; import { VirtualJoystic } from "./Input/VirtualJoystic"; import { Player } from "./Player/Player"; import { GameUI } from "./UI/GameUI"; +import { Upgrader } from "./Upgrades/Upgrader"; +import { UpgradeType } from "./Upgrades/UpgradeType"; import { Weapon } from "./Weapon"; const { ccclass, property } = _decorator; @@ -23,12 +26,19 @@ export class GameBootstrapper extends Component { @property(GameUI) private gameUI: GameUI; @property(Number) private requiredLevelXps: number[] = []; @property(ModalWindowManager) private modalWindowManager: ModalWindowManager; + @property(JsonAsset) private settingsAsset: JsonAsset; + @property(GameSettings) private settingsPref: GameSettings = new GameSettings(); private playerCollisionSystem: PlayerCollisionSystem; + private upgrader: Upgrader; private isPaused = false; public start(): void { + const gameSettings: GameSettings = this.settingsAsset.json; + console.log("Collision delay: " + gameSettings.playerSettings.collisionDelay); + console.log(JSON.stringify(new GameSettings())); + this.virtualJoystic.init(); this.weapon.init(this.strikeDelay); const wasd = new KeyboardInput(KeyCode.KEY_W, KeyCode.KEY_S, KeyCode.KEY_A, KeyCode.KEY_D); @@ -39,11 +49,15 @@ export class GameBootstrapper extends Component { this.playerCollisionSystem = new PlayerCollisionSystem(this.player, this.collisionDelay); new WeaponCollisionSystem(this.weapon); + this.upgrader = new Upgrader(this.player); + this.enemyManager.init(this.player.node); this.gameUI.init(this.player); this.showModal(); + + //console.log("DEfault hp: " + gameSettings.playerSettings.defaultHP); } public update(deltaTime: number): void { @@ -58,7 +72,7 @@ export class GameBootstrapper extends Component { private async showModal(): Promise { this.isPaused = true; - const result: string = await this.modalWindowManager.showModal("LevelUpModalWindow", "test params"); + const result: UpgradeType = await this.modalWindowManager.showModal("LevelUpModalWindow", "test params"); this.isPaused = false; console.log("Result: " + result); } diff --git a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts index 7d97128..67bad46 100644 --- a/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts +++ b/assets/Scripts/Game/UI/LevelUpWindow/LevelUpModalWindow.ts @@ -1,12 +1,13 @@ -import { CCString, instantiate, Node, Prefab, Vec3, _decorator } from "cc"; +import { instantiate, Node, Prefab, Vec3, _decorator } from "cc"; import { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow"; import { delay } from "../../../Services/Utils/AsyncUtils"; +import { UpgradeType } from "../../Upgrades/UpgradeType"; import { LevelUpSkill } from "./LevelUpSkill"; const { ccclass, property } = _decorator; @ccclass("LevelUpModalWindow") -export class LevelUpModalWindow extends ModalWindow { +export class LevelUpModalWindow extends ModalWindow { @property(Prefab) private skillPrefab: Prefab; @property(Node) private skillParent: Node; @@ -24,6 +25,6 @@ export class LevelUpModalWindow extends ModalWindow { } private chooseSkill(skill: LevelUpSkill): void { - this.dismiss("FInishedSuccessfuly"); + this.dismiss(UpgradeType.WeaponDamage); } } diff --git a/assets/Scripts/Game/Upgrades/UpgradeType.ts b/assets/Scripts/Game/Upgrades/UpgradeType.ts index f71c799..3f9305f 100644 --- a/assets/Scripts/Game/Upgrades/UpgradeType.ts +++ b/assets/Scripts/Game/Upgrades/UpgradeType.ts @@ -1,9 +1,12 @@ export enum UpgradeType { - MaxHP, WeaponLength, WeaponDamage, HorizontalProjectile, VerticalProjectile, - OverallDamage, Regeneration } + +export enum MetaUpgradeType { + MaxHp, + OverallDamage +} diff --git a/assets/Scripts/Game/Upgrades/Upgrader.ts b/assets/Scripts/Game/Upgrades/Upgrader.ts index c860649..e8affbc 100644 --- a/assets/Scripts/Game/Upgrades/Upgrader.ts +++ b/assets/Scripts/Game/Upgrades/Upgrader.ts @@ -5,16 +5,13 @@ export class Upgrader { private player: Player; private typeToAction: Map void> = new Map void>(); private typeToLevel: Map = new Map(); + private typeToMaxLevel: Map = new Map(); public constructor(player: Player) { this.player = player; - this.typeToAction.set(UpgradeType.MaxHP, this.upgradeMaxHp); - this.typeToAction.set(UpgradeType.WeaponLength, this.upgradeWeaponLength); - this.typeToAction.set(UpgradeType.WeaponDamage, this.upgradeWeaponDamage); - - this.typeToLevel.set(UpgradeType.MaxHP, 0); - this.typeToLevel.set(UpgradeType.WeaponLength, 0); + this.setTypeMaps(UpgradeType.WeaponLength, this.upgradeWeaponLength, 5); + this.setTypeMaps(UpgradeType.WeaponDamage, this.upgradeWeaponDamage, 5); } public upgradeSkill(type: UpgradeType): void { @@ -22,11 +19,10 @@ export class Upgrader { this.typeToAction.get(type)(); } - private upgradeMaxHp(): void { - const healthIncrease = 5; - const currentMax: number = this.player.Health.MaxHealthPoints; - this.player.Health.setMaxHealth(currentMax + healthIncrease); - this.player.Health.heal(healthIncrease); + private setTypeMaps(upgradeType: UpgradeType, action: () => void, maxLevel: number): void { + this.typeToAction.set(upgradeType, action); + this.typeToLevel.set(upgradeType, 0); + this.typeToMaxLevel.set(upgradeType, maxLevel); } private upgradeWeaponLength(): void { diff --git a/package-lock.json b/package-lock.json index 619869f..7fff52b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,8 +8,10 @@ "name": "VampSu", "version": "3.6.1", "dependencies": { + "@types/lodash": "^4.14.190", "eslint": "^8.25.0", "jest": "^29.2.2", + "lodash": "^4.17.21", "ts-jest": "^29.0.3" }, "devDependencies": { @@ -1154,6 +1156,11 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.14.190", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.190.tgz", + "integrity": "sha512-5iJ3FBJBvQHQ8sFhEhJfjUP+G+LalhavTkYyrAYqz5MEJG+erSv0k9KJLb6q7++17Lafk1scaTIFXcMJlwK8Mw==" + }, "node_modules/@types/node": { "version": "18.11.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.6.tgz", @@ -3801,6 +3808,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -5994,6 +6006,11 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "@types/lodash": { + "version": "4.14.190", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.190.tgz", + "integrity": "sha512-5iJ3FBJBvQHQ8sFhEhJfjUP+G+LalhavTkYyrAYqz5MEJG+erSv0k9KJLb6q7++17Lafk1scaTIFXcMJlwK8Mw==" + }, "@types/node": { "version": "18.11.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.6.tgz", @@ -7862,6 +7879,11 @@ "p-locate": "^5.0.0" } }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", diff --git a/package.json b/package.json index bd9c586..4adde9a 100644 --- a/package.json +++ b/package.json @@ -10,17 +10,19 @@ "test": "jest" }, "dependencies": { + "@types/lodash": "^4.14.190", "eslint": "^8.25.0", "jest": "^29.2.2", + "lodash": "^4.17.21", "ts-jest": "^29.0.3" }, "devDependencies": { - "@types/node": "^18.11.6", "@types/jest": "^29.2.0", + "@types/node": "^18.11.6", "@typescript-eslint/eslint-plugin": "^5.40.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "^7.31.10", "prettier": "^2.7.1" } -} +} \ No newline at end of file diff --git a/utils/regenerateGameSettings.ts b/utils/regenerateGameSettings.ts new file mode 100644 index 0000000..697896d --- /dev/null +++ b/utils/regenerateGameSettings.ts @@ -0,0 +1,15 @@ +import { readFileSync, writeFileSync } from "fs"; +import { merge } from "lodash"; +import { GameSettings } from "../assets/Scripts/Game/Data/GameSettings"; + +regenerateGameSettings(); +function regenerateGameSettings(): void { + const settingsPath: string = process.argv[2]; + + const blankSettings: GameSettings = new GameSettings(); + const savedSettingsJson: string = readFileSync(settingsPath, "utf8"); + const savedSettings: GameSettings = JSON.parse(savedSettingsJson); + + const result: GameSettings = merge(blankSettings, savedSettings); + writeFileSync(settingsPath, JSON.stringify(result)); +}