mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 00:26:04 +00:00
Meta updates
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { BoxCollider2D, Collider2D, Component, Vec2, Vec3, _decorator } from "cc";
|
||||
import { PlayerSettings } from "../../Data/GameSettings";
|
||||
import { IInput } from "../../Input/IInput";
|
||||
import { UnitHealth } from "../UnitHealth";
|
||||
import { UnitLevel } from "../UnitLevel";
|
||||
@@ -11,7 +10,6 @@ const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("Player")
|
||||
export class Player extends Component {
|
||||
@property private speed = 0;
|
||||
@property(BoxCollider2D) private collider: BoxCollider2D;
|
||||
@property(PlayerUI) private playerUI: PlayerUI;
|
||||
@property(Weapon) private weapon: Weapon;
|
||||
@@ -20,18 +18,18 @@ export class Player extends Component {
|
||||
private health: UnitHealth;
|
||||
private level: UnitLevel;
|
||||
private regeneration: PlayerRegeneration;
|
||||
private speed: number;
|
||||
|
||||
public init(input: IInput, settings: PlayerData): void {
|
||||
public init(input: IInput, data: PlayerData): void {
|
||||
this.input = input;
|
||||
this.health = new UnitHealth(settings.defaultHP);
|
||||
this.level = new UnitLevel(settings.requiredXP);
|
||||
this.regeneration = new PlayerRegeneration(this.health, settings.regenerationDelay);
|
||||
this.health = new UnitHealth(data.maxHp);
|
||||
this.level = new UnitLevel(data.requiredXP, data.xpMultiplier);
|
||||
this.regeneration = new PlayerRegeneration(this.health, data.regenerationDelay);
|
||||
this.speed = data.speed;
|
||||
|
||||
this.weapon.init(settings.weapon);
|
||||
this.weapon.init(data.strikeDelay, data.damage);
|
||||
|
||||
this.playerUI.init(this.health);
|
||||
|
||||
console.log("Bonus damage " + settings.bonusDamage);
|
||||
}
|
||||
|
||||
public get Health(): UnitHealth {
|
||||
@@ -70,10 +68,15 @@ export class Player extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export class PlayerData extends PlayerSettings {
|
||||
public bonusDamage = 0;
|
||||
public bonusHp = 0;
|
||||
public bonusSpeed = 0;
|
||||
public bonusXP = 0;
|
||||
public bonusGold = 0;
|
||||
export class PlayerData {
|
||||
public requiredXP: number[] = [];
|
||||
public speed = 0;
|
||||
public maxHp = 0;
|
||||
public regenerationDelay = 0;
|
||||
public xpMultiplier = 0;
|
||||
public goldMultiplier = 0;
|
||||
|
||||
// Weapon
|
||||
public strikeDelay = 0;
|
||||
public damage = 0;
|
||||
}
|
||||
|
@@ -14,9 +14,9 @@ export class Weapon extends Component {
|
||||
private strikeState: AnimationState;
|
||||
private damage: number;
|
||||
|
||||
public init(settings: WeaponSettings): void {
|
||||
this.strikeTimer = new GameTimer(settings.strikeDelay);
|
||||
this.damage = settings.damage;
|
||||
public init(strikeDelay: number, damage: number): void {
|
||||
this.strikeTimer = new GameTimer(strikeDelay);
|
||||
this.damage = damage;
|
||||
this.node.active = false;
|
||||
|
||||
this.weaponAnimation.on(Animation.EventType.FINISHED, this.endStrike, this);
|
||||
|
@@ -3,17 +3,15 @@ import { Signal } from "../../Services/EventSystem/Signal";
|
||||
|
||||
export class UnitLevel {
|
||||
private xp = 0;
|
||||
private requiredXPs: number[];
|
||||
|
||||
private currentLevel = 0;
|
||||
private levelUpEvent: Signal<number> = new Signal<number>();
|
||||
private xpAddedEvent: Signal<number> = new Signal<number>();
|
||||
|
||||
public constructor(requiredXPs: number[]) {
|
||||
this.requiredXPs = requiredXPs;
|
||||
}
|
||||
public constructor(private requiredXPs: number[], private xpMultiplier: number) {}
|
||||
|
||||
public addXp(points: number): void {
|
||||
this.xp += points;
|
||||
this.xp += points * this.xpMultiplier;
|
||||
this.xpAddedEvent.trigger(this.xp);
|
||||
this.tryLevelUp();
|
||||
}
|
||||
|
Reference in New Issue
Block a user