Attack moves
This commit is contained in:
parent
24c984b714
commit
6096a36896
@ -81,7 +81,8 @@
|
||||
],
|
||||
"tokens" : [
|
||||
"BLENDER_TRANSFORM",
|
||||
"SENTIENT"
|
||||
"SENTIENT",
|
||||
"ATTACKER"
|
||||
],
|
||||
"movementSystems" : [
|
||||
{
|
||||
@ -90,7 +91,15 @@
|
||||
"maxVelocity" : 0.015
|
||||
}
|
||||
],
|
||||
"modelPath" : "Models/person1walkanim.fbx"
|
||||
"attackMoves" : [
|
||||
{
|
||||
"type" : "MELEE_WEAPON_SWING_ONE_HAND",
|
||||
"animationName" : "Armature|SwingWeapon",
|
||||
"damageStartFrame" : 30,
|
||||
"damageEndFrame" : 50
|
||||
}
|
||||
],
|
||||
"modelPath" : "Models/person1animpass2.fbx"
|
||||
},
|
||||
|
||||
|
||||
@ -186,6 +195,14 @@
|
||||
"maxVelocity" : 0.025
|
||||
}
|
||||
],
|
||||
"attackMoves" : [
|
||||
{
|
||||
"type" : "MELEE_WEAPON_SWING_ONE_HAND",
|
||||
"animationName" : "Armature|SwingWeapon",
|
||||
"damageStartFrame" : 10,
|
||||
"damageEndFrame" : 30
|
||||
}
|
||||
],
|
||||
"modelPath" : "Models/goblin1.fbx"
|
||||
}
|
||||
|
||||
|
||||
BIN
assets/Models/person1animpass2.fbx
Normal file
BIN
assets/Models/person1animpass2.fbx
Normal file
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
package electrosphere.controls;
|
||||
|
||||
import electrosphere.entity.CameraEntityUtils;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
@ -315,7 +316,7 @@ public class ControlHandler {
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).isIsMouse() && glfwGetMouseButton(Globals.window, controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).getKeyValue()) == GLFW_PRESS){
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).isState() == false){
|
||||
if(attackTree != null){
|
||||
attackTree.start();
|
||||
attackTree.start(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
|
||||
}
|
||||
}
|
||||
controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).setState(true);
|
||||
|
||||
@ -106,6 +106,9 @@ public class EntityDataStrings {
|
||||
*/
|
||||
public static final String ATTACK_TREE = "attackTree";
|
||||
|
||||
public static final String ATTACK_MOVE_TYPE_ACTIVE = "attackMoveTypeActive";
|
||||
public static final String ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND = "MELEE_WEAPON_SWING_ONE_HAND";
|
||||
|
||||
/*
|
||||
idle behavior tree
|
||||
*/
|
||||
|
||||
@ -5,6 +5,7 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.server.creature.type.AttackMove;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.renderer.Actor;
|
||||
@ -30,6 +31,11 @@ public class AttackTree {
|
||||
|
||||
int frameCurrent;
|
||||
|
||||
int damageStartFrame = 1;
|
||||
int damageEndFrame = 2;
|
||||
|
||||
String animationName = "SwingWeapon";
|
||||
|
||||
int maxFrame = 60;
|
||||
|
||||
public AttackTree(Entity e){
|
||||
@ -41,7 +47,17 @@ public class AttackTree {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void start(){
|
||||
public void start(String attackType){
|
||||
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
|
||||
AttackMove currentMove;
|
||||
switch(attackType){
|
||||
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
currentMove = (AttackMove)parent.getData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
|
||||
damageStartFrame = currentMove.getDamageStartFrame();
|
||||
damageEndFrame = currentMove.getDamageEndFrame();
|
||||
animationName = currentMove.getAnimationName();
|
||||
break;
|
||||
}
|
||||
//TODO: check if can start moving
|
||||
state = AttackTreeState.WINDUP;
|
||||
frameCurrent = 0;
|
||||
@ -78,17 +94,17 @@ public class AttackTree {
|
||||
// System.out.println("Set state STARTUP");
|
||||
break;
|
||||
case 1:
|
||||
frameCurrent = 16;
|
||||
frameCurrent = damageStartFrame+1;
|
||||
state = AttackTreeState.ATTACK;
|
||||
// System.out.println("Set state MOVE");
|
||||
break;
|
||||
case 2:
|
||||
frameCurrent = 31;
|
||||
frameCurrent = damageEndFrame+1;
|
||||
state = AttackTreeState.COOLDOWN;
|
||||
// System.out.println("Set state SLOWDOWN");
|
||||
break;
|
||||
case 3:
|
||||
frameCurrent = 46;
|
||||
frameCurrent = 60;
|
||||
state = AttackTreeState.IDLE;
|
||||
// System.out.println("Set state IDLE");
|
||||
break;
|
||||
@ -103,13 +119,13 @@ public class AttackTree {
|
||||
switch(state){
|
||||
case WINDUP:
|
||||
if(entityActor != null){
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.getCurrentAnimation().equals(Animation.ANIMATION_SWING_PRIMARY)){
|
||||
entityActor.playAnimation(Animation.ANIMATION_SWING_PRIMARY);
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.getCurrentAnimation().equals(animationName)){
|
||||
entityActor.playAnimation(animationName);
|
||||
entityActor.incrementAnimationTime(0.01);
|
||||
}
|
||||
}
|
||||
frameCurrent++;
|
||||
if(frameCurrent > 7){
|
||||
if(frameCurrent > damageStartFrame){
|
||||
state = AttackTreeState.ATTACK;
|
||||
}
|
||||
break;
|
||||
@ -127,7 +143,7 @@ public class AttackTree {
|
||||
}
|
||||
}
|
||||
frameCurrent++;
|
||||
if(frameCurrent > 30){
|
||||
if(frameCurrent > damageEndFrame){
|
||||
state = AttackTreeState.COOLDOWN;
|
||||
}
|
||||
break;
|
||||
@ -145,7 +161,7 @@ public class AttackTree {
|
||||
}
|
||||
}
|
||||
frameCurrent++;
|
||||
if(frameCurrent > 45){
|
||||
if(frameCurrent > 60){
|
||||
state = AttackTreeState.IDLE;
|
||||
frameCurrent = 0;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import electrosphere.game.server.creature.type.CreatureType;
|
||||
import electrosphere.game.server.creature.type.MovementSystem;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.IdleTree;
|
||||
import electrosphere.game.server.creature.type.AttackMove;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
@ -75,10 +76,18 @@ public class CreatureUtils {
|
||||
case "ATTACKER":
|
||||
AttackTree attackTree = new AttackTree(rVal);
|
||||
rVal.putData(EntityDataStrings.ATTACK_TREE, attackTree);
|
||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||
Globals.entityManager.registerAttackerEntity(rVal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(AttackMove attackMove : rawType.getAttackMoves()){
|
||||
switch(attackMove.getType()){
|
||||
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, attackMove);
|
||||
break;
|
||||
}
|
||||
}
|
||||
rVal.putData(EntityDataStrings.IDLE_TREE, new IdleTree(rVal));
|
||||
Globals.entityManager.registerCreatureEntity(rVal);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE, true);
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package electrosphere.game.server.creature.type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class AttackMove {
|
||||
String type;
|
||||
String animationName;
|
||||
int damageStartFrame;
|
||||
int damageEndFrame;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getAnimationName() {
|
||||
return animationName;
|
||||
}
|
||||
|
||||
public int getDamageStartFrame() {
|
||||
return damageStartFrame;
|
||||
}
|
||||
|
||||
public int getDamageEndFrame() {
|
||||
return damageEndFrame;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -9,6 +9,7 @@ public class CreatureType {
|
||||
List<HitboxData> hitboxes;
|
||||
List<String> tokens;
|
||||
List<MovementSystem> movementSystems;
|
||||
List<AttackMove> attackMoves;
|
||||
String modelPath;
|
||||
|
||||
public String getName() {
|
||||
@ -34,6 +35,10 @@ public class CreatureType {
|
||||
public List<MovementSystem> getMovementSystems() {
|
||||
return movementSystems;
|
||||
}
|
||||
|
||||
public List<AttackMove> getAttackMoves() {
|
||||
return attackMoves;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ public class LoggerInterface {
|
||||
loggerNetworking = new Logger(LogLevel.WARNING);
|
||||
loggerFileIO = new Logger(LogLevel.WARNING);
|
||||
loggerGameLogic = new Logger(LogLevel.WARNING);
|
||||
loggerRenderer = new Logger(LogLevel.DEBUG);
|
||||
loggerRenderer = new Logger(LogLevel.WARNING);
|
||||
loggerEngine = new Logger(LogLevel.WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public class RenderingEngine {
|
||||
static ShaderProgram lightDepthShaderProgram;
|
||||
static Framebuffer lightDepthBuffer;
|
||||
|
||||
public static boolean renderHitboxes = false;
|
||||
public static boolean renderHitboxes = true;
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user