Beeg checkin

This commit is contained in:
2023-09-06 03:49:16 -07:00
parent f180d4cacd
commit f8cca640a6
320 changed files with 2751 additions and 26682 deletions

11
Player/Base/Controls.cs Normal file
View File

@@ -0,0 +1,11 @@
using Godot;
public partial class Controls : CharacterBody3D
{
private GameManager _gameManager;
public override void _Ready()
{
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
}
}

87
Player/Base/P1Controls.cs Normal file
View File

@@ -0,0 +1,87 @@
using Godot;
public partial class P1Controls : Controls
{
[Export]
private PackedScene _fireProjectile;
[Export]
private PackedScene _altFireProjectile;
[Export]
private float _speed = 3.0f;
public bool CanShoot { get; protected set; }
private GameManager _gameManager;
public override void _Ready()
{
CanShoot = true;
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
}
public override void _PhysicsProcess(double delta)
{
Velocity = CalculateCharacterMovement(delta);
MoveAndSlide();
}
public override void _UnhandledInput(InputEvent @event)
{
if (Input.IsActionJustPressed("exit"))
GetTree().Quit();
if (Input.IsActionJustPressed($"p1_fire") && CanShoot)
Fire();
if (Input.IsActionJustPressed($"p1_altfire") && CanShoot)
AltFire();
}
private Vector3 CalculateCharacterMovement(double delta)
{
var velocity = Velocity;
var inputDir = Input.GetVector($"p1_left", $"p1_right", $"p1_up", $"p1_down");
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero)
{
velocity.X = direction.X * _speed;
velocity.Z = direction.Z * _speed;
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Up);
}
else
{
velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
}
return velocity;
}
private async void Fire()
{
var projectile = _fireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 1f, 0f);
projectile.ParentCharacter = this;
GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
CanShoot = true;
}
private async void AltFire()
{
var projectile = _altFireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 1f, 0f);
projectile.ParentCharacter = this;
GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
CanShoot = true;
}
public void OnHit(Node3D node)
{
if (this != null)
_gameManager.CallDeferred(GameManager.MethodName.RemoveCharacter, this);
}
}

85
Player/Base/P2Controls.cs Normal file
View File

@@ -0,0 +1,85 @@
using Godot;
public partial class P2Controls : Controls
{
[Export]
private PackedScene _fireProjectile;
[Export]
private PackedScene _altFireProjectile;
[Export]
private float _speed = 3.0f;
public bool CanShoot { get; protected set; }
private GameManager _gameManager;
public override void _Ready()
{
CanShoot = true;
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
}
public override void _PhysicsProcess(double delta)
{
Velocity = CalculateCharacterMovement(delta);
MoveAndSlide();
}
public override void _UnhandledInput(InputEvent @event)
{
if (Input.IsActionJustPressed("exit"))
GetTree().Quit();
if (Input.IsActionJustPressed($"p2_fire") && CanShoot)
Fire();
if (Input.IsActionJustPressed($"p2_altfire") && CanShoot)
AltFire();
}
private Vector3 CalculateCharacterMovement(double delta)
{
var velocity = Velocity;
var inputDir = Input.GetVector($"p2_left", $"p2_right", $"p2_up", $"p2_down");
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero)
{
velocity.X = direction.X * _speed;
velocity.Z = direction.Z * _speed;
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Up);
GetNode<Node3D>("CollisionShape3D").LookAt(Position + direction, Vector3.Up);
}
else
{
velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
}
return velocity;
}
private async void Fire()
{
var projectile = _fireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 1f, 0f);
GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
CanShoot = true;
}
private async void AltFire()
{
var projectile = _altFireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 1f, 0f);
GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
CanShoot = true;
}
public void OnHit(Node3D node)
{
_gameManager.RemoveCharacter(this);
}
}

18
Player/Base/Player1.tscn Normal file
View File

@@ -0,0 +1,18 @@
[gd_scene load_steps=7 format=3 uid="uid://xcmspevaqcrc"]
[ext_resource type="Script" path="res://Player/Base/PlayerManager.cs" id="1_mmi2c"]
[ext_resource type="PackedScene" uid="uid://b38hcomu4tpm5" path="res://Player/Pisces/P1PiscesWitch.tscn" id="2_g10gf"]
[ext_resource type="PackedScene" uid="uid://iempdafdn6ct" path="res://Player/Scorpio/P1PlayerScorpio.tscn" id="3_nsh6r"]
[ext_resource type="PackedScene" uid="uid://bgkqfamdiwrrw" path="res://Player/Sagittarius/P1Megami.tscn" id="4_vnhuv"]
[ext_resource type="PackedScene" uid="uid://crkon4c8ah1a2" path="res://Player/Capricorn/CapricornP1.tscn" id="5_ccoeb"]
[ext_resource type="Script" path="res://Player/Base/SpawnPoint.cs" id="6_lida8"]
[node name="Player1" type="Node3D" node_paths=PackedStringArray("SpawnPoint")]
script = ExtResource("1_mmi2c")
SpawnPoint = NodePath("Marker3D")
PlayableCharacterScenes = Array[PackedScene]([ExtResource("2_g10gf"), ExtResource("3_nsh6r"), ExtResource("4_vnhuv"), ExtResource("5_ccoeb")])
[node name="Marker3D" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.5, 0, 5.513)
gizmo_extents = 1.0
script = ExtResource("6_lida8")

15
Player/Base/Player2.tscn Normal file
View File

@@ -0,0 +1,15 @@
[gd_scene load_steps=5 format=3 uid="uid://b57xus5rqasy8"]
[ext_resource type="Script" path="res://Player/Base/PlayerManager.cs" id="1_gttsr"]
[ext_resource type="Script" path="res://Player/Base/SpawnPoint.cs" id="1_xs6nn"]
[ext_resource type="PackedScene" uid="uid://dfanwejjy3iue" path="res://Player/Pisces/P2PiscesWitch.tscn" id="2_78cal"]
[ext_resource type="PackedScene" uid="uid://cg6hdoeq70ke8" path="res://Player/Scorpio/P2PlayerScorpio.tscn" id="3_04rrx"]
[node name="Player2" type="Node3D" groups=["Player"]]
script = ExtResource("1_gttsr")
PlayableCharacterScenes = Array[PackedScene]([ExtResource("2_78cal"), ExtResource("3_04rrx")])
[node name="Marker3D" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 0, 5.513)
gizmo_extents = 1.0
script = ExtResource("1_xs6nn")

View File

@@ -0,0 +1,30 @@
using Godot;
using Godot.Collections;
public partial class PlayerManager : Node3D
{
[Export]
public SpawnPoint SpawnPoint;
[Export]
public Array<PackedScene> PlayableCharacterScenes;
public Array<Controls> CharactersLeftOnStage = new Array<Controls>();
public Controls SelectedCharacter;
public bool IsSelectingCharacter = false;
public int _characterIndex = 0;
public bool GameOver = false;
public override void _Ready()
{
foreach (var character in PlayableCharacterScenes)
{
var instance = character.Instantiate();
CharactersLeftOnStage.Add((Controls)instance);
}
}
}

29
Player/Base/Projectile.cs Normal file
View File

@@ -0,0 +1,29 @@
using Godot;
public partial class Projectile : Node3D
{
[Export]
public double Cooldown { get; protected set; }
[Export]
public AudioStream _soundEffect;
public Controls ParentCharacter;
[Export]
private float _projectileSpeed = 1f;
public override void _Ready()
{
Speed = _projectileSpeed;
var sfxPlayer = GetTree().Root.GetNode<AudioStreamPlayer>("Main/SFXPlayer");
sfxPlayer.Stream = _soundEffect;
sfxPlayer.Play();
}
public float Speed { get; private set; }
public void OnTimeToLiveTimeout()
{
QueueFree();
}
}

10
Player/Base/SpawnPoint.cs Normal file
View File

@@ -0,0 +1,10 @@
using Godot;
public partial class SpawnPoint : Marker3D
{
public void SetPlayerPosition(Node3D character)
{
GD.Print("Moving character to spawn point");
character.Position = Position;
}
}