Update start_game_menu.cs
This commit is contained in:
parent
f86013b117
commit
0c6838e710
@ -2,7 +2,7 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class start_game_menu : Control {
|
public partial class start_game_menu : Control {
|
||||||
enum _state { START, LAN, HOST, QUIT };
|
enum _state { START, LAN, HOST, JOIN, QUIT };
|
||||||
enum _gameType { SINGLE, LOCAL, LAN };
|
enum _gameType { SINGLE, LOCAL, LAN };
|
||||||
|
|
||||||
private _state _currState = _state.START;
|
private _state _currState = _state.START;
|
||||||
@ -81,6 +81,20 @@ public partial class start_game_menu : Control {
|
|||||||
_ip.Set("visible", false);
|
_ip.Set("visible", false);
|
||||||
_lip.Set("visible", false);
|
_lip.Set("visible", false);
|
||||||
break;
|
break;
|
||||||
|
case _state.JOIN:
|
||||||
|
Error = "Waiting for server...";
|
||||||
|
_single.Set("visible", false);
|
||||||
|
_localMulti.Set("visible", false);
|
||||||
|
_LANMulti.Set("visible", false);
|
||||||
|
_cancel.Set("visible", true);
|
||||||
|
_yes.Set("visible", false);
|
||||||
|
_no.Set("visible", false);
|
||||||
|
_join.Set("visible", false);
|
||||||
|
_host.Set("visible", false);
|
||||||
|
_quit.Set("visible", false);
|
||||||
|
_ip.Set("visible", false);
|
||||||
|
_lip.Set("visible", false);
|
||||||
|
break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
_currState = value;
|
_currState = value;
|
||||||
@ -112,7 +126,7 @@ public partial class start_game_menu : Control {
|
|||||||
State = _state.START;
|
State = _state.START;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startGame(_gameType type) {
|
private void startGame(_gameType type, long id = 0) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case _gameType.SINGLE:
|
case _gameType.SINGLE:
|
||||||
|
|
||||||
@ -121,7 +135,7 @@ public partial class start_game_menu : Control {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case _gameType.LAN:
|
case _gameType.LAN:
|
||||||
|
Error = "YIPPE! " + id.ToString();
|
||||||
break;
|
break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
@ -133,9 +147,8 @@ public partial class start_game_menu : Control {
|
|||||||
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
||||||
peer.CreateServer(666, 2);
|
peer.CreateServer(666, 2);
|
||||||
Multiplayer.MultiplayerPeer = peer;
|
Multiplayer.MultiplayerPeer = peer;
|
||||||
|
peer.PeerConnected += (long id) => startGame(_gameType.LAN, id);
|
||||||
State = _state.HOST;
|
State = _state.HOST;
|
||||||
|
|
||||||
startGame(_gameType.LAN);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
string ip = _ip.Get("text").ToString();
|
string ip = _ip.Get("text").ToString();
|
||||||
@ -158,8 +171,7 @@ public partial class start_game_menu : Control {
|
|||||||
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
||||||
peer.CreateClient(ip, 666);
|
peer.CreateClient(ip, 666);
|
||||||
Multiplayer.MultiplayerPeer = peer;
|
Multiplayer.MultiplayerPeer = peer;
|
||||||
|
State = _state.JOIN;
|
||||||
startGame(_gameType.LAN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user