Tweaking attacking
This commit is contained in:
parent
9228fd43ee
commit
992ef0d159
@ -136,7 +136,7 @@
|
|||||||
"type" : "MELEE_WEAPON_SWING_ONE_HAND",
|
"type" : "MELEE_WEAPON_SWING_ONE_HAND",
|
||||||
"animationName" : "Armature|SwingWeapon",
|
"animationName" : "Armature|SwingWeapon",
|
||||||
"damageStartFrame" : 30,
|
"damageStartFrame" : 30,
|
||||||
"damageEndFrame" : 120
|
"damageEndFrame" : 60
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"healthSystem" : {
|
"healthSystem" : {
|
||||||
|
|||||||
@ -393,6 +393,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).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(controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).isState() == false){
|
||||||
if(attackTree != null){
|
if(attackTree != null){
|
||||||
|
CreatureUtils.setMovementVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
|
||||||
attackTree.start(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
|
attackTree.start(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,19 +51,25 @@ public class AttackTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start(String attackType){
|
public void start(String attackType){
|
||||||
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
|
if(canAttack()){
|
||||||
AttackMove currentMove;
|
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
|
||||||
switch(attackType){
|
AttackMove currentMove;
|
||||||
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
switch(attackType){
|
||||||
currentMove = (AttackMove)parent.getData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
|
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||||
damageStartFrame = currentMove.getDamageStartFrame();
|
currentMove = (AttackMove)parent.getData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
|
||||||
damageEndFrame = currentMove.getDamageEndFrame();
|
damageStartFrame = currentMove.getDamageStartFrame();
|
||||||
animationName = currentMove.getAnimationName();
|
damageEndFrame = currentMove.getDamageEndFrame();
|
||||||
break;
|
animationName = currentMove.getAnimationName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(parent.getDataKeys().contains(EntityDataStrings.DATA_STRING_MOVEMENT_BT)){
|
||||||
|
CreatureUtils.getEntityMovementTree(parent).interrupt();
|
||||||
|
}
|
||||||
|
Vector3d movementVector = CreatureUtils.getMovementVector(parent);
|
||||||
|
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
|
||||||
|
state = AttackTreeState.WINDUP;
|
||||||
|
frameCurrent = 0;
|
||||||
}
|
}
|
||||||
//TODO: check if can start moving
|
|
||||||
state = AttackTreeState.WINDUP;
|
|
||||||
frameCurrent = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interrupt(){
|
public void interrupt(){
|
||||||
@ -271,4 +277,12 @@ public class AttackTree {
|
|||||||
networkMessageQueue.add(networkMessage);
|
networkMessageQueue.add(networkMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean canAttack(){
|
||||||
|
boolean rVal = true;
|
||||||
|
if(state != AttackTreeState.IDLE){
|
||||||
|
rVal = false;
|
||||||
|
}
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,32 @@
|
|||||||
package electrosphere.entity.state.equip;
|
package electrosphere.entity.state.equip;
|
||||||
|
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
*/
|
*/
|
||||||
public class EquipState {
|
public class EquipState {
|
||||||
|
|
||||||
|
Entity parent;
|
||||||
|
|
||||||
|
Entity equipPrimary;
|
||||||
|
|
||||||
|
public EquipState(Entity parent){
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEquipPrimary(){
|
||||||
|
return equipPrimary == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entity getEquipPrimary() {
|
||||||
|
return equipPrimary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEquipPrimary(Entity equipPrimary) {
|
||||||
|
this.equipPrimary = equipPrimary;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import electrosphere.entity.types.creature.CreatureUtils;
|
|||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.state.AttackTree;
|
||||||
|
import electrosphere.entity.state.AttackTree.AttackTreeState;
|
||||||
import electrosphere.entity.state.GravityTree;
|
import electrosphere.entity.state.GravityTree;
|
||||||
import electrosphere.entity.state.GravityTree;
|
import electrosphere.entity.state.GravityTree;
|
||||||
import electrosphere.entity.state.movement.SprintTree.SprintTreeState;
|
import electrosphere.entity.state.movement.SprintTree.SprintTreeState;
|
||||||
@ -76,11 +78,14 @@ public class GroundMovementTree {
|
|||||||
|
|
||||||
public void start(){
|
public void start(){
|
||||||
//TODO: check if can start moving
|
//TODO: check if can start moving
|
||||||
state = MovementTreeState.STARTUP;
|
if(canStartMoving()){
|
||||||
|
state = MovementTreeState.STARTUP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interrupt(){
|
public void interrupt(){
|
||||||
state = MovementTreeState.IDLE;
|
state = MovementTreeState.IDLE;
|
||||||
|
CreatureUtils.setVelocity(parent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void slowdown(){
|
public void slowdown(){
|
||||||
@ -442,6 +447,14 @@ public class GroundMovementTree {
|
|||||||
tree.start();
|
tree.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canStartMoving(){
|
||||||
|
boolean rVal = true;
|
||||||
|
if(parent.getDataKeys().contains(EntityDataStrings.ATTACK_TREE) && ((AttackTree)parent.getData(EntityDataStrings.ATTACK_TREE)).getState() != AttackTreeState.IDLE){
|
||||||
|
rVal = false;
|
||||||
|
}
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAnimationStartUp(String animationStartUp) {
|
public void setAnimationStartUp(String animationStartUp) {
|
||||||
this.animationStartUp = animationStartUp;
|
this.animationStartUp = animationStartUp;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user