Fixed up a couple things, first steps towards a location manager
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
class_name npcConstruct
|
class_name npcConstruct
|
||||||
extends cCharacter
|
extends cCharacter
|
||||||
|
|
||||||
var defaultRoom = 0
|
|
||||||
|
|
||||||
signal location_changed(ai, old_location, new_location)
|
signal location_changed(ai, old_location, new_location)
|
||||||
signal state_changed(ai, old_state, new_state)
|
signal state_changed(ai, old_state, new_state)
|
||||||
|
|
||||||
var state: int = 0
|
var state: int = 0
|
||||||
|
|
||||||
func advance_state() -> void:
|
func advance_state() -> void:
|
||||||
if state >= MAX_STATE:
|
if state >= MAX_STATE:
|
||||||
if reset_after_climax:
|
if reset_after_climax:
|
||||||
@@ -14,11 +13,10 @@ func advance_state() -> void:
|
|||||||
else:
|
else:
|
||||||
state += 1
|
state += 1
|
||||||
|
|
||||||
func _ready():
|
func _init():
|
||||||
super._ready()
|
super._init()
|
||||||
print("Construct Ready")
|
print("Construct Ready")
|
||||||
|
|
||||||
|
|
||||||
Global.game.night.hour_changed.connect(_on_hour_changed)
|
Global.game.night.hour_changed.connect(_on_hour_changed)
|
||||||
|
|
||||||
func _on_hour_changed(hour: int):
|
func _on_hour_changed(hour: int):
|
||||||
@@ -29,6 +27,8 @@ func _on_hour_changed(hour: int):
|
|||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
super._process(delta)
|
super._process(delta)
|
||||||
|
print("Construct: Processing")
|
||||||
|
print(state)
|
||||||
|
|
||||||
match state:
|
match state:
|
||||||
0: pass # dormant
|
0: pass # dormant
|
||||||
@@ -38,6 +38,7 @@ func _process(delta: float) -> void:
|
|||||||
4: pass
|
4: pass
|
||||||
5: pass
|
5: pass
|
||||||
6: pass
|
6: pass
|
||||||
|
|
||||||
advance_state()
|
advance_state()
|
||||||
if (randi_range(1, 20) > 10):
|
if (randi_range(1, 20) > 10):
|
||||||
stunted = true
|
stunted = true
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
class_name cCharacter
|
class_name cCharacter
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
# --- Parameters ---
|
# --- Parameters ---
|
||||||
@export_range(0, 20) var ai_level := 10
|
@export_range(0, 20) var ai_level := 10
|
||||||
|
|
||||||
@@ -9,6 +8,8 @@ extends Node
|
|||||||
@export var reset_after_climax := true
|
@export var reset_after_climax := true
|
||||||
@export var character_name := "template"
|
@export var character_name := "template"
|
||||||
|
|
||||||
|
var default_room: cCamera = Global.game.cameras[0]
|
||||||
|
|
||||||
# --- Constants ---
|
# --- Constants ---
|
||||||
const MAX_STATE := 6
|
const MAX_STATE := 6
|
||||||
const DEBUG := true
|
const DEBUG := true
|
||||||
@@ -25,10 +26,7 @@ func move_to(room_id: int):
|
|||||||
current_room = room_id
|
current_room = room_id
|
||||||
Global.rooms[current_room].add_enemy(self)
|
Global.rooms[current_room].add_enemy(self)
|
||||||
|
|
||||||
func _init():
|
func _init() -> void:
|
||||||
_ready()
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
randomize()
|
randomize()
|
||||||
_set_next_interval()
|
_set_next_interval()
|
||||||
|
|
||||||
@@ -54,6 +52,7 @@ func try_move(delta: float) -> bool:
|
|||||||
return roll <= ai_level
|
return roll <= ai_level
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
print("Test Character Script")
|
||||||
if try_move(delta):
|
if try_move(delta):
|
||||||
if(stunted):
|
if(stunted):
|
||||||
stunted = false
|
stunted = false
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class_name cCamera
|
class_name cCamera
|
||||||
|
|
||||||
var cam: Dictionary
|
var cam: Dictionary
|
||||||
var camID: String
|
var camID: int
|
||||||
|
|
||||||
var camGraph = Global.loadJSON("res://Data/cameras.json")
|
var camGraph = Global.loadJSON("res://Data/cameras.json")
|
||||||
|
|
||||||
@@ -9,25 +9,23 @@ var name: String
|
|||||||
var disabled: bool
|
var disabled: bool
|
||||||
var rendersChart: Dictionary
|
var rendersChart: Dictionary
|
||||||
var renders: Dictionary
|
var renders: Dictionary
|
||||||
var locationID: String
|
var locationID: int
|
||||||
var location: cLocation
|
var location: cLocation
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _init(id: String) -> void:
|
func _init(id: int) -> void:
|
||||||
camID = id
|
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")
|
name = cam.get("name")
|
||||||
disabled = cam.get("disabled")
|
disabled = cam.get("disabled")
|
||||||
rendersChart = cam.get("renders")
|
rendersChart = cam.get("renders")
|
||||||
locationID = str( int( cam.get("location") ) )
|
locationID = int( cam.get("location") )
|
||||||
location = cLocation.new(locationID)
|
location = Global.locationManager.getLocation(id)
|
||||||
|
|
||||||
print(name)
|
|
||||||
print(disabled)
|
|
||||||
print(rendersChart)
|
|
||||||
print(location)
|
|
||||||
|
|
||||||
_loadRenders()
|
_loadRenders()
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,8 @@ func main(args: Array, context: Node) -> void:
|
|||||||
context._print("Invalid camera ID or name: %s" % input_value)
|
context._print("Invalid camera ID or name: %s" % input_value)
|
||||||
return
|
return
|
||||||
|
|
||||||
var cam_name = Global.cameraHelper.getName(cam_id)
|
var new_camera: cCamera = Global.game.cameras[cam_id]
|
||||||
|
var cam_name = new_camera.name
|
||||||
var newCam = cCamera.new(str(cam_id))
|
|
||||||
newCam._init(str(cam_id))
|
|
||||||
|
|
||||||
context._print("Camera set to %s" % cam_name.capitalize())
|
context._print("Camera set to %s" % cam_name.capitalize())
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
class_name cLocation
|
class_name cLocation
|
||||||
|
|
||||||
var locationGraph = Global.locations
|
var locationGraph: Dictionary
|
||||||
|
|
||||||
var location: Dictionary
|
var location: Dictionary
|
||||||
var locationID: String
|
|
||||||
|
|
||||||
|
var id: int
|
||||||
var name: String
|
var name: String
|
||||||
var connections: Array
|
var connections: Array
|
||||||
|
|
||||||
@@ -18,14 +17,12 @@ var yoshida = enemyTemplate.duplicate()
|
|||||||
var akers = enemyTemplate.duplicate()
|
var akers = enemyTemplate.duplicate()
|
||||||
var flesher = enemyTemplate.duplicate()
|
var flesher = enemyTemplate.duplicate()
|
||||||
|
|
||||||
func _init(id: String):
|
func _init(locationID: int, graph: Dictionary):
|
||||||
# Set immediate values
|
locationGraph = graph
|
||||||
locationID = id
|
id = locationID
|
||||||
print(locationGraph)
|
|
||||||
print(id)
|
location = locationGraph.get(str(id))
|
||||||
location = locationGraph.get(id)
|
|
||||||
|
|
||||||
# Set Fields
|
|
||||||
name = location.get("name")
|
name = location.get("name")
|
||||||
connections = location.get("connections")
|
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 night: cNight
|
||||||
var enemies: Dictionary = {}
|
var enemies: Dictionary = {}
|
||||||
var locations: Dictionary = {}
|
|
||||||
var cameras: Array = []
|
var cameras: Array = []
|
||||||
|
|
||||||
var nightStarted = false
|
var nightStarted = false
|
||||||
@@ -11,8 +10,7 @@ var nightCompleted = false
|
|||||||
func make_cameras():
|
func make_cameras():
|
||||||
var camera
|
var camera
|
||||||
for key in Global.cameras:
|
for key in Global.cameras:
|
||||||
print(key)
|
camera = cCamera.new(int(key))
|
||||||
camera = cCamera.new(key)
|
|
||||||
cameras.append(camera)
|
cameras.append(camera)
|
||||||
|
|
||||||
|
|
||||||
@@ -31,7 +29,6 @@ func make_enemies():
|
|||||||
func _setup():
|
func _setup():
|
||||||
print("Setting up Game")
|
print("Setting up Game")
|
||||||
night = cNight.new()
|
night = cNight.new()
|
||||||
locations = Global.locations
|
|
||||||
|
|
||||||
make_cameras()
|
make_cameras()
|
||||||
make_enemies()
|
make_enemies()
|
||||||
|
|||||||
@@ -4,16 +4,12 @@ var gameNight = 0
|
|||||||
var stars = 0
|
var stars = 0
|
||||||
|
|
||||||
var cameras
|
var cameras
|
||||||
var locations
|
|
||||||
var cameraHelper
|
|
||||||
var game: cGame
|
var game: cGame
|
||||||
|
var locationManager: cLocationManager
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
cameras = loadJSON("res://Data/cameras.json")
|
cameras = loadJSON("res://Data/cameras.json")
|
||||||
locations = loadJSON("res://Data/locations.json")
|
locationManager = cLocationManager.new()
|
||||||
|
|
||||||
cameraHelper = hCamera.new()
|
|
||||||
cameraHelper.setup(cameras)
|
|
||||||
|
|
||||||
begin_game()
|
begin_game()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user