-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGame.gd
More file actions
116 lines (100 loc) · 3.73 KB
/
Game.gd
File metadata and controls
116 lines (100 loc) · 3.73 KB
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
extends Node2D
var did := false
var world_areas := []
var player_in_area := 0
func _ready() -> void:
world_areas.append(Rect2(Vector2(-3, -8) * Rooms.tile_size * 8, Vector2(7, 9) * Rooms.tile_size * 8))
if randi() % 3112 == 31:
world_areas.append(Rect2(Vector2(-2002 - randi() % 31, randi() % 2002) * Rooms.tile_size * 8, Vector2(7, 8) * Rooms.tile_size * 8))
for i in Items.player_wands:
if i == null: continue
i.connect("casting_spell", self, "_on_casting_spell")
func _on_casting_spell(info: WandCastingInfo):
var spell := info.spell
var caster := info.caster
var offset := info.offset
var wand :Wand = info.wand
var position_caster := info.position_caster
if position_caster == null:
position_caster = caster
if !spell.is_cast_mod:
if is_instance_valid(caster):
var spell_instance = spell.entity.instance()
spell_instance.CastInfo.Caster = caster
spell_instance.CastInfo.position_caster = position_caster
spell_instance.CastInfo.goal_offset = Vector2(-offset + randf()*offset*2, -offset + randf()*offset*2) * 50
spell_instance.CastInfo.goal = position_caster.looking_at()
spell_instance.CastInfo.wand = wand
spell_instance.CastInfo.modifiers = spell.behavior_modifiers
spell_instance.CastInfo.spell = spell
add_child(spell_instance)
return
for i in spell.input_contents:
i.behavior_modifiers.append_array(spell.behavior_modifiers.duplicate())
var counts := {}
for j in i.behavior_modifiers:
if counts.has(j):
counts[j] += 1
else:
counts[j] = 1
if counts[j] == 2:
counts[j] = 0
i.behavior_modifiers.erase(j)
i.behavior_modifiers.erase(j)
match spell.id:
"multiply":
var new_info :WandCastingInfo = info.duplicate()
new_info.spell = spell.input_contents[0]
for i in spell.level:
_on_casting_spell(new_info)
new_info.offset = info.offset - 2 + randf() * 2
"unify":
var new_info_1 :WandCastingInfo = info.duplicate()
info.unreference()
var new_info_2 :WandCastingInfo = info.duplicate()
new_info_1.spell = spell.input_contents[0]
new_info_2.spell = spell.input_contents[1]
_on_casting_spell(new_info_1)
_on_casting_spell(new_info_2)
"cast_collider":
var new_info :WandCastingInfo = info.duplicate()
info.unreference()
spell.input_contents[0].behavior_modifiers.append(["cast_collider", spell.input_contents[1]])
new_info.spell = spell.input_contents[0]
_on_casting_spell(new_info)
func _process(delta: float) -> void:
if !did:
$World.ready()
did = true
if Items.selected_wand >= Items.player_wands.size():
Items.selected_wand = Items.player_wands.size() - 1
if Items.selected_wand < 0:
Items.selected_wand = 0
var player_tile :Vector2 = $World.get_round_point_to_tile($Player.position.snapped(Vector2(8, 8)) / 8)
for x in range(-2, 2):
for y in range(-2, 2):
var tile := player_tile + Vector2(x, y)
if not $World.world_tile_instances.has(tile):
var new_tile = preload("res://Rooms/Sacrifice/Empty_room.tscn").instance()
new_tile.position = tile * Rooms.tile_size * 8
new_tile.add_to_group("WorldPiece")
$World.world_tile_instances[tile] = new_tile
$World.add_child(new_tile)
var index := 0
var previous_area = player_in_area
player_in_area = -1
for i in world_areas:
if i.has_point($Player.position):
player_in_area = index
index += 1
if player_in_area != previous_area:
if player_in_area == -1:
if previous_area == 0:
$Player.send_message("Leving This World")
else:
if player_in_area == 0:
$Player.send_message("Entering World")
elif Time.get_datetime_dict_from_system()["month"] == 12 and Time.get_time()["day"] == 31:
$Player.send_message("Entered godiscryinggodiscryinggodiscryinggodisc")
else:
$Player.send_message("Entered 20797468736321816615543854419")