assigning jobs when a round starts, crew tab in multiplayer, repairtool particles light & sounds, attachable buttons, increased repairtool range & limbdamage, captain's uniform, wearable sprite bugfixes
This commit is contained in:
@@ -44,6 +44,7 @@ namespace Subsurface.Networking
|
||||
name = newName;
|
||||
|
||||
characterInfo = new CharacterInfo(Character.HumanConfigFile, name);
|
||||
characterInfo.Job = null;
|
||||
|
||||
otherClients = new List<Client>();
|
||||
|
||||
@@ -121,6 +122,7 @@ namespace Subsurface.Networking
|
||||
|
||||
private bool RetryConnection(GUIButton button, object obj)
|
||||
{
|
||||
if (client != null) client.Shutdown("Disconnecting");
|
||||
ConnectToServer(serverIP);
|
||||
return true;
|
||||
}
|
||||
@@ -175,6 +177,7 @@ namespace Subsurface.Networking
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient);
|
||||
otherClients.Add(otherClient);
|
||||
}
|
||||
|
||||
//add the name of own client to the lobby screen
|
||||
@@ -230,20 +233,9 @@ namespace Subsurface.Networking
|
||||
yield return Status.Success;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.K))
|
||||
//{
|
||||
// SendRandomData();
|
||||
//}
|
||||
//if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.L))
|
||||
//{
|
||||
// ConnectToServer(serverIP);
|
||||
//}
|
||||
|
||||
|
||||
if (gameStarted) inGameHUD.Update((float)Physics.step);
|
||||
base.Update(deltaTime);
|
||||
|
||||
if (!connected || updateTimer > DateTime.Now) return;
|
||||
|
||||
@@ -341,17 +333,15 @@ namespace Subsurface.Networking
|
||||
//myCharacter = ReadCharacterData(inc);
|
||||
//Character.Controlled = myCharacter;
|
||||
|
||||
List<Character> crew = new List<Character>();
|
||||
|
||||
int count = inc.ReadInt32();
|
||||
for (int n = 0; n < count; n++)
|
||||
{
|
||||
int id = inc.ReadInt32();
|
||||
Character newCharacter = ReadCharacterData(inc);
|
||||
Character newCharacter = ReadCharacterData(inc, id == myID);
|
||||
|
||||
if (id == myID)
|
||||
{
|
||||
myCharacter = newCharacter;
|
||||
Character.Controlled = myCharacter;
|
||||
}
|
||||
crew.Add(newCharacter);
|
||||
}
|
||||
|
||||
gameStarted = true;
|
||||
@@ -360,6 +350,8 @@ namespace Subsurface.Networking
|
||||
|
||||
AddChatMessage("Press TAB to chat", ChatMessageType.Server);
|
||||
|
||||
CreateCrewFrame(crew);
|
||||
|
||||
break;
|
||||
case (byte)PacketTypes.EndGame:
|
||||
string endMessage = inc.ReadString();
|
||||
@@ -370,6 +362,7 @@ namespace Subsurface.Networking
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient);
|
||||
otherClients.Add(otherClient);
|
||||
|
||||
AddChatMessage(otherClient.name + " has joined the server", ChatMessageType.Server);
|
||||
|
||||
@@ -459,7 +452,7 @@ namespace Subsurface.Networking
|
||||
client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||
}
|
||||
|
||||
private Character ReadCharacterData(NetIncomingMessage inc)
|
||||
private Character ReadCharacterData(NetIncomingMessage inc, bool isMyCharacter)
|
||||
{
|
||||
string newName = inc.ReadString();
|
||||
int ID = inc.ReadInt32();
|
||||
@@ -494,16 +487,20 @@ namespace Subsurface.Networking
|
||||
}
|
||||
|
||||
Character character = (closestWaypoint == null) ?
|
||||
new Character(ch, position) :
|
||||
new Character(ch, closestWaypoint);
|
||||
new Character(ch, position, true) :
|
||||
new Character(ch, closestWaypoint, true);
|
||||
|
||||
character.ID = ID;
|
||||
character.Inventory.ID = inventoryID;
|
||||
|
||||
character.IsNetworkPlayer = true;
|
||||
|
||||
|
||||
character.GiveJobItems(closestWaypoint);
|
||||
|
||||
if (isMyCharacter)
|
||||
{
|
||||
myCharacter = character;
|
||||
Character.Controlled = character;
|
||||
}
|
||||
|
||||
return character;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,12 +58,9 @@ namespace Subsurface.Networking
|
||||
DebugConsole.NewMessage("Server started", Color.Green);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
//if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.K))
|
||||
//{
|
||||
// SendRandomData();
|
||||
//}
|
||||
base.Update(deltaTime);
|
||||
|
||||
if (gameStarted) inGameHUD.Update((float)Physics.step);
|
||||
|
||||
@@ -208,7 +205,7 @@ namespace Subsurface.Networking
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignJobs();
|
||||
//AssignJobs();
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(sender);
|
||||
|
||||
@@ -346,6 +343,8 @@ namespace Subsurface.Networking
|
||||
{
|
||||
int seed = DateTime.Now.Millisecond;
|
||||
Rand.SetSyncedSeed(seed);
|
||||
|
||||
AssignJobs();
|
||||
|
||||
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
|
||||
|
||||
@@ -369,9 +368,12 @@ namespace Subsurface.Networking
|
||||
}
|
||||
characterInfos.Add(client.characterInfo);
|
||||
|
||||
client.characterInfo.Job = new Job(client.assignedJob);
|
||||
|
||||
//client.character = new Character(client.characterInfo, (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition, true);
|
||||
}
|
||||
|
||||
List<Character> crew = new List<Character>();
|
||||
WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos);
|
||||
|
||||
for (int i = 0; i < connectedClients.Count; i++ )
|
||||
@@ -379,6 +381,8 @@ namespace Subsurface.Networking
|
||||
connectedClients[i].character = new Character(
|
||||
connectedClients[i].characterInfo, assignedWayPoints[i], true);
|
||||
connectedClients[i].character.GiveJobItems(assignedWayPoints[i]);
|
||||
|
||||
crew.Add(connectedClients[i].character);
|
||||
}
|
||||
|
||||
//todo: fix
|
||||
@@ -427,6 +431,9 @@ namespace Subsurface.Networking
|
||||
|
||||
Game1.GameScreen.Select();
|
||||
|
||||
|
||||
CreateCrewFrame(crew);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -685,7 +692,7 @@ namespace Subsurface.Networking
|
||||
}
|
||||
}
|
||||
|
||||
UpdateNetLobby(null);
|
||||
//UpdateNetLobby(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface.Networking
|
||||
{
|
||||
@@ -40,9 +42,14 @@ namespace Subsurface.Networking
|
||||
|
||||
protected GUIFrame inGameHUD;
|
||||
protected GUIListBox chatBox;
|
||||
protected GUITextBox chatMsgBox;
|
||||
|
||||
public int Port;
|
||||
|
||||
private bool crewFrameOpen;
|
||||
private GUIButton crewButton;
|
||||
private GUIFrame crewFrame;
|
||||
|
||||
protected bool gameStarted;
|
||||
|
||||
public string Name
|
||||
@@ -72,13 +79,73 @@ namespace Subsurface.Networking
|
||||
width, height),
|
||||
Color.White * 0.5f, GUI.style, inGameHUD);
|
||||
|
||||
var textBox = new GUITextBox(
|
||||
chatMsgBox = new GUITextBox(
|
||||
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25),
|
||||
Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.style, inGameHUD);
|
||||
textBox.Font = GUI.SmallFont;
|
||||
textBox.OnEnter = EnterChatMessage;
|
||||
chatMsgBox.Font = GUI.SmallFont;
|
||||
chatMsgBox.OnEnter = EnterChatMessage;
|
||||
|
||||
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.style, inGameHUD);
|
||||
crewButton.OnClicked = ToggleCrewFrame;
|
||||
}
|
||||
|
||||
protected void CreateCrewFrame(List<Character> crew)
|
||||
{
|
||||
int width = 500, height = 400;
|
||||
|
||||
crewFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.style);
|
||||
crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
|
||||
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 200, 300), Color.White * 0.7f, GUI.style, crewFrame);
|
||||
crewList.OnSelected = SelectCharacter;
|
||||
|
||||
foreach (Character character in crew)
|
||||
{
|
||||
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList);
|
||||
frame.UserData = character;
|
||||
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
frame.HoverColor = Color.LightGray * 0.5f;
|
||||
frame.SelectedColor = Color.Gold * 0.5f;
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(40, 0, 0, 25),
|
||||
character.Info.Name + " ("+character.Info.Job.Name+")",
|
||||
Color.Transparent, Color.White,
|
||||
Alignment.Left, Alignment.Left,
|
||||
null, frame);
|
||||
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
||||
|
||||
new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.limbs[0].sprite, Alignment.Left, frame);
|
||||
}
|
||||
|
||||
var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.style, crewFrame);
|
||||
closeButton.OnClicked = ToggleCrewFrame;
|
||||
}
|
||||
|
||||
private bool SelectCharacter(object obj)
|
||||
{
|
||||
Character character = obj as Character;
|
||||
if (obj == null) return false;
|
||||
|
||||
GUIComponent existingFrame = crewFrame.FindChild("selectedcharacter");
|
||||
if (existingFrame != null) crewFrame.RemoveChild(existingFrame);
|
||||
|
||||
var previewPlayer = new GUIFrame(
|
||||
new Rectangle(0,0, 230, 300),
|
||||
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.style, crewFrame);
|
||||
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
previewPlayer.UserData = "selectedcharacter";
|
||||
|
||||
var infoFrame = character.Info.CreateInfoFrame(previewPlayer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ToggleCrewFrame(GUIButton button, object obj)
|
||||
{
|
||||
crewFrameOpen = !crewFrameOpen;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool EnterChatMessage(GUITextBox textBox, string message)
|
||||
{
|
||||
@@ -122,13 +189,36 @@ namespace Subsurface.Networking
|
||||
|
||||
public virtual void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { }
|
||||
|
||||
public virtual void Update() { }
|
||||
public virtual void Update(float deltaTime)
|
||||
{
|
||||
if (gameStarted)
|
||||
{
|
||||
inGameHUD.Update(deltaTime);
|
||||
|
||||
if (crewFrameOpen) crewFrame.Update(deltaTime);
|
||||
}
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Tab))
|
||||
{
|
||||
if (chatMsgBox.Selected)
|
||||
{
|
||||
chatMsgBox.Text = "";
|
||||
chatMsgBox.Deselect();
|
||||
}
|
||||
else
|
||||
{
|
||||
chatMsgBox.Select();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!gameStarted) return;
|
||||
|
||||
inGameHUD.Draw(spriteBatch);
|
||||
|
||||
if (crewFrameOpen) crewFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public virtual void Disconnect() { }
|
||||
|
||||
Reference in New Issue
Block a user