Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
amazliah committed Dec 7, 2023
1 parent 7883a77 commit 6336a90
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 50 deletions.
7 changes: 2 additions & 5 deletions prefabs/agents/agent_with_player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://dxygh0jwqfawt"]
[gd_scene load_steps=15 format=3 uid="uid://dxygh0jwqfawt"]

[ext_resource type="PhysicsMaterial" uid="uid://nfder5jo4p27" path="res://agent_physics_material.tres" id="1_niukr"]
[ext_resource type="Script" path="res://scripts/agent.gd" id="2_llj7m"]
Expand All @@ -10,7 +10,6 @@
[ext_resource type="Script" path="res://scripts/agents/agent_equipment.gd" id="8_3sxbl"]
[ext_resource type="Texture2D" uid="uid://bw5o7xbm5rwjg" path="res://art/projection-line.png" id="8_ela1w"]
[ext_resource type="Resource" uid="uid://uc34v13np0qq" path="res://resources/items/ice-staff.tres" id="9_cyirb"]
[ext_resource type="Script" path="res://scripts/agents/movement_prediction_line.gd" id="9_ex5n1"]

[sub_resource type="CylinderShape3D" id="CylinderShape3D_n4g5e"]
height = 10.0
Expand Down Expand Up @@ -113,11 +112,9 @@ agent_movement_projection = NodePath("MovementPredictionLine")

[node name="MovementPredictionLine" type="Line2D" parent="PlayerAgentController"]
material = SubResource("ShaderMaterial_vwksg")
width = 100.0
texture = ExtResource("8_ela1w")
texture_mode = 1
script = ExtResource("9_ex5n1")
max_points_to_predict = 30000
precision = 50

