Skip to content
Snippets Groups Projects
Commit b9ca6972 authored by STAVRIDIS ADONIS's avatar STAVRIDIS ADONIS :speech_balloon:
Browse files

#98 Revert + fix additions

parent 0ee823ce
Branches
Tags
No related merge requests found
extends KinematicBody extends KinematicBody
var player
var currentPosition:float = 0
func _ready():
player = get_node(".")
# Update the player's position based on the position computed by the remote scene on the server # Update the player's position based on the position computed by the remote scene on the server
puppet func getRemoteMovement(position:Vector3): puppet func getRemoteMovement(position:Vector3):
self.set_translation(position) self.set_translation(position)
if position.x > currentPosition:
player.set_rotation(Vector3())
elif position.x < currentPosition:
player.set_rotation(Vector3(0,-PI,0))
currentPosition = position.x
puppet func getAnimationTypePlay(animationType): puppet func getAnimationTypePlay(animationType):
get_node("AnimationTree").PlayAnimation(animationType) get_node("AnimationTree").PlayAnimation(animationType)
...@@ -21,4 +10,4 @@ puppet func getAnimationTypePlay(animationType): ...@@ -21,4 +10,4 @@ puppet func getAnimationTypePlay(animationType):
# Called by the remote player # Called by the remote player
puppet func hurt(damages:int): puppet func hurt(damages:int):
print("You suffered a hit and lost " + str(damages) + " HPs !") print("You suffered a hit and lost " + str(damages) + " HPs !")
\ No newline at end of file
This diff is collapsed.
...@@ -40,13 +40,13 @@ enum {NONE=0, PRIMARY=1, SECONDARY=2} ...@@ -40,13 +40,13 @@ enum {NONE=0, PRIMARY=1, SECONDARY=2}
onready var primaryHitArea:Area = $primaryHitArea onready var primaryHitArea:Area = $primaryHitArea
var primaryAttackDmg:float = 30.0 var primaryAttackDmg:float = 30.0
var primaryAttackDist:float = 1.2 var primaryAttackDist:float = 1.2
var primaryAttackDuration:float = 0.55 var primaryAttackDuration:float = 0.6
# Secondary attack parameters # Secondary attack parameters
onready var secondaryHitArea:Area = $secondaryHitArea onready var secondaryHitArea:Area = $secondaryHitArea
var secondaryAttackDmg:float = 15.0 var secondaryAttackDmg:float = 15.0
var secondaryAttackDist:float = 1.2 var secondaryAttackDist:float = 1.2
var secondaryAttackDuration:float = 0.5 var secondaryAttackDuration:float = 0.3
# Character informations # Character informations
var damages:int = 30.0 var damages:int = 30.0
...@@ -80,33 +80,28 @@ func _physics_process(delta): ...@@ -80,33 +80,28 @@ func _physics_process(delta):
# Called from the game script to update the vars # Called from the game script to update the vars
func getPlayerInputs(movementInput, jumpInput, sprintInput, attackTypeInput): func getPlayerInputs(movementInput, jumpInput, sprintInput, attackTypeInput):
# Check if the character isn't already attacking motion = 0
if !isAttacking:
motion = movementInput motion = movementInput
if attackTypeInput!=NONE:
if self.is_on_floor():
motion = 0
processAttack(attackTypeInput)
else:
if self.is_on_floor():
motion = 0
else:
motion = movementInput
isSprinting = sprintInput isSprinting = sprintInput
isJumping = jumpInput && !isJumping isJumping = jumpInput && !isJumping
# Check if the character isn't already attacking
if attackTypeInput!=NONE && !isAttacking:
processAttack(attackTypeInput)
func processMovement(delta): func processMovement(delta):
# Set the side faced by the character # Set the side faced by the character
if self.is_on_floor(): if motion > 0:
if motion > 0: set_rotation_degrees(Vector3(0, 0, 0))
set_rotation_degrees(Vector3(0, 0, 0)) broadcastAnimation(-1)
broadcastAnimation(ANIM_RUN) elif motion < 0:
elif motion < 0: set_rotation_degrees(Vector3(0, 180, 0))
set_rotation_degrees(Vector3(0, 180, 0)) broadcastAnimation(-1)
broadcastAnimation(ANIM_RUN) elif motion == 0:
else: broadcastAnimation(0)
broadcastAnimation(ANIM_IDLE)
if self.is_on_floor(): if self.is_on_floor():
currentJump = 1 currentJump = 1
...@@ -114,7 +109,7 @@ func processMovement(delta): ...@@ -114,7 +109,7 @@ func processMovement(delta):
if isJumping: if isJumping:
isJumping = false isJumping = false
if currentJump < maxJump: if currentJump < maxJump:
broadcastAnimation(ANIM_JUMP) broadcastAnimation(3)
print(currentJump) print(currentJump)
currentJump += 1 currentJump += 1
vel.y = JUMP_SPEED vel.y = JUMP_SPEED
...@@ -158,29 +153,13 @@ func processAttack(attackType): ...@@ -158,29 +153,13 @@ func processAttack(attackType):
# Turn off the other attacks input for the time being # Turn off the other attacks input for the time being
isAttacking = true isAttacking = true
# Create random number (0,1)
var rng = RandomNumberGenerator.new()
rng.randomize()
var rand = rng.randi_range(0,1)
# Use the right function # Use the right function
match attackType: match attackType:
PRIMARY: PRIMARY:
primaryAttack() primaryAttack()
if self.is_on_floor():
if (rand):
broadcastAnimation(ANIM_PUNCH_1)
else:
broadcastAnimation(ANIM_PUNCH_2)
else:
broadcastAnimation(ANIM_JUMP_KICK_SIDE)
SECONDARY: SECONDARY:
secondaryAttack() secondaryAttack()
if self.is_on_floor(): broadcastAnimation(attackType)
if (rand):
broadcastAnimation(ANIM_KICK_1)
else:
broadcastAnimation(ANIM_KICK_2)
func primaryAttack(): func primaryAttack():
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment