zappa
This commit is contained in:
parent
166966df54
commit
788964b128
BIN
audio/dot.wav
Normal file
BIN
audio/dot.wav
Normal file
Binary file not shown.
@ -12,6 +12,9 @@ public partial class start_game_menu : Control {
|
|||||||
private LineEdit _ip;
|
private LineEdit _ip;
|
||||||
private Label _error, _lip;
|
private Label _error, _lip;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private AudioStreamPlayer _sndBtn, _sndState;
|
||||||
|
|
||||||
private string Error { set { _error.Set("text", value); } }
|
private string Error { set { _error.Set("text", value); } }
|
||||||
private string IP_address {
|
private string IP_address {
|
||||||
set {
|
set {
|
||||||
@ -24,6 +27,7 @@ public partial class start_game_menu : Control {
|
|||||||
if (value == _currState)
|
if (value == _currState)
|
||||||
return;
|
return;
|
||||||
IP_address = "";
|
IP_address = "";
|
||||||
|
_sndState.Play();
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case _state.START:
|
case _state.START:
|
||||||
Error = "";
|
Error = "";
|
||||||
@ -117,12 +121,12 @@ public partial class start_game_menu : Control {
|
|||||||
_single.Pressed += () => startGame(_gameType.SINGLE);
|
_single.Pressed += () => startGame(_gameType.SINGLE);
|
||||||
//_localMulti.Pressed += () => startGame(_gameType.LOCAL);
|
//_localMulti.Pressed += () => startGame(_gameType.LOCAL);
|
||||||
//_LANMulti.Pressed += () => State = _state.LAN;
|
//_LANMulti.Pressed += () => State = _state.LAN;
|
||||||
_host.Pressed += () => setupLANMultiGame();
|
_host.Pressed += () => { _sndBtn.Play(); setupLANMultiGame();};
|
||||||
_join.Pressed += () => setupLANMultiGame(false);
|
_join.Pressed += () => { _sndBtn.Play(); setupLANMultiGame(false);};
|
||||||
_quit.Pressed += () => State = _state.QUIT;
|
_quit.Pressed += () => { _sndBtn.Play(); State = _state.QUIT;};
|
||||||
_cancel.Pressed += () => State = _state.START;
|
_cancel.Pressed += () => { _sndBtn.Play(); State = _state.START;};
|
||||||
_no.Pressed += () => State = _state.START;
|
_no.Pressed += () => { _sndBtn.Play(); State = _state.START;};
|
||||||
_yes.Pressed += () => GetTree().Quit();
|
_yes.Pressed += () => { _sndBtn.Play(); GetTree().Quit();};
|
||||||
State = _state.START;
|
State = _state.START;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
[gd_scene load_steps=8 format=3 uid="uid://4tym1auav4yv"]
|
[gd_scene load_steps=10 format=3 uid="uid://4tym1auav4yv"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://menu/start_game_menu.cs" id="1_0k2xm"]
|
[ext_resource type="Script" path="res://menu/start_game_menu.cs" id="1_0k2xm"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b44vs2lwgnh37" path="res://images/mushroom_cloud001.webp" id="2_aky60"]
|
[ext_resource type="Texture2D" uid="uid://b44vs2lwgnh37" path="res://images/mushroom_cloud001.webp" id="2_aky60"]
|
||||||
[ext_resource type="AudioStream" uid="uid://ckg5eypyrhidg" path="res://music/I Feel Grunge (Slow).wav" id="2_yw57x"]
|
[ext_resource type="AudioStream" uid="uid://ckg5eypyrhidg" path="res://music/I Feel Grunge (Slow).wav" id="2_yw57x"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://c8dcqkmytnyay" path="res://audio/btn.wav" id="4_fx2mk"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://dja6tipmq1m8l" path="res://audio/dot.wav" id="5_y8gc7"]
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_n38oc"]
|
[sub_resource type="LabelSettings" id="LabelSettings_n38oc"]
|
||||||
font_size = 290
|
font_size = 290
|
||||||
@ -24,7 +26,7 @@ keycode = 4194310
|
|||||||
[sub_resource type="Shortcut" id="Shortcut_pweny"]
|
[sub_resource type="Shortcut" id="Shortcut_pweny"]
|
||||||
events = [SubResource("InputEventKey_x36ok"), SubResource("InputEventKey_hjkcu")]
|
events = [SubResource("InputEventKey_x36ok"), SubResource("InputEventKey_hjkcu")]
|
||||||
|
|
||||||
[node name="StartGameMenu" type="Control"]
|
[node name="StartGameMenu" type="Control" node_paths=PackedStringArray("_sndBtn", "_sndState")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -32,6 +34,8 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_0k2xm")
|
script = ExtResource("1_0k2xm")
|
||||||
|
_sndBtn = NodePath("Button")
|
||||||
|
_sndState = NodePath("State")
|
||||||
|
|
||||||
[node name="MushroomCloud001" type="Sprite2D" parent="."]
|
[node name="MushroomCloud001" type="Sprite2D" parent="."]
|
||||||
modulate = Color(0.317647, 0.133333, 0.137255, 1)
|
modulate = Color(0.317647, 0.133333, 0.137255, 1)
|
||||||
@ -162,3 +166,9 @@ horizontal_alignment = 1
|
|||||||
[node name="Music" type="AudioStreamPlayer" parent="."]
|
[node name="Music" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("2_yw57x")
|
stream = ExtResource("2_yw57x")
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|
||||||
|
[node name="Button" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource("4_fx2mk")
|
||||||
|
|
||||||
|
[node name="State" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource("5_y8gc7")
|
||||||
|
262
player/player.cs
262
player/player.cs
@ -3,162 +3,162 @@ using System;
|
|||||||
|
|
||||||
public partial class player : Camera3D
|
public partial class player : Camera3D
|
||||||
{
|
{
|
||||||
private const string _path = "/root/player/";
|
private const string _path = "/root/player/";
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private Label _con;
|
private Label _con;
|
||||||
[Export]
|
[Export]
|
||||||
private Label _mousePosLabel;
|
private Label _mousePosLabel;
|
||||||
[Export]
|
[Export]
|
||||||
private Label _cursorPosLabel;
|
private Label _cursorPosLabel;
|
||||||
[Export]
|
[Export]
|
||||||
private RayCast3D _cursor;
|
private RayCast3D _cursor;
|
||||||
[Export]
|
[Export]
|
||||||
private Node3D _cursorPoint;
|
private Node3D _cursorPoint;
|
||||||
private bool _mUp, _mDown, _mLeft, _mRight, _wIn, _wOut;
|
private bool _mUp, _mDown, _mLeft, _mRight, _wIn, _wOut;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private PackedScene _test_building;
|
private PackedScene _test_building;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private TextureProgressBar _nuke, _pr, _kash;
|
private TextureProgressBar _nuke, _pr, _kash;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private Label _chatter;
|
private Label _chatter;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private AudioStreamPlayer _sndChtr, _sndBtn;
|
private AudioStreamPlayer _sndChtr, _sndBtn;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
private Timer _tmrChtr;
|
private Timer _tmrChtr;
|
||||||
|
|
||||||
private float Nuke { get => (float)_nuke.Value; set => _nuke.Value = value; }
|
private float Nuke { get => (float)_nuke.Value; set => _nuke.Value = value; }
|
||||||
private float PR { get => (float)_pr.Value; set => _pr.Value = value; }
|
private float PR { get => (float)_pr.Value; set => _pr.Value = value; }
|
||||||
private float Kash { get => (float)_kash.Value; set => _kash.Value = value; }
|
private float Kash { get => (float)_kash.Value; set => _kash.Value = value; }
|
||||||
|
|
||||||
private string Chatter
|
private string Chatter
|
||||||
{
|
{
|
||||||
get => _chatter.Get("text").ToString(); set
|
get => _chatter.Get("text").ToString(); set
|
||||||
{
|
{
|
||||||
if (!(bool)_tmrChtr.Get("is_stopped") && value != "")
|
if (!(bool)_tmrChtr.Get("is_stopped") && value != "")
|
||||||
_sndChtr.Play();
|
_sndChtr.Play();
|
||||||
_chatter.Set("text", value);
|
_chatter.Set("text", value);
|
||||||
_tmrChtr.Start();
|
_tmrChtr.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node3D CurrentBuilding { get; set; }
|
public Node3D CurrentBuilding { get; set; }
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
//for debugging TODO: Remove
|
//for debugging TODO: Remove
|
||||||
game_manager.CurrentState = game_manager.State.Building;
|
game_manager.CurrentState = game_manager.State.Building;
|
||||||
if (_test_building != null)
|
if (_test_building != null)
|
||||||
{
|
{
|
||||||
CurrentBuilding = _test_building.Instantiate<Node3D>();
|
CurrentBuilding = _test_building.Instantiate<Node3D>();
|
||||||
GD.Print(CurrentBuilding);
|
GD.Print(CurrentBuilding);
|
||||||
|
|
||||||
GetTree().Root.CallDeferred("add_child", CurrentBuilding);
|
GetTree().Root.CallDeferred("add_child", CurrentBuilding);
|
||||||
}
|
}
|
||||||
_tmrChtr.Start();
|
_tmrChtr.Start();
|
||||||
_tmrChtr.Timeout += () => Chatter = "";
|
_tmrChtr.Timeout += () => Chatter = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
Vector3 rot = this.Rotation;
|
Vector3 rot = this.Rotation;
|
||||||
bool zin = true, zout = true;
|
bool zin = true, zout = true;
|
||||||
|
|
||||||
if (Input.IsActionPressed("CamNorth"))
|
if (Input.IsActionPressed("CamNorth"))
|
||||||
_mUp = true;
|
_mUp = true;
|
||||||
if (Input.IsActionPressed("CamSouth"))
|
if (Input.IsActionPressed("CamSouth"))
|
||||||
_mDown = true;
|
_mDown = true;
|
||||||
if (Input.IsActionPressed("CamEast"))
|
if (Input.IsActionPressed("CamEast"))
|
||||||
_mRight = true;
|
_mRight = true;
|
||||||
if (Input.IsActionPressed("CamWest"))
|
if (Input.IsActionPressed("CamWest"))
|
||||||
_mLeft = true;
|
_mLeft = true;
|
||||||
|
|
||||||
this.Rotation -= rot;
|
this.Rotation -= rot;
|
||||||
if (this.Position.Y < 5)
|
if (this.Position.Y < 5)
|
||||||
zin = false;
|
zin = false;
|
||||||
else if (this.Position.Y > 45)
|
else if (this.Position.Y > 45)
|
||||||
zout = false;
|
zout = false;
|
||||||
if (_mLeft && this.Position.X > -30)
|
if (_mLeft && this.Position.X > -30)
|
||||||
this.Translate(new Vector3((float)-delta * 10, 0, 0));
|
this.Translate(new Vector3((float)-delta * 10, 0, 0));
|
||||||
if (_mRight && this.Position.X < 30)
|
if (_mRight && this.Position.X < 30)
|
||||||
this.Translate(new Vector3((float)delta * 10, 0, 0));
|
this.Translate(new Vector3((float)delta * 10, 0, 0));
|
||||||
if (_mUp && this.Position.Z > -25)
|
if (_mUp && this.Position.Z > -25)
|
||||||
this.Translate(new Vector3(0, 0, (float)-delta * 10));
|
this.Translate(new Vector3(0, 0, (float)-delta * 10));
|
||||||
if (_mDown && this.Position.Z < 25)
|
if (_mDown && this.Position.Z < 25)
|
||||||
this.Translate(new Vector3(0, 0, (float)delta * 10));
|
this.Translate(new Vector3(0, 0, (float)delta * 10));
|
||||||
this.Rotation += rot;
|
this.Rotation += rot;
|
||||||
|
|
||||||
if (_wIn && zin)
|
if (_wIn && zin)
|
||||||
this.Translate(new Vector3(0, 0, (float)-delta * 10));
|
this.Translate(new Vector3(0, 0, (float)-delta * 10));
|
||||||
if (_wOut && zout)
|
if (_wOut && zout)
|
||||||
this.Translate(new Vector3(0, 0, (float)delta * 10));
|
this.Translate(new Vector3(0, 0, (float)delta * 10));
|
||||||
|
|
||||||
_con.Set("text", this.Position);
|
_con.Set("text", this.Position);
|
||||||
|
|
||||||
|
|
||||||
if (_cursor != null && _cursorPoint != null)
|
if (_cursor != null && _cursorPoint != null)
|
||||||
{
|
{
|
||||||
//Get the collision with map and change its X and Z value to always be in the center of a tile
|
//Get the collision with map and change its X and Z value to always be in the center of a tile
|
||||||
Vector3I collisionVector = (Vector3I)_cursor.GetCollisionPoint();
|
Vector3I collisionVector = (Vector3I)_cursor.GetCollisionPoint();
|
||||||
_cursorPosLabel.Text = "Virtual Cursor Postion" + collisionVector.ToString();
|
_cursorPosLabel.Text = "Virtual Cursor Postion" + collisionVector.ToString();
|
||||||
_cursorPoint.GlobalPosition = new Vector3(collisionVector.X - collisionVector.X % 2, 1.1f, collisionVector.Z - collisionVector.Z % 2);
|
_cursorPoint.GlobalPosition = new Vector3(collisionVector.X - collisionVector.X % 2, 1.1f, collisionVector.Z - collisionVector.Z % 2);
|
||||||
|
|
||||||
if (game_manager.CurrentState == game_manager.State.Building)
|
if (game_manager.CurrentState == game_manager.State.Building)
|
||||||
HandleBuilding();
|
HandleBuilding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Input(InputEvent @event)
|
public override void _Input(InputEvent @event)
|
||||||
{
|
{
|
||||||
_mLeft = _mRight = _mUp = _mDown = _wIn = _wOut = false;
|
_mLeft = _mRight = _mUp = _mDown = _wIn = _wOut = false;
|
||||||
|
|
||||||
if (@event is InputEventMouseMotion mouse)
|
if (@event is InputEventMouseMotion mouse)
|
||||||
{
|
{
|
||||||
Vector2 vec = mouse.Position;
|
Vector2 vec = mouse.Position;
|
||||||
if (vec.X < 5)
|
if (vec.X < 5)
|
||||||
_mLeft = true;
|
_mLeft = true;
|
||||||
else if (vec.X > 1915)
|
else if (vec.X > 1915)
|
||||||
_mRight = true;
|
_mRight = true;
|
||||||
if (vec.Y < 20)
|
if (vec.Y < 20)
|
||||||
_mUp = true;
|
_mUp = true;
|
||||||
else if (vec.Y > 1060)
|
else if (vec.Y > 1060)
|
||||||
_mDown = true;
|
_mDown = true;
|
||||||
|
|
||||||
|
|
||||||
_mousePosLabel.Text = "Mouse position: " + vec.ToString();
|
_mousePosLabel.Text = "Mouse position: " + vec.ToString();
|
||||||
|
|
||||||
_cursor.Position = new Vector3(
|
_cursor.Position = new Vector3(
|
||||||
(vec.X - GetViewport().GetVisibleRect().Size.X / 2) * this.Position.Y / 1000,
|
(vec.X - GetViewport().GetVisibleRect().Size.X / 2) * this.Position.Y / 1000,
|
||||||
-((vec.Y - GetViewport().GetVisibleRect().Size.Y / 2) * this.Position.Y / 1000)
|
-((vec.Y - GetViewport().GetVisibleRect().Size.Y / 2) * this.Position.Y / 1000)
|
||||||
, 0
|
, 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (@event is InputEventMouseButton mousebtn)
|
else if (@event is InputEventMouseButton mousebtn)
|
||||||
{
|
{
|
||||||
if (mousebtn.ButtonIndex == MouseButton.WheelUp)
|
if (mousebtn.ButtonIndex == MouseButton.WheelUp)
|
||||||
_wIn = true;
|
_wIn = true;
|
||||||
else if (mousebtn.ButtonIndex == MouseButton.WheelDown)
|
else if (mousebtn.ButtonIndex == MouseButton.WheelDown)
|
||||||
_wOut = true;
|
_wOut = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleBuilding()
|
public void HandleBuilding()
|
||||||
{
|
{
|
||||||
if (CurrentBuilding != null)
|
if (CurrentBuilding != null)
|
||||||
{
|
{
|
||||||
CurrentBuilding.GlobalPosition = _cursorPoint.GlobalPosition;
|
CurrentBuilding.GlobalPosition = _cursorPoint.GlobalPosition;
|
||||||
|
|
||||||
if (Input.IsActionJustPressed("build"))
|
if (Input.IsActionJustPressed("build"))
|
||||||
{
|
{
|
||||||
Node3D tempBuilding = (Node3D)CurrentBuilding.Duplicate();
|
Node3D tempBuilding = (Node3D)CurrentBuilding.Duplicate();
|
||||||
GetTree().Root.CallDeferred("add_child", tempBuilding);
|
GetTree().Root.CallDeferred("add_child", tempBuilding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user