[node name="AgentEquipment" type="Node" parent="." node_paths=PackedStringArray("_head_place_holder", "_right_hand_place_holder", "_left_hand_place_holder", "_legs_place_holder")]
script = ExtResource("8_3sxbl")
Expand Down
28 changes: 26 additions & 2 deletions scenes/game_scene_base.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,37 @@
[ext_resource type="PhysicsMaterial" uid="uid://hlsflh436ngb" path="res://arena_wall_physics_material.tres" id="5_dlqts"]
[ext_resource type="PackedScene" uid="uid://02lpxvdyrnb6" path="res://prefabs/agents/agent_with_ai.tscn" id="6_du88s"]
[ext_resource type="Theme" uid="uid://dx4axq65l727t" path="res://theme.tres" id="6_mnvth"]
[ext_resource type="Script" path="res://scripts/agents/movement_prediction_line.gd" id="6_srus8"]
[ext_resource type="PackedScene" uid="uid://dxygh0jwqfawt" path="res://prefabs/agents/agent_with_player.tscn" id="7_ajaon"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_4sn0y"]
shader = ExtResource("4_e7c2u")
shader_parameter/scrolling_speed = 2.0

[sub_resource type="GDScript" id="GDScript_88pyj"]
script/source = "extends Line2D

class_name AgentMovementProjection

@export var max_points_to_predict = 300
@export_range(1, 100) var precision = 1
@export var gravity = 0

func update_trajectory(direction: Vector2, speed: float, delta: float):
clear_points()
delta /= precision
var position : Vector2 = Vector2.ZERO
$CollisionCheck.position = position
var velocity = direction * speed
for i in max_points_to_predict:
add_point(position)
velocity.y += gravity * delta
position += velocity * delta
var collision = $CollisionCheck.move_and_collide(velocity * delta, true, true, true)
if collision:
return
$CollisionCheck.position = position
"

[sub_resource type="PlaneMesh" id="PlaneMesh_og77g"]
size = Vector2(100, 200)

Expand Down Expand Up @@ -147,7 +171,7 @@ grow_vertical = 0
material = SubResource("ShaderMaterial_4sn0y")
texture = ExtResource("5_3srou")
texture_mode = 1
script = ExtResource("6_srus8")
script = SubResource("GDScript_88pyj")
max_points_to_predict = 30000
precision = 50

Expand Down
32 changes: 32 additions & 0 deletions scenes/main_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ grow_vertical = 2
flat = true

[node name="ItemsTab" type="Control" parent="UI/TabContainer"]
visible = false
layout_mode = 2
mouse_filter = 2
script = ExtResource("9_hdxf0")
Expand Down Expand Up @@ -1121,6 +1122,7 @@ alignment = 1
[node name="HeadSlot" type="Panel" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/MyItemsContainer"]
custom_minimum_size = Vector2(150, 220)
layout_mode = 2
mouse_filter = 1
theme = ExtResource("2_bv25m")
theme_override_styles/panel = SubResource("StyleBoxFlat_di1xv")

Expand All @@ -1145,6 +1147,7 @@ stretch_mode = 5
[node name="RightHandSlot" type="Panel" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/MyItemsContainer"]
custom_minimum_size = Vector2(150, 220)
layout_mode = 2
mouse_filter = 1
theme = ExtResource("2_bv25m")
theme_override_styles/panel = SubResource("StyleBoxFlat_di1xv")

Expand All @@ -1169,6 +1172,7 @@ stretch_mode = 5
[node name="LeftHandSlot" type="Panel" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/MyItemsContainer"]
custom_minimum_size = Vector2(150, 220)
layout_mode = 2
mouse_filter = 1
theme = ExtResource("2_bv25m")
theme_override_styles/panel = SubResource("StyleBoxFlat_di1xv")

Expand All @@ -1193,6 +1197,7 @@ stretch_mode = 5
[node name="BootsSlot" type="Panel" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/MyItemsContainer"]
custom_minimum_size = Vector2(150, 220)
layout_mode = 2
mouse_filter = 1
theme = ExtResource("2_bv25m")
theme_override_styles/panel = SubResource("StyleBoxFlat_di1xv")

Expand Down Expand Up @@ -1226,6 +1231,33 @@ layout_mode = 2
mouse_filter = 2
columns = 4

[node name="ItemView" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView2" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView3" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView4" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView5" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView6" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView7" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView8" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemView9" parent="UI/TabContainer/ItemsTab/ScrollContainer/MarginContainer/ItemsContainer/OwnedItemsGridContainer" instance=ExtResource("15_e5ni1")]
layout_mode = 2

[node name="ItemDetailsPopup" type="Control" parent="UI/TabContainer/ItemsTab"]
visible = false
anchors_preset = 0
Expand Down
2 changes: 1 addition & 1 deletion scripts/agent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func _ready():
current_health = max_health
current_damage = starting_damage

func _physics_process(delta):
func _physics_process(_delta):
if linear_velocity.length_squared() > 0.01:
moving = true
elif linear_velocity.length_squared() < 0.01:
Expand Down
22 changes: 0 additions & 22 deletions scripts/agents/movement_prediction_line.gd

This file was deleted.

16 changes: 8 additions & 8 deletions scripts/agents/player_agent_controller.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends Node3D

@export var distance_from_touch_location_to_count_play : float = 60
@export var agent_movement_projection: AgentMovementProjection
@export var agent_movement_projection: Line2D
@export var max_points_to_predict: int = 300

@onready var agent: MyAgent = self.get_parent()
Expand Down Expand Up @@ -45,17 +45,17 @@ func _input(event):
else:
should_draw_projection = false

func calculate_movement(direction: Vector3, delta: float) -> PackedVector2Array:
func calculate_movement(_direction: Vector3, delta: float) -> PackedVector2Array:
var points = PackedVector2Array()
var space_state = get_world_3d().direct_space_state
var position : Vector3 = global_position
var velocity = direction * agent.current_velocity
var current_position : Vector3 = global_position
var velocity = _direction * agent.current_velocity
var last_position: Vector3
for i in max_points_to_predict:
last_position = position
points.append(camera.unproject_position(position))
position += velocity * delta
var query = PhysicsRayQueryParameters3D.create(last_position, position)
last_position = current_position
points.append(camera.unproject_position(current_position))
current_position += velocity * delta
var query = PhysicsRayQueryParameters3D.create(last_position, current_position)
query.collide_with_areas = true
var result = space_state.intersect_ray(query)
if result:
Expand Down
4 changes: 2 additions & 2 deletions scripts/items/effects/status_effect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class_name StatusEffect

func execute(agent: Agent):
var targets = _get_targets(target, agent)
for target in targets:
target.status = status
for current_target: MyAgent in targets:
current_target.status = status

func _get_targets(who_to_find: Target, agent: Agent) -> Array:
match who_to_find:
Expand Down
10 changes: 5 additions & 5 deletions scripts/items/items_catalog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class CatalogItem:
var description: String
var type: CatalogItemType

func _init(playfab_id: String, name: String, description: String, type: CatalogItemType):
self.playfab_id = playfab_id
self.name = name
self.description = description
self.type = type
func _init(_playfab_id: String, _name: String, _description: String, _type: CatalogItemType):
playfab_id = _playfab_id
name = _name
description = _description
type = _type

enum CatalogItemType {
currency
Expand Down
9 changes: 4 additions & 5 deletions scripts/player/player_equipment.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ var amount_to_upgrade: int :
get:
return EquipmentData.amount_per_level.get(level + 1)

func _init(equipment: Equipment, level: int, amount: int):
self.equipment = equipment
self.level = level
self.amount = amount
func _init(_equipment: Equipment, _level: int, _amount: int):
self.equipment = _equipment
self.level = _level
self.amount = _amount

func can_upgrade() -> bool:
var amount_to_upgrade = EquipmentData.amount_per_level.get(level + 1)
return amount >= amount_to_upgrade

0 comments on commit 6336a90

Please sign in to comment.