mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:55:35 +00:00
Focus sprites
This commit is contained in:
parent
5452b36f32
commit
9717ca8a55
5 changed files with 90 additions and 76 deletions
|
|
@ -112,15 +112,13 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
|
||||
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
|
||||
//_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
|
||||
_movementDirection = Vector2.Zero;
|
||||
_facingDirection = Vector2.Zero;
|
||||
_rightStickInput = Vector2.Zero;
|
||||
_isStrafing = false;
|
||||
|
||||
_gameManager = this.GetGameManager(); //GetNode<GameManager>("/root/GameScene");
|
||||
|
||||
_gameManager = this.GetGameManager();
|
||||
_inventoryManager = this.GetInventoryManager();
|
||||
|
||||
_gameManager.GameStateChange += GameManagerOnGameStateChange;
|
||||
|
|
@ -167,28 +165,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
}
|
||||
}
|
||||
|
||||
/*public override _Process(float _delta)
|
||||
{
|
||||
if (Input.IsActionPressed("ui_right"))
|
||||
{
|
||||
_animatedSprite.Play("run");
|
||||
}
|
||||
else
|
||||
{
|
||||
_animatedSprite.Stop();
|
||||
}
|
||||
}*/
|
||||
|
||||
// public void ItemAdded(LootItem item, int amount)
|
||||
// {
|
||||
// switch (item.Item)
|
||||
// {
|
||||
// case ItemTypes.Weapon:
|
||||
// AddWeapon(item.WeaponData);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
public void AddWeapon(Weapon weapon)
|
||||
{
|
||||
EquippedWeapons.Add(weapon);
|
||||
|
|
@ -222,25 +198,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
EquipWeapon(EquippedWeapons[CurrentWeaponIndex]);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
SetAnimation();
|
||||
if (!_canMove) return;
|
||||
HandleShoot();
|
||||
FindInteractable();
|
||||
|
||||
if (Input.IsActionJustPressed("next_weapon"))
|
||||
{
|
||||
NextWeapon();
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("previous_weapon"))
|
||||
{
|
||||
PreviousWeapon();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void FindInteractable()
|
||||
{
|
||||
if (!Input.IsActionJustPressed("Use") || _selector.SelectedInteractable == null) return;
|
||||
|
|
@ -266,13 +223,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
EquippedWeapon.ShootDirection = this._facingDirection;
|
||||
EquippedWeapon.Shoot();
|
||||
|
||||
// //Debug.WriteLine("Shoot");
|
||||
// var bullet = BulletScene.Instantiate<Bullet>();
|
||||
// Owner.AddChild(bullet);
|
||||
// bullet.Transform = Muzzle.GlobalTransform;
|
||||
// bullet.Position = this.Position;
|
||||
// bullet.SetDirection(this._facingDirection);
|
||||
}
|
||||
|
||||
private void SetAnimation()
|
||||
|
|
@ -333,25 +283,13 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
}
|
||||
|
||||
// public override void _Draw()
|
||||
// {
|
||||
// if (_isStrafing)
|
||||
// {
|
||||
// HitboxSprite.Visible = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// HitboxSprite.Visible = false;
|
||||
// }
|
||||
// base._Draw();
|
||||
// }
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
SetAnimation();
|
||||
if (!_canMove) return;
|
||||
|
||||
|
||||
_movementDirection = GetInput();
|
||||
|
||||
|
||||
_isStrafing = Input.IsActionPressed("strafe");
|
||||
// Toggle visibility of the hitbox sprite based on strafing
|
||||
if (HitboxSprite != null)
|
||||
|
|
@ -373,16 +311,30 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
_facingDirection = _movementDirection;
|
||||
}
|
||||
}
|
||||
|
||||
HandleShoot();
|
||||
FindInteractable();
|
||||
|
||||
if (Input.IsActionJustPressed("next_weapon"))
|
||||
{
|
||||
NextWeapon();
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("previous_weapon"))
|
||||
{
|
||||
PreviousWeapon();
|
||||
}
|
||||
|
||||
_crosshair.Position = CalculateCrosshairPosition();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (!_canMove) return;
|
||||
|
||||
// if (_movementDirection != Vector2.Zero)
|
||||
// {
|
||||
// _facingDirection = _movementDirection;
|
||||
// }
|
||||
Velocity = _movementDirection * (float)( MovementSpeed/* * delta*/);
|
||||
|
||||
MoveAndSlide();
|
||||
|
||||
_crosshair.Position = CalculateCrosshairPosition();
|
||||
}
|
||||
|
||||
private void _on_interaction_controller_area_entered(Area2D area)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue