forked from interstellar_development/freeftf
Milestone 2: Beast
This update to the code adds a fully working beast, which is randomly selected and can capture any of the other players.
This commit is contained in:
parent
dfe714044d
commit
812821b510
7 changed files with 242 additions and 14 deletions
|
|
@ -13,7 +13,12 @@ const SPEED = 5.0
|
|||
const JUMP_VELOCITY = 4.5
|
||||
var zoom = 0
|
||||
var player_no
|
||||
var npc = false
|
||||
var enabled = false
|
||||
var caught = false
|
||||
var captured_by
|
||||
var position_pre
|
||||
var got_person = false
|
||||
|
||||
|
||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
|
@ -21,12 +26,11 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
|||
func _ready():
|
||||
player_no = Game.players
|
||||
Game.players += 1
|
||||
print(Server.players)
|
||||
print(Server.players_numbered[player_no])
|
||||
print(multiplayer.get_unique_id())
|
||||
if Server.players_numbered[player_no] == multiplayer.get_unique_id():
|
||||
enabled = true
|
||||
$cam_y/Camera3D.current = true
|
||||
else:
|
||||
npc = true
|
||||
|
||||
func _physics_process(delta):
|
||||
if enabled:
|
||||
|
|
@ -50,8 +54,12 @@ func _physics_process(delta):
|
|||
move_and_slide()
|
||||
Server.sync_player.rpc(name, position, rotation)
|
||||
|
||||
if caught and !npc:
|
||||
Server.sync_player.rpc(name, position, rotation)
|
||||
|
||||
|
||||
func _input(event):
|
||||
if enabled:
|
||||
if !npc:
|
||||
|
||||
if event is InputEventMouseMotion and (Input.is_action_pressed("cam_look") or $cam_y/Camera3D.position.z == 0):
|
||||
var camera_rotation = event.relative * 0.01
|
||||
|
|
@ -66,8 +74,7 @@ func _input(event):
|
|||
rotate(Vector3.DOWN, camera_rotation.x)
|
||||
|
||||
func _unhandled_input(event):
|
||||
if enabled:
|
||||
|
||||
if !npc:
|
||||
if event.is_action_pressed("zoom_in") && $cam_y/Camera3D.position.z > 0:
|
||||
zoom = -1
|
||||
$cam_y/Camera3D.position.z += zoom
|
||||
|
|
@ -76,3 +83,45 @@ func _unhandled_input(event):
|
|||
$cam_y/Camera3D.position.z += zoom
|
||||
else:
|
||||
zoom = 0
|
||||
|
||||
func beast_init():
|
||||
position.y += 10
|
||||
$detect_hit.monitoring = true
|
||||
$detect_hit.monitorable = true
|
||||
$detect_hit/CollisionShape3D.disabled = false
|
||||
$hammer_bag.visible = true
|
||||
|
||||
func _on_detect_hit_body_entered(body):
|
||||
if enabled and body is CharacterBody3D and !got_person:
|
||||
Server.player_hit.rpc(body.name, name)
|
||||
|
||||
func captured(beast):
|
||||
if !npc:
|
||||
$in_bag.visible = true
|
||||
print(beast)
|
||||
$time_in_bag.start()
|
||||
visible = false
|
||||
enabled = false
|
||||
caught = true
|
||||
captured_by = beast
|
||||
position_pre = position
|
||||
position = Vector3(10000, 10000, 10000)
|
||||
|
||||
|
||||
func got_one(target):
|
||||
got_person = true
|
||||
$hammer_bag/CSGCylinder3D/CSGSphere3D.visible = true
|
||||
|
||||
func lost_one():
|
||||
got_person = false
|
||||
$hammer_bag/CSGCylinder3D/CSGSphere3D.visible = false
|
||||
|
||||
|
||||
func _on_time_in_bag_timeout():
|
||||
visible = true
|
||||
if !npc:
|
||||
enabled = true
|
||||
caught = false
|
||||
captured_by.lost_one()
|
||||
position = position_pre
|
||||
$in_bag.visible = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue