Merge remote-tracking branch 'origin/feature/showcase_kathi' into feature/fight_system
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class AnimationStarter : Node2D
|
||||
{
|
||||
[Export] private AnimationPlayer _animationPlayer;
|
||||
[Export] private string _animationName;
|
||||
[Export] private bool _repeatable = true;
|
||||
|
||||
private bool _played;
|
||||
|
||||
public void PlayAnimation()
|
||||
{
|
||||
if (_animationPlayer == null || string.IsNullOrEmpty(_animationName))
|
||||
return;
|
||||
|
||||
if (!_repeatable && _played)
|
||||
return;
|
||||
|
||||
_animationPlayer.Play(_animationName);
|
||||
_played = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://31p67cdowuw4
|
||||
@@ -0,0 +1,88 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Animation;
|
||||
|
||||
public partial class Duck : Node2D
|
||||
{
|
||||
[Export] private CharacterBody2D _characterBody;
|
||||
[Export] private AudioPlayer _nakNakAudio;
|
||||
[Export] private AudioPlayer _wingFlapAudio;
|
||||
[Export] private Node2D _vesna;
|
||||
[Export] private float _runningSpeed = 3f;
|
||||
[Export] private float _slowSpeed = 0.5f;
|
||||
[Export] private float _minDistanceToVesna = 1000f;
|
||||
[Export] private Node2D _duckRight;
|
||||
[Export] private Node2D _duckLeft;
|
||||
|
||||
private bool _vesnaInReach = false;
|
||||
private bool _penEntered = false;
|
||||
private int _numberOfFramesPerDirection = 1000;
|
||||
private int _currentFramesThisDirection = 0;
|
||||
private bool _duckLookingRight = true;
|
||||
private Vector2 _movementVector = Vector2.Zero;
|
||||
|
||||
|
||||
public void PenEntered()
|
||||
{
|
||||
_nakNakAudio.PlayOneShot();
|
||||
_penEntered = true;
|
||||
}
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
DrawLine(_characterBody.GlobalPosition, _movementVector, new Color(255, 0, 0), 2f, false);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_penEntered)
|
||||
{
|
||||
_characterBody.Velocity = Vector2.Zero;
|
||||
_characterBody.MoveAndSlide();
|
||||
GD.Print("Pen entered.");
|
||||
return;
|
||||
}
|
||||
|
||||
float currentDistance = _vesna.GlobalPosition.DistanceTo(_characterBody.GlobalPosition);
|
||||
|
||||
if (currentDistance < _minDistanceToVesna)
|
||||
{
|
||||
_movementVector = new Vector2( _characterBody.GlobalPosition.X - _vesna.GlobalPosition.X,
|
||||
_characterBody.GlobalPosition.Y - _vesna.GlobalPosition.Y).Normalized();
|
||||
_movementVector *= _runningSpeed;
|
||||
_characterBody.Velocity = _movementVector;
|
||||
_characterBody.MoveAndSlide();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentFramesThisDirection >= _numberOfFramesPerDirection)
|
||||
{
|
||||
_currentFramesThisDirection = 0;
|
||||
FastNoiseLite fastNoiseLite = new FastNoiseLite();
|
||||
_movementVector = new Vector2(fastNoiseLite.GetNoise1D(_characterBody.GlobalPosition.X * Time.GetTicksMsec()), fastNoiseLite.GetNoise1D(_characterBody.GlobalPosition.Y * Time.GetTicksMsec())).Normalized();
|
||||
}
|
||||
|
||||
_currentFramesThisDirection++;
|
||||
_characterBody.Velocity = _movementVector * _slowSpeed;
|
||||
_characterBody.MoveAndSlide();
|
||||
}
|
||||
|
||||
// if läuftNachLinks && schautNachRechts || läuftNachRechts && schautNachLinks
|
||||
if ((_characterBody.Velocity.X < 0 && _duckLookingRight)
|
||||
|| (_characterBody.Velocity.X > 0 && !_duckLookingRight))
|
||||
{
|
||||
if (_duckLookingRight)
|
||||
{
|
||||
_duckRight.Visible = false;
|
||||
_duckLeft.Visible = true;
|
||||
_duckLookingRight = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_duckRight.Visible = true;
|
||||
_duckLeft.Visible = false;
|
||||
_duckLookingRight = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c4qxtuym7syjc
|
||||
@@ -0,0 +1,12 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Animation;
|
||||
|
||||
public partial class PenCollider : Area2D
|
||||
{
|
||||
// bisons vorschlag:
|
||||
|
||||
// duck entered pen -> pen detects collision,
|
||||
// collision reffences somehow to the duck -> pen "catches" duck object -> sets duck "i am your pen now"
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://fvo04di6k7we
|
||||
@@ -13,19 +13,30 @@ public partial class InteractionArea2D : Node2D
|
||||
[Signal] public delegate void InteractedToolEventHandler(int id); // TODO: remove
|
||||
[Signal] public delegate void InteractedEventHandler();
|
||||
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
public void OnPlayerEntered(Node2D player)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
if(_showLabel)
|
||||
_label.Show();
|
||||
}
|
||||
|
||||
public void OnPlayerExited(Node2D player)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
_label.Hide();
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
if (@event.IsAction("interact") && @event.IsPressed() && _area.HasOverlappingBodies())
|
||||
{
|
||||
_label.Hide();
|
||||
@@ -36,9 +47,18 @@ public partial class InteractionArea2D : Node2D
|
||||
|
||||
public void SetSpriteActiveState(bool success, int id) // TODO: remove
|
||||
{
|
||||
if(!IsActive)
|
||||
return;
|
||||
|
||||
if (_id == id)
|
||||
{
|
||||
_sprites.SwitchState(!success);
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleActive()
|
||||
{
|
||||
IsActive = !IsActive;
|
||||
_label.Hide();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.NPC;
|
||||
|
||||
public partial class DialogicOverlayStarter : Node2D
|
||||
{
|
||||
[Export] private string[] _timelinesToPlay;
|
||||
[Export] private int _timelineIndex = 0;
|
||||
[Export] private bool _startOnReady = true;
|
||||
|
||||
[Signal] public delegate void DialogueEventHandler(string timelineName);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (_startOnReady)
|
||||
ToggleDialogue();
|
||||
}
|
||||
|
||||
public void ToggleDialogue()
|
||||
{
|
||||
ToggleDialogue(_timelinesToPlay[_timelineIndex]);
|
||||
}
|
||||
|
||||
public void ToggleDialogue(int index)
|
||||
{
|
||||
ToggleDialogue(_timelinesToPlay[index]);
|
||||
}
|
||||
|
||||
public void ToggleDialogue(string timelineName)
|
||||
{
|
||||
EmitSignal(SignalName.Dialogue, timelineName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dnipeibppjirs
|
||||
@@ -0,0 +1,88 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.SceneManagement;
|
||||
public partial class SceneTransitionThreaded : CanvasLayer
|
||||
{
|
||||
public static SceneTransitionThreaded Instance { get; private set; }
|
||||
|
||||
// set to true if don't wanna use it
|
||||
public bool userCodeLoadCompleted = true;
|
||||
|
||||
private ThreadedLoadingStateEn threadedLoadingState = ThreadedLoadingStateEn._none;
|
||||
public enum ThreadedLoadingStateEn
|
||||
{
|
||||
_none,
|
||||
_fading_in,
|
||||
_loading,
|
||||
_loading_user_code
|
||||
}
|
||||
|
||||
[Export] private AnimationPlayer animationPlayer;
|
||||
private string scenePathThreaded = "";
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
CheckLoadThreaded();
|
||||
}
|
||||
|
||||
private void CheckLoadThreaded()
|
||||
{
|
||||
if (scenePathThreaded == "")
|
||||
{ return; }
|
||||
|
||||
if (threadedLoadingState == ThreadedLoadingStateEn._loading && ResourceLoader.LoadThreadedGetStatus(scenePathThreaded) == ResourceLoader.ThreadLoadStatus.Loaded)
|
||||
{
|
||||
OnResourceLoadThreadedComplete();
|
||||
}
|
||||
else if (threadedLoadingState == ThreadedLoadingStateEn._loading_user_code && userCodeLoadCompleted)
|
||||
{
|
||||
OnResourceLoadThreadedCompleteUserCode();
|
||||
}
|
||||
}
|
||||
|
||||
public async void ChangeSceneToFile(string scenePath)
|
||||
{
|
||||
animationPlayer.Play("fadeIn");
|
||||
//yield(animationPlayer, "animation_finished");
|
||||
await ToSignal(animationPlayer, "animation_finished");
|
||||
GetTree().ChangeSceneToFile(scenePath);
|
||||
animationPlayer.Play("fadeOut");
|
||||
}
|
||||
|
||||
public void OnFadeInCompletedThreaded()
|
||||
{
|
||||
if (scenePathThreaded == "")
|
||||
{ return; }
|
||||
|
||||
ResourceLoader.LoadThreadedRequest(scenePathThreaded);
|
||||
threadedLoadingState = ThreadedLoadingStateEn._loading;
|
||||
}
|
||||
|
||||
// https://docs.godotengine.org/en/stable/tutorials/io/background_loading.html
|
||||
public void ChangeSceneToFileThreaded(string scenePath)
|
||||
{
|
||||
scenePathThreaded = scenePath;
|
||||
animationPlayer.Play("fadeIn");
|
||||
threadedLoadingState = ThreadedLoadingStateEn._fading_in;
|
||||
}
|
||||
|
||||
private void OnResourceLoadThreadedComplete()
|
||||
{
|
||||
PackedScene loadedScene = (PackedScene)ResourceLoader.LoadThreadedGet(scenePathThreaded);
|
||||
//Node sceneInstance = loadedScene.Instantiate();
|
||||
GetTree().ChangeSceneToPacked(loadedScene);
|
||||
threadedLoadingState = ThreadedLoadingStateEn._loading_user_code;
|
||||
}
|
||||
|
||||
private void OnResourceLoadThreadedCompleteUserCode()
|
||||
{
|
||||
animationPlayer.Play("fadeOut");
|
||||
scenePathThreaded = "";
|
||||
threadedLoadingState = ThreadedLoadingStateEn._none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bo2jik2jtuqlw
|
||||
@@ -1,23 +1,29 @@
|
||||
using Babushka.scripts.CSharp.Common.SceneManagement;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common;
|
||||
|
||||
public partial class SceneTransition : Node
|
||||
{
|
||||
[Export] private PackedScene _sceneToLoad;
|
||||
[Export] private Node? _sceneInstanceParent;
|
||||
[Export] private string[] _sceneNamesToLoad;
|
||||
[Export] private int _sceneIndex;
|
||||
[Export] private bool _unloadSelf = true;
|
||||
|
||||
public void LoadScene()
|
||||
{
|
||||
Node sceneInstance = _sceneToLoad.Instantiate();
|
||||
if(_sceneInstanceParent != null)
|
||||
_sceneInstanceParent.AddChild(sceneInstance);
|
||||
else
|
||||
{
|
||||
GetTree().Root.AddChild(sceneInstance);
|
||||
}
|
||||
LoadSceneAtIndex(0);
|
||||
}
|
||||
|
||||
public void LoadSceneAtIndex(int index)
|
||||
{
|
||||
string sceneName = _sceneNamesToLoad[index];
|
||||
SceneTransitionThreaded.Instance.ChangeSceneToFileThreaded(sceneName);
|
||||
UnloadAfterDelay();
|
||||
}
|
||||
|
||||
private async void UnloadAfterDelay()
|
||||
{
|
||||
await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); // 1.0f seconds
|
||||
if (_unloadSelf)
|
||||
{
|
||||
QueueFree();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Temp;
|
||||
|
||||
/// <summary>
|
||||
/// Temporary Duck behaviour to make sure we can use them in the first showcase
|
||||
/// </summary>
|
||||
public partial class MVPDuck : Node2D
|
||||
{
|
||||
[Export] private Node2D _penTarget;
|
||||
[Export] private int _transferDelayMs;
|
||||
[Export] private AnimationPlayer _animationPlayer;
|
||||
[Export] private string _flapAnimationName = "flapFlap";
|
||||
|
||||
|
||||
public void TransferToTargetAfterDelay()
|
||||
{
|
||||
MoveAfterDelay();
|
||||
PlayAnimation();
|
||||
}
|
||||
|
||||
private void PlayAnimation()
|
||||
{
|
||||
_animationPlayer.CurrentAnimation = _flapAnimationName;
|
||||
_animationPlayer.Play();
|
||||
}
|
||||
|
||||
public async void MoveAfterDelay()
|
||||
{
|
||||
await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); // 1.0f seconds
|
||||
Position = _penTarget.GlobalPosition; // Now this works!
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://7m1rt7agb6rm
|
||||
Reference in New Issue
Block a user