mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
Halo projectile launcher
This commit is contained in:
parent
a0bd11b61d
commit
da70723f2d
@ -14,17 +14,24 @@
|
|||||||
20
|
20
|
||||||
],
|
],
|
||||||
"regenerationDelay": 5,
|
"regenerationDelay": 5,
|
||||||
"collisionDelay": 0.5
|
"collisionDelay": 0.5,
|
||||||
},
|
"weapon": {
|
||||||
"weapon": {
|
"strikeDelay": 2,
|
||||||
"strikeDelay": 2,
|
"damage": 1
|
||||||
"damage": 1
|
},
|
||||||
|
"haloLauncher": {
|
||||||
|
"projectileLifetime": 2,
|
||||||
|
"projectileSpeed": 150,
|
||||||
|
"projectilesToSpawn": 24,
|
||||||
|
"cooldown": 10
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"upgrades": {
|
"upgrades": {
|
||||||
"maxWeaponLengthUpgrades": 5,
|
"maxWeaponLengthUpgrades": 5,
|
||||||
"maxWeaponDamageUpgrades": 5,
|
"maxWeaponDamageUpgrades": 5,
|
||||||
"maxHorizontalProjectileUpgrades": 0,
|
"maxHorizontalProjectileUpgrades": 0,
|
||||||
"maxVerticalProjectileUpgrades": 0,
|
"maxVerticalProjectileUpgrades": 0,
|
||||||
|
"maxHaloProjectileUpgrades": 5,
|
||||||
"maxRegenerationUpgrades": 5
|
"maxRegenerationUpgrades": 5
|
||||||
}
|
}
|
||||||
}
|
}
|
194
assets/Media/Prefabs/PlayerProjectile.prefab
Normal file
194
assets/Media/Prefabs/PlayerProjectile.prefab
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"__type__": "cc.Prefab",
|
||||||
|
"_name": "PlayerProjectile",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_native": "",
|
||||||
|
"data": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"optimizationPolicy": 0,
|
||||||
|
"persistent": false,
|
||||||
|
"asyncLoadAssets": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "PlayerProjectile",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": null,
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 8
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 10
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"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": 33554432,
|
||||||
|
"_euler": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 3
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 26,
|
||||||
|
"height": 26
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "baF+RbIRdMqqYdGWVAqM48"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Sprite",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 5
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 197,
|
||||||
|
"g": 35,
|
||||||
|
"b": 35,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_spriteFrame": {
|
||||||
|
"__uuid__": "f12a23c4-b924-4322-a260-3d982428f1e8@f9941",
|
||||||
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
|
},
|
||||||
|
"_type": 0,
|
||||||
|
"_fillType": 0,
|
||||||
|
"_sizeMode": 1,
|
||||||
|
"_fillCenter": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"_fillStart": 0,
|
||||||
|
"_fillRange": 0,
|
||||||
|
"_isTrimmedMode": true,
|
||||||
|
"_useGrayscale": false,
|
||||||
|
"_atlas": null,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "46qOXlbU5GmbOpfjiX4jGV"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CircleCollider2D",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 7
|
||||||
|
},
|
||||||
|
"tag": 0,
|
||||||
|
"_group": 8,
|
||||||
|
"_density": 1,
|
||||||
|
"_sensor": false,
|
||||||
|
"_friction": 0.2,
|
||||||
|
"_restitution": 0,
|
||||||
|
"_offset": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"_radius": 13,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "7cR5oa68RG/oqkiwJ9HQ3X"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "6a24eYAhmtMDZo5Wb8iLC5Q",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 9
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "a81ki8NjhA4KniWAiobzy2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "26opAI9A5IGabbGPZh6QDI"
|
||||||
|
}
|
||||||
|
]
|
13
assets/Media/Prefabs/PlayerProjectile.prefab.meta
Normal file
13
assets/Media/Prefabs/PlayerProjectile.prefab.meta
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.40",
|
||||||
|
"importer": "prefab",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "ff0be112-7028-424c-87b8-fc54a106015a",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"syncNodeName": "PlayerProjectile"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,5 @@
|
|||||||
export class GameSettings {
|
export class GameSettings {
|
||||||
public player: PlayerSettings = new PlayerSettings();
|
public player: PlayerSettings = new PlayerSettings();
|
||||||
public weapon: WeaponSettings = new WeaponSettings();
|
|
||||||
public upgrades: UpgradeSettings = new UpgradeSettings();
|
public upgrades: UpgradeSettings = new UpgradeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9,6 +8,8 @@ export class PlayerSettings {
|
|||||||
public requiredXP: number[] = [];
|
public requiredXP: number[] = [];
|
||||||
public regenerationDelay = 0;
|
public regenerationDelay = 0;
|
||||||
public collisionDelay = 0;
|
public collisionDelay = 0;
|
||||||
|
public weapon: WeaponSettings = new WeaponSettings();
|
||||||
|
public haloLauncher: HaloLauncherSettings = new HaloLauncherSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WeaponSettings {
|
export class WeaponSettings {
|
||||||
@ -16,10 +17,18 @@ export class WeaponSettings {
|
|||||||
public damage = 0;
|
public damage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class HaloLauncherSettings {
|
||||||
|
public projectileLifetime = 0;
|
||||||
|
public projectileSpeed = 0;
|
||||||
|
public projectilesToSpawn = 0;
|
||||||
|
public cooldown = 0;
|
||||||
|
}
|
||||||
|
|
||||||
export class UpgradeSettings {
|
export class UpgradeSettings {
|
||||||
public maxWeaponLengthUpgrades = 0;
|
public maxWeaponLengthUpgrades = 0;
|
||||||
public maxWeaponDamageUpgrades = 0;
|
public maxWeaponDamageUpgrades = 0;
|
||||||
public maxHorizontalProjectileUpgrades = 0;
|
public maxHorizontalProjectileUpgrades = 0;
|
||||||
public maxVerticalProjectileUpgrades = 0;
|
public maxVerticalProjectileUpgrades = 0;
|
||||||
|
public maxHaloProjectileUpgrades = 0;
|
||||||
public maxRegenerationUpgrades = 0;
|
public maxRegenerationUpgrades = 0;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,9 @@ import { GameModalLauncher } from "./ModalWIndows/GameModalLauncher";
|
|||||||
import { Pauser } from "./Pauser";
|
import { Pauser } from "./Pauser";
|
||||||
import { GameUI } from "./UI/GameUI";
|
import { GameUI } from "./UI/GameUI";
|
||||||
import { EnemyManager } from "./Unit/Enemy/EnemyManager";
|
import { EnemyManager } from "./Unit/Enemy/EnemyManager";
|
||||||
|
import { HaloProjectileLauncher } from "./Unit/Player/Halo/HaloProjectileLauncher";
|
||||||
import { Player } from "./Unit/Player/Player";
|
import { Player } from "./Unit/Player/Player";
|
||||||
import { Weapon } from "./Unit/Player/Weapon/Weapon";
|
|
||||||
import { Upgrader } from "./Upgrades/Upgrader";
|
import { Upgrader } from "./Upgrades/Upgrader";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
@ -20,7 +21,7 @@ const { ccclass, property } = _decorator;
|
|||||||
export class GameBootstrapper extends Component {
|
export class GameBootstrapper extends Component {
|
||||||
@property(VirtualJoystic) private virtualJoystic: VirtualJoystic;
|
@property(VirtualJoystic) private virtualJoystic: VirtualJoystic;
|
||||||
@property(Player) private player: Player;
|
@property(Player) private player: Player;
|
||||||
@property(Weapon) private weapon: Weapon;
|
@property(HaloProjectileLauncher) private haloProjectiles: HaloProjectileLauncher;
|
||||||
@property(EnemyManager) private enemyManager: EnemyManager;
|
@property(EnemyManager) private enemyManager: EnemyManager;
|
||||||
@property(Camera) private camera: Camera;
|
@property(Camera) private camera: Camera;
|
||||||
@property(GameUI) private gameUI: GameUI;
|
@property(GameUI) private gameUI: GameUI;
|
||||||
@ -35,20 +36,23 @@ export class GameBootstrapper extends Component {
|
|||||||
const settings: GameSettings = <GameSettings>this.settingsAsset.json;
|
const settings: GameSettings = <GameSettings>this.settingsAsset.json;
|
||||||
|
|
||||||
this.virtualJoystic.init();
|
this.virtualJoystic.init();
|
||||||
this.weapon.init(settings.weapon);
|
|
||||||
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);
|
||||||
const arrowKeys = new KeyboardInput(KeyCode.ARROW_UP, KeyCode.ARROW_DOWN, KeyCode.ARROW_LEFT, KeyCode.ARROW_RIGHT);
|
const arrowKeys = new KeyboardInput(KeyCode.ARROW_UP, KeyCode.ARROW_DOWN, KeyCode.ARROW_LEFT, KeyCode.ARROW_RIGHT);
|
||||||
const dualInput: MultiInput = new MultiInput([this.virtualJoystic, wasd, arrowKeys]);
|
const dualInput: MultiInput = new MultiInput([this.virtualJoystic, wasd, arrowKeys]);
|
||||||
this.player.init(dualInput, this.weapon, settings.player);
|
this.player.init(dualInput, settings.player);
|
||||||
|
|
||||||
this.playerCollisionSystem = new PlayerCollisionSystem(this.player, settings.player.collisionDelay);
|
this.playerCollisionSystem = new PlayerCollisionSystem(this.player, settings.player.collisionDelay);
|
||||||
new WeaponCollisionSystem(this.weapon);
|
new WeaponCollisionSystem(this.player.Weapon);
|
||||||
|
|
||||||
const upgrader = new Upgrader(this.player, settings.upgrades);
|
const upgrader = new Upgrader(this.player, settings.upgrades);
|
||||||
new GameModalLauncher(this.modalWindowManager, this.player, this.gamePauser, upgrader);
|
new GameModalLauncher(this.modalWindowManager, this.player, this.gamePauser, upgrader);
|
||||||
|
|
||||||
this.enemyManager.init(this.player.node);
|
this.enemyManager.init(this.player.node);
|
||||||
|
|
||||||
|
this.haloProjectiles.init(this.player.node, settings.player.haloLauncher);
|
||||||
|
this.haloProjectiles.upgrade();
|
||||||
|
|
||||||
this.gameUI.init(this.player);
|
this.gameUI.init(this.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +62,7 @@ export class GameBootstrapper extends Component {
|
|||||||
this.player.gameTick(deltaTime);
|
this.player.gameTick(deltaTime);
|
||||||
this.playerCollisionSystem.gameTick(deltaTime);
|
this.playerCollisionSystem.gameTick(deltaTime);
|
||||||
this.enemyManager.gameTick(deltaTime);
|
this.enemyManager.gameTick(deltaTime);
|
||||||
|
this.haloProjectiles.gameTick(deltaTime);
|
||||||
|
|
||||||
this.camera.node.worldPosition = this.player.node.worldPosition;
|
this.camera.node.worldPosition = this.player.node.worldPosition;
|
||||||
}
|
}
|
||||||
|
12
assets/Scripts/Game/Unit/Player/Halo.meta
Normal file
12
assets/Scripts/Game/Unit/Player/Halo.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "b89dc5a7-3450-47e4-bc36-ae5d08f4bc89",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"compressionType": {},
|
||||||
|
"isRemoteBundle": {}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
import { Component, Prefab, Vec2, Vec3, _decorator, Node } from "cc";
|
||||||
|
import { GameTimer } from "../../../../Services/GameTimer";
|
||||||
|
import { ObjectPool } from "../../../../Services/ObjectPool";
|
||||||
|
import { roundToOneDecimal } from "../../../../Services/Utils/MathUtils";
|
||||||
|
import { HaloLauncherSettings } from "../../../Data/GameSettings";
|
||||||
|
import { PlayerProjectile } from "./PlayerProjectile";
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass("HaloProjectileLauncher")
|
||||||
|
export class HaloProjectileLauncher extends Component {
|
||||||
|
@property(Prefab) private projectilePrefab: Prefab;
|
||||||
|
private fireTimer: GameTimer;
|
||||||
|
private lifetimeTimer: GameTimer;
|
||||||
|
private projectilesToSpawn: number;
|
||||||
|
private defaultCooldown: number;
|
||||||
|
private speed: number;
|
||||||
|
private currentLevel = 0;
|
||||||
|
|
||||||
|
private isFiring = false;
|
||||||
|
|
||||||
|
private projectilePool: ObjectPool<PlayerProjectile>;
|
||||||
|
private projectiles: PlayerProjectile[] = [];
|
||||||
|
private directions: Vec2[] = [];
|
||||||
|
|
||||||
|
private playerNode: Node;
|
||||||
|
|
||||||
|
public init(playerNode: Node, settings: HaloLauncherSettings): void {
|
||||||
|
this.playerNode = playerNode;
|
||||||
|
this.projectilesToSpawn = settings.projectilesToSpawn;
|
||||||
|
this.projectilePool = new ObjectPool<PlayerProjectile>(this.projectilePrefab, this.node, this.projectilesToSpawn, "PlayerProjectile");
|
||||||
|
|
||||||
|
this.speed = settings.projectileSpeed;
|
||||||
|
this.defaultCooldown = settings.cooldown;
|
||||||
|
this.lifetimeTimer = new GameTimer(settings.projectileLifetime);
|
||||||
|
this.fireTimer = new GameTimer(this.defaultCooldown);
|
||||||
|
|
||||||
|
const angle: number = (2 * Math.PI) / this.projectilesToSpawn;
|
||||||
|
|
||||||
|
for (let i = 0; i < this.projectilesToSpawn; i++) {
|
||||||
|
const x: number = roundToOneDecimal(Math.sin(angle * i));
|
||||||
|
const y: number = roundToOneDecimal(Math.cos(angle * i));
|
||||||
|
this.directions.push(new Vec2(x, y).normalize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public upgrade(): void {
|
||||||
|
this.currentLevel++;
|
||||||
|
this.fireTimer = new GameTimer(this.defaultCooldown - this.currentLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public gameTick(deltaTime: number): void {
|
||||||
|
if (this.currentLevel == 0) return;
|
||||||
|
|
||||||
|
this.fireTimer.gameTick(deltaTime);
|
||||||
|
if (this.isFiring) {
|
||||||
|
this.moveAllProjectiles(deltaTime);
|
||||||
|
this.tryRemoveAllProjectiles(deltaTime);
|
||||||
|
} else {
|
||||||
|
if (this.fireTimer.tryFinishPeriod()) {
|
||||||
|
this.fireProjectiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fireProjectiles(): void {
|
||||||
|
for (let index = 0; index < this.projectilesToSpawn; index++) {
|
||||||
|
const projectile: PlayerProjectile = this.projectilePool.borrow();
|
||||||
|
projectile.node.setWorldPosition(this.playerNode.worldPosition);
|
||||||
|
projectile.node.active = true;
|
||||||
|
this.projectiles.push(projectile);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isFiring = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private moveAllProjectiles(deltaTime: number): void {
|
||||||
|
for (let i = 0; i < this.projectiles.length; i++) {
|
||||||
|
const newPosition: Vec3 = this.projectiles[i].node.worldPosition;
|
||||||
|
newPosition.x += this.directions[i].x * deltaTime * this.speed;
|
||||||
|
newPosition.y += this.directions[i].y * deltaTime * this.speed;
|
||||||
|
|
||||||
|
this.projectiles[i].node.setWorldPosition(newPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private tryRemoveAllProjectiles(deltaTime: number): void {
|
||||||
|
this.lifetimeTimer.gameTick(deltaTime);
|
||||||
|
if (this.lifetimeTimer.tryFinishPeriod()) {
|
||||||
|
for (const projectile of this.projectiles) {
|
||||||
|
this.projectilePool.return(projectile);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.projectiles = [];
|
||||||
|
this.isFiring = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "422b46ec-3e15-437d-97fc-7f44a277c3be",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
14
assets/Scripts/Game/Unit/Player/Halo/PlayerProjectile.ts
Normal file
14
assets/Scripts/Game/Unit/Player/Halo/PlayerProjectile.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { _decorator, Component, Node } from 'cc';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('PlayerProjectile')
|
||||||
|
export class PlayerProjectile extends Component {
|
||||||
|
start() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
update(deltaTime: number) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "6a24e600-866b-4c0d-9a39-59bf222c2e50",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -14,22 +14,20 @@ export class Player extends Component {
|
|||||||
@property private speed = 0;
|
@property private speed = 0;
|
||||||
@property(BoxCollider2D) private collider: BoxCollider2D;
|
@property(BoxCollider2D) private collider: BoxCollider2D;
|
||||||
@property(PlayerUI) private playerUI: PlayerUI;
|
@property(PlayerUI) private playerUI: PlayerUI;
|
||||||
|
@property(Weapon) private weapon: Weapon;
|
||||||
|
|
||||||
private input: IInput;
|
private input: IInput;
|
||||||
private weapon: Weapon;
|
|
||||||
private health: UnitHealth;
|
private health: UnitHealth;
|
||||||
private level: UnitLevel;
|
private level: UnitLevel;
|
||||||
private regeneration: PlayerRegeneration;
|
private regeneration: PlayerRegeneration;
|
||||||
|
|
||||||
public init(input: IInput, weapon: Weapon, settings: PlayerSettings): void {
|
public init(input: IInput, settings: PlayerSettings): void {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.weapon = weapon;
|
|
||||||
this.health = new UnitHealth(settings.defaultHP);
|
this.health = new UnitHealth(settings.defaultHP);
|
||||||
this.level = new UnitLevel(settings.requiredXP);
|
this.level = new UnitLevel(settings.requiredXP);
|
||||||
this.regeneration = new PlayerRegeneration(this.health, settings.regenerationDelay);
|
this.regeneration = new PlayerRegeneration(this.health, settings.regenerationDelay);
|
||||||
|
|
||||||
this.weapon.node.parent = this.node;
|
this.weapon.init(settings.weapon);
|
||||||
this.weapon.node.setPosition(new Vec3());
|
|
||||||
|
|
||||||
this.playerUI.init(this.health);
|
this.playerUI.init(this.health);
|
||||||
}
|
}
|
||||||
|
3
assets/Scripts/Services/Utils/MathUtils.ts
Normal file
3
assets/Scripts/Services/Utils/MathUtils.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function roundToOneDecimal(num: number): number {
|
||||||
|
return Math.round(num * 10) / 10;
|
||||||
|
}
|
9
assets/Scripts/Services/Utils/MathUtils.ts.meta
Normal file
9
assets/Scripts/Services/Utils/MathUtils.ts.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "93ac2648-b208-4662-911a-688684084e2a",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user