-
Notifications
You must be signed in to change notification settings - Fork 0
/
player_Gun_Pick.gd
223 lines (147 loc) · 4.83 KB
/
player_Gun_Pick.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
extends CharacterBody2D
signal Droped(drop:bool)
@export var button : TouchScreenButton
func _enter_tree():
mul.rpc()
@rpc("any_peer","call_local")
func mul():
$"..".set_multiplayer_authority(0)
# Called when the node enters the scene tree for the first time.
func _ready():
#connect("Droped",Drop())
Hide()
#$player_F/TouchScreenButton.hide()
ID = get_multiplayer_authority()
func Drop():
pass
@onready var player = null
@export var pick_gun = false
@export var GunAuthority = false
@export var syncPos = Vector2(0,0)
@export var syncRot = 0
@export var gravity = 30
@onready var ID
@onready var vis :bool
func _process(delta):
#print(" ", vis)
if ! is_on_floor():
velocity.y += gravity * delta
move_and_slide()
#print(get_multiplayer_authority()," selfffffffffffffffffffff ",get_instance_id()," Gravity ",is_on_floor() )
#player
syncPos = global_position
syncRot = rotation_degrees
if ! player:
#button.hide()
$"..".set_multiplayer_authority(0)
$player_F/Label.text = str("Authority For Gun Famas: ", get_multiplayer_authority()," Gravity ", is_on_floor())
$".".rotation = 0
if player && GunAuthority== true:#and Input.is_action_just_pressed("ui_up"):
$"..".visible = GameManager.Vissible
#$".".set_multiplayer_authority(player.get_multiplayer_authority())
if player.is_multiplayer_authority():
Hide()
Gun_Pucked.rpc()
#$".".global_position = player.global_position
player
#pick_gun = true
#$Area2D/Coll.disabled = true
#$".".position = player.position
##get_tree().create_timer(22).timeout
if player.health <= 0:
player = null
GunDrop.rpc()
Hide()
#
#
#
#
##$"..".position = player.position
#$Label.text = str("Authority For Gun Famas: ", player.get_node(".").get_multiplayer_authority())
#if player.health <= 0:
#pick_gun = false
##self.set_multiplayer_authority(0)
#$Area2D/Coll.disabled = false
var buttonplayer
func _on_area_2d_body_entered(body):
if body.has_method("Playerr"):
if body.is_multiplayer_authority():
Show()
#buttonplayer = body.get_node("CanvasLayer/GunPick")
#buttonplayer.show()
#Show.rpc()
#var UiId = body.get_multiplayer_authority()
#if UiId:
#Show()
#$player_F/TouchScreenButton.show()
#Show.rpc()
#if Input.is_action_just_pressed("ui_up"):
player = body
if GunAuthority == false:
var pid = player.multiplayer.get_remote_sender_id()
#if body.is_multiplayer_authority():
# Hide()
#$player_F/TouchScreenButton.show()
#if GunAuthority:
#var Authority = body.get_multiplayer_authority()
#set_multiplayer_authority(Authority)
#pick_gun = true
#$Area2D/Coll.disabled = true
#GunAuthority = false
func _on_area_2d_body_exited(body):
if body.has_method("Playerr"):
if body.is_multiplayer_authority():
Hide()
#Hide()
#$player_F/TouchScreenButton.hide()
func Gun_Pick():
return true
func _on_touch_screen_button_pressed() -> void:
GunAuthority = true
var id : int
" ///////////////////// I Spent 5 Days To Complete Gun System ..... //////////// "
@rpc("any_peer","call_local","reliable",2)
func Gun_Pucked():
$"..".visible = GameManager.Vissible
$"..".set_multiplayer_authority(player.get_multiplayer_authority())
$player_F/MultiplayerSynchronizer.set_multiplayer_authority(player.get_multiplayer_authority())
call_deferred("POS")
call_deferred("is_multiplayer_authority")
#$".".glbal_position = player.global_position
$player_F/Label.text = str("Authority For Gun Famas: ", player.get_multiplayer_authority() , " Gravity ",is_on_floor() )
#print($"..".get_multiplayer_authority()," RPC Authority .....")
#$player_F/Area2D/Coll.disabled = true
$Area2D.monitoring = false
$Coll.disabled = true
gravity = 0
@rpc("any_peer","call_local","reliable",2)
func GunDrop():
#Hide.rpc()
$"..".rotation = 0
GunAuthority = false
$"..".set_multiplayer_authority(0)
$Area2D.monitoring = true
$Coll.disabled = false
gravity = 30
$"..".global_position = $"..".global_position
#@rpc("call_local")
func Hide():
vis = false
button.hide()
#@rpc("any_peer")
func Show():
vis =true
#var buttonplayer = body.get_node("CanvasLayer/GunPick")
button.show()
#button.show()
func POS():
if player:
button.hide()
var gun_rotation_node = player.get_node("GunRotation/BulletSpawn")
$"..".global_position = gun_rotation_node.global_position
$".".global_position = $"..".global_position
$"..".global_rotation_degrees = gun_rotation_node.global_rotation_degrees
$".".global_rotation_degrees = $"..".global_rotation_degrees
#$".".global_rotation_degrees = gun_rotation_node.global_rotation_degrees
#$".".look_at(get_viewport().get_mouse_position())
#var joy = player.get_node("CanvasLayer/Right")