Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #THIS IS MY MULTIPLE SCRIPTS... I THINK THEY WORK BUT I DON'T KNOW HOW TO CONNECT THEM TO MY BUTTON
- #Entity.gd
- 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
- #PLAYER.gd (NOT IMPORTANT, JUST SHOWING I USE THE SAME STATS FOR PLAYERS AND NPCs
- extends Entity
- func _ready() -> void:
- Username = "Anon1990"
- Country = "Canada"
- IPAddress = "192.168.XXX.XXX"
- Money = 0
- Level = 1
- XP = 0
- Nexp = 100
- CloudSpace = 200
- Attack = 1
- Penetration = 1
- Defense = 1
- Survellience = 1
- Health = 100
- Damage = 2
- var Faction = "None"
- var JoinDate = "December 3rd, 2024"
- var is_data_loaded = false
- #NPCs.gd (THIS I WHERE THE NPC's .JSON FILE IS DEFINED)
- 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).result
- file.close()
- else:
- print("Failed to Load Enemies.json")
- func spawn_enemies():
- var enemy_scene = preload("res://Game/Scenes/Enemy.tscn")
- for enemy in enemy_data:
- var new_enemy = enemy_scene.initiate()
- new_enemy.initialiaze(enemy) #Initialize(enemy) is defined below
- add_child(new_enemy)
- #EnemyScript.gd (#THIS IS WHERE THE INITIALIZE() CODE COME FROM FOR THE ABOVE (COMMENTED) CODE)
- 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"])
- #FINALLY, AT THE BOTTOM OF THIS SCRIPT WHERE IT SAYS PRINT(SCANNING NPCs...) IS WHERE I WANT TO ATTACH ALL OF THIS CODE FOR FINDING AN ENEMY.
- extends MenuBar
- @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...")
- 1:
- pass
- 2:
- pass
- 3:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement