Skip to content

Commit

Permalink
reveno de la lasero. algoritmo por niveldesegnado
Browse files Browse the repository at this point in the history
  • Loading branch information
HassanHeydariNasab committed Jul 1, 2017
1 parent 98b3328 commit e0bf450
Show file tree
Hide file tree
Showing 18 changed files with 555 additions and 195 deletions.
3 changes: 2 additions & 1 deletion Defendiloj/Kugloj/Kuglo/Kuglo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ var pistolo
var nivelo = 0
var angulo = 0

onready var Kuglo = get_node("Kuglo")
onready var Vivtempilo = get_node("Vivtempilo")

func _ready():
if nivelo != 0 and angulo != 0:
set_fixed_process(true)

func _fixed_process(delta):
get_node("Kuglo").move((Vector2(4.0*(log(nivelo)+1.0)*cos(angulo), -4.0*(log(nivelo)+1.0)*sin(angulo))))
Kuglo.move((Vector2(4.0*(log(nivelo)+1.0)*cos(angulo), -4.0*(log(nivelo)+1.0)*sin(angulo))))

func _on_Area2D_body_enter( korpo ):
var patro_nomo = korpo.get_parent().nomo
Expand Down
21 changes: 3 additions & 18 deletions Defendiloj/Kugloj/Kuglo/Kuglo.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
[gd_scene load_steps=5 format=1]
[gd_scene load_steps=4 format=1]

[ext_resource path="res://Defendiloj/Kugloj/Kuglo/Kuglo.gd" type="Script" id=1]
[ext_resource path="res://Defendiloj/Kugloj/Kuglo/kuglo.png" type="Texture" id=2]

[sub_resource type="CircleShape2D" id=1]

custom_solver_bias = 0.0
radius = 22.0167

[sub_resource type="CircleShape2D" id=2]

custom_solver_bias = 0.0
radius = 4.48251

Expand All @@ -20,20 +15,10 @@ script/script = ExtResource( 1 )
[node name="Kuglo" type="KinematicBody2D" parent="."]

input/pickable = false
shapes/0/shape = SubResource( 1 )
shapes/0/transform = Matrix32( 0.2, 0, 0, 0.2, 0, 0 )
shapes/0/trigger = false
collision/layers = 2048
collision/mask = 0
collision/margin = 0.08

[node name="CollisionShape2D" type="CollisionShape2D" parent="Kuglo"]

transform/scale = Vector2( 0.2, 0.2 )
shape = SubResource( 1 )
trigger = false
_update_shape_index = 0

[node name="Sprite" type="Sprite" parent="Kuglo"]

transform/scale = Vector2( 0.2, 0.2 )
Expand All @@ -42,7 +27,7 @@ texture = ExtResource( 2 )
[node name="Area2D" type="Area2D" parent="Kuglo"]

