Functional networkevent validation, functional single player saving, requireditem ui texts, titlescreen & loading

This commit is contained in:
Regalis
2015-07-19 02:44:42 +03:00
parent 237df18765
commit baa207985c
78 changed files with 1237 additions and 596 deletions
+9 -9
View File
@@ -57,16 +57,16 @@ namespace Subsurface
AmbientSoundManager.Update();
if (Game1.GameSession!=null && Game1.GameSession.Level != null)
{
Vector2 targetMovement = Vector2.Zero;
if (PlayerInput.KeyDown(Keys.I)) targetMovement.Y += 1.0f;
if (PlayerInput.KeyDown(Keys.K)) targetMovement.Y -= 1.0f;
if (PlayerInput.KeyDown(Keys.J)) targetMovement.X -= 1.0f;
if (PlayerInput.KeyDown(Keys.L)) targetMovement.X += 1.0f;
//if (Game1.GameSession!=null && Game1.GameSession.Level != null)
//{
// Vector2 targetMovement = Vector2.Zero;
// if (PlayerInput.KeyDown(Keys.I)) targetMovement.Y += 1.0f;
// if (PlayerInput.KeyDown(Keys.K)) targetMovement.Y -= 1.0f;
// if (PlayerInput.KeyDown(Keys.J)) targetMovement.X -= 1.0f;
// if (PlayerInput.KeyDown(Keys.L)) targetMovement.X += 1.0f;
Game1.GameSession.Submarine.ApplyForce(targetMovement*100000.0f);
}
// Game1.GameSession.Submarine.ApplyForce(targetMovement*100000.0f);
//}
if (Game1.GameSession!=null) Game1.GameSession.Update((float)deltaTime);
//EventManager.Update(gameTime);
+1 -1
View File
@@ -243,7 +243,7 @@ namespace Subsurface
if (selectedRightPanel == (int)PanelTab.Map)
{
Game1.GameSession.map.Draw(spriteBatch, new Rectangle(
Game1.GameSession.Map.Draw(spriteBatch, new Rectangle(
rightPanel[selectedRightPanel].Rect.Right - 20 - 400,
rightPanel[selectedRightPanel].Rect.Y + 20,
400, 400));
+21 -7
View File
@@ -15,6 +15,8 @@ namespace Subsurface
private GUIListBox saveList;
private GUITextBox seedBox;
private GUITextBox nameBox, ipBox;
private Game1 game;
@@ -58,23 +60,30 @@ namespace Subsurface
menuTabs[(int)Tabs.NewGame] = new GUIFrame(panelRect, GUI.style);
//menuTabs[(int)Tabs.NewGame].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 0, 30), "New Game", null, null, Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle(0, -20, 0, 30), "New Game", null, null, Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected submarine:", null, null, Alignment.Left, GUI.style, menuTabs[(int)Tabs.NewGame]);
mapList = new GUIListBox(new Rectangle(0, 60, 200, 360), GUI.style, menuTabs[(int)Tabs.NewGame]);
foreach (Submarine map in Submarine.SavedSubmarines)
foreach (Submarine sub in Submarine.SavedSubmarines)
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
map.Name,
sub.Name,
GUI.style,
Alignment.Left, Alignment.Left, mapList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = map;
textBlock.UserData = sub;
}
if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]);
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 30, 100, 20),
"Map Seed: ", GUI.style, Alignment.Left, Alignment.TopLeft, menuTabs[(int)Tabs.NewGame]);
seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 60, 180, 20),
Alignment.TopLeft, GUI.style, menuTabs[(int)Tabs.NewGame]);
seedBox.Text = ToolBox.RandomSeed(8);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",Alignment.BottomRight, GUI.style, menuTabs[(int)Tabs.NewGame]);
button.OnClicked = StartGame;
@@ -102,7 +111,7 @@ namespace Subsurface
string[] saveFiles = Directory.GetFiles(SaveUtil.SaveFolder, "*.save");
//new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
saveList = new GUIListBox(new Rectangle(0, 60, 200, 400), Color.White, GUI.style, menuTabs[(int)Tabs.LoadGame]);
saveList = new GUIListBox(new Rectangle(0, 60, 200, 360), Color.White, GUI.style, menuTabs[(int)Tabs.LoadGame]);
foreach (string saveFile in saveFiles)
{
@@ -140,7 +149,7 @@ namespace Subsurface
for (int i = 1; i < 4; i++ )
{
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Back", Alignment.TopLeft, GUI.style, menuTabs[i]);
button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menuTabs[i]);
button.OnClicked = PreviousTab;
}
@@ -170,13 +179,17 @@ namespace Subsurface
public override void Update(double deltaTime)
{
menuTabs[selectedTab].Update((float)deltaTime);
Game1.TitleScreen.Position.Y = MathHelper.Lerp(Game1.TitleScreen.Position.Y, -870.0f, 0.1f);
}
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
{
graphics.Clear(Color.CornflowerBlue);
Game1.GameScreen.DrawMap(graphics, spriteBatch);
Game1.TitleScreen.Draw(spriteBatch, graphics, -1.0f, (float)deltaTime);
//Game1.GameScreen.DrawMap(graphics, spriteBatch);
spriteBatch.Begin();
@@ -193,6 +206,7 @@ namespace Subsurface
if (selectedMap == null) return false;
Game1.GameSession = new GameSession(selectedMap, GameModePreset.list.Find(gm => gm.Name == "Single Player"));
(Game1.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text);
Game1.LobbyScreen.Select();
+12 -8
View File
@@ -110,6 +110,7 @@ namespace Subsurface
chatBox = new GUIListBox(new Rectangle(0,0,0,chatFrame.Rect.Height-80), Color.White, GUI.style, chatFrame);
textBox = new GUITextBox(new Rectangle(0, 25, 0, 25), Alignment.Bottom, GUI.style, chatFrame);
textBox.Font = GUI.SmallFont;
textBox.OnEnter = EnterChatMessage;
//player info panel ------------------------------------------------------------
@@ -309,9 +310,6 @@ namespace Subsurface
{
base.Update(deltaTime);
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
Vector2 pos = new Vector2(
Submarine.Borders.X + Submarine.Borders.Width / 2,
Submarine.Borders.Y - Submarine.Borders.Height / 2);
@@ -324,6 +322,7 @@ namespace Subsurface
pos += offset * 0.8f;
Game1.GameScreen.Cam.TargetPos = pos;
Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
menu.Update((float)deltaTime);
@@ -353,10 +352,16 @@ namespace Subsurface
float prevSize = chatBox.BarSize;
float oldScroll = chatBox.BarScroll;
while (chatBox.CountChildren>20)
{
chatBox.RemoveChild(chatBox.children[1]);
}
GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, 0, 20),
message,
((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.1f, color,
Alignment.Left, GUI.style, null, true);
msg.Font = GUI.SmallFont;
msg.Padding = new Vector4(20, 0, 0, 0);
chatBox.AddChild(msg);
@@ -398,13 +403,12 @@ namespace Subsurface
Gender gender = (Gender)obj;
Game1.Client.CharacterInfo.Gender = gender;
Game1.Client.SendCharacterData();
UpdatePreviewPlayer(Game1.Client.CharacterInfo);
//CreatePreviewCharacter();
}
catch
{
return false;
}
catch {}
UpdatePreviewPlayer(Game1.Client.CharacterInfo);
return true;
}