Initial commit
This commit is contained in:
51
Characters/CharacterBase.cs
Normal file
51
Characters/CharacterBase.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Godot;
|
||||
|
||||
public abstract partial class CharacterBase : CharacterBody2D
|
||||
{
|
||||
protected const string InputUp = "character_move_up";
|
||||
protected const string InputDown = "character_move_down";
|
||||
protected const string InputLeft = "character_move_left";
|
||||
protected const string InputRight = "character_move_right";
|
||||
protected const string PrimaryAction = "character_primary_action";
|
||||
|
||||
[ExportCategory("Movement")]
|
||||
[Export] public float Speed { get; set; }
|
||||
|
||||
[ExportCategory("Abilities")]
|
||||
[Export] public float PrimaryCooldown { get; set; }
|
||||
|
||||
public float FacingRotation
|
||||
=> (GetGlobalMousePosition() - GlobalPosition).Angle();
|
||||
protected bool IsPrimaryOnCooldown
|
||||
=> primaryCooldown > 0f;
|
||||
|
||||
float primaryCooldown;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
HandleInput(delta);
|
||||
MoveAndSlide();
|
||||
}
|
||||
|
||||
protected virtual void _UsePrimary()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HandleInput(double delta)
|
||||
{
|
||||
var direction = Input.GetVector(InputLeft, InputRight, InputUp, InputDown);
|
||||
|
||||
Velocity = direction * Speed;
|
||||
|
||||
if (Input.IsActionPressed(PrimaryAction) && !IsPrimaryOnCooldown)
|
||||
{
|
||||
_UsePrimary();
|
||||
primaryCooldown = PrimaryCooldown;
|
||||
}
|
||||
else if (IsPrimaryOnCooldown)
|
||||
{
|
||||
primaryCooldown -= (float)delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Characters/CharacterBase.cs.uid
Normal file
1
Characters/CharacterBase.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b02ykq5hq2x0e
|
||||
BIN
Characters/Knight/Body.png
Normal file
BIN
Characters/Knight/Body.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 157 B |
40
Characters/Knight/Body.png.import
Normal file
40
Characters/Knight/Body.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://4yg084mipkvx"
|
||||
path="res://.godot/imported/Body.png-9ac1bc650c921cb3e7a32b6cc11a85a8.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Characters/Knight/Body.png"
|
||||
dest_files=["res://.godot/imported/Body.png-9ac1bc650c921cb3e7a32b6cc11a85a8.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
27
Characters/Knight/Knight.cs
Normal file
27
Characters/Knight/Knight.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
public partial class Knight : CharacterBase
|
||||
{
|
||||
[Export] public PackedScene Weapon { get; set; } = default!;
|
||||
|
||||
public override string[] _GetConfigurationWarnings()
|
||||
{
|
||||
var strings = new List<string>();
|
||||
|
||||
if (!Weapon?.CanInstantiate() ?? true)
|
||||
{
|
||||
strings.Add("Weapon is not set or invalid scene.");
|
||||
}
|
||||
|
||||
return [.. strings];
|
||||
}
|
||||
|
||||
protected override void _UsePrimary()
|
||||
{
|
||||
var weapon = Weapon.Instantiate<MeleeBase>();
|
||||
|
||||
weapon.Spawn(this);
|
||||
AddChild(weapon);
|
||||
}
|
||||
}
|
||||
1
Characters/Knight/Knight.cs.uid
Normal file
1
Characters/Knight/Knight.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c3ydje1po7p2w
|
||||
21
Characters/Knight/Knight.tscn
Normal file
21
Characters/Knight/Knight.tscn
Normal file
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://csrkrerssl8wm"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c3ydje1po7p2w" path="res://Characters/Knight/Knight.cs" id="1_8l5bb"]
|
||||
[ext_resource type="PackedScene" uid="uid://bqiniro3w8jom" path="res://Abilities/Sword/Sword.tscn" id="2_0fgit"]
|
||||
[ext_resource type="Texture2D" uid="uid://4yg084mipkvx" path="res://Characters/Knight/Body.png" id="3_5avd5"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0fgit"]
|
||||
size = Vector2(16, 32)
|
||||
|
||||
[node name="Character" type="CharacterBody2D"]
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_8l5bb")
|
||||
Weapon = ExtResource("2_0fgit")
|
||||
Speed = 300.0
|
||||
PrimaryCooldown = 1.0
|
||||
|
||||
[node name="Body" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("3_5avd5")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_0fgit")
|
||||
BIN
Characters/Wizard/Body.png
Normal file
BIN
Characters/Wizard/Body.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 157 B |
40
Characters/Wizard/Body.png.import
Normal file
40
Characters/Wizard/Body.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://qi1cvcj41wxr"
|
||||
path="res://.godot/imported/Body.png-daff6fe764e3d2af10242c881fd809fa.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Characters/Wizard/Body.png"
|
||||
dest_files=["res://.godot/imported/Body.png-daff6fe764e3d2af10242c881fd809fa.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
27
Characters/Wizard/Wizard.cs
Normal file
27
Characters/Wizard/Wizard.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
public partial class Wizard : CharacterBase
|
||||
{
|
||||
[Export] public PackedScene Projectile { get; set; } = default!;
|
||||
|
||||
public override string[] _GetConfigurationWarnings()
|
||||
{
|
||||
var strings = new List<string>();
|
||||
|
||||
if (!Projectile?.CanInstantiate() ?? true)
|
||||
{
|
||||
strings.Add("Projectile is not set or invalid scene.");
|
||||
}
|
||||
|
||||
return [.. strings];
|
||||
}
|
||||
|
||||
protected override void _UsePrimary()
|
||||
{
|
||||
var projectile = Projectile.Instantiate<ProjectileBase>();
|
||||
|
||||
projectile.Spawn(this);
|
||||
GetTree().CurrentScene.AddChild(projectile);
|
||||
}
|
||||
}
|
||||
1
Characters/Wizard/Wizard.cs.uid
Normal file
1
Characters/Wizard/Wizard.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cx2flf2i3h0rv
|
||||
21
Characters/Wizard/Wizard.tscn
Normal file
21
Characters/Wizard/Wizard.tscn
Normal file
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://xcfscklhvnew"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://qi1cvcj41wxr" path="res://Characters/Wizard/Body.png" id="1_pptet"]
|
||||
[ext_resource type="Script" uid="uid://cx2flf2i3h0rv" path="res://Characters/Wizard/Wizard.cs" id="1_vgyld"]
|
||||
[ext_resource type="PackedScene" uid="uid://b2u2xirxjo68h" path="res://Abilities/Fireballv3.tscn" id="2_n5kae"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_n5kae"]
|
||||
size = Vector2(16, 32)
|
||||
|
||||
[node name="Character" type="CharacterBody2D"]
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_vgyld")
|
||||
Projectile = ExtResource("2_n5kae")
|
||||
Speed = 300.0
|
||||
PrimaryCooldown = 0.5
|
||||
|
||||
[node name="Body" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_pptet")
|
||||
|
||||
[node name="CollisionBox" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_n5kae")
|
||||
Reference in New Issue
Block a user