Skip to content

Commit

Permalink
Merge pull request #106 from rafaelcastrocouto/main
Browse files Browse the repository at this point in the history
prepare for 4.0 migration (start)
  • Loading branch information
rafaelcastrocouto authored Oct 10, 2022
2 parents 8ccd230 + adc2bb8 commit 51456ba
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion prototype/controls/camera.gd
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func _unhandled_input(event):



func start():
func map_loaded():
offset = game.map.mid
var h = offset.x
limit_left = -h
Expand Down
2 changes: 1 addition & 1 deletion prototype/controls/selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func advance(unit, point):
func attack(unit, point):
if unit.attacks and game.can_control(unit):
var order_point = order(unit, point)
game.unit.attack.start(unit, order_point)
game.unit.attack.point(unit, order_point)

func teleport(unit, point):
if unit.moves and game.can_control(unit):
Expand Down
4 changes: 2 additions & 2 deletions prototype/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func build():
ui.main_menu.get_node("container/play_button").play_down()


func start():
func map_loaded():
if not started:
started = true
paused = false
Expand All @@ -85,7 +85,7 @@ func start():
elif test.stress:
test.spawn_random_units()
else:
unit.spawn.start()
unit.spawn.pawns()
ui.get_node("score_board").visible = false
yield(get_tree().create_timer(4), "timeout")
unit.spawn.leaders()
Expand Down
6 changes: 3 additions & 3 deletions prototype/map/maps.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ func load_map(map_name):
game.map = game.maps.get_node(map_name)
game.map.mid = Vector2(game.map.size/2, game.map.size/2)
game.map.visible = true
game.ui.minimap.start()
game.ui.minimap.map_loaded()


func map_loaded():
game.map.fog.visible = game.map.fog_of_war
game.map.trees.occluder_light_mask = 2
game.map.walls.occluder_light_mask = 2
game.camera.start()
game.camera.map_loaded()
game.ui.buttons_update()
game.start()
game.map_loaded()


func setup_leaders():
Expand Down
2 changes: 1 addition & 1 deletion prototype/test/test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func unit_wait_end(unit1):
if stress:
var o = 2000
var d = Vector2(randf()*o,randf()*o)
if game.unit.moves: game.unit.advance.start(unit1, d)
if game.unit.moves: game.unit.advance.point(unit1, d)


func respawn(unit1):
Expand Down
2 changes: 1 addition & 1 deletion prototype/ui/minimap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func over_minimap(event):
event.position.y > get_viewport().size.y - size
)

func start():
func map_loaded():
map_sprite = game.map.get_node("zoom_out_sprite")
map_tiles = game.map.get_node("tiles")
game.ui.minimap.update_map_texture = true
Expand Down
20 changes: 10 additions & 10 deletions prototype/unit/behavior/advance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func _ready():
game = get_tree().get_current_scene()


