mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-25 11:18:54 +00:00
Chest modal
This commit is contained in:
parent
756e9db049
commit
bbae1a3145
@ -173,7 +173,7 @@
|
||||
"goldReward": 0,
|
||||
"healthPotionRewardChance": 0.01,
|
||||
"magnetRewardChance": 0.01,
|
||||
"chestRewardChance": 0
|
||||
"chestRewardChance": 1
|
||||
},
|
||||
{
|
||||
"id": "StandardEnemy",
|
||||
@ -471,9 +471,9 @@
|
||||
"individualEnemySpawners": [
|
||||
{
|
||||
"common": {
|
||||
"enemyId": "SiegeEnemyRanged",
|
||||
"enemyId": "BasicEnemy",
|
||||
"startDelay": 0,
|
||||
"stopDelay": 2,
|
||||
"stopDelay": 100,
|
||||
"cooldown": 1
|
||||
}
|
||||
},
|
||||
|
12
assets/Media/Prefabs/ModalWindows/Chest.meta
Normal file
12
assets/Media/Prefabs/ModalWindows/Chest.meta
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "5bf41cb5-9a22-495b-91ae-a8dcd4cd7e46",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
1626
assets/Media/Prefabs/ModalWindows/Chest/ChestModalWindow.prefab
Normal file
1626
assets/Media/Prefabs/ModalWindows/Chest/ChestModalWindow.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
||||
{
|
||||
"ver": "1.1.40",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "d07d3ad3-88c1-4b8e-af61-05f53a405d59",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "ChestModalWindow"
|
||||
}
|
||||
}
|
@ -269,7 +269,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 319.99999999999994,
|
||||
"y": 479.99999999999994,
|
||||
"y": 480.00000000000006,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@ -1639,7 +1639,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -320,
|
||||
"y": 480,
|
||||
"y": 480.0000000000001,
|
||||
"z": -1000
|
||||
},
|
||||
"_lrot": {
|
||||
@ -2954,6 +2954,10 @@
|
||||
{
|
||||
"__uuid__": "cc259578-1eb4-4dd3-87b0-fd42c11668b1",
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
{
|
||||
"__uuid__": "d07d3ad3-88c1-4b8e-af61-05f53a405d59",
|
||||
"__expectedType__": "cc.Prefab"
|
||||
}
|
||||
],
|
||||
"_id": "1afHrrV8tIPrYb4xymz6bQ"
|
||||
@ -3391,7 +3395,7 @@
|
||||
"_priority": 1073741824,
|
||||
"_fov": 45,
|
||||
"_fovAxis": 0,
|
||||
"_orthoHeight": 480,
|
||||
"_orthoHeight": 480.00000000000006,
|
||||
"_near": 0,
|
||||
"_far": 2000,
|
||||
"_color": {
|
||||
@ -3622,8 +3626,8 @@
|
||||
"_target": null,
|
||||
"_left": -5.684341886080802e-14,
|
||||
"_right": 0,
|
||||
"_top": 0,
|
||||
"_bottom": -5.684341886080802e-14,
|
||||
"_top": 1.1368683772161603e-13,
|
||||
"_bottom": 5.684341886080802e-14,
|
||||
"_horizontalCenter": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
|
@ -97,7 +97,6 @@ export class Game extends Component {
|
||||
|
||||
this.player.init(multiInput, this.createPlayerData(settings.player, metaUpgrades));
|
||||
this.enemyManager.init(this.player.node, settings.enemyManager);
|
||||
this.itemManager.init(this.enemyManager, this.player, this.gameResult, settings.items);
|
||||
|
||||
this.playerCollisionSystem = new PlayerCollisionSystem(this.player, settings.player.collisionDelay, this.itemManager);
|
||||
new WeaponCollisionSystem(this.player.Weapon);
|
||||
@ -157,6 +156,7 @@ export class Game extends Component {
|
||||
);
|
||||
const modalLauncher = new GameModalLauncher(this.modalWindowManager, this.player, this.gamePauser, upgrader, translationData);
|
||||
|
||||
this.itemManager.init(this.enemyManager, this.player, this.gameResult, modalLauncher, settings.items);
|
||||
this.gameUI.init(this.player, modalLauncher);
|
||||
this.background.init(this.player.node);
|
||||
|
||||
|
@ -3,6 +3,7 @@ import { ISignal } from "../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../Services/EventSystem/Signal";
|
||||
import { ItemSettings } from "../Data/GameSettings";
|
||||
import { GameResult } from "../Game";
|
||||
import { GameModalLauncher } from "../ModalWIndows/GameModalLauncher";
|
||||
import { Enemy } from "../Unit/Enemy/Enemy";
|
||||
import { EnemyManager } from "../Unit/Enemy/EnemyManager";
|
||||
import { Player } from "../Unit/Player/Player";
|
||||
@ -24,15 +25,17 @@ export class ItemManager extends Component {
|
||||
|
||||
private player: Player;
|
||||
private gameResult: GameResult;
|
||||
private modalLauncher: GameModalLauncher;
|
||||
private healthPerPotion: number;
|
||||
|
||||
private pickupEvent = new Signal<ItemType>();
|
||||
|
||||
private itemTypeToAction = new Map<ItemType, () => void>();
|
||||
|
||||
public init(enemyManager: EnemyManager, player: Player, gameResult: GameResult, settings: ItemSettings): void {
|
||||
public init(enemyManager: EnemyManager, player: Player, gameResult: GameResult, modalLauncher: GameModalLauncher, settings: ItemSettings): void {
|
||||
this.player = player;
|
||||
this.gameResult = gameResult;
|
||||
this.modalLauncher = modalLauncher;
|
||||
this.healthPerPotion = settings.healthPerPotion;
|
||||
|
||||
enemyManager.EnemyAddedEvent.on(this.addEnemyListeners, this);
|
||||
@ -50,7 +53,7 @@ export class ItemManager extends Component {
|
||||
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));
|
||||
this.itemTypeToAction.set(ItemType.Chest, this.openChest.bind(this));
|
||||
}
|
||||
|
||||
public get PickupEvent(): ISignal<ItemType> {
|
||||
@ -84,7 +87,9 @@ export class ItemManager extends Component {
|
||||
this.player.Magnet.activate();
|
||||
}
|
||||
|
||||
private giveRandomSkill(): void {}
|
||||
private openChest(): void {
|
||||
this.modalLauncher.showChestModal();
|
||||
}
|
||||
|
||||
private addEnemyListeners(enemy: Enemy): void {
|
||||
enemy.DeathEvent.on(this.trySpawnItems, this);
|
||||
|
21
assets/Scripts/Game/ModalWIndows/ChestModalWindow.ts
Normal file
21
assets/Scripts/Game/ModalWIndows/ChestModalWindow.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { randomRangeInt, _decorator } from "cc";
|
||||
import { ModalWindow } from "../../Services/ModalWindowSystem/ModalWindow";
|
||||
import { UIButton } from "../../Services/UI/Button/UIButton";
|
||||
import { LevelUpModalWindowParams } from "../UI/LevelUpWindow/LevelUpModalWindow";
|
||||
import { LevelUpSkill } from "../UI/LevelUpWindow/LevelUpSkill";
|
||||
import { UpgradeType } from "../Upgrades/UpgradeType";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("ChestModalWindow")
|
||||
export class ChestModalWindow extends ModalWindow<LevelUpModalWindowParams, UpgradeType> {
|
||||
@property(LevelUpSkill) private levelUpSkill: LevelUpSkill;
|
||||
@property(UIButton) private okButton: UIButton;
|
||||
|
||||
protected setup(params: LevelUpModalWindowParams): void {
|
||||
const randomIndex = randomRangeInt(0, params.availableUpgrades.length - 1);
|
||||
const skillToUpgrade = params.availableUpgrades[randomIndex];
|
||||
this.levelUpSkill.init(skillToUpgrade, params.translationData);
|
||||
|
||||
this.okButton.InteractedEvent.on(() => this.dismiss(skillToUpgrade), this);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "422c8f7d-cc38-4c6a-9c61-420c291a610b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@ -27,8 +27,18 @@ export class GameModalLauncher {
|
||||
GameModalWindowTypes.LevelUp,
|
||||
{ availableUpgrades: Array.from(this.upgrader.getAvailableUpgrades()), translationData: this.translationData }
|
||||
);
|
||||
this.gamePauser.resume();
|
||||
this.upgrader.upgradeSkill(skillToUpgrade);
|
||||
this.gamePauser.resume();
|
||||
}
|
||||
|
||||
public async showChestModal(): Promise<void> {
|
||||
this.gamePauser.pause();
|
||||
const skillToUpgrade: UpgradeType = await this.modalWindowManager.showModal<LevelUpModalWindowParams, UpgradeType>(
|
||||
GameModalWindowTypes.Chest,
|
||||
{ availableUpgrades: Array.from(this.upgrader.getAvailableUpgrades()), translationData: this.translationData }
|
||||
);
|
||||
this.upgrader.upgradeSkill(skillToUpgrade);
|
||||
this.gamePauser.resume();
|
||||
}
|
||||
|
||||
public async showPauseModal(): Promise<void> {
|
||||
|
@ -1,4 +1,5 @@
|
||||
export enum GameModalWindowTypes {
|
||||
LevelUp = "LevelUpModalWindow",
|
||||
Chest = "ChestModalWindow",
|
||||
Pause = "PauseModalWindow"
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ export class ModalWindowManager extends Component {
|
||||
windowNode.setParent(this.node);
|
||||
|
||||
const modalWindow: ModalWindow<TParams, TResult> = <ModalWindow<TParams, TResult>>windowNode.getComponent(name);
|
||||
|
||||
const result: TResult = await modalWindow.runAsync(params);
|
||||
windowNode.destroy();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user