mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:25:35 +00:00
58 lines
No EOL
1.3 KiB
C#
58 lines
No EOL
1.3 KiB
C#
using System;
|
|
using Cirno.Scripts.Enums;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Actors._3D;
|
|
|
|
[Tool]
|
|
public partial class Chair3D : StaticBody3D
|
|
{
|
|
[Export]
|
|
public Direction Direction { get; set; } = Direction.Down;
|
|
private AnimatedSprite3D _animatedSprite;
|
|
|
|
[Export]
|
|
public StringName SpinAnimationName = "Spin";
|
|
|
|
[Export] public float SpinTime { get; private set; } = 4f;
|
|
|
|
private double _timer = 0f;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_animatedSprite = GetNode<AnimatedSprite3D>("AnimatedSprite3D");
|
|
|
|
_animatedSprite.Play(Direction.ToString());
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (Engine.IsEditorHint()) return;
|
|
|
|
if (_animatedSprite.Animation != SpinAnimationName) return;
|
|
_timer += delta;
|
|
|
|
if (_timer >= SpinTime)
|
|
{
|
|
_timer = 0;
|
|
_animatedSprite.SpeedScale = 0;
|
|
}
|
|
|
|
}
|
|
|
|
private void OnBulletCollision(Area3D area)
|
|
{
|
|
_animatedSprite.SpeedScale = 1;
|
|
_animatedSprite.Play("Spin");
|
|
|
|
_timer = 0;
|
|
}
|
|
|
|
private Direction GetRandomDirection()
|
|
{
|
|
var directions = (Direction[])Enum.GetValues(typeof(Direction));
|
|
|
|
//GD.RandRange(0, directions.Length -1);
|
|
return directions[GD.RandRange(0, directions.Length - 1)];
|
|
}
|
|
} |