func start(unit, objective, smart_move = false): # move_and_attack
func point(unit, objective, smart_move = false): # move_and_attack
game.unit.attack.set_target(unit, null)
if objective: unit.objective = objective
if (unit.attacks and game.unit.move.in_bounds(unit.objective) and
Expand All @@ -21,17 +21,17 @@ func start(unit, objective, smart_move = false): # move_and_attack
var has_path = (unit.current_path.size() > 0)
if not enemies:
if not at_objective: move(unit, unit.objective, smart_move)
elif has_path: game.unit.follow.start(unit, unit.current_path, "advance")
elif has_path: game.unit.follow.path(unit, unit.current_path, "advance")
else:
var target = game.unit.orders.select_target(unit, enemies)
if not target:
if not at_objective: move(unit, unit.objective, smart_move)
elif has_path: game.unit.follow.start(unit, unit.current_path, "advance")
elif has_path: game.unit.follow.path(unit, unit.current_path, "advance")
else:
game.unit.attack.set_target(unit, target)
var target_position = target.global_position + target.collision_position
if game.unit.attack.in_range(unit, target):
game.unit.attack.start(unit, target_position)
game.unit.attack.point(unit, target_position)
else: move(unit, target_position, smart_move)


Expand All @@ -45,24 +45,24 @@ func move(unit, objective, smart_move):
func on_collision(unit):
if unit.behavior == "advance" and unit.collide_target == unit.target:
var target_position = unit.target.global_position + unit.target.collision_position
game.unit.attack.start(unit, target_position)
game.unit.attack.point(unit, target_position)


func resume(unit):
if unit.behavior == "advance":
start(unit, null)
point(unit, null)


func end(unit):
if unit.behavior == "advance":
if unit.current_destiny != unit.objective:
start(unit, null)
point(unit, null)
else: stop(unit)


func react(target, attacker):
if target.behavior == "stop" or target.behavior == "advance":
start(target, attacker.global_position)
point(target, attacker.global_position)


func ally_attacked(target, attacker):
Expand All @@ -78,8 +78,8 @@ func stop(unit):

func on_idle_end(unit):
if unit.behavior == "advance" or unit.behavior == "stop":
if unit.attacks: start(unit, unit.global_position)
if unit.attacks: point(unit, unit.global_position)


func smart(unit, objective):
start(unit, objective, true)
point(unit, objective, true)
2 changes: 1 addition & 1 deletion prototype/unit/behavior/attack.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func _ready():
game = get_tree().get_current_scene()


func start(unit, point):
func point(unit, point):
if unit.attacks and not unit.stunned and game.unit.move.in_bounds(point):
if unit.ranged and unit.weapon:
unit.weapon.look_at(point)
Expand Down
10 changes: 5 additions & 5 deletions prototype/unit/behavior/follow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ func in_limits(p):
return ((p.x > 0 and p.y > 0) and (p.x < path_grid.width and p.y < path_grid.height))


func start(unit, path, cb):
func path(unit, path, cb):
if path and path.size():
var next_point = path.pop_front()
unit.current_path = path
game.unit[cb].start(unit, next_point)
game.unit[cb].point(unit, next_point)


func next(unit):
start(unit, unit.current_path, unit.behavior)
path(unit, unit.current_path, unit.behavior)


func draw_path(unit):
Expand Down Expand Up @@ -111,7 +111,7 @@ func lane(unit):
var path = game.map.lanes_paths[lane].duplicate()
if unit.team == "red": path.invert()
if unit.type != 'leader':
start(unit, path, "advance")
path(unit, path, "advance")
else: smart(unit, path, "advance")


Expand All @@ -121,7 +121,7 @@ func smart(unit, path, cb):
var new_path = unit.cut_path(path)
var next_point = new_path.pop_front()
unit.current_path = new_path
game.unit[cb].start(unit, next_point)
game.unit[cb].point(unit, next_point)



Expand Down
4 changes: 2 additions & 2 deletions prototype/unit/behavior/move.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func setup_timer(unit):
unit.add_child(unit.channeling_timer)


func start(unit, destiny):
func point(unit, destiny):
if unit.moves and not unit.stunned and in_bounds(destiny):
unit.set_behavior("move")
move(unit, destiny)
Expand Down Expand Up @@ -109,5 +109,5 @@ func stand(unit):
func smart(unit, point, cb):
if not unit.stunned:
var path = game.unit.follow.find_path(unit.global_position, point)
if path: game.unit.follow.start(unit, path, cb)
if path: game.unit.follow.path(unit, path, cb)

8 changes: 4 additions & 4 deletions prototype/unit/behavior/spawn.gd
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ func leaders():

func send_leader(leader, path):
yield(get_tree(), "idle_frame")
game.unit.follow.start(leader, path, "advance")
game.unit.follow.path(leader, path, "advance")


func start():
func pawns():
spawn_group_cycle()


Expand Down Expand Up @@ -133,7 +133,7 @@ func send_pawn(template, lane, team):
var unit_template = self[template]
pawn = game.maps.create(unit_template, lane, team, "point_random", path.start)
game.unit.orders.set_pawn(pawn)
game.unit.follow.start(pawn, path.follow, "advance")
game.unit.follow.path(pawn, path.follow, "advance")



Expand Down Expand Up @@ -185,4 +185,4 @@ func cemitery_add_leader(leader):
var start = path.pop_front()
leader = spawn_unit(leader, lane, team, "point_random", start)
leader.reset_unit()
game.unit.follow.start(leader, path, "advance")
game.unit.follow.path(leader, path, "advance")

0 comments on commit 51456ba

Please sign in to comment.