Game settings, tool to regenerate

This commit is contained in:
Martin 2022-11-24 13:17:05 +01:00
parent b1f8f66499
commit 1c30cb93ea
14 changed files with 156 additions and 40 deletions

12
assets/Data.meta Normal file
View File

@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "c99ac9fe-c6a9-4142-a419-4d10885c744d",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@ -0,0 +1 @@
{"playerSettings":{"defaultHP":50,"requiredXP":[],"collisionDelay":0},"weaponSettings":{"strikeDelay":0.5,"newTest":33}}

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.0",
"importer": "json",
"imported": true,
"uuid": "6828fb79-0a56-437e-b718-9f43bf234fbc",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -1070,7 +1070,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "EnemySpawner", "_name": "XPSpawner",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 32 "__id__": 32
@ -1109,10 +1109,10 @@
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
"_id": "936Vpv3ydL8JZMvakVgAP5" "_id": "b7cM/vyZtNY6PANwPA4aXG"
}, },
{ {
"__type__": "8aa2aOTzVFLtKl5CV5vzpWp", "__type__": "ab9e2Br8RpBfIFLB9KcWe1u",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
@ -1120,17 +1120,15 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"enemies": [ "xpPrefab": {
{ "__uuid__": "b83dbe32-6b43-4ea9-b0e2-5f96c09f459d",
"__uuid__": "fc9a455d-1b5f-460e-96eb-7c0ebf07d3d0", "__expectedType__": "cc.Prefab"
"__expectedType__": "cc.Prefab" },
} "_id": "cbPY3r6KtPXJ5MuqA3BqfN"
],
"_id": "0bYOmE6uFKe6bZiYUsXVFn"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "XPSpawner", "_name": "EnemySpawner",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 32 "__id__": 32
@ -1169,10 +1167,10 @@
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
"_id": "b7cM/vyZtNY6PANwPA4aXG" "_id": "936Vpv3ydL8JZMvakVgAP5"
}, },
{ {
"__type__": "ab9e2Br8RpBfIFLB9KcWe1u", "__type__": "8aa2aOTzVFLtKl5CV5vzpWp",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
@ -1180,11 +1178,13 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"xpPrefab": { "enemies": [
"__uuid__": "b83dbe32-6b43-4ea9-b0e2-5f96c09f459d", {
"__expectedType__": "cc.Prefab" "__uuid__": "fc9a455d-1b5f-460e-96eb-7c0ebf07d3d0",
}, "__expectedType__": "cc.Prefab"
"_id": "cbPY3r6KtPXJ5MuqA3BqfN" }
],
"_id": "0bYOmE6uFKe6bZiYUsXVFn"
}, },
{ {
"__type__": "c5416rtZLFCbpWbvH1cdF52", "__type__": "c5416rtZLFCbpWbvH1cdF52",
@ -1196,10 +1196,10 @@
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"enemySpawner": { "enemySpawner": {
"__id__": 34 "__id__": 36
}, },
"xpSpawner": { "xpSpawner": {
"__id__": 36 "__id__": 34
}, },
"_id": "389jvXDeVHmanyKnmtceKg" "_id": "389jvXDeVHmanyKnmtceKg"
}, },
@ -2836,6 +2836,10 @@
"modalWindowManager": { "modalWindowManager": {
"__id__": 75 "__id__": 75
}, },
"settingsAsset": {
"__uuid__": "6828fb79-0a56-437e-b718-9f43bf234fbc",
"__expectedType__": "cc.JsonAsset"
},
"_id": "3a9z1bqlFCGL4/WyDwU4L5" "_id": "3a9z1bqlFCGL4/WyDwU4L5"
}, },
{ {

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "0811e8aa-50a1-4cee-8c6f-1ce5e4085e07",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@ -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;
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "5f9b9fda-b2fa-4c93-a328-8699238bdf09",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -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 { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager";
import { PlayerCollisionSystem } from "./Collision/PlayerCollisionSystem"; import { PlayerCollisionSystem } from "./Collision/PlayerCollisionSystem";
import { WeaponCollisionSystem } from "./Collision/WeaponCollisionSystem"; import { WeaponCollisionSystem } from "./Collision/WeaponCollisionSystem";
import { GameSettings } from "./Data/GameSettings";
import { EnemyManager } from "./Enemy/EnemyManager"; import { EnemyManager } from "./Enemy/EnemyManager";
import { KeyboardInput } from "./Input/KeyboardInput"; import { KeyboardInput } from "./Input/KeyboardInput";
import { MultiInput } from "./Input/MultiInput"; import { MultiInput } from "./Input/MultiInput";
import { VirtualJoystic } from "./Input/VirtualJoystic"; import { VirtualJoystic } from "./Input/VirtualJoystic";
import { Player } from "./Player/Player"; import { Player } from "./Player/Player";
import { GameUI } from "./UI/GameUI"; import { GameUI } from "./UI/GameUI";
import { Upgrader } from "./Upgrades/Upgrader";
import { UpgradeType } from "./Upgrades/UpgradeType";
import { Weapon } from "./Weapon"; import { Weapon } from "./Weapon";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ -23,12 +26,19 @@ export class GameBootstrapper extends Component {
@property(GameUI) private gameUI: GameUI; @property(GameUI) private gameUI: GameUI;
@property(Number) private requiredLevelXps: number[] = []; @property(Number) private requiredLevelXps: number[] = [];
@property(ModalWindowManager) private modalWindowManager: ModalWindowManager; @property(ModalWindowManager) private modalWindowManager: ModalWindowManager;
@property(JsonAsset) private settingsAsset: JsonAsset;
@property(GameSettings) private settingsPref: GameSettings = new GameSettings();
private playerCollisionSystem: PlayerCollisionSystem; private playerCollisionSystem: PlayerCollisionSystem;
private upgrader: Upgrader;
private isPaused = false; private isPaused = false;
public start(): void { public start(): void {
const gameSettings: GameSettings = <GameSettings>this.settingsAsset.json;
console.log("Collision delay: " + gameSettings.playerSettings.collisionDelay);
console.log(JSON.stringify(new GameSettings()));
this.virtualJoystic.init(); this.virtualJoystic.init();
this.weapon.init(this.strikeDelay); this.weapon.init(this.strikeDelay);
const wasd = new KeyboardInput(KeyCode.KEY_W, KeyCode.KEY_S, KeyCode.KEY_A, KeyCode.KEY_D); 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); this.playerCollisionSystem = new PlayerCollisionSystem(this.player, this.collisionDelay);
new WeaponCollisionSystem(this.weapon); new WeaponCollisionSystem(this.weapon);
this.upgrader = new Upgrader(this.player);
this.enemyManager.init(this.player.node); this.enemyManager.init(this.player.node);
this.gameUI.init(this.player); this.gameUI.init(this.player);
this.showModal(); this.showModal();
//console.log("DEfault hp: " + gameSettings.playerSettings.defaultHP);
} }
public update(deltaTime: number): void { public update(deltaTime: number): void {
@ -58,7 +72,7 @@ export class GameBootstrapper extends Component {
private async showModal(): Promise<void> { private async showModal(): Promise<void> {
this.isPaused = true; this.isPaused = true;
const result: string = await this.modalWindowManager.showModal<string, string>("LevelUpModalWindow", "test params"); const result: UpgradeType = await this.modalWindowManager.showModal<string, UpgradeType>("LevelUpModalWindow", "test params");
this.isPaused = false; this.isPaused = false;
console.log("Result: " + result); console.log("Result: " + result);
} }

View File

@ -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 { ModalWindow } from "../../../Services/ModalWindowSystem/ModalWindow";
import { delay } from "../../../Services/Utils/AsyncUtils"; import { delay } from "../../../Services/Utils/AsyncUtils";
import { UpgradeType } from "../../Upgrades/UpgradeType";
import { LevelUpSkill } from "./LevelUpSkill"; import { LevelUpSkill } from "./LevelUpSkill";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass("LevelUpModalWindow") @ccclass("LevelUpModalWindow")
export class LevelUpModalWindow extends ModalWindow<string, string> { export class LevelUpModalWindow extends ModalWindow<string, UpgradeType> {
@property(Prefab) private skillPrefab: Prefab; @property(Prefab) private skillPrefab: Prefab;
@property(Node) private skillParent: Node; @property(Node) private skillParent: Node;
@ -24,6 +25,6 @@ export class LevelUpModalWindow extends ModalWindow<string, string> {
} }
private chooseSkill(skill: LevelUpSkill): void { private chooseSkill(skill: LevelUpSkill): void {
this.dismiss("FInishedSuccessfuly"); this.dismiss(UpgradeType.WeaponDamage);
} }
} }

View File

@ -1,9 +1,12 @@
export enum UpgradeType { export enum UpgradeType {
MaxHP,
WeaponLength, WeaponLength,
WeaponDamage, WeaponDamage,
HorizontalProjectile, HorizontalProjectile,
VerticalProjectile, VerticalProjectile,
OverallDamage,
Regeneration Regeneration
} }
export enum MetaUpgradeType {
MaxHp,
OverallDamage
}

View File

@ -5,16 +5,13 @@ export class Upgrader {
private player: Player; private player: Player;
private typeToAction: Map<UpgradeType, () => void> = new Map<UpgradeType, () => void>(); private typeToAction: Map<UpgradeType, () => void> = new Map<UpgradeType, () => void>();
private typeToLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>(); private typeToLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
private typeToMaxLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
public constructor(player: Player) { public constructor(player: Player) {
this.player = player; this.player = player;
this.typeToAction.set(UpgradeType.MaxHP, this.upgradeMaxHp); this.setTypeMaps(UpgradeType.WeaponLength, this.upgradeWeaponLength, 5);
this.typeToAction.set(UpgradeType.WeaponLength, this.upgradeWeaponLength); this.setTypeMaps(UpgradeType.WeaponDamage, this.upgradeWeaponDamage, 5);
this.typeToAction.set(UpgradeType.WeaponDamage, this.upgradeWeaponDamage);
this.typeToLevel.set(UpgradeType.MaxHP, 0);
this.typeToLevel.set(UpgradeType.WeaponLength, 0);
} }
public upgradeSkill(type: UpgradeType): void { public upgradeSkill(type: UpgradeType): void {
@ -22,11 +19,10 @@ export class Upgrader {
this.typeToAction.get(type)(); this.typeToAction.get(type)();
} }
private upgradeMaxHp(): void { private setTypeMaps(upgradeType: UpgradeType, action: () => void, maxLevel: number): void {
const healthIncrease = 5; this.typeToAction.set(upgradeType, action);
const currentMax: number = this.player.Health.MaxHealthPoints; this.typeToLevel.set(upgradeType, 0);
this.player.Health.setMaxHealth(currentMax + healthIncrease); this.typeToMaxLevel.set(upgradeType, maxLevel);
this.player.Health.heal(healthIncrease);
} }
private upgradeWeaponLength(): void { private upgradeWeaponLength(): void {

22
package-lock.json generated
View File

@ -8,8 +8,10 @@
"name": "VampSu", "name": "VampSu",
"version": "3.6.1", "version": "3.6.1",
"dependencies": { "dependencies": {
"@types/lodash": "^4.14.190",
"eslint": "^8.25.0", "eslint": "^8.25.0",
"jest": "^29.2.2", "jest": "^29.2.2",
"lodash": "^4.17.21",
"ts-jest": "^29.0.3" "ts-jest": "^29.0.3"
}, },
"devDependencies": { "devDependencies": {
@ -1154,6 +1156,11 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "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": { "node_modules/@types/node": {
"version": "18.11.6", "version": "18.11.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.6.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.6.tgz",
@ -3801,6 +3808,11 @@
"url": "https://github.com/sponsors/sindresorhus" "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": { "node_modules/lodash.memoize": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", "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==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "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": { "@types/node": {
"version": "18.11.6", "version": "18.11.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.6.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.6.tgz",
@ -7862,6 +7879,11 @@
"p-locate": "^5.0.0" "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": { "lodash.memoize": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",

View File

@ -10,13 +10,15 @@
"test": "jest" "test": "jest"
}, },
"dependencies": { "dependencies": {
"@types/lodash": "^4.14.190",
"eslint": "^8.25.0", "eslint": "^8.25.0",
"jest": "^29.2.2", "jest": "^29.2.2",
"lodash": "^4.17.21",
"ts-jest": "^29.0.3" "ts-jest": "^29.0.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.11.6",
"@types/jest": "^29.2.0", "@types/jest": "^29.2.0",
"@types/node": "^18.11.6",
"@typescript-eslint/eslint-plugin": "^5.40.1", "@typescript-eslint/eslint-plugin": "^5.40.1",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",

View File

@ -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 = <GameSettings>JSON.parse(savedSettingsJson);
const result: GameSettings = merge(blankSettings, savedSettings);
writeFileSync(settingsPath, JSON.stringify(result));
}