Add click-powered idle arcade abilities and roaming helpers
This commit is contained in:
+29
-22
@@ -13,6 +13,8 @@ const REMOVE_SOUND=preload("res://audio/apparatus_remove.wav")
|
||||
const Icon=preload("res://talent_icon.gd")
|
||||
var g
|
||||
var sentences
|
||||
var arcade = preload("res://idle_arcade.gd").new()
|
||||
var roaming = preload("res://helper_roaming.gd").new()
|
||||
const DIALOGUE_INTERVAL=30.0
|
||||
const HERO_INTERVAL=100.0
|
||||
var dialogue_clock=0.0
|
||||
@@ -75,6 +77,7 @@ var mesh_walking=preload("res://mesh_walking.gd").new()
|
||||
func setup(game):
|
||||
g=game
|
||||
mesh_walking.setup(g)
|
||||
roaming.setup(self)
|
||||
sentences=preload("res://judgement.gd").new();sentences.setup(self)
|
||||
losses.setup(self)
|
||||
build_player=AudioStreamPlayer.new();g.add_child(build_player);build_player.max_polyphony=4
|
||||
@@ -89,6 +92,7 @@ func setup(game):
|
||||
make_ui()
|
||||
drag.setup(self)
|
||||
make_level_bar()
|
||||
arcade.setup(self)
|
||||
rebuild_nav()
|
||||
var saved=g.get_meta("workshop_save",{})
|
||||
if saved is Dictionary and not saved.is_empty():
|
||||
@@ -180,7 +184,7 @@ func make_tree():
|
||||
var specs=[
|
||||
{"title":"I ОРУДИЯ", "subtitle":"Золото · покупка новых орудий", "nodes":tool_nodes},
|
||||
{"title":"II СУККУБА", "subtitle":"1 очко за каждый новый уровень", "nodes":[["boot","Поступь тени","+25% к скорости","speed"],["whip","Владычица боли","+20% к своим действиям","power"],["wings","Хозяйка цеха","+8% к работе всей команды","leadership"],["lock","Крылья госпожи","Будущее развитие","future"]]},
|
||||
{"title":"III СВИТА", "subtitle":"Души · до 3 помощниц", "nodes":[["wings","Призвать помощницу","Доставка душ к свободным орудиям","hire"],["soul","Надсмотрщицы","Самостоятельная работа у орудий","auto"],["boot","Стремительная свита","+25% к скорости движения","haste"],["whip","Усердная свита","+25% к скорости работы","diligence"],["lock","Легион тьмы","Будущее развитие","future"]]}
|
||||
{"title":"III СВИТА", "subtitle":"Души · до 3 помощниц", "nodes":[["wings","Призвать помощницу","Доставка душ к свободным орудиям","hire"],["soul","Надсмотрщицы","Работа орудия на полной скорости","auto"],["boot","Стремительная свита","+25% к скорости движения","haste"],["whip","Усердная свита","+25% к скорости работы","diligence"],["lock","Легион тьмы","Будущее развитие","future"]]}
|
||||
]
|
||||
for spec in specs:
|
||||
var column=VBoxContainer.new();columns.add_child(column);column.custom_minimum_size=Vector2(376,0)
|
||||
@@ -235,6 +239,7 @@ func make_grid():
|
||||
grid.hide();preview.hide()
|
||||
|
||||
func reset():
|
||||
arcade.reset()
|
||||
if g.life: g.life.activities.reset()
|
||||
losses.reset();expansion_level=0;g.architecture.growth.set_level(0)
|
||||
cancel_placement(false)
|
||||
@@ -260,6 +265,7 @@ func toggle_build():
|
||||
if not g.game_started or (g.paused and not build_mode):return
|
||||
if g.held>=0:drop_held()
|
||||
cancel_placement(false)
|
||||
if not build_mode:arcade.release()
|
||||
build_mode=not build_mode;g.paused=build_mode
|
||||
g.orbit.preserve_focus()
|
||||
g.orbit.stop();pending=-1;moving=-1;preview.hide();context.hide()
|
||||
@@ -562,7 +568,7 @@ func can_afford_upgrade(cost):
|
||||
return g.coins>=cost+(PRICES[0] if stations.is_empty() else 0)
|
||||
|
||||
func add_helper():
|
||||
var root=Node3D.new();g.add_child(root);root.position=Vector3(-3+helpers.size(),0,4.8)
|
||||
var root=Node3D.new();g.add_child(root);root.position=roaming.spawn_point()
|
||||
var model=preload("res://succubus_actor.gd").new();root.add_child(model);model.scale=Vector3.ONE*.9;model.configure(g)
|
||||
model.set_meta("helper_tint",Color("779fff"))
|
||||
for mesh in model.find_children("*","MeshInstance3D",true,false):
|
||||
@@ -628,7 +634,7 @@ func refresh():
|
||||
n.button.modulate=Color.WHITE
|
||||
build_button.text="";build_button.set_pressed_no_signal(build_mode)
|
||||
grimoire_button.text="";grimoire_button.set_pressed_no_signal(tree.visible)
|
||||
help_primary.text="ЛКМ — установить · Колесо — поворот" if build_mode else "ЛКМ — душа / удар · ПКМ — работать"
|
||||
help_primary.text="ЛКМ — установить · Колесо — поворот" if build_mode else "ЛКМ — душа / пульс · ПКМ — кликай для разгона"
|
||||
help_secondary.text="ПКМ / Esc — отменить · [B] — выйти" if build_mode else "WASD — идти · Колесо — камера"
|
||||
|
||||
func queued():
|
||||
@@ -639,7 +645,7 @@ func waiting():
|
||||
|
||||
func queue_load():
|
||||
# Carrying a soul reserves its queue slot so dropping it can never create an eighth occupant.
|
||||
return waiting().size()+g.souls.filter(func(s):return s.get("state","")=="held" and s.get("queue_reserved",true)).size()
|
||||
return waiting().size()+g.souls.filter(func(s):return s.get("state","") in ["held","charmed"] and s.get("queue_reserved",true)).size()
|
||||
|
||||
func spawn():
|
||||
if not g.game_started or stations.is_empty() or queue_load()>=QUEUE_CAPACITY:return false
|
||||
@@ -688,6 +694,7 @@ func try_player_attach(station_index):
|
||||
if g.player.position.distance_to(approach(d))>1.5:return false
|
||||
if not attach(g.souls[index],station_index):return false
|
||||
g.held=-1
|
||||
arcade.add_charge(10)
|
||||
return true
|
||||
|
||||
func reroute_helper(hi):
|
||||
@@ -720,12 +727,13 @@ func finish(d):
|
||||
var reward=Economy.reward(soul.required,g.development.xp)
|
||||
g.coins+=reward.gold;g.essence+=reward.souls;g.done+=1
|
||||
g.development.reward(reward.xp)
|
||||
arcade.add_charge(5)
|
||||
|
||||
d.soul=-1;d.cooldown=2.6;d.release_clock=2.05;d.operator=-1;d.bar.hide()
|
||||
if d.flame:d.flame.hide()
|
||||
refresh();g.save_progress()
|
||||
|
||||
func step_station(s,dt,active):
|
||||
func step_station(s,dt,active,production_scale=1.0,arcade_work=false):
|
||||
s.cooldown=maxf(0,s.cooldown-dt);s.hit_clock=maxf(0,s.hit_clock-dt)
|
||||
s.release_clock=maxf(0,s.release_clock-dt)
|
||||
if s.cooldown<=.45 and s.soul<0 and s.door:
|
||||
@@ -746,7 +754,7 @@ func step_station(s,dt,active):
|
||||
if is_instance_valid(s.transfer):s.transfer.finish()
|
||||
s.transfer=null
|
||||
return
|
||||
if soul.state in ["held","transit"]:s.idle_time=0;return
|
||||
if soul.state in ["held","transit","charmed"]:s.idle_time=0;return
|
||||
s.idle_time=0.0 if active and not s.ready else s.idle_time+dt
|
||||
if s.idle_time+.00001>=losses.TIMEOUT:losses.station_timeout(s);return
|
||||
if s.ready:
|
||||
@@ -755,15 +763,16 @@ func step_station(s,dt,active):
|
||||
s.bar.position=g.camera.unproject_position(s.device.position+Vector3(0,3.4,0))-Vector2(48,0)
|
||||
return
|
||||
soul.node.position=s.device.position
|
||||
var rate=action_rate(s)
|
||||
var rate=action_rate(s)*production_scale
|
||||
if active:
|
||||
if s.selected==0:
|
||||
if s.hit_clock<=0:
|
||||
s.hit_clock=.45/rate;s.hits+=1;g.play_whip()
|
||||
s.hit_clock=.45/rate;s.hits+=1
|
||||
if not arcade_work:g.play_whip()
|
||||
soul.visual.whip_reaction()
|
||||
preload("res://whip_impact.gd").new().play(g,s.device,soul.visual,(g.avatar.global_position if s.operator<0 else helpers[s.operator].model.global_position)+Vector3(0,1.45,0))
|
||||
if s.operator<0:g.avatar.strike(s.hit_clock)
|
||||
elif s.operator<helpers.size():helpers[s.operator].model.strike(s.hit_clock)
|
||||
if not arcade_work:preload("res://whip_impact.gd").new().play(g,s.device,soul.visual,(g.avatar.global_position if s.operator<0 else helpers[s.operator].model.global_position)+Vector3(0,1.45,0))
|
||||
if not arcade_work and s.operator<0:g.avatar.strike(s.hit_clock)
|
||||
elif not arcade_work and s.operator>=0 and s.operator<helpers.size():helpers[s.operator].model.strike(s.hit_clock)
|
||||
s.elapsed=float(s.hits)/5.0
|
||||
elif s.selected==1:
|
||||
s.elapsed+=dt*rate
|
||||
@@ -820,7 +829,8 @@ func update_helpers(dt):
|
||||
if is_free(stations[si]) and sentences.accepts(candidate,stations[si].selected):free=si;soul=candidate;break
|
||||
if soul!=null:break
|
||||
if soul==null:
|
||||
h.model.set_walking(false);continue
|
||||
roaming.update(h,dt);continue
|
||||
roaming.cancel(h)
|
||||
soul.state="reserved_next" if soul.get("origin_station",-1)>=0 else "reserved";soul.assigned=hi
|
||||
h.soul=soul.id;h.station=free;h.state="collect";stations[free].reserved=hi
|
||||
var index=g.index_of(h.soul)
|
||||
@@ -870,6 +880,7 @@ func update_soul_dialogue(dt):
|
||||
announce_soul(s)
|
||||
|
||||
func input(event):
|
||||
if arcade.input(event):return true
|
||||
if drag.active and event is InputEventMouseButton and event.button_index==MOUSE_BUTTON_LEFT and event.pressed:
|
||||
return drag.confirm(event.position)
|
||||
if event is InputEventMouseButton and event.button_index==MOUSE_BUTTON_LEFT and not event.pressed:
|
||||
@@ -905,8 +916,7 @@ func input(event):
|
||||
return true
|
||||
if picked>=0 and g.souls[picked].get("state","")=="mounted":
|
||||
var target=g.souls[picked].assigned
|
||||
if target>=0 and target<stations.size() and stations[target].selected==0 and g.player.position.distance_to(approach(stations[target]))<2:
|
||||
step_station(stations[target],0,true)
|
||||
arcade.tap(target)
|
||||
return true
|
||||
var p=ground_point(event.position)
|
||||
# Devices are selected by their floor footprint, independent of camera angle.
|
||||
@@ -918,8 +928,7 @@ func input(event):
|
||||
var ready_index=g.index_of(stations[i].soul)
|
||||
if ready_index>=0:sentences.pickup(g.souls[ready_index])
|
||||
return true
|
||||
if not build_mode and stations[i].selected==0 and g.player.position.distance_to(approach(stations[i]))<2:
|
||||
step_station(stations[i],0,true)
|
||||
if not build_mode:arcade.tap(i)
|
||||
return true
|
||||
context.hide();selected=-1
|
||||
if build_mode:return true
|
||||
@@ -948,6 +957,7 @@ func update(dt):
|
||||
drag.update(dt)
|
||||
update_preview()
|
||||
sentences.update_icons()
|
||||
arcade.update(dt)
|
||||
if g.paused:return
|
||||
if is_instance_valid(g.development.bubble):
|
||||
var d=g.development;d.bubble_time-=dt
|
||||
@@ -991,13 +1001,10 @@ func update(dt):
|
||||
candidates.sort_custom(func(a,b):return g.player.position.distance_squared_to(approach(stations[a]))<g.player.position.distance_squared_to(approach(stations[b])))
|
||||
for i in candidates:
|
||||
if try_player_attach(i):break
|
||||
arcade.follow(dt)
|
||||
update_helpers(dt)
|
||||
var over_ui=g.get_viewport().gui_get_hovered_control()!=null
|
||||
for s in stations:
|
||||
var near=g.player.position.distance_to(approach(s))<2.0
|
||||
var manual=near and not over_ui and Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT)
|
||||
var automatic=s.operator>=0 and automation
|
||||
step_station(s,dt,automatic or (manual and s.selected>0))
|
||||
step_station(s,dt,true,arcade.production(s),true)
|
||||
g.life.update(dt)
|
||||
for i in range(g.popups.size()-1,-1,-1):
|
||||
var p=g.popups[i];p.ttl-=dt;p.node.position.y+=dt*.7
|
||||
@@ -1009,7 +1016,7 @@ func move_player(dt):
|
||||
var down=g.camera.global_basis.z;down.y=0;down=down.normalized()
|
||||
var direction=(right*move.x+down*move.y).normalized()
|
||||
var previous_position=g.player.position
|
||||
var desired=g.player.position+direction*dt*(3.3+g.speed_level*.825)
|
||||
var desired=g.player.position+direction*dt*(3.3+g.speed_level*.825)*(1.5 if arcade.frenzy>0 else 1.0)
|
||||
desired.x=clampf(desired.x,-7.1,walk_right());desired.z=clampf(desired.z,-4.8,5.6)
|
||||
mesh_walking.move_actor(g.player,desired-g.player.position)
|
||||
if direction.length()>.01:
|
||||
|
||||
Reference in New Issue
Block a user