feat: oh yeah it's all coming together
This commit is contained in:
@@ -11,9 +11,9 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="connect4-moderator-observer"
|
config/name="connect4-moderator-observer"
|
||||||
run/main_scene="uid://cr8fi0e4r88s8"
|
run/main_scene="uid://dcx5nvs0pa7me"
|
||||||
config/features=PackedStringArray("4.5", "C#", "Forward Plus")
|
config/features=PackedStringArray("4.5", "C#", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="uid://ckmfi0cjgxgyk"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dm25u0a2lqk2x" path="res://scripts/BracketScene.cs" id="1_dvj3m"]
|
[ext_resource type="Script" uid="uid://dm25u0a2lqk2x" path="res://scripts/BracketScene.cs" id="1_dvj3m"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ckmfi0cjgxgyk" path="res://assets/sprites/RedChip.png" id="2_7c11m"]
|
[ext_resource type="Texture2D" uid="uid://ckmfi0cjgxgyk" path="res://assets/sprites/RedChip.png" id="2_7c11m"]
|
||||||
[ext_resource type="PackedScene" uid="uid://m542qwlp7hl7" path="res://scenes/board_screen.tscn" id="3_1511b"]
|
[ext_resource type="PackedScene" uid="uid://cr8fi0e4r88s8" path="res://scenes/game.tscn" id="3_1511b"]
|
||||||
|
|
||||||
[node name="BracketView" type="Control" node_paths=PackedStringArray("Players", "Matches")]
|
[node name="BracketView" type="Control" node_paths=PackedStringArray("Players", "Matches")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class BoardScreen : Node2D {
|
public partial class BoardScreen : Node2D {
|
||||||
|
|
||||||
|
[Export] public PackedScene BracketScene;
|
||||||
|
|
||||||
private const string RED_CHIP_PATH = "res://scenes/red_chip.tscn";
|
private const string RED_CHIP_PATH = "res://scenes/red_chip.tscn";
|
||||||
private const string YELLOW_CHIP_PATH = "res://scenes/yellow_chip.tscn";
|
private const string YELLOW_CHIP_PATH = "res://scenes/yellow_chip.tscn";
|
||||||
private const int CHIP_SCALE = 3;
|
private const int CHIP_SCALE = 3;
|
||||||
@@ -16,8 +19,7 @@ public partial class BoardScreen : Node2D {
|
|||||||
|
|
||||||
private Node2D player1Card;
|
private Node2D player1Card;
|
||||||
private Node2D player2Card;
|
private Node2D player2Card;
|
||||||
private PlayerData p1;
|
private MatchData matchData;
|
||||||
private PlayerData p2;
|
|
||||||
|
|
||||||
private RigidBody2D[,] chips = new RigidBody2D[6, 7]; // 6 rows 7 cols | 0, 0 is top left
|
private RigidBody2D[,] chips = new RigidBody2D[6, 7]; // 6 rows 7 cols | 0, 0 is top left
|
||||||
|
|
||||||
@@ -32,31 +34,85 @@ public partial class BoardScreen : Node2D {
|
|||||||
|
|
||||||
redChip = GD.Load<PackedScene>(RED_CHIP_PATH);
|
redChip = GD.Load<PackedScene>(RED_CHIP_PATH);
|
||||||
ylwChip = GD.Load<PackedScene>(YELLOW_CHIP_PATH);
|
ylwChip = GD.Load<PackedScene>(YELLOW_CHIP_PATH);
|
||||||
|
|
||||||
|
matchData = Connection.Instance.CurrentObservingMatch;
|
||||||
|
player1Card.GetNode<Label>("Name").Text = matchData.player1;
|
||||||
|
player2Card.GetNode<Label>("Name").Text = matchData.player2;
|
||||||
|
|
||||||
|
Connection.Instance.OnObserveWin += ObserveWin;
|
||||||
|
Connection.Instance.OnObserveDraw += ObserveDraw;
|
||||||
|
Connection.Instance.OnObserveTerminated += ObserveTerminated;
|
||||||
|
Connection.Instance.OnObserveMove += ObserveMove;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
Connection.Instance.OnObserveWin -= ObserveWin;
|
||||||
|
Connection.Instance.OnObserveDraw -= ObserveDraw;
|
||||||
|
Connection.Instance.OnObserveTerminated -= ObserveTerminated;
|
||||||
|
Connection.Instance.OnObserveMove -= ObserveMove;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ObserveMove(string username, int column)
|
||||||
|
{
|
||||||
|
if (username == matchData.player1)
|
||||||
|
{
|
||||||
|
spawnRed(column);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spawnYellow(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ObserveWin(string winner)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
TransitionToBracket();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ObserveDraw()
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
TransitionToBracket();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ObserveTerminated()
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
TransitionToBracket();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TransitionToBracket()
|
||||||
|
{
|
||||||
|
GetTree().ChangeSceneToPacked(BracketScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
public override void _Process(double delta) {
|
public override void _Process(double delta) {
|
||||||
|
/*
|
||||||
if(p1 != null) {
|
if(p1 != null) {
|
||||||
Label username = player1Card.GetNode<Label>("Name");
|
Label username = player1Card.GetNode<Label>("Name");
|
||||||
username.Text = p1.username;
|
username.Text = p1.username;
|
||||||
|
|
||||||
if(p1.isReady) {
|
if(p1.isReady) {
|
||||||
Label status = player1Card.GetNode<Label>("Status");
|
Label status = player1Card.GetNode<Label>("Status");
|
||||||
status.Text = "Ready!";
|
status.Text = "Ready!";
|
||||||
status.AddThemeColorOverride("font_color", Colors.LimeGreen);
|
status.AddThemeColorOverride("font_color", Colors.LimeGreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p2 != null) {
|
if(p2 != null) {
|
||||||
Label username = player2Card.GetNode<Label>("Name");
|
Label username = player2Card.GetNode<Label>("Name");
|
||||||
username.Text = p2.username;
|
username.Text = p2.username;
|
||||||
|
|
||||||
if(p2.isReady) {
|
if(p2.isReady) {
|
||||||
Label status = player2Card.GetNode<Label>("Status");
|
Label status = player2Card.GetNode<Label>("Status");
|
||||||
status.Text = "Ready!";
|
status.Text = "Ready!";
|
||||||
status.AddThemeColorOverride("font_color", Colors.LimeGreen);
|
status.AddThemeColorOverride("font_color", Colors.LimeGreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user