barbarian anim

This commit is contained in:
Martin 2022-12-31 12:53:49 +01:00
parent e03274d3cb
commit 50c44b7d64
13 changed files with 107 additions and 231 deletions

View File

@ -151,7 +151,7 @@
"projectileLifetime": 8,
"projectileSpeed": 140,
"projectileDamage": 4,
"cooldown": 2.5
"cooldown": 3.67
},
"magicOrbLauncher": {
"enemyIds": [],
@ -464,16 +464,16 @@
},
{
"enemyIdToAffect": "SiegeEnemyRanged",
"followTime": 4,
"waitTime": 4
"followTime": 3,
"waitTime": 0.67
}
],
"individualEnemySpawners": [
{
"common": {
"enemyId": "BasicEnemy",
"enemyId": "SiegeEnemyRanged",
"startDelay": 0,
"stopDelay": 59,
"stopDelay": 2,
"cooldown": 1
}
},

View File

@ -1,174 +0,0 @@
[
{
"__type__": "cc.animation.AnimationGraph",
"_name": "",
"_objFlags": 0,
"_native": "",
"_layers": [
{
"__id__": 1
}
],
"_variables": {}
},
{
"__type__": "cc.animation.Layer",
"_stateMachine": {
"__id__": 2
},
"name": "",
"weight": 1,
"mask": null
},
{
"__type__": "cc.animation.StateMachine",
"_states": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
},
{
"__id__": 6
},
{
"__id__": 8
}
],
"_transitions": [
{
"__id__": 10
},
{
"__id__": 11
}
],
"_entryState": {
"__id__": 3
},
"_exitState": {
"__id__": 4
},
"_anyState": {
"__id__": 5
}
},
{
"__type__": "cc.animation.State",
"__editorExtras__": {
"centerX": -143,
"centerY": -22,
"id": "16724216539930.48119152753701666"
},
"name": "Entry"
},
{
"__type__": "cc.animation.State",
"name": "Exit"
},
{
"__type__": "cc.animation.State",
"__editorExtras__": {
"centerX": 126,
"centerY": 0,
"id": "16724216387450.1472316540497729"
},
"name": "Any"
},
{
"__type__": "cc.animation.Motion",
"__editorExtras__": {
"centerX": 14,
"centerY": -116.5,
"id": "16724216351510.5534679250082009"
},
"name": "Shoot",
"_components": [],
"motion": {
"__id__": 7
},
"speed": 1,
"speedMultiplier": "",
"speedMultiplierEnabled": false
},
{
"__type__": "cc.animation.ClipMotion",
"__editorExtras__": {
"id": "16724216351480.6384312560331595",
"centerX": 0,
"centerY": 0,
"name": ""
},
"clip": {
"__uuid__": "02f5cb0a-b58e-418e-aa60-45f28f5a4e9f",
"__expectedType__": "cc.AnimationClip"
}
},
{
"__type__": "cc.animation.Motion",
"__editorExtras__": {
"centerX": 14,
"centerY": -31.5,
"id": "16724216351510.4468726373332348"
},
"name": "Move",
"_components": [],
"motion": {
"__id__": 9
},
"speed": 1,
"speedMultiplier": "",
"speedMultiplierEnabled": false
},
{
"__type__": "cc.animation.ClipMotion",
"__editorExtras__": {
"id": "16724216351510.04360222304205896",
"centerX": 0,
"centerY": 0,
"name": ""
},
"clip": {
"__uuid__": "01f039bc-a24c-45e7-a938-336d2111f3dc",
"__expectedType__": "cc.AnimationClip"
}
},
{
"__type__": "cc.animation.AnimationTransition",
"from": {
"__id__": 8
},
"to": {
"__id__": 6
},
"conditions": [],
"duration": 0.3,
"relativeDuration": false,
"exitConditionEnabled": true,
"destinationStart": 0,
"relativeDestinationStart": false,
"interruptionSource": 0,
"_exitCondition": 1
},
{
"__type__": "cc.animation.AnimationTransition",
"from": {
"__id__": 6
},
"to": {
"__id__": 8
},
"conditions": [],
"duration": 0.3,
"relativeDuration": false,
"exitConditionEnabled": true,
"destinationStart": 0,
"relativeDestinationStart": false,
"interruptionSource": 0,
"_exitCondition": 1
}
]

View File

@ -1,11 +0,0 @@
{
"ver": "1.1.0",
"importer": "animation-graph",
"imported": true,
"uuid": "10c1208e-fa86-4f5b-851b-7fb7c52ebcf1",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -8,6 +8,6 @@
],
"subMetas": {},
"userData": {
"name": "Shoot"
"name": "Idle"
}
}

View File

@ -1 +0,0 @@
{"ver":"2.0.3","importer":"animation-clip","imported":true,"uuid":"01f039bc-a24c-45e7-a938-336d2111f3dc","files":[".cconb"],"subMetas":{},"userData":{"name":"Move"}}

View File

@ -0,0 +1,13 @@
{
"ver": "2.0.3",
"importer": "animation-clip",
"imported": true,
"uuid": "01f039bc-a24c-45e7-a938-336d2111f3dc",
"files": [
".cconb"
],
"subMetas": {},
"userData": {
"name": "Run"
}
}

View File

@ -257,37 +257,6 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "5dR8969SVAfLXx5AY1X9B5"
},
{
"__type__": "7f8b6NKHsNNW5nLY3fwejhw",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 13
},
"collider": {
"__id__": 10
},
"sprite": {
"__id__": 5
},
"defaultMaterial": {
"__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
"__expectedType__": "cc.Material"
},
"whiteMaterial": {
"__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44",
"__expectedType__": "cc.Material"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b5ONKVkchBpaoqReE981lo"
},
{
"__type__": "cc.Animation",
"_name": "",
@ -297,7 +266,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 15
"__id__": 13
},
"playOnLoad": true,
"_clips": [
@ -320,6 +289,40 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "74x/uTmM5C8J/ZyOW71lz5"
},
{
"__type__": "2fbd7DLmiNFybvIJxxrW6Iu",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 15
},
"collider": {
"__id__": 10
},
"sprite": {
"__id__": 5
},
"defaultMaterial": {
"__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
"__expectedType__": "cc.Material"
},
"whiteMaterial": {
"__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44",
"__expectedType__": "cc.Material"
},
"animation": {
"__id__": 12
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "23A8mHvnBHz7LyWYrq9p/n"
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@ -0,0 +1,36 @@
import { Animation, Vec3, _decorator } from "cc";
import { Enemy } from "./Enemy";
const { ccclass, property } = _decorator;
@ccclass("AnimatedEnemy")
export class AnimatedEnemy extends Enemy {
@property(Animation) private animation: Animation;
private isAnimatingIdle = false;
public gameTick(move: Vec3, deltaTime: number): void {
super.gameTick(move, deltaTime);
console.log("Move x: " + move.x + " Move y: " + move.y);
if (move.x === 0 && move.y === 0) {
this.animateIdle();
} else {
this.animateRun();
}
}
private animateIdle(): void {
if (this.isAnimatingIdle) return;
this.isAnimatingIdle = true;
this.animation.play("Idle");
}
private animateRun(): void {
if (!this.isAnimatingIdle) return;
this.isAnimatingIdle = false;
this.animation.play("Run");
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2fbd70cb-9a23-45c9-bbc8-271c6b5ba22e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -118,7 +118,7 @@ export class Enemy extends Component {
if (move.x < 0) {
this.sprite.node.setScale(-1, 1, 1);
} else {
} else if (0 < move.x) {
this.sprite.node.setScale(1, 1, 1);
}

View File

@ -26,12 +26,13 @@ export class PeriodicFollowTargetEnemyMover extends EnemyMover {
this.switchEnemyFollowState(enemy);
} else {
this.enemyToStateTimeLeft.set(enemy, stateTimeLeft);
if (this.enemyToFollowState.get(enemy) === EnemyFollowState.Follow) {
let direction: Vec3 = new Vec3();
direction = Vec3.subtract(direction, this.targetNode.worldPosition, enemy.node.worldPosition);
enemy.gameTick(direction.normalize(), deltaTime);
}
}
if (this.enemyToFollowState.get(enemy) === EnemyFollowState.Follow) {
let direction: Vec3 = new Vec3();
direction = Vec3.subtract(direction, this.targetNode.worldPosition, enemy.node.worldPosition);
enemy.gameTick(direction.normalize(), deltaTime);
} else if (this.enemyToFollowState.get(enemy) === EnemyFollowState.Wait) {
enemy.gameTick(new Vec3(), deltaTime);
}
}
}