Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Hi Alice, this is my Code, I hope you can help: ##
- ## Entity.gd ## ALL NPCs AND PLAYERS SHARE THIS TEMPLATE ##
- extends Node
- class_name Entity
- var Username: String
- var Country: String
- var IPAddress: String
- var Money: int
- var Level: int
- var XP: int
- var Nexp: int
- var CloudSpace: int
- var Attack: int
- var Penetration: int
- var Defense: int
- var Survellience: int
- var Health: int
- var Damage: int
- ## NPCs.gd ## ALL NPC DATA IS BEING SETUP ##
- extends Entity
- var enemy_data = []
- func _ready() -> void:
- load_enemy_data()
- spawn_enemies()
- func load_enemy_data():
- var file = FileAccess.open("res://Game/Data/Enemies.json", FileAccess.READ)
- if file:
- var json_data = file.get_as_text()
- enemy_data = JSON.parse_string(json_data)
- file.close()
- else:
- print("Failed to Load Enemies.json")
- func spawn_enemies(enemy_data_array : Array):
- var enemy_scene = preload("res://Game/Scenes/EnemyScript.gd")
- for enemy_data in enemy_data_array:
- var enemy_instance = enemy_scene.instance()
- add_child(enemy_instance)
- enemy_instance.initialize(enemy_data)
- ## Enemies.json ## THIS IS A JSON FILE WITH 2 ENEMIES AND THEIR STATS ##
- [
- {
- "Username" : "Anon22310001",
- "Country" : "United States",
- "IPAddress" : "192.168.XXX.XXX",
- "Money" : 495,
- "Level" : 1,
- "XP" : 0,
- "Nexp" : 100,
- "CloudSpace" : 200,
- "Attack" : 9,
- "Penetration" : 4,
- "Defense" : 9,
- "Survellience" : 1,
- "Health" : 225,
- "Damage" : 8
- },
- {
- "Username" : "Anon22002193",
- "Country" : "United Kingdom",
- "IPAddress" : "192.168.XXX.XXX",
- "Money" : 750,
- "Level" : 2,
- "XP" : 0,
- "Nexp" : 100,
- "CloudSpace" : 200,
- "Attack" : 11,
- "Penetration" : 5,
- "Defense" : 11,
- "Survellience" : 2,
- "Health" : 270,
- "Damage" : 11
- }
- ]
- ## EnemyScript.gd ## THIS CODE IS SUPPOSED TO TAKE ALL OF THE JSON INFORMATION AND TURN IT BACK INTO VARIABLES
- extends Entity
- func initialize(enemy_data):
- Username = enemy_data["Username"]
- Country = enemy_data["Country"]
- IPAddress = enemy_data["IPAddress"]
- Money = enemy_data["Money"]
- Level = enemy_data["Level"]
- XP = enemy_data["XP"]
- Nexp = enemy_data["Nexp"]
- CloudSpace = enemy_data["CloudSpace"]
- Attack = enemy_data["Attack"]
- Penetration = enemy_data["Penetration"]
- Defense = enemy_data["Defense"]
- Survellience = enemy_data["Survellience"]
- Health = enemy_data["Health"]
- Damage = enemy_data["Damage"]
- print("Enemy Username : " + enemy_data["Username"])
- ## AND THIS IS WHERE I AM TRYING TO CALL THE SCRIPT BUT I DON'T THINK IT RELEVENT: ##
- extends MenuBar
- const NPCs = preload("res://Scripts/Entities/NPCs.gd")
- @export var Menu: PopupMenu
- @export var Hack: PopupMenu
- #ABOVE NOT NECCESSARY
- @onready var menu_bar: MenuBar = %MenuBar
- @onready var menu: PopupMenu = %Menu
- @onready var hack: PopupMenu = %Hack
- func _ready() -> void:
- pass
- func _on_menu_index_pressed(index: int) -> void:
- match index:
- 0:
- print(Menu.get_item_text(index))
- get_tree().change_scene_to_packed(load("res://Game/Scenes/GameProfileScreen.tscn"))
- 1:
- print(Menu.get_item_text(index))
- 2:
- print(Menu.get_item_text(index))
- 3:
- print(Menu.get_item_text(index))
- 4:
- pass
- 5:
- print(Menu.get_item_text(index))
- SaveFile.saveGame()
- get_tree().change_scene_to_packed(load("res://Game/Scenes/TiitleScreen.tscn"))
- 6:
- print(Menu.get_item_text(index))
- Player.Money += 125
- func _on_hack_index_pressed(index: int) -> void:
- match index:
- 0:
- print("Scanning IPs...")
- var npc_manager = NPCs.new()
- npc_manager.load_enemy_data()
- npc_manager.spawn_enemies()
- 1:
- pass
- 2:
- pass
- 3:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement