117 lines
2.8 KiB
GDScript3
117 lines
2.8 KiB
GDScript3
|
|
extends MapLogic
|
||
|
|
class_name ShipLogic
|
||
|
|
|
||
|
|
var main: Main
|
||
|
|
|
||
|
|
var generatorBiomeExists: bool = true
|
||
|
|
|
||
|
|
var levelGenSeed: int = 0
|
||
|
|
|
||
|
|
var lobbyScene: String = "res://Maps/Lobby/Lobby.tscn"
|
||
|
|
|
||
|
|
var roomList: Array[BasicRoom]
|
||
|
|
var generatorRoomList: Array[BasicRoom]
|
||
|
|
var hallwayLights: Array[OmniLight3D]
|
||
|
|
|
||
|
|
var power: bool = false
|
||
|
|
var hullBreached: bool = false
|
||
|
|
var finishingMission: bool = false
|
||
|
|
|
||
|
|
const HULL_BREACHED_CONDITION_DROP_SPEED: float = 0.8
|
||
|
|
var shipCondition: float = 100.0
|
||
|
|
var shipFuel: float = 100.0
|
||
|
|
|
||
|
|
var taskDict: Dictionary = {0: MissionTask.new("FixGenerator","Get the Generator back running.")}
|
||
|
|
|
||
|
|
@export var levelGenerator: LevelGenerator
|
||
|
|
|
||
|
|
#@export var controllRoom: ControlRoom
|
||
|
|
#@export var breakableRoom: CorridorDeadEndBreakable
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
main = get_node("/root/Main")
|
||
|
|
levelGenerator.generate(levelGenSeed)
|
||
|
|
|
||
|
|
main.mapScreen.addTask(taskDict[0])
|
||
|
|
|
||
|
|
|
||
|
|
func _process(_delta: float) -> void:
|
||
|
|
finishAstarSetup()
|
||
|
|
|
||
|
|
if Multiplayer.alivePlayerDict.size() == 0:
|
||
|
|
looseMission()
|
||
|
|
|
||
|
|
if taskDict[0].completed:
|
||
|
|
power = true
|
||
|
|
updateLights()
|
||
|
|
|
||
|
|
#if hullBreached:
|
||
|
|
#shipCondition -= HULL_BREACHED_CONDITION_DROP_SPEED * delta
|
||
|
|
#updateShipConditionScreen()
|
||
|
|
|
||
|
|
func finishMission() -> void:
|
||
|
|
if finishingMission: return
|
||
|
|
finishingMission = true
|
||
|
|
|
||
|
|
#Might be temp solution
|
||
|
|
var missionSucces: bool = true
|
||
|
|
for key in taskDict:
|
||
|
|
if !taskDict[key].completed:
|
||
|
|
missionSucces = false
|
||
|
|
break
|
||
|
|
|
||
|
|
if missionSucces:
|
||
|
|
main.missionEndScreen.label.text = "Success!"
|
||
|
|
else:
|
||
|
|
main.missionEndScreen.label.text = "Failure!"
|
||
|
|
|
||
|
|
main.displayMissionEndScreen = true
|
||
|
|
await get_tree().create_timer(8).timeout
|
||
|
|
|
||
|
|
main.displayMissionEndScreen = false
|
||
|
|
main.changeMenu(main.hud)
|
||
|
|
|
||
|
|
main.changeMap.rpc(lobbyScene)
|
||
|
|
|
||
|
|
func setSeed(mapSeed: int) -> void:
|
||
|
|
levelGenSeed = mapSeed
|
||
|
|
|
||
|
|
func addRoomToRoomList(room: BasicRoom) -> void:
|
||
|
|
roomList.push_back(room)
|
||
|
|
if room.biomeName == "generator":
|
||
|
|
generatorRoomList.push_back(room)
|
||
|
|
|
||
|
|
func updateLights() -> void:
|
||
|
|
for room in roomList:
|
||
|
|
room.showLights(power)
|
||
|
|
for light in hallwayLights:
|
||
|
|
light.visible = power
|
||
|
|
#Julian was here
|
||
|
|
func solveTask(id: int) -> void:
|
||
|
|
taskDict[id].completed = true
|
||
|
|
main.mapScreen.completeTask(taskDict[id])
|
||
|
|
|
||
|
|
##TODO
|
||
|
|
#func unSolveTask(id: int) -> void:
|
||
|
|
#taskDict[id].completed = false
|
||
|
|
#main.mapScreen.completeTask(taskDict[id])
|
||
|
|
|
||
|
|
func onLevelGenFinished() -> void:
|
||
|
|
if generatorBiomeExists:
|
||
|
|
var mainRoom: Generator = generatorRoomList[0]
|
||
|
|
for n in generatorRoomList.size()-1:
|
||
|
|
mainRoom.cellSpawners.append_array(generatorRoomList[n+1].powerCellSpawners)
|
||
|
|
mainRoom.wireSpawners.append_array(generatorRoomList[n+1].wireSpawners)
|
||
|
|
mainRoom.Ready()
|
||
|
|
|
||
|
|
#func collisionWithAstroid():
|
||
|
|
#onCollision.emit()
|
||
|
|
#hullBreached = true
|
||
|
|
#shipCondition -= 10
|
||
|
|
#if breakableRoom:
|
||
|
|
#breakableRoom.updateWallVisibility(false)
|
||
|
|
#
|
||
|
|
#func updateShipConditionScreen():
|
||
|
|
#if controllRoom:
|
||
|
|
#controllRoom.shipConditionDisplayNumber = clamp(shipCondition + 1,0,100)
|