player variables uses getter and setter instead of function
This commit is contained in:
19
src/player_variables.cs
Normal file
19
src/player_variables.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public partial class player_variables : Node
|
||||
{
|
||||
private static string _playername = "Yannik";
|
||||
public static string PlayerName
|
||||
{
|
||||
get { return _playername; }
|
||||
set
|
||||
{
|
||||
_playername = Regex.Replace(value, @"\[[^]]+\]", "");
|
||||
_playername = Regex.Replace(_playername, @"<[^>]*>", "");
|
||||
if (PlayerName.Length > 12)
|
||||
_playername = PlayerName.Substring(0, 12);
|
||||
}
|
||||
}
|
||||
}
|
@@ -103,7 +103,6 @@ public partial class console : PopupPanel
|
||||
public void playername(string name)
|
||||
{
|
||||
player_variables.PlayerName = name;
|
||||
player_variables.ClearPlayerName();
|
||||
textblock.AddText("Your new name is now: " + player_variables.PlayerName + "\n");
|
||||
}
|
||||
public void reload() => GetTree().ReloadCurrentScene();
|
||||
|
@@ -57,4 +57,15 @@ public partial class player : CharacterBody2D
|
||||
animatedSprite.SpeedScale = Math.Abs(movement.Y * speed * 1.3f);
|
||||
}
|
||||
}
|
||||
public void OnAnimationChanged()
|
||||
{
|
||||
if (animatedSprite.Animation == "move_side")
|
||||
{
|
||||
//GetNode<CollisionShape2D>("collision_shape").Shape
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user