adding in some example pegs and their actions. organizing folders, still working on pathing for some reason it won't move sometimes, and causes the looping to break
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Shortbow : PegAction
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_priority = 1000;
|
||||
_healthChange = -1;
|
||||
_cost = 2;
|
||||
_range = 1;
|
||||
_usesMax = 1;
|
||||
_usesRemaining = _usesMax;
|
||||
}
|
||||
public override Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
Vector2 target = PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
|
||||
Tween subtween = CreateTween();
|
||||
subtween.TweenProperty(_image, "visible", true, 0.0f);
|
||||
subtween.TweenProperty(_image, "global_position", target, 0.5f);
|
||||
subtween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
PEG._pegController._playerController.ChangeHealth(_healthChange, this);
|
||||
Position = Vector2.Zero;
|
||||
Visible = false;
|
||||
}));
|
||||
return subtween;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dt7qbvowj1sm4
|
||||
@@ -0,0 +1,31 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Shortsword : PegAction
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_priority = 1000;
|
||||
_healthChange = -2;
|
||||
_cost = 2;
|
||||
_range = 0;
|
||||
_usesMax = 1;
|
||||
_usesRemaining = _usesMax;
|
||||
}
|
||||
public override Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
Vector2 target = PEG.GlobalPosition + (Vector2.Up * 50);
|
||||
Tween subtween = CreateTween();
|
||||
subtween.TweenProperty(_image, "visible", true, 0.0f);
|
||||
subtween.TweenProperty(_image, "global_position", target, 0.5f);
|
||||
subtween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
PEG._pegController._playerController.ChangeHealth(_healthChange, this);
|
||||
_image.Position = Vector2.Zero;
|
||||
_image.Visible = false;
|
||||
}));
|
||||
return subtween;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://td6dv1t4y5os
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene format=3 uid="uid://duspilwelsiy3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dt7qbvowj1sm4" path="res://Pegs/Actions/Shortbow.cs" id="1_yhiab"]
|
||||
|
||||
[node name="Shortbow" type="Node2D" unique_id=518048625]
|
||||
script = ExtResource("1_yhiab")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="." unique_id=944294157]
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_scene format=3 uid="uid://c6df6ib0qan5g"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://td6dv1t4y5os" path="res://Pegs/Actions/Shortsword.cs" id="1_rflgk"]
|
||||
[ext_resource type="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="2_fs74r"]
|
||||
|
||||
[node name="Shortsword" type="Node2D" unique_id=518048625]
|
||||
script = ExtResource("1_rflgk")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="." unique_id=906537972]
|
||||
visible = false
|
||||
scale = Vector2(0.1, 0.1)
|
||||
texture = ExtResource("2_fs74r")
|
||||
@@ -0,0 +1,15 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public partial class HostilePeg : Peg
|
||||
{
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dfba4vq6jv0a6
|
||||
@@ -0,0 +1,12 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Archer : HostilePeg
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_stamina = 2;
|
||||
_action = GetNode<Shortbow>("Shortbow");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b3a0x3r3yx861
|
||||
@@ -0,0 +1,12 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Infantry : HostilePeg
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_stamina = 3;
|
||||
_action = GetNode<Shortsword>("Shortsword");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://xlg4cblo1vf1
|
||||
@@ -0,0 +1,38 @@
|
||||
[gd_scene format=3 uid="uid://dwqhme11j5ihb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b3a0x3r3yx861" path="res://Pegs/HostilePegs/Archer.cs" id="1_ij48w"]
|
||||
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_j7but"]
|
||||
[ext_resource type="PackedScene" uid="uid://duspilwelsiy3" path="res://Pegs/Actions/shortbow.tscn" id="3_c81uf"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
|
||||
bounce = 0.5
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
||||
radius = 12.5
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_6w6fg"]
|
||||
radius = 12.5
|
||||
|
||||
[node name="Archer" type="StaticBody2D" unique_id=1417697759]
|
||||
input_pickable = true
|
||||
physics_material_override = SubResource("PhysicsMaterial_7k104")
|
||||
script = ExtResource("1_ij48w")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1762191899]
|
||||
shape = SubResource("CircleShape2D_4gyqm")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1941012605]
|
||||
self_modulate = Color(0, 0, 1, 1)
|
||||
texture_filter = 1
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("2_j7but")
|
||||
|
||||
[node name="Shortbow" parent="." unique_id=518048625 instance=ExtResource("3_c81uf")]
|
||||
|
||||
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=2142666816]
|
||||
shape = SubResource("CircleShape2D_6w6fg")
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
||||
@@ -0,0 +1,38 @@
|
||||
[gd_scene format=3 uid="uid://d55ut168gh3k"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://xlg4cblo1vf1" path="res://Pegs/HostilePegs/Infantry.cs" id="1_wlksp"]
|
||||
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_b77ka"]
|
||||
[ext_resource type="PackedScene" uid="uid://c6df6ib0qan5g" path="res://Pegs/Actions/shortsword.tscn" id="3_lwlv5"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
|
||||
bounce = 0.5
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
||||
radius = 12.5
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_6w6fg"]
|
||||
radius = 12.5
|
||||
|
||||
[node name="Infantry" type="StaticBody2D" unique_id=1417697759]
|
||||
input_pickable = true
|
||||
physics_material_override = SubResource("PhysicsMaterial_7k104")
|
||||
script = ExtResource("1_wlksp")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1762191899]
|
||||
shape = SubResource("CircleShape2D_4gyqm")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1941012605]
|
||||
self_modulate = Color(1, 0, 0, 1)
|
||||
texture_filter = 1
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("2_b77ka")
|
||||
|
||||
[node name="Shortsword" parent="." unique_id=518048625 instance=ExtResource("3_lwlv5")]
|
||||
|
||||
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=2142666816]
|
||||
shape = SubResource("CircleShape2D_6w6fg")
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
||||
@@ -0,0 +1,19 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PegAction : Node2D
|
||||
{
|
||||
public int _priority, _healthChange, _cost, _range, _usesMax, _usesRemaining, _triggers = 0;
|
||||
public Sprite2D _image;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_image = GetNode<Sprite2D>("Image");
|
||||
}
|
||||
|
||||
public virtual Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dpa15pxib2qyr
|
||||
@@ -0,0 +1,37 @@
|
||||
[gd_scene format=3 uid="uid://43ty0uit6ylb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://Pegs/HostilePeg.cs" id="1_nc8fp"]
|
||||
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_0icqg"]
|
||||
[ext_resource type="PackedScene" uid="uid://bj2qrn0l01us1" path="res://Pegs/peg_action.tscn" id="3_nc8fp"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
|
||||
bounce = 0.5
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_4gyqm"]
|
||||
radius = 12.5
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_6w6fg"]
|
||||
radius = 12.5
|
||||
|
||||
[node name="HostilePeg" type="StaticBody2D" unique_id=1417697759]
|
||||
input_pickable = true
|
||||
physics_material_override = SubResource("PhysicsMaterial_7k104")
|
||||
script = ExtResource("1_nc8fp")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1762191899]
|
||||
shape = SubResource("CircleShape2D_4gyqm")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1941012605]
|
||||
texture_filter = 1
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("2_0icqg")
|
||||
|
||||
[node name="PegAction" parent="." unique_id=637569115 instance=ExtResource("3_nc8fp")]
|
||||
|
||||
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=2142666816]
|
||||
shape = SubResource("CircleShape2D_6w6fg")
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene format=3 uid="uid://bj2qrn0l01us1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dpa15pxib2qyr" path="res://Pegs/PegAction.cs" id="1_8o8tf"]
|
||||
|
||||
[node name="PegAction" type="Node2D" unique_id=460007250]
|
||||
script = ExtResource("1_8o8tf")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="." unique_id=1133735272]
|
||||
Reference in New Issue
Block a user