input/pickable = false
shapes/0/shape = SubResource( 2 )
shapes/0/shape = SubResource( 1 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
shapes/0/trigger = false
gravity_vec = Vector2( 0, 0 )
Expand All @@ -54,7 +39,7 @@ collision/mask = 4

[node name="CollisionShape2D" type="CollisionShape2D" parent="Kuglo/Area2D"]

shape = SubResource( 2 )
shape = SubResource( 1 )
trigger = false
_update_shape_index = 0

Expand Down
24 changes: 14 additions & 10 deletions Defendiloj/Kugloj/Laserradio/Laserradio.gd
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
extends Node2D

var pistolo
var t = 0
var nivelo = 0
var angulo = 0

onready var Laserradio = get_node("Laserradio")
onready var Vivtempilo = get_node("Vivtempilo")

func _ready():
if nivelo != 0 and angulo != 0:
set_process(true)
set_global_rot(angulo+deg2rad(90))
set_fixed_process(true)

func _fixed_process(delta):
get_node("Laserradio").move((Vector2(50*cos(angulo), -50*sin(angulo))))
Laserradio.move((Vector2(25.0*cos(angulo), -25.0*sin(angulo))))
set_scale(Vector2(1, (5-Vivtempilo.get_time_left())*10))

func _process(delta):
if get_node("Laserradio").is_colliding():
get_node("Laserradio").get_collider().get_parent().vivo -= nivelo
func _on_Area2D_body_enter( korpo ):
var patro_nomo = korpo.get_parent().nomo
if patro_nomo == "Malamiko_0_" or patro_nomo == "Malamiko_1_" or patro_nomo == "Malamiko_2_":
korpo.get_parent().vivo -= log(nivelo+3)*20-10
queue_free()
t += 10
t += 1
if t > 200:
queue_free()


func _on_Vivtempilo_timeout():
queue_free()
57 changes: 43 additions & 14 deletions Defendiloj/Kugloj/Laserradio/Laserradio.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[gd_scene load_steps=4 format=1]
[gd_scene load_steps=3 format=1]

[ext_resource path="res://Defendiloj/Kugloj/Laserradio/Laserradio.gd" type="Script" id=1]
[ext_resource path="res://Defendiloj/Kugloj/Laserradio/laserradio.png" type="Texture" id=2]

[sub_resource type="RectangleShape2D" id=1]
[sub_resource type="ConvexPolygonShape2D" id=1]

custom_solver_bias = 0.0
extents = Vector2( 16.1141, 256.509 )
points = Vector2Array( -8, -16, 8, -16, 8, 16, -8, 16 )

[node name="Laserradio" type="Node2D"]

Expand All @@ -15,23 +14,53 @@ script/script = ExtResource( 1 )
[node name="Laserradio" type="KinematicBody2D" parent="."]

input/pickable = false
collision/layers = 2048
collision/mask = 0
collision/margin = 0.08

[node name="Polygon2D" type="Polygon2D" parent="Laserradio"]

polygon = Vector2Array( -8, -16, 8, -16, 8, 16, -8, 16 )
uv = Vector2Array( )
color = Color( 0.4, 0.6, 1, 1 )
vertex_colors = ColorArray( )
offset = Vector2( 0, 0 )
texture/texture = null
texture/offset = Vector2( 0, 0 )
texture/scale = Vector2( 1, 1 )
texture/rotation = 0.0
invert/enable = false
invert/border = 100.0

[node name="Area2D" type="Area2D" parent="Laserradio"]

input/pickable = true
shapes/0/shape = SubResource( 1 )
shapes/0/transform = Matrix32( 0.2, 0, 0, 0.2, 0, 0 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
shapes/0/trigger = false
gravity_vec = Vector2( 0, 0 )
gravity = 0.0
linear_damp = 0.1
angular_damp = 1.0
collision/layers = 2048
collision/mask = 4100
collision/margin = 0.08
collision/mask = 4

[node name="CollisionShape2D" type="CollisionShape2D" parent="Laserradio"]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Laserradio/Area2D"]

transform/scale = Vector2( 0.2, 0.2 )
shape = SubResource( 1 )
build_mode = 0
polygon = Vector2Array( -8, -16, 8, -16, 8, 16, -8, 16 )
shape_range = Vector2( 0, 0 )
trigger = false
_update_shape_index = 0

[node name="Sprite" type="Sprite" parent="Laserradio"]
[node name="Vivtempilo" type="Timer" parent="."]

process_mode = 1
wait_time = 4.0
one_shot = true
autostart = true

[connection signal="body_enter" from="Laserradio/Area2D" to="." method="_on_Area2D_body_enter"]

transform/scale = Vector2( 0.2, 0.2 )
texture = ExtResource( 2 )
[connection signal="timeout" from="Vivtempilo" to="." method="_on_Vivtempilo_timeout"]


4 changes: 3 additions & 1 deletion Defendiloj/Pistoloj/Kanono/Kanono.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ script/script = ExtResource( 1 )

[node name="Kanono" type="KinematicBody2D" parent="."]

editor/display_folded = true
input/pickable = true
shapes/0/shape = SubResource( 1 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
Expand Down Expand Up @@ -83,6 +82,7 @@ texture = ExtResource( 4 )

[node name="Area2D" type="Area2D" parent="."]

editor/display_folded = true
transform/rot = 8.14222e-13
input/pickable = true
shapes/0/shape = SubResource( 3 )
Expand All @@ -109,6 +109,7 @@ texture = ExtResource( 5 )

[node name="Reta" type="Area2D" parent="."]

editor/display_folded = true
input/pickable = true
shapes/0/shape = SubResource( 4 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
Expand Down Expand Up @@ -151,6 +152,7 @@ max_lines_visible = -1

[node name="Strategio" type="Node2D" parent="."]

editor/display_folded = true
transform/pos = Vector2( -833.333, 433.333 )
transform/rot = 90.0
transform/scale = Vector2( 2, 2 )
Expand Down
111 changes: 93 additions & 18 deletions Defendiloj/Pistoloj/Lasero/Lasero.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,139 @@ var Malamikoj = []

onready var F = get_node("Fiksata")
onready var P = get_node("Lasero")
onready var Kuglujo = get_node("Lasero/Kuglujo")
onready var Laserradiujo = get_node("Lasero/Laserradiujo")
onready var Elektumo = get_node("Lasero/Elektumo")
onready var Nivelo = get_node("Nivelo")
onready var Areo = get_node("Area2D")
onready var Limo = get_node("Area2D/Limo")
onready var K = preload("res://Defendiloj/Kugloj/Laserradio/Laserradio.tscn")
onready var Strategio = get_node("Strategio")
onready var DK = get_node("DuoblaKlako")
onready var Radiko = get_tree().get_root().get_node("Radiko")
onready var Enreta = get_node("Lasero/Enreta")
onready var Fajro = get_node("Fajro")

var Kugloj


var nk = 0
var atendado_nova_K = 0
var nivelo = 1
var strategio = 'nova'
var enreta = false

func _ready():
Kugloj = get_tree().get_root().get_node("Radiko/Kugloj")
Strategio.hide()
Enreta.hide()
set_process(true)

func _on_Area2D_body_enter( korpo ):
if korpo.get_name() == "Malamiko_0":
Malamikoj.push_front(korpo)
if korpo.get_name() == "Malamiko":
Malamikoj.push_back(korpo)

func _on_Area2D_body_exit( korpo ):
if korpo.get_name() == "Malamiko_0":
if korpo.get_name() == "Malamiko":
Malamikoj.remove(Malamikoj.find(korpo))

func _process(delta):
if enreta:
Enreta.show()
else:
Enreta.hide()
if Malamikoj.size() > 0:
#se la malamiko liberigxis
#se malamiko liberigxis
for Malamiko in Malamikoj:
if not weakref(Malamiko).get_ref():
Malamikoj.erase(Malamiko)
if Malamikoj.size() > 0:
#PORFARI sxangxu gxin laux la strategio
#se ankoraux ni havas malamikojn
if Malamikoj.size() > 0 and enreta:
var Malamiko = Malamikoj[0]
if strategio == 'nova':
Malamiko = Malamikoj[-1]
elif strategio == 'malnova':
Malamiko = Malamikoj[0]
elif strategio == 'forta':
for M in Malamikoj:
if M.get_parent().vivo > Malamiko.get_parent().vivo:
Malamiko = M
elif strategio == 'malforta':
for M in Malamikoj:
if M.get_parent().vivo < Malamiko.get_parent().vivo:
Malamiko = M
else:
Malamiko = Malamikoj[-1]
var angulo = get_angle_to(Malamiko.get_global_pos())
angulo -= deg2rad(180)
P.set_rot(angulo)
atendado_nova_K += 1
if atendado_nova_K < 100 and atendado_nova_K % 50 == 0:
Fajro.play()
Radiko.mono -= 5
var K_ = K.instance()
K_.pistolo = self
K_.nivelo = nivelo
K_.angulo = angulo
K_.set_rot(angulo+deg2rad(90))
K_.set_global_pos(Kuglujo.get_global_pos())
K_.set_global_scale(Vector2(nivelo, nivelo))
get_tree().get_root().add_child(K_)
K_.set_global_pos(Laserradiujo.get_global_pos())
#K_.set_global_scale(Vector2(log(nivelo)+1.0, log(nivelo)+1.0))
Kugloj.add_child(K_)
elif atendado_nova_K >= 100:
atendado_nova_K = 2
if get_tree().get_root().get_node("Radiko").kaptitajxo == self:
atendado_nova_K = 0
if Radiko.kaptitajxo == self:
set_global_pos(get_global_mouse_pos())
set_global_scale(Vector2(1.35, 1.35))
Elektumo.show()
Limo.show()
else:
set_global_scale(Vector2(1.3, 1.3))
Elektumo.hide()
Limo.hide()

Nivelo.set_text(str(nivelo))

Areo.set_scale(Vector2(log(nivelo)/5.0+1,log(nivelo)/5.0+1))

func _on_Lasero_input_event( viewport, event, shape_idx ):
if event.type == InputEvent.SCREEN_TOUCH:
if event.pressed:
get_tree().get_root().get_node("Radiko").kaptitajxo = self
nk += 1
DK.start()
Radiko.kaptitajxo = self
else:
get_tree().get_root().get_node("Radiko").kaptitajxo = null
Radiko.kaptitajxo = null
if nk >= 2:
if Strategio.is_hidden():
Strategio.show()
else:
Strategio.hide()
nk = 0
DK.stop()

elif event.type == InputEvent.MOUSE_BUTTON:
if event.doubleclick:
if Strategio.is_hidden():
Strategio.show()
else:
Strategio.hide()
if event.button_mask == 0:
get_tree().get_root().get_node("Radiko").kaptitajxo = self
Radiko.kaptitajxo = self
else:
get_tree().get_root().get_node("Radiko").kaptitajxo = null
Radiko.kaptitajxo = null

func _on_DuoblaKlako_timeout():
nk = 0

func _on_MalForta_button_up():
Strategio.hide()
strategio = 'malforta'

func _on_Nova_button_up():
Strategio.hide()
strategio = 'nova'

func _on_MalNova_button_up():
Strategio.hide()
strategio = 'malnova'

func _on_Forta_button_up():
Strategio.hide()
strategio = 'forta'
Loading

0 comments on commit e0bf450

Please sign in to comment.