mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
Player anim
This commit is contained in:
parent
da97f5355c
commit
eabce40b3a
@ -8,30 +8,6 @@
|
|||||||
".png"
|
".png"
|
||||||
],
|
],
|
||||||
"subMetas": {
|
"subMetas": {
|
||||||
"6c48a": {
|
|
||||||
"importer": "texture",
|
|
||||||
"uuid": "29bf4d7b-909b-472f-839a-bbb94136bab3@6c48a",
|
|
||||||
"displayName": "HealthBarBg",
|
|
||||||
"id": "6c48a",
|
|
||||||
"name": "texture",
|
|
||||||
"userData": {
|
|
||||||
"wrapModeS": "clamp-to-edge",
|
|
||||||
"wrapModeT": "clamp-to-edge",
|
|
||||||
"minfilter": "nearest",
|
|
||||||
"magfilter": "nearest",
|
|
||||||
"mipfilter": "none",
|
|
||||||
"anisotropy": 0,
|
|
||||||
"isUuid": true,
|
|
||||||
"imageUuidOrDatabaseUri": "29bf4d7b-909b-472f-839a-bbb94136bab3",
|
|
||||||
"visible": false
|
|
||||||
},
|
|
||||||
"ver": "1.0.22",
|
|
||||||
"imported": true,
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {}
|
|
||||||
},
|
|
||||||
"f9941": {
|
"f9941": {
|
||||||
"importer": "sprite-frame",
|
"importer": "sprite-frame",
|
||||||
"uuid": "29bf4d7b-909b-472f-839a-bbb94136bab3@f9941",
|
"uuid": "29bf4d7b-909b-472f-839a-bbb94136bab3@f9941",
|
||||||
@ -123,6 +99,30 @@
|
|||||||
".json"
|
".json"
|
||||||
],
|
],
|
||||||
"subMetas": {}
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "29bf4d7b-909b-472f-839a-bbb94136bab3@6c48a",
|
||||||
|
"displayName": "HealthBarBg",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"minfilter": "nearest",
|
||||||
|
"magfilter": "nearest",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0,
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "29bf4d7b-909b-472f-839a-bbb94136bab3",
|
||||||
|
"visible": false
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"userData": {
|
"userData": {
|
||||||
|
@ -8,30 +8,6 @@
|
|||||||
".png"
|
".png"
|
||||||
],
|
],
|
||||||
"subMetas": {
|
"subMetas": {
|
||||||
"6c48a": {
|
|
||||||
"importer": "texture",
|
|
||||||
"uuid": "0ca53d61-de26-4d01-9770-eec0e3ac06ae@6c48a",
|
|
||||||
"displayName": "HealthBarFill",
|
|
||||||
"id": "6c48a",
|
|
||||||
"name": "texture",
|
|
||||||
"userData": {
|
|
||||||
"wrapModeS": "clamp-to-edge",
|
|
||||||
"wrapModeT": "clamp-to-edge",
|
|
||||||
"minfilter": "nearest",
|
|
||||||
"magfilter": "nearest",
|
|
||||||
"mipfilter": "none",
|
|
||||||
"anisotropy": 0,
|
|
||||||
"isUuid": true,
|
|
||||||
"imageUuidOrDatabaseUri": "0ca53d61-de26-4d01-9770-eec0e3ac06ae",
|
|
||||||
"visible": false
|
|
||||||
},
|
|
||||||
"ver": "1.0.22",
|
|
||||||
"imported": true,
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {}
|
|
||||||
},
|
|
||||||
"f9941": {
|
"f9941": {
|
||||||
"importer": "sprite-frame",
|
"importer": "sprite-frame",
|
||||||
"uuid": "0ca53d61-de26-4d01-9770-eec0e3ac06ae@f9941",
|
"uuid": "0ca53d61-de26-4d01-9770-eec0e3ac06ae@f9941",
|
||||||
@ -123,6 +99,30 @@
|
|||||||
".json"
|
".json"
|
||||||
],
|
],
|
||||||
"subMetas": {}
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "0ca53d61-de26-4d01-9770-eec0e3ac06ae@6c48a",
|
||||||
|
"displayName": "HealthBarFill",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"minfilter": "nearest",
|
||||||
|
"magfilter": "nearest",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0,
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "0ca53d61-de26-4d01-9770-eec0e3ac06ae",
|
||||||
|
"visible": false
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"userData": {
|
"userData": {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -196,7 +196,7 @@
|
|||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": null,
|
"__prefab": null,
|
||||||
"maxHpLevel": 0,
|
"maxHpLevel": 0,
|
||||||
"bonusDamageLevel": 5,
|
"bonusDamageLevel": 0,
|
||||||
"projectilePiercingLevel": 0,
|
"projectilePiercingLevel": 0,
|
||||||
"movementSpeedLevel": 0,
|
"movementSpeedLevel": 0,
|
||||||
"xpGathererLevel": 0,
|
"xpGathererLevel": 0,
|
||||||
@ -2584,14 +2584,6 @@
|
|||||||
"modalWindowManager": {
|
"modalWindowManager": {
|
||||||
"__id__": 76
|
"__id__": 76
|
||||||
},
|
},
|
||||||
"settingsAsset": {
|
|
||||||
"__uuid__": "4a156ee8-535e-4443-8bf5-8b979a08d232",
|
|
||||||
"__expectedType__": "cc.JsonAsset"
|
|
||||||
},
|
|
||||||
"translationAsset": {
|
|
||||||
"__uuid__": "7d43843c-0765-427c-9161-2fd9030369c8",
|
|
||||||
"__expectedType__": "cc.JsonAsset"
|
|
||||||
},
|
|
||||||
"_id": "3a9z1bqlFCGL4/WyDwU4L5"
|
"_id": "3a9z1bqlFCGL4/WyDwU4L5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BoxCollider2D, Collider2D, Component, Vec2, Vec3, _decorator } from "cc";
|
import { Animation, Node, BoxCollider2D, Collider2D, Component, Vec2, Vec3, _decorator } from "cc";
|
||||||
import { IInput } from "../../Input/IInput";
|
import { IInput } from "../../Input/IInput";
|
||||||
import { UnitHealth } from "../UnitHealth";
|
import { UnitHealth } from "../UnitHealth";
|
||||||
import { UnitLevel } from "../UnitLevel";
|
import { UnitLevel } from "../UnitLevel";
|
||||||
@ -13,6 +13,8 @@ export class Player extends Component {
|
|||||||
@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;
|
@property(Weapon) private weapon: Weapon;
|
||||||
|
@property(Node) private playerGraphics: Node;
|
||||||
|
@property(Animation) private animation: Animation;
|
||||||
|
|
||||||
private input: IInput;
|
private input: IInput;
|
||||||
private health: UnitHealth;
|
private health: UnitHealth;
|
||||||
@ -20,6 +22,8 @@ export class Player extends Component {
|
|||||||
private regeneration: PlayerRegeneration;
|
private regeneration: PlayerRegeneration;
|
||||||
private speed: number;
|
private speed: number;
|
||||||
|
|
||||||
|
private isMoveAnimationPlaying = false;
|
||||||
|
|
||||||
public init(input: IInput, data: PlayerData): void {
|
public init(input: IInput, data: PlayerData): void {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.health = new UnitHealth(data.maxHp);
|
this.health = new UnitHealth(data.maxHp);
|
||||||
@ -54,14 +58,32 @@ export class Player extends Component {
|
|||||||
|
|
||||||
public gameTick(deltaTime: number): void {
|
public gameTick(deltaTime: number): void {
|
||||||
const movement: Vec2 = this.input.getAxis();
|
const movement: Vec2 = this.input.getAxis();
|
||||||
movement.x *= deltaTime * this.speed;
|
if (!movement.equals(Vec2.ZERO)) {
|
||||||
movement.y *= deltaTime * this.speed;
|
movement.x *= deltaTime * this.speed;
|
||||||
|
movement.y *= deltaTime * this.speed;
|
||||||
|
|
||||||
const newPosition: Vec3 = this.node.worldPosition;
|
const newPosition: Vec3 = this.node.worldPosition;
|
||||||
newPosition.x += movement.x;
|
newPosition.x += movement.x;
|
||||||
newPosition.y += movement.y;
|
newPosition.y += movement.y;
|
||||||
|
|
||||||
this.node.setWorldPosition(newPosition);
|
this.node.setWorldPosition(newPosition);
|
||||||
|
|
||||||
|
if (!this.isMoveAnimationPlaying) {
|
||||||
|
this.isMoveAnimationPlaying = true;
|
||||||
|
this.animation.play("Move");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (movement.x <= 0) {
|
||||||
|
this.playerGraphics.setScale(new Vec3(1, 1, 1));
|
||||||
|
} else {
|
||||||
|
this.playerGraphics.setScale(new Vec3(-1, 1, 1));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.isMoveAnimationPlaying) {
|
||||||
|
this.isMoveAnimationPlaying = false;
|
||||||
|
this.animation.play("Idle");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.weapon.gameTick(deltaTime);
|
this.weapon.gameTick(deltaTime);
|
||||||
this.regeneration.gameTick(deltaTime);
|
this.regeneration.gameTick(deltaTime);
|
||||||
|
Loading…
Reference in New Issue
Block a user