mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Game settings, tool to regenerate
This commit is contained in:
12
assets/Scripts/Game/Data.meta
Normal file
12
assets/Scripts/Game/Data.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "0811e8aa-50a1-4cee-8c6f-1ce5e4085e07",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
14
assets/Scripts/Game/Data/GameSettings.ts
Normal file
14
assets/Scripts/Game/Data/GameSettings.ts
Normal 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;
|
||||
}
|
9
assets/Scripts/Game/Data/GameSettings.ts.meta
Normal file
9
assets/Scripts/Game/Data/GameSettings.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5f9b9fda-b2fa-4c93-a328-8699238bdf09",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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 = <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<void> {
|
||||
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;
|
||||
console.log("Result: " + result);
|
||||
}
|
||||
|
@@ -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<string, string> {
|
||||
export class LevelUpModalWindow extends ModalWindow<string, UpgradeType> {
|
||||
@property(Prefab) private skillPrefab: Prefab;
|
||||
@property(Node) private skillParent: Node;
|
||||
|
||||
@@ -24,6 +25,6 @@ export class LevelUpModalWindow extends ModalWindow<string, string> {
|
||||
}
|
||||
|
||||
private chooseSkill(skill: LevelUpSkill): void {
|
||||
this.dismiss("FInishedSuccessfuly");
|
||||
this.dismiss(UpgradeType.WeaponDamage);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,12 @@
|
||||
export enum UpgradeType {
|
||||
MaxHP,
|
||||
WeaponLength,
|
||||
WeaponDamage,
|
||||
HorizontalProjectile,
|
||||
VerticalProjectile,
|
||||
OverallDamage,
|
||||
Regeneration
|
||||
}
|
||||
|
||||
export enum MetaUpgradeType {
|
||||
MaxHp,
|
||||
OverallDamage
|
||||
}
|
||||
|
@@ -5,16 +5,13 @@ export class Upgrader {
|
||||
private player: Player;
|
||||
private typeToAction: Map<UpgradeType, () => void> = new Map<UpgradeType, () => void>();
|
||||
private typeToLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
|
||||
private typeToMaxLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
|
||||
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user