Fixed up a couple things, first steps towards a location manager
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
class_name npcConstruct
|
||||
extends cCharacter
|
||||
|
||||
var defaultRoom = 0
|
||||
|
||||
signal location_changed(ai, old_location, new_location)
|
||||
signal state_changed(ai, old_state, new_state)
|
||||
|
||||
var state: int = 0
|
||||
|
||||
func advance_state() -> void:
|
||||
if state >= MAX_STATE:
|
||||
if reset_after_climax:
|
||||
@@ -14,11 +13,10 @@ func advance_state() -> void:
|
||||
else:
|
||||
state += 1
|
||||
|
||||
func _ready():
|
||||
super._ready()
|
||||
func _init():
|
||||
super._init()
|
||||
print("Construct Ready")
|
||||
|
||||
|
||||
Global.game.night.hour_changed.connect(_on_hour_changed)
|
||||
|
||||
func _on_hour_changed(hour: int):
|
||||
@@ -29,6 +27,8 @@ func _on_hour_changed(hour: int):
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
super._process(delta)
|
||||
print("Construct: Processing")
|
||||
print(state)
|
||||
|
||||
match state:
|
||||
0: pass # dormant
|
||||
@@ -38,6 +38,7 @@ func _process(delta: float) -> void:
|
||||
4: pass
|
||||
5: pass
|
||||
6: pass
|
||||
|
||||
advance_state()
|
||||
if (randi_range(1, 20) > 10):
|
||||
stunted = true
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class_name cCharacter
|
||||
extends Node
|
||||
|
||||
# --- Parameters ---
|
||||
@export_range(0, 20) var ai_level := 10
|
||||
|
||||
@@ -9,6 +8,8 @@ extends Node
|
||||
@export var reset_after_climax := true
|
||||
@export var character_name := "template"
|
||||
|
||||
var default_room: cCamera = Global.game.cameras[0]
|
||||
|
||||
# --- Constants ---
|
||||
const MAX_STATE := 6
|
||||
const DEBUG := true
|
||||
@@ -25,10 +26,7 @@ func move_to(room_id: int):
|
||||
current_room = room_id
|
||||
Global.rooms[current_room].add_enemy(self)
|
||||
|
||||
func _init():
|
||||
_ready()
|
||||
|
||||
func _ready() -> void:
|
||||
func _init() -> void:
|
||||
randomize()
|
||||
_set_next_interval()
|
||||
|
||||
@@ -54,6 +52,7 @@ func try_move(delta: float) -> bool:
|
||||
return roll <= ai_level
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
print("Test Character Script")
|
||||
if try_move(delta):
|
||||
if(stunted):
|
||||
stunted = false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class_name cCamera
|
||||
|
||||
var cam: Dictionary
|
||||
var camID: String
|
||||
var camID: int
|
||||
|
||||
var camGraph = Global.loadJSON("res://Data/cameras.json")
|
||||
|
||||
@@ -9,25 +9,23 @@ var name: String
|
||||
var disabled: bool
|
||||
var rendersChart: Dictionary
|
||||
var renders: Dictionary
|
||||
var locationID: String
|
||||
var locationID: int
|
||||
var location: cLocation
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _init(id: String) -> void:
|
||||
func _init(id: int) -> void:
|
||||
camID = id
|
||||
cam = camGraph[camID]
|
||||
|
||||
print("Setting up camera " + camID)
|
||||
if not camGraph.has(str(camID)):
|
||||
camID = 0
|
||||
|
||||
cam = camGraph[str(camID)]
|
||||
|
||||
name = cam.get("name")
|
||||
disabled = cam.get("disabled")
|
||||
rendersChart = cam.get("renders")
|
||||
locationID = str( int( cam.get("location") ) )
|
||||
location = cLocation.new(locationID)
|
||||
|
||||
print(name)
|
||||
print(disabled)
|
||||
print(rendersChart)
|
||||
print(location)
|
||||
locationID = int( cam.get("location") )
|
||||
location = Global.locationManager.getLocation(id)
|
||||
|
||||
_loadRenders()
|
||||
|
||||
|
||||
@@ -20,9 +20,8 @@ func main(args: Array, context: Node) -> void:
|
||||
context._print("Invalid camera ID or name: %s" % input_value)
|
||||
return
|
||||
|
||||
var cam_name = Global.cameraHelper.getName(cam_id)
|
||||
|
||||
var newCam = cCamera.new(str(cam_id))
|
||||
newCam._init(str(cam_id))
|
||||
var new_camera: cCamera = Global.game.cameras[cam_id]
|
||||
var cam_name = new_camera.name
|
||||
|
||||
context._print("Camera set to %s" % cam_name.capitalize())
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
class_name cLocation
|
||||
|
||||
var locationGraph = Global.locations
|
||||
|
||||
var locationGraph: Dictionary
|
||||
var location: Dictionary
|
||||
var locationID: String
|
||||
|
||||
var id: int
|
||||
var name: String
|
||||
var connections: Array
|
||||
|
||||
@@ -18,14 +17,12 @@ var yoshida = enemyTemplate.duplicate()
|
||||
var akers = enemyTemplate.duplicate()
|
||||
var flesher = enemyTemplate.duplicate()
|
||||
|
||||
func _init(id: String):
|
||||
# Set immediate values
|
||||
locationID = id
|
||||
print(locationGraph)
|
||||
print(id)
|
||||
location = locationGraph.get(id)
|
||||
func _init(locationID: int, graph: Dictionary):
|
||||
locationGraph = graph
|
||||
id = locationID
|
||||
|
||||
location = locationGraph.get(str(id))
|
||||
|
||||
# Set Fields
|
||||
name = location.get("name")
|
||||
connections = location.get("connections")
|
||||
|
||||
|
||||
75
Scripts/Gameplay/Location/cLocationManager.gd
Normal file
75
Scripts/Gameplay/Location/cLocationManager.gd
Normal file
@@ -0,0 +1,75 @@
|
||||
class_name cLocationManager
|
||||
extends Node
|
||||
|
||||
var locationsJSON: Dictionary
|
||||
var locations: Array
|
||||
|
||||
enum eCharacter {
|
||||
CONSTRUCT,
|
||||
YOSHIDA,
|
||||
AKERS,
|
||||
FLESHER
|
||||
}
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _init() -> void:
|
||||
print("Init location manager")
|
||||
locationsJSON = Global.loadJSON("res://Data/locations.json")
|
||||
|
||||
_cache()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _cache() -> void:
|
||||
var location: cLocation
|
||||
for l in locationsJSON:
|
||||
location = cLocation.new(int(l), locationsJSON)
|
||||
locations.append(location)
|
||||
|
||||
func setLocationByID(character: eCharacter, currentLocationID: int, newLocationID: int) -> void:
|
||||
|
||||
pass
|
||||
|
||||
func setLocationBy(character: eCharacter, currentLocation: cLocation, newLocation: cLocation) -> void:
|
||||
|
||||
pass
|
||||
|
||||
func getCharacterLocation(character: eCharacter) -> cLocation:
|
||||
|
||||
return null
|
||||
|
||||
func clearLocation(character: eCharacter) -> void:
|
||||
|
||||
pass
|
||||
|
||||
# Mainly for the flesher enemy
|
||||
# Will pick a random location, has the option to exclude locations which are not connected
|
||||
# If the office is picked, it will by default roll back to the hangar to prevent an unfair death
|
||||
func randomLocation(
|
||||
currentLocation: int = 0,
|
||||
teleport: bool = false,
|
||||
allowOffice: bool = false,
|
||||
) -> cLocation:
|
||||
if teleport:
|
||||
var location: cLocation = locations[currentLocation]
|
||||
var validLocations = location.connections
|
||||
|
||||
return validLocations.pick_random()
|
||||
else:
|
||||
var location: cLocation = locations.pick_random()
|
||||
if not allowOffice && location.id == 0: location = locations[1]
|
||||
return location
|
||||
|
||||
func canMove(currentLocation: int, newLocation: int) -> bool:
|
||||
var locationA: cLocation = locations[currentLocation]
|
||||
var locationB: cLocation = locations[newLocation]
|
||||
|
||||
if locationB.connections.has(locationA.id):
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
func getLocation(location: int) -> cLocation:
|
||||
return locations[location]
|
||||
1
Scripts/Gameplay/Location/cLocationManager.gd.uid
Normal file
1
Scripts/Gameplay/Location/cLocationManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b8wog1q54q3nj
|
||||
@@ -2,7 +2,6 @@ class_name cGame
|
||||
|
||||
var night: cNight
|
||||
var enemies: Dictionary = {}
|
||||
var locations: Dictionary = {}
|
||||
var cameras: Array = []
|
||||
|
||||
var nightStarted = false
|
||||
@@ -11,8 +10,7 @@ var nightCompleted = false
|
||||
func make_cameras():
|
||||
var camera
|
||||
for key in Global.cameras:
|
||||
print(key)
|
||||
camera = cCamera.new(key)
|
||||
camera = cCamera.new(int(key))
|
||||
cameras.append(camera)
|
||||
|
||||
|
||||
@@ -31,7 +29,6 @@ func make_enemies():
|
||||
func _setup():
|
||||
print("Setting up Game")
|
||||
night = cNight.new()
|
||||
locations = Global.locations
|
||||
|
||||
make_cameras()
|
||||
make_enemies()
|
||||
|
||||
@@ -4,16 +4,12 @@ var gameNight = 0
|
||||
var stars = 0
|
||||
|
||||
var cameras
|
||||
var locations
|
||||
var cameraHelper
|
||||
var game: cGame
|
||||
var locationManager: cLocationManager
|
||||
|
||||
func _ready() -> void:
|
||||
cameras = loadJSON("res://Data/cameras.json")
|
||||
locations = loadJSON("res://Data/locations.json")
|
||||
|
||||
cameraHelper = hCamera.new()
|
||||
cameraHelper.setup(cameras)
|
||||
locationManager = cLocationManager.new()
|
||||
|
||||
begin_game()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user