refactor to latest godot api

item-info
John Montagu, the 4th Earl of Sandvich 2023-01-29 12:05:44 -08:00
parent 38bfae2aaa
commit f0797388d8
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
9 changed files with 182 additions and 183 deletions

View File

@ -18,6 +18,7 @@ generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1

View File

@ -83,7 +83,7 @@ namespace SupaLidlGame.Characters
StateMachine.Process(delta);
}
Sprite.FlipH = Target.x < 0;
Sprite.FlipH = Target.X < 0;
DrawTarget();
}
@ -136,16 +136,16 @@ namespace SupaLidlGame.Characters
protected void DrawTarget()
{
Vector2 target = Target;
float angle = Mathf.Atan2(target.y, Mathf.Abs(target.x));
float angle = Mathf.Atan2(target.Y, Mathf.Abs(target.X));
Vector2 scale = Inventory.Scale;
if (target.x < 0)
if (target.X < 0)
{
scale.y = -1;
scale.Y = -1;
angle = Mathf.Pi - angle;
}
else
{
scale.y = 1;
scale.Y = 1;
}
Inventory.Scale = scale;
Inventory.Rotation = angle;

View File

@ -120,8 +120,8 @@ namespace SupaLidlGame.Characters
Vector2 dir = Target.Normalized();
float dist = GlobalPosition.DistanceSquaredTo(pos);
var spaceState = GetWorld2d().DirectSpaceState;
var exclude = new Godot.Collections.Array<RID>();
var spaceState = GetWorld2D().DirectSpaceState;
var exclude = new Godot.Collections.Array<Godot.Rid>();
exclude.Add(this.GetRid());
for (int i = 0; i < 16; i++)
@ -243,7 +243,7 @@ namespace SupaLidlGame.Characters
public Vector2 GetBlocking()
{
var spaceState = GetWorld2d().DirectSpaceState;
var spaceState = GetWorld2D().DirectSpaceState;
int rayLength = 16;
float[] weights = new float[16];
Vector2[] rays = new Vector2[16];
@ -254,7 +254,7 @@ namespace SupaLidlGame.Characters
// the length determines its strength
// exclude itself from raycasts
var exclude = new Godot.Collections.Array<RID>();
var exclude = new Godot.Collections.Array<Godot.Rid>();
exclude.Add(GetRid());
var rayParams = new PhysicsRayQueryParameters2D

View File

@ -1,5 +1,4 @@
using Godot;
using System.Linq;
namespace SupaLidlGame.Extensions
{
@ -7,8 +6,8 @@ namespace SupaLidlGame.Extensions
{
public static Vector2 Midpoint(this Vector2 vector, Vector2 other)
{
return new Vector2((vector.x + other.x) / 2,
(vector.y + other.y) / 2);
return new Vector2((vector.X + other.X) / 2,
(vector.Y + other.Y) / 2);
}
public static Vector2 Midpoints(params Vector2[] vectors)
@ -19,8 +18,8 @@ namespace SupaLidlGame.Extensions
for (int i = 0; i < length; i++)
{
x += vectors[i].x;
y += vectors[i].y;
x += vectors[i].X;
y += vectors[i].Y;
}
return new Vector2(x / length, y / length);
@ -28,12 +27,12 @@ namespace SupaLidlGame.Extensions
public static Vector2 Counterclockwise90(this Vector2 vector)
{
return new Vector2(-vector.y, vector.x);
return new Vector2(-vector.Y, vector.X);
}
public static Vector2 Clockwise90(this Vector2 vector)
{
return new Vector2(vector.y, -vector.x);
return new Vector2(vector.Y, -vector.X);
}
}
}

View File

@ -26,7 +26,7 @@ namespace SupaLidlGame.Items.Weapons
public double AttackTime { get; set; } = 0;
[Export]
public CPUParticles2D ParryParticles { get; set; }
public CpuParticles2D ParryParticles { get; set; }
public override bool IsParryable { get; protected set; }
@ -98,7 +98,7 @@ namespace SupaLidlGame.Items.Weapons
Hitbox.IsDisabled = true;
ProcessHits();
Hitbox.ResetIgnoreList();
AnimationPlayer.PlaybackSpeed = 1;
AnimationPlayer.SpeedScale = 1;
}
public override void _Ready()
@ -146,7 +146,7 @@ namespace SupaLidlGame.Items.Weapons
{
// our character was parried
IsParried = true;
AnimationPlayer.PlaybackSpeed = 0.25f;
AnimationPlayer.SpeedScale = 0.25f;
Character.Stun(1.5f);
GetNode<AudioStreamPlayer2D>("ParrySound").Play();
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.7">
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.16">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>

View File

@ -1,5 +1,4 @@
using Godot;
using System;
public partial class StaticMovement : CharacterBody2D
{
@ -15,22 +14,22 @@ public partial class StaticMovement : CharacterBody2D
// Add the gravity.
if (!IsOnFloor())
velocity.y += gravity * (float)delta;
velocity.Y += gravity * (float)delta;
// Handle Jump.
if (Input.IsActionJustPressed("ui_accept") && IsOnFloor())
velocity.y = JumpVelocity;
velocity.Y = JumpVelocity;
// Get the input direction and handle the movement/deceleration.
// As good practice, you should replace UI actions with custom gameplay actions.
Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down");
if (direction != Vector2.Zero)
{
velocity.x = direction.x * Speed;
velocity.X = direction.X * Speed;
}
else
{
velocity.x = Mathf.MoveToward(Velocity.x, 0, Speed);
velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
}
Velocity = velocity;

View File

@ -42,8 +42,8 @@ namespace SupaLidlGame.Utils
{
Vector2 ret = Vector2.Zero;
var rng = new RandomNumberGenerator();
ret.x = (rng.Randf() - 0.5f) * intensity;
ret.y = (rng.Randf() - 0.5f) * intensity;
ret.X = (rng.Randf() - 0.5f) * intensity;
ret.Y = (rng.Randf() - 0.5f) * intensity;
return ret;
}
}

View File

@ -23,32 +23,32 @@ project/assembly_name="SupaLidlGame"
ui_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
]
}
roll={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"pressed":false,"double_click":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
attack1={
@ -58,7 +58,7 @@ attack1={
}
equip={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}