WIP CrashReporter, misc refactoring
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
|
||||
#----------------------------- Global Properties ----------------------------#
|
||||
|
||||
/outputDir:bin/Windows
|
||||
/intermediateDir:obj/Windows
|
||||
/platform:Windows
|
||||
/config:
|
||||
/profile:Reach
|
||||
/compress:False
|
||||
|
||||
#-------------------------------- References --------------------------------#
|
||||
|
||||
|
||||
#---------------------------------- Content ---------------------------------#
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{6BE950CD-9A34-49C9-939A-786AC89C287E}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CrashReporter</RootNamespace>
|
||||
<AssemblyName>CrashReporter</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MonoGamePlatform>Windows</MonoGamePlatform>
|
||||
<MonoGameContentBuilderExe>
|
||||
</MonoGameContentBuilderExe>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Windows\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Windows\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ReporterMain.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework">
|
||||
<HintPath>$(MSBuildProgramFiles32)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Subsurface\Subsurface.csproj">
|
||||
<Project>{008c0f83-e914-4966-9135-ea885059edd8}</Project>
|
||||
<Name>Subsurface</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 144 KiB |
@@ -0,0 +1,26 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace CrashReporter
|
||||
{
|
||||
#if WINDOWS || LINUX
|
||||
/// <summary>
|
||||
/// The main class.
|
||||
/// </summary>
|
||||
public static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
using (var game = new ReporterMain())
|
||||
game.Run();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CrashReporter")]
|
||||
[assembly: AssemblyProduct("CrashReporter")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5087c690-b7c4-4087-979a-a064ada558b4")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("3.3.0.2069")]
|
||||
[assembly: AssemblyFileVersion("3.3.0.2069")]
|
||||
@@ -0,0 +1,147 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Subsurface;
|
||||
using System.IO;
|
||||
|
||||
namespace CrashReporter
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the main type for your game
|
||||
/// </summary>
|
||||
public class ReporterMain : Game
|
||||
{
|
||||
GraphicsDeviceManager graphics;
|
||||
SpriteBatch spriteBatch;
|
||||
|
||||
int graphicsWidth, graphicsHeight;
|
||||
|
||||
Texture2D backgroundTexture, titleTexture;
|
||||
|
||||
GUIFrame guiRoot;
|
||||
|
||||
string crashReport;
|
||||
|
||||
public ReporterMain()
|
||||
: base()
|
||||
{
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
Content.RootDirectory = "Content";
|
||||
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
graphics.PreferredBackBufferWidth = 640;
|
||||
graphics.PreferredBackBufferHeight = 360;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to perform any initialization it needs to before starting to run.
|
||||
/// This is where it can query for any required services and load any non-graphic
|
||||
/// related content. Calling base.Initialize will enumerate through any components
|
||||
/// and initialize them as well.
|
||||
/// </summary>
|
||||
protected override void Initialize()
|
||||
{
|
||||
// TODO: Add your initialization logic here
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoadContent will be called once per game and is the place to load
|
||||
/// all of your content.
|
||||
/// </summary>
|
||||
protected override void LoadContent()
|
||||
{
|
||||
// Create a new SpriteBatch, which can be used to draw textures.
|
||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
|
||||
graphicsWidth = GraphicsDevice.Viewport.Width;
|
||||
graphicsHeight = GraphicsDevice.Viewport.Height;
|
||||
|
||||
TextureLoader.Init(GraphicsDevice);
|
||||
|
||||
GUI.Init(Content);
|
||||
|
||||
// Create a new SpriteBatch, which can be used to draw textures.
|
||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
|
||||
GUI.LoadContent(GraphicsDevice);
|
||||
|
||||
backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png");
|
||||
titleTexture = TextureLoader.FromFile("Content/UI/titleText.png");
|
||||
|
||||
guiRoot = new GUIFrame(new Rectangle(0, 0, graphicsWidth, graphicsHeight), Color.Transparent);
|
||||
guiRoot.Padding = new Vector4(40.0f, 40.0f, 40.0f, 40.0f);
|
||||
|
||||
GUIListBox infoBox = new GUIListBox(new Rectangle(0, 0, 330, 150), GUI.Style, guiRoot);
|
||||
infoBox.Visible = false;
|
||||
|
||||
crashReport = System.IO.File.ReadAllText("CrashReport.txt");
|
||||
|
||||
string wrappedText = ToolBox.WrapText(crashReport, infoBox.Rect.Width, GUI.SmallFont);
|
||||
|
||||
int lineHeight = (int)GUI.SmallFont.MeasureString(" ").Y;
|
||||
|
||||
string[] lines = wrappedText.Split('\n');
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line)) continue;
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, lineHeight),
|
||||
line, GUI.Style,
|
||||
Alignment.TopLeft, Alignment.TopLeft,
|
||||
infoBox, false, GUI.SmallFont);
|
||||
textBlock.CanBeFocused = false;
|
||||
}
|
||||
|
||||
GUIButton sendButton = new GUIButton(new Rectangle(0, 0, 100, 30), "SEND", Alignment.BottomRight, GUI.Style, guiRoot);
|
||||
//se.OnClicked = LaunchClick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UnloadContent will be called once per game and is the place to unload
|
||||
/// all content.
|
||||
/// </summary>
|
||||
protected override void UnloadContent()
|
||||
{
|
||||
// TODO: Unload any non ContentManager content here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to run logic such as updating the world,
|
||||
/// checking for collisions, gathering input, and playing audio.
|
||||
/// </summary>
|
||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||
protected override void Update(GameTime gameTime)
|
||||
{
|
||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
// TODO: Add your update logic here
|
||||
|
||||
base.Update(gameTime);
|
||||
|
||||
guiRoot.Update((float)gameTime.ElapsedGameTime.TotalMilliseconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when the game should draw itself.
|
||||
/// </summary>
|
||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
guiRoot.Draw(spriteBatch);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
private void SendReport()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
<stylecopresultscache>
|
||||
<version>12</version>
|
||||
<project key="-635107402">
|
||||
<configuration>DEBUG;TRACE;WINDOWS</configuration>
|
||||
</project>
|
||||
<sourcecode name="Game1.cs" parser="StyleCop.CSharp.CsParser">
|
||||
<timestamps>
|
||||
<styleCop>2014.04.01 10:18:24.000</styleCop>
|
||||
<settingsFile>2012.09.27 21:03:32.000</settingsFile>
|
||||
<sourceFile>2015.09.17 23:21:18.138</sourceFile>
|
||||
<parser>2014.04.01 10:18:24.000</parser>
|
||||
<StyleCop.CSharp.DocumentationRules>2014.04.01 10:18:24.000</StyleCop.CSharp.DocumentationRules>
|
||||
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||
<StyleCop.CSharp.LayoutRules>2014.04.01 10:18:24.000</StyleCop.CSharp.LayoutRules>
|
||||
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||
<StyleCop.CSharp.MaintainabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.MaintainabilityRules>
|
||||
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.NamingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.NamingRules>
|
||||
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.OrderingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.OrderingRules>
|
||||
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||
<StyleCop.CSharp.ReadabilityRules>2014.04.01 10:18:24.000</StyleCop.CSharp.ReadabilityRules>
|
||||
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||
<StyleCop.CSharp.SpacingRules>2014.04.01 10:18:24.000</StyleCop.CSharp.SpacingRules>
|
||||
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||
</timestamps>
|
||||
<violations>
|
||||
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="FileMustHaveHeader" ruleCheckId="SA1633">
|
||||
<context>The file has no header, the header Xml is invalid, or the header is not located at the top of the file.</context>
|
||||
<line>1</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||
<context>All using directives must be placed inside of the namespace.</context>
|
||||
<line>1</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||
<context>All using directives must be placed inside of the namespace.</context>
|
||||
<line>2</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||
<context>All using directives must be placed inside of the namespace.</context>
|
||||
<line>3</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||
<context>All using directives must be placed inside of the namespace.</context>
|
||||
<line>4</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||
<context>All using directives must be placed inside of the namespace.</context>
|
||||
<line>5</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.OrderingRules" rule="SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives" ruleCheckId="SA1208">
|
||||
<context>System using directives must be placed before all other using directives.</context>
|
||||
<line>5</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="CodeMustNotContainMultipleBlankLinesInARow" ruleCheckId="SA1507">
|
||||
<context>The code must not contain multiple blank lines in a row.</context>
|
||||
<line>23</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="CodeMustNotContainMultipleBlankLinesInARow" ruleCheckId="SA1507">
|
||||
<context>The code must not contain multiple blank lines in a row.</context>
|
||||
<line>24</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||
<context>The field must have a documentation header.</context>
|
||||
<line>14</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="AccessModifierMustBeDeclared" ruleCheckId="SA1400">
|
||||
<context>The field must have an access modifier.</context>
|
||||
<line>14</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||
<context>The field must have a documentation header.</context>
|
||||
<line>15</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="AccessModifierMustBeDeclared" ruleCheckId="SA1400">
|
||||
<context>The field must have an access modifier.</context>
|
||||
<line>15</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||
<context>The field must have a documentation header.</context>
|
||||
<line>17</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="AccessModifierMustBeDeclared" ruleCheckId="SA1400">
|
||||
<context>The field must have an access modifier.</context>
|
||||
<line>17</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||
<context>The field must have a documentation header.</context>
|
||||
<line>19</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="AccessModifierMustBeDeclared" ruleCheckId="SA1400">
|
||||
<context>The field must have an access modifier.</context>
|
||||
<line>19</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||
<context>The field must have a documentation header.</context>
|
||||
<line>21</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.MaintainabilityRules" rule="AccessModifierMustBeDeclared" ruleCheckId="SA1400">
|
||||
<context>The field must have an access modifier.</context>
|
||||
<line>21</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||
<context>The constructor must have a documentation header.</context>
|
||||
<line>25</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphics must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>28</line>
|
||||
<index>601</index>
|
||||
<endIndex>608</endIndex>
|
||||
<startLine>28</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>28</endLine>
|
||||
<endColumn>20</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphics must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>31</line>
|
||||
<index>708</index>
|
||||
<endIndex>715</endIndex>
|
||||
<startLine>31</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>31</endLine>
|
||||
<endColumn>20</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphics must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>32</line>
|
||||
<index>765</index>
|
||||
<endIndex>772</endIndex>
|
||||
<startLine>32</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>32</endLine>
|
||||
<endColumn>20</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphics must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>33</line>
|
||||
<index>819</index>
|
||||
<endIndex>826</endIndex>
|
||||
<startLine>33</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>33</endLine>
|
||||
<endColumn>20</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="SingleLineCommentsMustNotBeFollowedByBlankLine" ruleCheckId="SA1512">
|
||||
<context>A single-line comment must not be followed by a blank line. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.</context>
|
||||
<line>44</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="CurlyBracketsMustNotBeOmitted" ruleCheckId="SA1503">
|
||||
<context>The body of the if statement must be wrapped in opening and closing curly brackets.</context>
|
||||
<line>88</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="SingleLineCommentMustBePrecededByBlankLine" ruleCheckId="SA1515">
|
||||
<context>A single-line comment must be preceded by a blank line or another single-line comment, or must be the first item in its scope. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.</context>
|
||||
<line>99</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="ParametersMustBeOnSameLineOrSeparateLines" ruleCheckId="SA1117">
|
||||
<context>All method parameters must be placed on the same line, or each parameter must be placed on a separate line.</context>
|
||||
<line>90</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="ParameterMustFollowComma" ruleCheckId="SA1115">
|
||||
<context>The parameter must begin on the line after the previous parameter.</context>
|
||||
<line>92</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="ParameterMustFollowComma" ruleCheckId="SA1115">
|
||||
<context>The parameter must begin on the line after the previous parameter.</context>
|
||||
<line>93</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="ParameterMustFollowComma" ruleCheckId="SA1115">
|
||||
<context>The parameter must begin on the line after the previous parameter.</context>
|
||||
<line>94</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to spriteBatch must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>56</line>
|
||||
<index>1712</index>
|
||||
<endIndex>1722</endIndex>
|
||||
<startLine>56</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>56</endLine>
|
||||
<endColumn>23</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphicsWidth must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>58</line>
|
||||
<index>1774</index>
|
||||
<endIndex>1786</endIndex>
|
||||
<startLine>58</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>58</endLine>
|
||||
<endColumn>25</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphicsHeight must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>59</line>
|
||||
<index>1834</index>
|
||||
<endIndex>1847</endIndex>
|
||||
<startLine>59</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>59</endLine>
|
||||
<endColumn>26</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to GraphicsDevice must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>61</line>
|
||||
<index>1917</index>
|
||||
<endIndex>1930</endIndex>
|
||||
<startLine>61</startLine>
|
||||
<startColumn>32</startColumn>
|
||||
<endLine>61</endLine>
|
||||
<endColumn>45</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to Content must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>63</line>
|
||||
<index>1958</index>
|
||||
<endIndex>1964</endIndex>
|
||||
<startLine>63</startLine>
|
||||
<startColumn>22</startColumn>
|
||||
<endLine>63</endLine>
|
||||
<endColumn>28</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to spriteBatch must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>66</line>
|
||||
<index>2061</index>
|
||||
<endIndex>2071</endIndex>
|
||||
<startLine>66</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>66</endLine>
|
||||
<endColumn>23</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to GraphicsDevice must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>68</line>
|
||||
<index>2139</index>
|
||||
<endIndex>2152</endIndex>
|
||||
<startLine>68</startLine>
|
||||
<startColumn>29</startColumn>
|
||||
<endLine>68</endLine>
|
||||
<endColumn>42</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to backgroundTexture must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>70</line>
|
||||
<index>2171</index>
|
||||
<endIndex>2187</endIndex>
|
||||
<startLine>70</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>70</endLine>
|
||||
<endColumn>29</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to titleTexture must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>71</line>
|
||||
<index>2262</index>
|
||||
<endIndex>2273</endIndex>
|
||||
<startLine>71</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>71</endLine>
|
||||
<endColumn>24</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to guiRoot must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>73</line>
|
||||
<index>2344</index>
|
||||
<endIndex>2350</endIndex>
|
||||
<startLine>73</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>73</endLine>
|
||||
<endColumn>19</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphicsWidth must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>73</line>
|
||||
<index>2387</index>
|
||||
<endIndex>2399</endIndex>
|
||||
<startLine>73</startLine>
|
||||
<startColumn>56</startColumn>
|
||||
<endLine>73</endLine>
|
||||
<endColumn>68</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to graphicsHeight must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>73</line>
|
||||
<index>2402</index>
|
||||
<endIndex>2415</endIndex>
|
||||
<startLine>73</startLine>
|
||||
<startColumn>71</startColumn>
|
||||
<endLine>73</endLine>
|
||||
<endColumn>84</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to guiRoot must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>74</line>
|
||||
<index>2452</index>
|
||||
<endIndex>2458</endIndex>
|
||||
<startLine>74</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>74</endLine>
|
||||
<endColumn>19</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to guiRoot must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>76</line>
|
||||
<index>2616</index>
|
||||
<endIndex>2622</endIndex>
|
||||
<startLine>76</startLine>
|
||||
<startColumn>91</startColumn>
|
||||
<endLine>76</endLine>
|
||||
<endColumn>97</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to guiRoot must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>98</line>
|
||||
<index>3542</index>
|
||||
<endIndex>3548</endIndex>
|
||||
<startLine>98</startLine>
|
||||
<startColumn>122</startColumn>
|
||||
<endLine>98</endLine>
|
||||
<endColumn>128</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="UseStringEmptyForEmptyStrings" ruleCheckId="SA1122">
|
||||
<context>Use string.Empty rather than "".</context>
|
||||
<line>79</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.SpacingRules" rule="SingleLineCommentsMustBeginWithSingleSpace" ruleCheckId="SA1005">
|
||||
<context>The comment must start with a single space. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.</context>
|
||||
<line>99</line>
|
||||
<index>3565</index>
|
||||
<endIndex>3593</endIndex>
|
||||
<startLine>99</startLine>
|
||||
<startColumn>13</startColumn>
|
||||
<endLine>99</endLine>
|
||||
<endColumn>41</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="CurlyBracketsMustNotBeOmitted" ruleCheckId="SA1503">
|
||||
<context>The body of the if statement must be wrapped in opening and closing curly brackets.</context>
|
||||
<line>119</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="SingleLineCommentsMustNotBeFollowedByBlankLine" ruleCheckId="SA1512">
|
||||
<context>A single-line comment must not be followed by a blank line. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.</context>
|
||||
<line>121</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="PrefixCallsCorrectly" ruleCheckId="SA1126">
|
||||
<context>The call to Exit must begin with the 'this.', 'base.', 'object.' or 'ReporterMain.' or 'Game.' prefix to indicate the intended method call. </context>
|
||||
<line>119</line>
|
||||
<index>4396</index>
|
||||
<endIndex>4399</endIndex>
|
||||
<startLine>119</startLine>
|
||||
<startColumn>17</startColumn>
|
||||
<endLine>119</endLine>
|
||||
<endColumn>20</endColumn>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
<violation namespace="StyleCop.CSharp.LayoutRules" rule="SingleLineCommentsMustNotBeFollowedByBlankLine" ruleCheckId="SA1512">
|
||||
<context>A single-line comment must not be followed by a blank line. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.</context>
|
||||
<line>134</line>
|
||||
<warning>False</warning>
|
||||
</violation>
|
||||
</violations>
|
||||
</sourcecode>
|
||||
</stylecopresultscache>
|
||||
@@ -433,7 +433,7 @@ namespace Launcher2
|
||||
return;
|
||||
}
|
||||
|
||||
UpdaterUtil.CleanUnnecessaryFiles(latestVersionFiles);
|
||||
//UpdaterUtil.CleanUnnecessaryFiles(latestVersionFiles);
|
||||
|
||||
updateInfoText.Text = "The game was updated succesfully!";
|
||||
launchButton.Enabled = true;
|
||||
|
||||
Binary file not shown.
@@ -105,13 +105,13 @@ namespace Subsurface
|
||||
position = Vector2.Zero;
|
||||
|
||||
worldView = new Rectangle(0,0,
|
||||
Game1.GraphicsWidth,
|
||||
Game1.GraphicsHeight);
|
||||
GameMain.GraphicsWidth,
|
||||
GameMain.GraphicsHeight);
|
||||
|
||||
resolution = new Point(Game1.GraphicsWidth, Game1.GraphicsHeight);
|
||||
resolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
|
||||
viewMatrix =
|
||||
Matrix.CreateTranslation(new Vector3(Game1.GraphicsWidth / 2.0f, Game1.GraphicsHeight / 2.0f, 0));
|
||||
Matrix.CreateTranslation(new Vector3(GameMain.GraphicsWidth / 2.0f, GameMain.GraphicsHeight / 2.0f, 0));
|
||||
}
|
||||
|
||||
public Vector2 TargetPos
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace Subsurface
|
||||
|
||||
public Vector2 Position
|
||||
{
|
||||
get { return Character.AnimController.limbs[0].SimPosition; }
|
||||
get { return Character.AnimController.Limbs[0].SimPosition; }
|
||||
}
|
||||
|
||||
public Vector2 Velocity
|
||||
{
|
||||
get { return Character.AnimController.limbs[0].LinearVelocity; }
|
||||
get { return Character.AnimController.Limbs[0].LinearVelocity; }
|
||||
}
|
||||
|
||||
public AiState State
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Subsurface
|
||||
|
||||
private void UpdateDistanceAccumulator()
|
||||
{
|
||||
Limb limb = Character.AnimController.limbs[0];
|
||||
Limb limb = Character.AnimController.Limbs[0];
|
||||
distanceAccumulator += (limb.SimPosition - prevPosition).Length();
|
||||
|
||||
prevPosition = limb.body.SimPosition;
|
||||
@@ -187,7 +187,7 @@ namespace Subsurface
|
||||
//check if any of the limbs is close enough to attack the target
|
||||
if (attackingLimb == null)
|
||||
{
|
||||
foreach (Limb limb in Character.AnimController.limbs)
|
||||
foreach (Limb limb in Character.AnimController.Limbs)
|
||||
{
|
||||
if (limb.attack==null || limb.attack.Type == AttackType.None) continue;
|
||||
if (Vector2.Distance(limb.SimPosition, attackPosition) > limb.attack.Range) continue;
|
||||
@@ -210,7 +210,7 @@ namespace Subsurface
|
||||
//System.Diagnostics.Debug.WriteLine("cooldown");
|
||||
|
||||
if (selectedAiTarget.Entity is Hull ||
|
||||
Vector2.Distance(attackPosition, Character.AnimController.limbs[0].SimPosition) < ConvertUnits.ToSimUnits(500.0f))
|
||||
Vector2.Distance(attackPosition, Character.AnimController.Limbs[0].SimPosition) < ConvertUnits.ToSimUnits(500.0f))
|
||||
{
|
||||
steeringManager.SteeringSeek(attackPosition, -0.8f);
|
||||
steeringManager.SteeringAvoid(deltaTime, 1.0f);
|
||||
@@ -226,7 +226,7 @@ namespace Subsurface
|
||||
{
|
||||
targetEntity = null;
|
||||
//check if there's a wall between the target and the character
|
||||
Vector2 rayStart = Character.AnimController.limbs[0].SimPosition;
|
||||
Vector2 rayStart = Character.AnimController.Limbs[0].SimPosition;
|
||||
Vector2 rayEnd = selectedAiTarget.Position;
|
||||
Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd);
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
dist = Vector2.Distance(
|
||||
character.AnimController.limbs[0].SimPosition,
|
||||
character.AnimController.Limbs[0].SimPosition,
|
||||
target.Position);
|
||||
dist = ConvertUnits.ToDisplayUnits(dist);
|
||||
|
||||
@@ -383,7 +383,7 @@ namespace Subsurface
|
||||
|
||||
if (Math.Abs(valueModifier) > Math.Abs(targetValue) && (dist < target.SightRange * sight || dist < target.SoundRange * hearing))
|
||||
{
|
||||
Vector2 rayStart = character.AnimController.limbs[0].SimPosition;
|
||||
Vector2 rayStart = character.AnimController.Limbs[0].SimPosition;
|
||||
Vector2 rayEnd = target.Position;
|
||||
|
||||
Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd);
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Subsurface.Networking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
class AICharacter : Character
|
||||
{
|
||||
private AIController aiController;
|
||||
|
||||
public AICharacter(string file) : this(file, Vector2.Zero, null)
|
||||
{
|
||||
}
|
||||
|
||||
public AICharacter(string file, Vector2 position)
|
||||
: this(file, position, null)
|
||||
{
|
||||
}
|
||||
|
||||
public AICharacter(CharacterInfo characterInfo, WayPoint spawnPoint, bool isNetworkPlayer = false)
|
||||
: this(characterInfo.File, spawnPoint.SimPosition, characterInfo, isNetworkPlayer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public AICharacter(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false)
|
||||
: this(characterInfo.File, position, characterInfo, isNetworkPlayer)
|
||||
{
|
||||
}
|
||||
|
||||
public AICharacter(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
|
||||
: base(file, position, characterInfo, isNetworkPlayer)
|
||||
{
|
||||
aiController = new EnemyAIController(this, file);
|
||||
}
|
||||
|
||||
public override void Update(Camera cam, float deltaTime)
|
||||
{
|
||||
base.Update(cam, deltaTime);
|
||||
|
||||
if (isDead) return;
|
||||
|
||||
if (soundTimer > 0)
|
||||
{
|
||||
soundTimer -= deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySound((aiController == null) ? AIController.AiState.None : aiController.State);
|
||||
soundTimer = soundInterval;
|
||||
}
|
||||
|
||||
aiController.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
||||
{
|
||||
if (type == NetworkEventType.KillCharacter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
message.Write((float)NetTime.Now);
|
||||
|
||||
message.Write(LargeUpdateTimer <= 0);
|
||||
|
||||
message.Write(AnimController.TargetDir == Direction.Right);
|
||||
message.Write(AnimController.TargetMovement.X);
|
||||
message.Write(AnimController.TargetMovement.Y);
|
||||
|
||||
if (LargeUpdateTimer <= 0)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
message.Write(limb.body.SimPosition.X);
|
||||
message.Write(limb.body.SimPosition.Y);
|
||||
|
||||
message.Write(limb.body.Rotation);
|
||||
i++;
|
||||
}
|
||||
|
||||
message.WriteRangedSingle(MathHelper.Clamp(AnimController.StunTimer, 0.0f, 60.0f), 0.0f, 60.0f, 8);
|
||||
message.Write((byte)((health / maxHealth) * 255.0f));
|
||||
|
||||
aiController.FillNetworkData(message);
|
||||
|
||||
LargeUpdateTimer = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
message.Write(AnimController.RefLimb.SimPosition.X);
|
||||
message.Write(AnimController.RefLimb.SimPosition.Y);
|
||||
|
||||
LargeUpdateTimer = Math.Max(0, LargeUpdateTimer - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
||||
{
|
||||
if (type == NetworkEventType.KillCharacter)
|
||||
{
|
||||
Kill(true);
|
||||
return;
|
||||
}
|
||||
|
||||
float sendingTime = 0.0f;
|
||||
Vector2 targetMovement = Vector2.Zero;
|
||||
bool targetDir = false;
|
||||
|
||||
bool isLargeUpdate;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
sendingTime = message.ReadFloat();
|
||||
isLargeUpdate = message.ReadBoolean();
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (sendingTime <= LastNetworkUpdate) return;
|
||||
|
||||
try
|
||||
{
|
||||
targetDir = message.ReadBoolean();
|
||||
targetMovement.X = message.ReadFloat();
|
||||
targetMovement.Y = message.ReadFloat();
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AnimController.TargetDir = (targetDir) ? Direction.Right : Direction.Left;
|
||||
AnimController.TargetMovement = targetMovement;
|
||||
|
||||
|
||||
if (isLargeUpdate)
|
||||
{
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
Vector2 pos = Vector2.Zero, vel = Vector2.Zero;
|
||||
float rotation = 0.0f;
|
||||
|
||||
try
|
||||
{
|
||||
pos.X = message.ReadFloat();
|
||||
pos.Y = message.ReadFloat();
|
||||
|
||||
rotation = message.ReadFloat();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (limb.body != null)
|
||||
{
|
||||
limb.body.TargetVelocity = limb.body.LinearVelocity;
|
||||
limb.body.TargetPosition = pos;// +vel * (float)(deltaTime / 60.0);
|
||||
limb.body.TargetRotation = rotation;// +angularVel * (float)(deltaTime / 60.0);
|
||||
limb.body.TargetAngularVelocity = limb.body.AngularVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
float newStunTimer = 0.0f, newHealth = 0.0f;
|
||||
|
||||
try
|
||||
{
|
||||
newStunTimer = message.ReadRangedSingle(0.0f, 60.0f, 8);
|
||||
newHealth = (message.ReadByte() / 255.0f) * maxHealth;
|
||||
}
|
||||
catch { return; }
|
||||
|
||||
AnimController.StunTimer = newStunTimer;
|
||||
Health = newHealth;
|
||||
|
||||
LargeUpdateTimer = 1;
|
||||
|
||||
aiController.ReadNetworkData(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 pos = Vector2.Zero;
|
||||
try
|
||||
{
|
||||
pos.X = message.ReadFloat();
|
||||
pos.Y = message.ReadFloat();
|
||||
}
|
||||
|
||||
catch { return; }
|
||||
|
||||
|
||||
Limb torso = AnimController.GetLimb(LimbType.Torso);
|
||||
if (torso == null) torso = AnimController.GetLimb(LimbType.Head);
|
||||
torso.body.TargetPosition = pos;
|
||||
|
||||
LargeUpdateTimer = 0;
|
||||
}
|
||||
|
||||
LastNetworkUpdate = sendingTime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace Subsurface
|
||||
|
||||
if (depth > 0.0f)
|
||||
{
|
||||
Vector2 camOffset = drawPos - Game1.GameScreen.Cam.WorldViewCenter;
|
||||
Vector2 camOffset = drawPos - GameMain.GameScreen.Cam.WorldViewCenter;
|
||||
|
||||
drawPos = drawPos - camOffset * (depth / MaxDepth) * 0.05f;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ namespace Subsurface
|
||||
private Item[] selectedItems;
|
||||
|
||||
public AnimController AnimController;
|
||||
private AIController aiController;
|
||||
|
||||
private Vector2 cursorPosition;
|
||||
|
||||
@@ -246,9 +245,9 @@ namespace Subsurface
|
||||
get { return closestItem; }
|
||||
}
|
||||
|
||||
public AIController AIController
|
||||
public virtual AIController AIController
|
||||
{
|
||||
get { return aiController; }
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public bool IsDead
|
||||
@@ -258,12 +257,12 @@ namespace Subsurface
|
||||
|
||||
public override Vector2 SimPosition
|
||||
{
|
||||
get { return AnimController.limbs[0].SimPosition; }
|
||||
get { return AnimController.Limbs[0].SimPosition; }
|
||||
}
|
||||
|
||||
public Vector2 Position
|
||||
{
|
||||
get { return ConvertUnits.ToDisplayUnits(AnimController.limbs[0].SimPosition); }
|
||||
get { return ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition); }
|
||||
}
|
||||
|
||||
public Character(string file) : this(file, Vector2.Zero, null)
|
||||
@@ -332,11 +331,9 @@ namespace Subsurface
|
||||
AnimController = new FishAnimController(this, doc.Root.Element("ragdoll"));
|
||||
PressureProtection = 100.0f;
|
||||
//FishAnimController fishAnim = (FishAnimController)animController;
|
||||
|
||||
aiController = new EnemyAIController(this, file);
|
||||
}
|
||||
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
limb.body.SetTransform(position+limb.SimPosition, 0.0f);
|
||||
//limb.prevPosition = ConvertUnits.ToDisplayUnits(position);
|
||||
@@ -397,7 +394,7 @@ namespace Subsurface
|
||||
{
|
||||
if (string.IsNullOrEmpty(humanConfigFile))
|
||||
{
|
||||
var characterFiles = Game1.SelectedPackage.GetFilesOfType(ContentType.Character);
|
||||
var characterFiles = GameMain.SelectedPackage.GetFilesOfType(ContentType.Character);
|
||||
|
||||
humanConfigFile = characterFiles.Find(c => c.EndsWith("human.xml"));
|
||||
if (humanConfigFile == null)
|
||||
@@ -632,15 +629,15 @@ namespace Subsurface
|
||||
|
||||
if (moveCam)
|
||||
{
|
||||
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.limbs[0].SimPosition);
|
||||
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
||||
}
|
||||
|
||||
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
|
||||
if (Vector2.Distance(AnimController.limbs[0].SimPosition, mouseSimPos)>1.0f)
|
||||
if (Vector2.Distance(AnimController.Limbs[0].SimPosition, mouseSimPos)>1.0f)
|
||||
{
|
||||
Body body = Submarine.PickBody(AnimController.limbs[0].SimPosition, mouseSimPos);
|
||||
Body body = Submarine.PickBody(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
||||
Structure structure = null;
|
||||
if (body != null) structure = body.UserData as Structure;
|
||||
if (structure != null)
|
||||
@@ -678,7 +675,7 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(Camera cam, float deltaTime)
|
||||
public virtual void Update(Camera cam, float deltaTime)
|
||||
{
|
||||
if (isDead) return;
|
||||
|
||||
@@ -714,22 +711,13 @@ namespace Subsurface
|
||||
PressureProtection -= deltaTime*100.0f;
|
||||
}
|
||||
|
||||
if (soundTimer > 0)
|
||||
{
|
||||
soundTimer -= deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySound((aiController == null) ? AIController.AiState.None : aiController.State);
|
||||
soundTimer = soundInterval;
|
||||
}
|
||||
|
||||
|
||||
//foreach (Limb limb in animController.limbs)
|
||||
//{
|
||||
Health = health - bleeding * deltaTime;
|
||||
//}
|
||||
|
||||
if (aiController != null) aiController.Update(deltaTime);
|
||||
}
|
||||
|
||||
private void UpdateSightRange()
|
||||
@@ -738,7 +726,7 @@ namespace Subsurface
|
||||
|
||||
//distance is approximated based on the mass of the character
|
||||
//(which corresponds to size because all the characters have the same limb density)
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
aiTarget.SightRange += limb.Mass * 1000.0f;
|
||||
}
|
||||
@@ -761,7 +749,7 @@ namespace Subsurface
|
||||
|
||||
public void DrawFront(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 pos = ConvertUnits.ToDisplayUnits(AnimController.limbs[0].SimPosition);
|
||||
Vector2 pos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
if (this == Character.controlled) return;
|
||||
@@ -772,7 +760,7 @@ namespace Subsurface
|
||||
spriteBatch.DrawString(GUI.Font, Info.Name, namePos - new Vector2(1.0f, 1.0f), Color.Black);
|
||||
spriteBatch.DrawString(GUI.Font, Info.Name, namePos, Color.White);
|
||||
|
||||
if (Game1.DebugDraw)
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
spriteBatch.DrawString(GUI.Font, ID.ToString(), namePos - new Vector2(0.0f, 20.0f), Color.White);
|
||||
}
|
||||
@@ -790,9 +778,9 @@ namespace Subsurface
|
||||
if (drowningBar == null)
|
||||
{
|
||||
int width = 100, height = 20;
|
||||
drowningBar = new GUIProgressBar(new Rectangle(20, Game1.GraphicsHeight / 2, width, height), Color.Blue, 1.0f);
|
||||
drowningBar = new GUIProgressBar(new Rectangle(20, GameMain.GraphicsHeight / 2, width, height), Color.Blue, 1.0f);
|
||||
|
||||
healthBar = new GUIProgressBar(new Rectangle(20, Game1.GraphicsHeight / 2 + 30, width, height), Color.Red, 1.0f);
|
||||
healthBar = new GUIProgressBar(new Rectangle(20, GameMain.GraphicsHeight / 2 + 30, width, height), Color.Red, 1.0f);
|
||||
}
|
||||
|
||||
drowningBar.BarSize = Controlled.Oxygen / 100.0f;
|
||||
@@ -860,7 +848,7 @@ namespace Subsurface
|
||||
if (n == selectedSound && sounds[i]!=null)
|
||||
{
|
||||
sounds[i].Play(1.0f, 2000.0f,
|
||||
AnimController.limbs[0].body.FarseerBody);
|
||||
AnimController.Limbs[0].body.FarseerBody);
|
||||
Debug.WriteLine("playing: " + sounds[i]);
|
||||
return;
|
||||
}
|
||||
@@ -874,7 +862,7 @@ namespace Subsurface
|
||||
|
||||
Limb closestLimb = null;
|
||||
float closestDistance = 0.0f;
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
float distance = Vector2.Distance(position, limb.SimPosition);
|
||||
if (closestLimb == null || distance < closestDistance)
|
||||
@@ -915,7 +903,7 @@ namespace Subsurface
|
||||
|
||||
health = 0.0f;
|
||||
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
Vector2 diff = centerOfMass - limb.SimPosition;
|
||||
if (diff == Vector2.Zero) continue;
|
||||
@@ -927,12 +915,12 @@ namespace Subsurface
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Particle p = Game1.ParticleManager.CreateParticle("waterblood",
|
||||
Particle p = GameMain.ParticleManager.CreateParticle("waterblood",
|
||||
centerOfMass + Rand.Vector(50.0f),
|
||||
Vector2.Zero);
|
||||
if (p!=null) p.Size *= 2.0f;
|
||||
|
||||
Game1.ParticleManager.CreateParticle("bubbles",
|
||||
GameMain.ParticleManager.CreateParticle("bubbles",
|
||||
centerOfMass + Rand.Vector(50.0f),
|
||||
new Vector2(Rand.Range(-50f, 50f), Rand.Range(-100f,50f)));
|
||||
}
|
||||
@@ -949,20 +937,22 @@ namespace Subsurface
|
||||
float dimDuration = 8.0f;
|
||||
float timer = 0.0f;
|
||||
|
||||
Color prevAmbientLight = Game1.LightManager.AmbientLight;
|
||||
Color prevAmbientLight = GameMain.LightManager.AmbientLight;
|
||||
|
||||
while (timer < dimDuration)
|
||||
{
|
||||
AnimController.UpdateAnim(1.0f / 60.0f);
|
||||
timer += 1.0f / 60.0f;
|
||||
|
||||
if (cam != null)
|
||||
if (Character.controlled == this)
|
||||
{
|
||||
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.limbs[0].SimPosition);
|
||||
cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
if (cam != null)
|
||||
{
|
||||
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
|
||||
cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
|
||||
Game1.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, Color.DarkGray, timer / dimDuration);
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, Color.DarkGray, timer / dimDuration);
|
||||
}
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
@@ -977,7 +967,7 @@ namespace Subsurface
|
||||
{
|
||||
lerpLightBack = Math.Min(lerpLightBack+0.05f,1.0f);
|
||||
|
||||
Game1.LightManager.AmbientLight = Color.Lerp(Color.DarkGray, prevAmbientLight, lerpLightBack);
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(Color.DarkGray, prevAmbientLight, lerpLightBack);
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
@@ -989,7 +979,7 @@ namespace Subsurface
|
||||
if (isDead) return;
|
||||
|
||||
//if the game is run by a client, characters are only killed when the server says so
|
||||
if (Game1.Client != null)
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
if (networkMessage)
|
||||
{
|
||||
@@ -1001,7 +991,7 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
CoroutineManager.StartCoroutine(DeathAnim(Game1.GameScreen.Cam));
|
||||
CoroutineManager.StartCoroutine(DeathAnim(GameMain.GameScreen.Cam));
|
||||
|
||||
health = 0.0f;
|
||||
|
||||
@@ -1017,7 +1007,7 @@ namespace Subsurface
|
||||
aiTarget.Remove();
|
||||
aiTarget = null;
|
||||
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
if (limb.pullJoint == null) continue;
|
||||
limb.pullJoint.Enabled = false;
|
||||
@@ -1029,14 +1019,14 @@ namespace Subsurface
|
||||
joint.MaxMotorTorque = 0.0f;
|
||||
}
|
||||
|
||||
if (Game1.Server != null)
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, false);
|
||||
}
|
||||
|
||||
if (Game1.GameSession != null)
|
||||
if (GameMain.GameSession != null)
|
||||
{
|
||||
Game1.GameSession.KillCharacter(this);
|
||||
GameMain.GameSession.KillCharacter(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1053,16 +1043,21 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
var hasInputs = (GetInputState(InputType.Left) ||
|
||||
GetInputState(InputType.Right) ||
|
||||
GetInputState(InputType.Up) ||
|
||||
GetInputState(InputType.Down) ||
|
||||
GetInputState(InputType.ActionHeld) ||
|
||||
GetInputState(InputType.SecondaryHeld));
|
||||
var hasInputs =
|
||||
(GetInputState(InputType.Left) ||
|
||||
GetInputState(InputType.Right) ||
|
||||
GetInputState(InputType.Up) ||
|
||||
GetInputState(InputType.Down) ||
|
||||
GetInputState(InputType.ActionHeld) ||
|
||||
GetInputState(InputType.SecondaryHeld));
|
||||
|
||||
message.Write(hasInputs || LargeUpdateTimer <= 0);
|
||||
|
||||
message.Write((float)NetTime.Now);
|
||||
|
||||
// Write byte = move direction
|
||||
//message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -10.0f, 10.0f), -10.0f, 10.0f, 8);
|
||||
//message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.Y, -10.0f, 10.0f), -10.0f, 10.0f, 8);
|
||||
|
||||
message.Write(keys[(int)InputType.ActionHeld].Dequeue);
|
||||
message.Write(keys[(int)InputType.SecondaryHeld].Dequeue);
|
||||
@@ -1074,27 +1069,16 @@ namespace Subsurface
|
||||
message.Write(keys[(int)InputType.Down].Dequeue);
|
||||
|
||||
message.Write(keys[(int)InputType.Run].Dequeue);
|
||||
|
||||
// Write byte = move direction
|
||||
//message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -10.0f, 10.0f), -10.0f, 10.0f, 8);
|
||||
//message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.Y, -10.0f, 10.0f), -10.0f, 10.0f, 8);
|
||||
|
||||
if (aiController==null)
|
||||
{
|
||||
message.Write(cursorPosition.X);
|
||||
message.Write(cursorPosition.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
message.Write(AnimController.TargetDir == Direction.Right);
|
||||
}
|
||||
message.Write(cursorPosition.X);
|
||||
message.Write(cursorPosition.Y);
|
||||
|
||||
message.Write(LargeUpdateTimer <= 0);
|
||||
|
||||
if (LargeUpdateTimer<=0)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
message.Write(limb.body.SimPosition.X);
|
||||
message.Write(limb.body.SimPosition.Y);
|
||||
@@ -1110,8 +1094,6 @@ namespace Subsurface
|
||||
message.WriteRangedSingle(MathHelper.Clamp(AnimController.StunTimer,0.0f,60.0f), 0.0f, 60.0f, 8);
|
||||
message.Write((byte)((health/maxHealth)*255.0f));
|
||||
|
||||
if (aiController != null) aiController.FillNetworkData(message);
|
||||
|
||||
LargeUpdateTimer = 10;
|
||||
}
|
||||
else
|
||||
@@ -1150,10 +1132,10 @@ namespace Subsurface
|
||||
else if (type == NetworkEventType.KillCharacter)
|
||||
{
|
||||
Kill(true);
|
||||
if (Game1.NetworkMember != null && controlled == this)
|
||||
if (GameMain.NetworkMember != null && controlled == this)
|
||||
{
|
||||
Game1.Client.AddChatMessage("YOU HAVE DIED. Your chat messages will only be visible to other dead players.", ChatMessageType.Dead);
|
||||
Game1.LightManager.LosEnabled = false;
|
||||
GameMain.Client.AddChatMessage("YOU HAVE DIED. Your chat messages will only be visible to other dead players.", ChatMessageType.Dead);
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1161,8 +1143,6 @@ namespace Subsurface
|
||||
bool actionKeyState = false;
|
||||
bool secondaryKeyState = false;
|
||||
float sendingTime = 0.0f;
|
||||
//Vector2 targetMovement = Vector2.Zero;
|
||||
bool targetDir = false;
|
||||
Vector2 cursorPos = Vector2.Zero;
|
||||
|
||||
bool leftKeyState = false, rightKeyState = false;
|
||||
@@ -1211,37 +1191,26 @@ namespace Subsurface
|
||||
keys[(int)InputType.Down].State = downKeyState;
|
||||
|
||||
keys[(int)InputType.Run].State = runState;
|
||||
|
||||
|
||||
bool isLargeUpdate;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (aiController == null)
|
||||
{
|
||||
cursorPos = new Vector2(
|
||||
message.ReadFloat(),
|
||||
message.ReadFloat());
|
||||
}
|
||||
else
|
||||
{
|
||||
targetDir = message.ReadBoolean();
|
||||
}
|
||||
cursorPos = new Vector2(
|
||||
message.ReadFloat(),
|
||||
message.ReadFloat());
|
||||
isLargeUpdate = message.ReadBoolean();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (aiController == null)
|
||||
|
||||
cursorPosition = cursorPos;
|
||||
|
||||
if (isLargeUpdate)
|
||||
{
|
||||
cursorPosition = cursorPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnimController.TargetDir = (targetDir) ? Direction.Right : Direction.Left;
|
||||
}
|
||||
|
||||
if (message.ReadBoolean())
|
||||
{
|
||||
foreach (Limb limb in AnimController.limbs)
|
||||
foreach (Limb limb in AnimController.Limbs)
|
||||
{
|
||||
Vector2 pos = Vector2.Zero, vel = Vector2.Zero;
|
||||
float rotation = 0.0f;
|
||||
@@ -1285,8 +1254,6 @@ namespace Subsurface
|
||||
Health = newHealth;
|
||||
|
||||
LargeUpdateTimer = 1;
|
||||
|
||||
if (aiController != null) aiController.ReadNetworkData(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1319,7 +1286,7 @@ namespace Subsurface
|
||||
|
||||
if (controlled == this) controlled = null;
|
||||
|
||||
if (Game1.Client!=null && Game1.Client.Character == this) Game1.Client.Character = null;
|
||||
if (GameMain.Client!=null && GameMain.Client.Character == this) GameMain.Client.Character = null;
|
||||
|
||||
if (inventory != null) inventory.Remove();
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Subsurface
|
||||
{
|
||||
if (character.IsDead)
|
||||
{
|
||||
UpdateStruggling(deltaTime);
|
||||
UpdateDying(deltaTime);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Subsurface
|
||||
|
||||
if (stunTimer>0.0f)
|
||||
{
|
||||
UpdateStruggling(deltaTime);
|
||||
//UpdateStruggling(deltaTime);
|
||||
stunTimer -= deltaTime;
|
||||
return;
|
||||
}
|
||||
@@ -185,18 +185,18 @@ namespace Subsurface
|
||||
if (!inWater) steerForce.Y = 0.0f;
|
||||
}
|
||||
|
||||
for (int i = 0; i < limbs.Count(); i++)
|
||||
for (int i = 0; i < Limbs.Count(); i++)
|
||||
{
|
||||
if (steerForce!=Vector2.Zero)
|
||||
limbs[i].body.ApplyForce(steerForce * limbs[i].SteerForce * limbs[i].Mass);
|
||||
Limbs[i].body.ApplyForce(steerForce * Limbs[i].SteerForce * Limbs[i].Mass);
|
||||
|
||||
if (limbs[i].type != LimbType.Torso) continue;
|
||||
if (Limbs[i].type != LimbType.Torso) continue;
|
||||
|
||||
float dist = (limbs[0].SimPosition - limbs[i].SimPosition).Length();
|
||||
float dist = (Limbs[0].SimPosition - Limbs[i].SimPosition).Length();
|
||||
|
||||
Vector2 limbPos = limbs[0].SimPosition - Vector2.Normalize(movement) * dist;
|
||||
Vector2 limbPos = Limbs[0].SimPosition - Vector2.Normalize(movement) * dist;
|
||||
|
||||
limbs[i].body.ApplyForce(((limbPos - limbs[i].SimPosition) * 3.0f - limbs[i].LinearVelocity * 3.0f) * limbs[i].Mass);
|
||||
Limbs[i].body.ApplyForce(((limbPos - Limbs[i].SimPosition) * 3.0f - Limbs[i].LinearVelocity * 3.0f) * Limbs[i].Mass);
|
||||
}
|
||||
|
||||
if (!inWater)
|
||||
@@ -205,7 +205,7 @@ namespace Subsurface
|
||||
}
|
||||
else
|
||||
{
|
||||
floorY = limbs[0].SimPosition.Y;
|
||||
floorY = Limbs[0].SimPosition.Y;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace Subsurface
|
||||
//out whether the ragdoll is standing on ground
|
||||
float closestFraction = 1;
|
||||
//Structure closestStructure = null;
|
||||
Game1.World.RayCast((fixture, point, normal, fraction) =>
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
//other limbs and bodies with no collision detection are ignored
|
||||
if (fixture == null ||
|
||||
@@ -301,7 +301,7 @@ namespace Subsurface
|
||||
(float)Math.Cos(walkPos) * stepSize.X * 3.0f,
|
||||
(float)Math.Sin(walkPos) * stepSize.Y * 2.0f);
|
||||
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
switch (limb.type)
|
||||
{
|
||||
@@ -343,7 +343,7 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateStruggling(float deltaTime)
|
||||
void UpdateDying(float deltaTime)
|
||||
{
|
||||
Limb head = GetLimb(LimbType.Head);
|
||||
Limb tail = GetLimb(LimbType.Tail);
|
||||
@@ -355,7 +355,7 @@ namespace Subsurface
|
||||
|
||||
Vector2 centerOfMass = GetCenterOfMass();
|
||||
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
if (limb.type == LimbType.Head || limb.type == LimbType.Tail) continue;
|
||||
|
||||
@@ -367,7 +367,7 @@ namespace Subsurface
|
||||
{
|
||||
base.Flip();
|
||||
|
||||
foreach (Limb l in limbs)
|
||||
foreach (Limb l in Limbs)
|
||||
{
|
||||
if (!l.DoesFlip) continue;
|
||||
|
||||
@@ -378,22 +378,22 @@ namespace Subsurface
|
||||
|
||||
private void Mirror()
|
||||
{
|
||||
float leftX = limbs[0].SimPosition.X, rightX = limbs[0].SimPosition.X;
|
||||
for (int i = 1; i < limbs.Count(); i++ )
|
||||
float leftX = Limbs[0].SimPosition.X, rightX = Limbs[0].SimPosition.X;
|
||||
for (int i = 1; i < Limbs.Count(); i++ )
|
||||
{
|
||||
if (limbs[i].SimPosition.X < leftX)
|
||||
if (Limbs[i].SimPosition.X < leftX)
|
||||
{
|
||||
leftX = limbs[i].SimPosition.X;
|
||||
leftX = Limbs[i].SimPosition.X;
|
||||
}
|
||||
else if (limbs[i].SimPosition.X > rightX)
|
||||
else if (Limbs[i].SimPosition.X > rightX)
|
||||
{
|
||||
rightX = limbs[i].SimPosition.X;
|
||||
rightX = Limbs[i].SimPosition.X;
|
||||
}
|
||||
}
|
||||
|
||||
float midX = GetCenterOfMass().X;
|
||||
|
||||
foreach (Limb l in limbs)
|
||||
foreach (Limb l in Limbs)
|
||||
{
|
||||
Vector2 newPos = new Vector2(midX - (l.SimPosition.X - midX), l.SimPosition.Y);
|
||||
|
||||
|
||||
@@ -30,11 +30,7 @@ namespace Subsurface
|
||||
|
||||
public override void UpdateAnim(float deltaTime)
|
||||
{
|
||||
if (character.IsDead)
|
||||
{
|
||||
UpdateStruggling();
|
||||
return;
|
||||
}
|
||||
if (character.IsDead) return;
|
||||
|
||||
Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition;
|
||||
|
||||
@@ -49,7 +45,7 @@ namespace Subsurface
|
||||
//out whether the ragdoll is standing on ground
|
||||
float closestFraction = 1;
|
||||
Structure closestStructure = null;
|
||||
Game1.World.RayCast((fixture, point, normal, fraction) =>
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
switch (fixture.CollisionCategories)
|
||||
{
|
||||
@@ -136,7 +132,7 @@ namespace Subsurface
|
||||
|
||||
if (stunTimer > 0)
|
||||
{
|
||||
UpdateStruggling();
|
||||
//UpdateStruggling();
|
||||
stunTimer -= deltaTime;
|
||||
return;
|
||||
}
|
||||
@@ -159,7 +155,7 @@ namespace Subsurface
|
||||
|
||||
if (TargetDir != dir) Flip();
|
||||
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
limb.Disabled = false;
|
||||
}
|
||||
@@ -223,7 +219,7 @@ namespace Subsurface
|
||||
//place the anchors of the head and the torso to make the ragdoll stand
|
||||
if (onGround && LowestLimb != null && (LowestLimb.SimPosition.Y-floorY < 0.5f || stairs != null) && head !=null)
|
||||
{
|
||||
getUpSpeed = Math.Max(getUpSpeed * (head.SimPosition.Y - colliderPos.Y), 0.25f);
|
||||
getUpSpeed = getUpSpeed * (head.SimPosition.Y - colliderPos.Y);//, 0.25f);
|
||||
|
||||
if (stairs != null)
|
||||
{
|
||||
@@ -325,8 +321,7 @@ namespace Subsurface
|
||||
posAdditon.Y += 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!rightHand.Disabled)
|
||||
{
|
||||
rightHand.body.ApplyTorque(walkPosY * runningModifier * Dir);
|
||||
@@ -676,26 +671,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UpdateStruggling()
|
||||
{
|
||||
Limb leftLeg = GetLimb(LimbType.LeftFoot);
|
||||
Limb rightLeg = GetLimb(LimbType.RightFoot);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
|
||||
//walkPos += 0.2f;
|
||||
|
||||
if (inWater) return;
|
||||
|
||||
HandIK(GetLimb(LimbType.RightHand), GetLimb(LimbType.Head).SimPosition,0.1f);
|
||||
HandIK(GetLimb(LimbType.LeftHand), GetLimb(LimbType.Head).SimPosition,0.1f);
|
||||
|
||||
//Vector2 footPos = torso.body.Position+ new Vector2(TorsoPosition*Dir,0.0f);
|
||||
|
||||
//MoveLimb(leftLeg, footPos, 0.7f);
|
||||
//MoveLimb(rightLeg, footPos, 0.7f);
|
||||
}
|
||||
|
||||
|
||||
//float punchTimer;
|
||||
//bool punching;
|
||||
|
||||
@@ -885,7 +861,7 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Limb l in limbs)
|
||||
foreach (Limb l in Limbs)
|
||||
{
|
||||
switch (l.type)
|
||||
{
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace Subsurface
|
||||
pullJoint.Enabled = false;
|
||||
pullJoint.MaxForce = 150.0f * body.Mass;
|
||||
|
||||
Game1.World.AddJoint(pullJoint);
|
||||
GameMain.World.AddJoint(pullJoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -325,14 +325,14 @@ namespace Subsurface
|
||||
Vector2 particleVel = SimPosition - position;
|
||||
if (particleVel != Vector2.Zero) particleVel = Vector2.Normalize(particleVel);
|
||||
|
||||
Game1.ParticleManager.CreateParticle("blood",
|
||||
GameMain.ParticleManager.CreateParticle("blood",
|
||||
Position,
|
||||
particleVel * Rand.Range(100.0f, 300.0f));
|
||||
}
|
||||
|
||||
for (int i = 0; i < bloodAmount / 2; i++)
|
||||
{
|
||||
Game1.ParticleManager.CreateParticle("waterblood", Position, Vector2.Zero);
|
||||
GameMain.ParticleManager.CreateParticle("waterblood", Position, Vector2.Zero);
|
||||
}
|
||||
|
||||
return new AttackResult(amount, bleedingAmount, hitArmor);
|
||||
@@ -343,7 +343,7 @@ namespace Subsurface
|
||||
if (LinearVelocity.X>100.0f)
|
||||
{
|
||||
DebugConsole.ThrowError("CHARACTER EXPLODED");
|
||||
foreach (Limb limb in character.AnimController.limbs)
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
{
|
||||
limb.body.ResetDynamics();
|
||||
limb.body.SetTransform(body.SimPosition, 0.0f);
|
||||
@@ -421,7 +421,7 @@ namespace Subsurface
|
||||
1.0f, spriteEffect, sprite.Depth - 0.000001f);
|
||||
}
|
||||
|
||||
if (!Game1.DebugDraw) return;
|
||||
if (!GameMain.DebugDraw) return;
|
||||
|
||||
if (pullJoint!=null)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Subsurface
|
||||
|
||||
protected Hull currentHull;
|
||||
|
||||
public Limb[] limbs;
|
||||
public Limb[] Limbs;
|
||||
private Dictionary<LimbType, Limb> limbDictionary;
|
||||
public RevoluteJoint[] limbJoints;
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Subsurface
|
||||
if (ignorePlatforms == value) return;
|
||||
ignorePlatforms = value;
|
||||
|
||||
foreach (Limb l in limbs)
|
||||
foreach (Limb l in Limbs)
|
||||
{
|
||||
if (l.ignoreCollisions) continue;
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Subsurface
|
||||
dir = Direction.Right;
|
||||
|
||||
//int limbAmount = ;
|
||||
limbs = new Limb[element.Elements("limb").Count()];
|
||||
Limbs = new Limb[element.Elements("limb").Count()];
|
||||
limbJoints = new RevoluteJoint[element.Elements("joint").Count()];
|
||||
limbDictionary = new Dictionary<LimbType, Limb>();
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Subsurface
|
||||
|
||||
limb.body.FarseerBody.OnCollision += OnLimbCollision;
|
||||
|
||||
limbs[ID] = limb;
|
||||
Limbs[ID] = limb;
|
||||
Mass += limb.Mass;
|
||||
if (!limbDictionary.ContainsKey(limb.type)) limbDictionary.Add(limb.type, limb);
|
||||
break;
|
||||
@@ -207,7 +207,7 @@ namespace Subsurface
|
||||
Vector2 limb2Pos = ToolBox.GetAttributeVector2(subElement, "limb2anchor", Vector2.Zero);
|
||||
limb2Pos = ConvertUnits.ToSimUnits(limb2Pos);
|
||||
|
||||
RevoluteJoint joint = new RevoluteJoint(limbs[limb1ID].body.FarseerBody, limbs[limb2ID].body.FarseerBody, limb1Pos, limb2Pos);
|
||||
RevoluteJoint joint = new RevoluteJoint(Limbs[limb1ID].body.FarseerBody, Limbs[limb2ID].body.FarseerBody, limb1Pos, limb2Pos);
|
||||
|
||||
joint.CollideConnected = false;
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Subsurface
|
||||
joint.MotorEnabled = true;
|
||||
joint.MaxMotorTorque = 0.25f;
|
||||
|
||||
Game1.World.AddJoint(joint);
|
||||
GameMain.World.AddJoint(joint);
|
||||
|
||||
for (int i = 0; i < limbJoints.Length; i++ )
|
||||
{
|
||||
@@ -257,7 +257,7 @@ namespace Subsurface
|
||||
startDepth+=increment;
|
||||
}
|
||||
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.0001f;
|
||||
}
|
||||
@@ -328,16 +328,16 @@ namespace Subsurface
|
||||
Vector2 normal = contact.Manifold.LocalNormal;
|
||||
|
||||
Vector2 avgVelocity = Vector2.Zero;
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
avgVelocity += limb.LinearVelocity;
|
||||
}
|
||||
|
||||
avgVelocity = avgVelocity / limbs.Count();
|
||||
avgVelocity = avgVelocity / Limbs.Count();
|
||||
|
||||
float impact = Vector2.Dot((f1.Body.LinearVelocity + avgVelocity) / 2.0f, -normal);
|
||||
|
||||
if (Game1.Server != null) impact = impact / 2.0f;
|
||||
if (GameMain.Server != null) impact = impact / 2.0f;
|
||||
|
||||
Limb l = (Limb)f1.Body.UserData;
|
||||
|
||||
@@ -350,20 +350,20 @@ namespace Subsurface
|
||||
|
||||
AmbientSoundManager.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, l.body.FarseerBody);
|
||||
|
||||
if (Character.Controlled == character) Game1.GameScreen.Cam.Shake = strongestImpact;
|
||||
if (Character.Controlled == character) GameMain.GameScreen.Cam.Shake = strongestImpact;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
limb.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
if (!Game1.DebugDraw) return;
|
||||
if (!GameMain.DebugDraw) return;
|
||||
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
|
||||
if (limb.pullJoint != null)
|
||||
@@ -420,29 +420,29 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < limbs.Count(); i++)
|
||||
for (int i = 0; i < Limbs.Count(); i++)
|
||||
{
|
||||
if (limbs[i] == null) continue;
|
||||
if (Limbs[i] == null) continue;
|
||||
|
||||
Vector2 spriteOrigin = limbs[i].sprite.Origin;
|
||||
spriteOrigin.X = limbs[i].sprite.SourceRect.Width - spriteOrigin.X;
|
||||
limbs[i].sprite.Origin = spriteOrigin;
|
||||
Vector2 spriteOrigin = Limbs[i].sprite.Origin;
|
||||
spriteOrigin.X = Limbs[i].sprite.SourceRect.Width - spriteOrigin.X;
|
||||
Limbs[i].sprite.Origin = spriteOrigin;
|
||||
|
||||
limbs[i].Dir = Dir;
|
||||
Limbs[i].Dir = Dir;
|
||||
|
||||
if (limbs[i].pullJoint == null) continue;
|
||||
if (Limbs[i].pullJoint == null) continue;
|
||||
|
||||
limbs[i].pullJoint.LocalAnchorA =
|
||||
Limbs[i].pullJoint.LocalAnchorA =
|
||||
new Vector2(
|
||||
-limbs[i].pullJoint.LocalAnchorA.X,
|
||||
limbs[i].pullJoint.LocalAnchorA.Y);
|
||||
-Limbs[i].pullJoint.LocalAnchorA.X,
|
||||
Limbs[i].pullJoint.LocalAnchorA.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 GetCenterOfMass()
|
||||
{
|
||||
Vector2 centerOfMass = Vector2.Zero;
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
centerOfMass += limb.Mass * limb.SimPosition;
|
||||
}
|
||||
@@ -465,11 +465,11 @@ namespace Subsurface
|
||||
|
||||
public void ResetPullJoints()
|
||||
{
|
||||
for (int i = 0; i < limbs.Count(); i++)
|
||||
for (int i = 0; i < Limbs.Count(); i++)
|
||||
{
|
||||
if (limbs[i] == null) continue;
|
||||
if (limbs[i].pullJoint == null) continue;
|
||||
limbs[i].pullJoint.Enabled = false;
|
||||
if (Limbs[i] == null) continue;
|
||||
if (Limbs[i].pullJoint == null) continue;
|
||||
Limbs[i].pullJoint.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ namespace Subsurface
|
||||
|
||||
}
|
||||
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
Vector2 limbPosition = ConvertUnits.ToDisplayUnits(limb.SimPosition);
|
||||
|
||||
@@ -562,7 +562,7 @@ namespace Subsurface
|
||||
{
|
||||
|
||||
//create a splash particle
|
||||
Subsurface.Particles.Particle splash = Game1.ParticleManager.CreateParticle("watersplash",
|
||||
Subsurface.Particles.Particle splash = GameMain.ParticleManager.CreateParticle("watersplash",
|
||||
new Vector2(limb.Position.X, limbHull.Surface),
|
||||
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 10.0f)),
|
||||
0.0f);
|
||||
@@ -572,7 +572,7 @@ namespace Subsurface
|
||||
// limbHull.Rect.Y,
|
||||
// limbHull.Rect.Y - limbHull.Rect.Height));
|
||||
|
||||
Game1.ParticleManager.CreateParticle("bubbles",
|
||||
GameMain.ParticleManager.CreateParticle("bubbles",
|
||||
new Vector2(limb.Position.X, limbHull.Surface),
|
||||
limb.LinearVelocity*0.001f,
|
||||
0.0f);
|
||||
@@ -629,7 +629,7 @@ namespace Subsurface
|
||||
{
|
||||
if (inWater)
|
||||
{
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
if (limb.body.TargetPosition == Vector2.Zero) continue;
|
||||
|
||||
@@ -647,7 +647,7 @@ namespace Subsurface
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("reset ragdoll limb positions");
|
||||
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
if (limb.body.TargetPosition == Vector2.Zero) continue;
|
||||
|
||||
@@ -663,7 +663,7 @@ namespace Subsurface
|
||||
|
||||
private Vector2 GetFlowForce()
|
||||
{
|
||||
Vector2 limbPos = ConvertUnits.ToDisplayUnits(limbs[0].SimPosition);
|
||||
Vector2 limbPos = ConvertUnits.ToDisplayUnits(Limbs[0].SimPosition);
|
||||
|
||||
Vector2 force = Vector2.Zero;
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
@@ -693,7 +693,7 @@ namespace Subsurface
|
||||
{
|
||||
//find the lowest limb
|
||||
lowestLimb = null;
|
||||
foreach (Limb limb in limbs)
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
if (lowestLimb == null)
|
||||
lowestLimb = limb;
|
||||
@@ -704,10 +704,10 @@ namespace Subsurface
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
foreach (Limb l in limbs) l.Remove();
|
||||
foreach (Limb l in Limbs) l.Remove();
|
||||
foreach (RevoluteJoint joint in limbJoints)
|
||||
{
|
||||
Game1.World.RemoveJoint(joint);
|
||||
GameMain.World.RemoveJoint(joint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Subsurface
|
||||
NewMessage("Press F3 to open/close the debug console", Color.Green);
|
||||
}
|
||||
|
||||
public static void Update(Game1 game, float deltaTime)
|
||||
public static void Update(GameMain game, float deltaTime)
|
||||
{
|
||||
if (PlayerInput.KeyHit(Keys.F3))
|
||||
{
|
||||
@@ -138,7 +138,7 @@ namespace Subsurface
|
||||
textBox.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public static void ExecuteCommand(string command, Game1 game)
|
||||
public static void ExecuteCommand(string command, GameMain game)
|
||||
{
|
||||
#if !DEBUG
|
||||
if (Game1.Client!=null)
|
||||
@@ -163,9 +163,9 @@ namespace Subsurface
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||
Character.Controlled = new Character(Character.HumanConfigFile, (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
if (Game1.GameSession != null)
|
||||
if (GameMain.GameSession != null)
|
||||
{
|
||||
SinglePlayerMode mode = Game1.GameSession.gameMode as SinglePlayerMode;
|
||||
SinglePlayerMode mode = GameMain.GameSession.gameMode as SinglePlayerMode;
|
||||
if (mode == null) break;
|
||||
mode.CrewManager.AddCharacter(Character.Controlled);
|
||||
mode.CrewManager.SelectCharacter(null, Character.Controlled);
|
||||
@@ -174,7 +174,7 @@ namespace Subsurface
|
||||
else
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||
new Character("Content/Characters/" + commands[1] + "/" + commands[1] + ".xml", (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
new AICharacter("Content/Characters/" + commands[1] + "/" + commands[1] + ".xml", (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -183,50 +183,50 @@ namespace Subsurface
|
||||
// Game1.NetworkMember = new GameServer();
|
||||
// break;
|
||||
case "kick":
|
||||
if (Game1.Server == null) break;
|
||||
Game1.Server.KickPlayer(commands[1]);
|
||||
if (GameMain.Server == null) break;
|
||||
GameMain.Server.KickPlayer(commands[1]);
|
||||
break;
|
||||
case "startclient":
|
||||
if (commands.Length == 1) return;
|
||||
if (Game1.Client == null)
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
Game1.NetworkMember = new GameClient("Name");
|
||||
Game1.Client.ConnectToServer(commands[1]);
|
||||
GameMain.NetworkMember = new GameClient("Name");
|
||||
GameMain.Client.ConnectToServer(commands[1]);
|
||||
}
|
||||
break;
|
||||
case "mainmenuscreen":
|
||||
case "mainmenu":
|
||||
case "menu":
|
||||
Game1.MainMenuScreen.Select();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
break;
|
||||
case "gamescreen":
|
||||
case "game":
|
||||
Game1.GameScreen.Select();
|
||||
GameMain.GameScreen.Select();
|
||||
break;
|
||||
case "editmapscreen":
|
||||
case "editmap":
|
||||
case "edit":
|
||||
Game1.EditMapScreen.Select();
|
||||
GameMain.EditMapScreen.Select();
|
||||
break;
|
||||
case "editcharacter":
|
||||
case "editchar":
|
||||
Game1.EditCharacterScreen.Select();
|
||||
GameMain.EditCharacterScreen.Select();
|
||||
break;
|
||||
case "freecamera":
|
||||
case "freecam":
|
||||
Character.Controlled = null;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
break;
|
||||
case "editwater":
|
||||
case "water":
|
||||
if (Game1.Client== null)
|
||||
if (GameMain.Client== null)
|
||||
{
|
||||
Hull.EditWater = !Hull.EditWater;
|
||||
}
|
||||
break;
|
||||
case "generatelevel":
|
||||
Game1.Level = new Level("asdf", 50.0f, 500,500, 50);
|
||||
Game1.Level.Generate(100.0f);
|
||||
GameMain.Level = new Level("asdf", 50.0f, 500,500, 50);
|
||||
GameMain.Level.Generate(100.0f);
|
||||
break;
|
||||
case "fixitems":
|
||||
foreach (Item it in Item.itemList)
|
||||
@@ -245,18 +245,18 @@ namespace Subsurface
|
||||
}
|
||||
break;
|
||||
case "shake":
|
||||
Game1.GameScreen.Cam.Shake = 10.0f;
|
||||
GameMain.GameScreen.Cam.Shake = 10.0f;
|
||||
break;
|
||||
case "losenabled":
|
||||
case "los":
|
||||
case "drawlos":
|
||||
Game1.LightManager.LosEnabled = !Game1.LightManager.LosEnabled;
|
||||
GameMain.LightManager.LosEnabled = !GameMain.LightManager.LosEnabled;
|
||||
break;
|
||||
case "lighting":
|
||||
case "lightingenabled":
|
||||
case "light":
|
||||
case "lights":
|
||||
Game1.LightManager.LightingEnabled = !Game1.LightManager.LightingEnabled;
|
||||
GameMain.LightManager.LightingEnabled = !GameMain.LightManager.LightingEnabled;
|
||||
break;
|
||||
case "oxygen":
|
||||
case "air":
|
||||
@@ -270,7 +270,7 @@ namespace Subsurface
|
||||
break;
|
||||
case "lobbyscreen":
|
||||
case "lobby":
|
||||
Game1.LobbyScreen.Select();
|
||||
GameMain.LobbyScreen.Select();
|
||||
break;
|
||||
case "savemap":
|
||||
case "savesub":
|
||||
@@ -297,7 +297,7 @@ namespace Subsurface
|
||||
case "debugdraw":
|
||||
//Hull.DebugDraw = !Hull.DebugDraw;
|
||||
//Ragdoll.DebugDraw = !Ragdoll.DebugDraw;
|
||||
Game1.DebugDraw = !Game1.DebugDraw;
|
||||
GameMain.DebugDraw = !GameMain.DebugDraw;
|
||||
break;
|
||||
default:
|
||||
NewMessage("Command not found", Color.Red);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Subsurface
|
||||
Vector2 position = (randomWayPoint == null) ? Vector2.Zero : randomWayPoint.SimPosition;
|
||||
position.X += Rand.Range(-0.5f, 0.5f);
|
||||
position.Y += Rand.Range(-0.5f, 0.5f);
|
||||
monsters[i] = new Character(characterFile, position);
|
||||
monsters[i] = new AICharacter(characterFile, position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace Subsurface
|
||||
|
||||
public void GiveReward()
|
||||
{
|
||||
var mode = Game1.GameSession.gameMode as SinglePlayerMode;
|
||||
var mode = GameMain.GameSession.gameMode as SinglePlayerMode;
|
||||
mode.Money += reward;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(successMessage))
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace Subsurface
|
||||
|
||||
public Task(float priority, string name)
|
||||
{
|
||||
if (Game1.GameSession==null || Game1.GameSession.taskManager == null) return;
|
||||
if (GameMain.GameSession==null || GameMain.GameSession.taskManager == null) return;
|
||||
|
||||
taskManager = Game1.GameSession.taskManager;
|
||||
taskManager = GameMain.GameSession.taskManager;
|
||||
musicType = "repair";
|
||||
this.priority = priority;
|
||||
this.name = name;
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Subsurface
|
||||
|
||||
public static void TogglePauseMenu()
|
||||
{
|
||||
if (Screen.Selected == Game1.MainMenuScreen) return;
|
||||
if (Screen.Selected == GameMain.MainMenuScreen) return;
|
||||
|
||||
TogglePauseMenu(null, null);
|
||||
|
||||
@@ -75,22 +75,22 @@ namespace Subsurface
|
||||
|
||||
y += 60;
|
||||
|
||||
if (Screen.Selected == Game1.GameScreen && Game1.GameSession !=null)
|
||||
if (Screen.Selected == GameMain.GameScreen && GameMain.GameSession !=null)
|
||||
{
|
||||
SinglePlayerMode spMode = Game1.GameSession.gameMode as SinglePlayerMode;
|
||||
SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode;
|
||||
if (spMode!=null)
|
||||
{
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 30), "Load previous", Alignment.CenterX, GUI.Style, pauseMenu);
|
||||
button.OnClicked += TogglePauseMenu;
|
||||
button.OnClicked += Game1.GameSession.LoadPrevious;
|
||||
button.OnClicked += GameMain.GameSession.LoadPrevious;
|
||||
|
||||
y += 60;
|
||||
}
|
||||
}
|
||||
|
||||
if (Screen.Selected == Game1.LobbyScreen)
|
||||
if (Screen.Selected == GameMain.LobbyScreen)
|
||||
{
|
||||
SinglePlayerMode spMode = Game1.GameSession.gameMode as SinglePlayerMode;
|
||||
SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode;
|
||||
if (spMode != null)
|
||||
{
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 30), "Save & quit", Alignment.CenterX, GUI.Style, pauseMenu);
|
||||
@@ -121,11 +121,11 @@ namespace Subsurface
|
||||
{
|
||||
if (button.UserData as string == "save")
|
||||
{
|
||||
SaveUtil.SaveGame(Game1.GameSession.SaveFile);
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
|
||||
}
|
||||
|
||||
|
||||
Game1.MainMenuScreen.Select();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
//Game1.MainMenuScreen.SelectTab(null, (int)MainMenuScreen.Tabs.Main);
|
||||
|
||||
return true;
|
||||
@@ -301,15 +301,15 @@ namespace Subsurface
|
||||
public static void Draw(float deltaTime, SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
spriteBatch.DrawString(Font,
|
||||
"FPS: " + (int)Game1.FrameCounter.AverageFramesPerSecond,
|
||||
"FPS: " + (int)GameMain.FrameCounter.AverageFramesPerSecond,
|
||||
new Vector2(10, 10), Color.White);
|
||||
|
||||
if (Game1.DebugDraw)
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
spriteBatch.DrawString(Font,
|
||||
"Physics: " + Game1.World.UpdateTime
|
||||
+ " - bodies: " + Game1.World.BodyList.Count
|
||||
+ " Camera pos: " + Game1.GameScreen.Cam.Position,
|
||||
"Physics: " + GameMain.World.UpdateTime
|
||||
+ " - bodies: " + GameMain.World.BodyList.Count
|
||||
+ " Camera pos: " + GameMain.GameScreen.Cam.Position,
|
||||
new Vector2(10, 30), Color.White);
|
||||
|
||||
if (Submarine.Loaded!=null)
|
||||
@@ -318,12 +318,10 @@ namespace Subsurface
|
||||
"Sub pos: " + Submarine.Loaded.Position,
|
||||
new Vector2(10, 50), Color.White);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (Character.Controlled != null && cam!=null) Character.Controlled.DrawHud(spriteBatch, cam);
|
||||
if (Game1.NetworkMember != null) Game1.NetworkMember.Draw(spriteBatch);
|
||||
if (GameMain.NetworkMember != null) GameMain.NetworkMember.Draw(spriteBatch);
|
||||
|
||||
DrawMessages(spriteBatch, (float)deltaTime);
|
||||
|
||||
@@ -366,7 +364,7 @@ namespace Subsurface
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 currPos = new Vector2(Game1.GraphicsWidth / 2.0f, Game1.GraphicsHeight * 0.7f);
|
||||
Vector2 currPos = new Vector2(GameMain.GraphicsWidth / 2.0f, GameMain.GraphicsHeight * 0.7f);
|
||||
currPos.Y += messages.Count * 30;
|
||||
|
||||
messages.Add(new GUIMessage(message, color, currPos, lifeTime));
|
||||
@@ -382,7 +380,7 @@ namespace Subsurface
|
||||
{
|
||||
if (messages.Count == 0) return;
|
||||
|
||||
Vector2 currPos = new Vector2(Game1.GraphicsWidth / 2.0f, Game1.GraphicsHeight * 0.7f);
|
||||
Vector2 currPos = new Vector2(GameMain.GraphicsWidth / 2.0f, GameMain.GraphicsHeight * 0.7f);
|
||||
|
||||
int i = 1;
|
||||
foreach (GUIMessage msg in messages)
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace Subsurface
|
||||
|
||||
protected virtual void UpdateDimensions(GUIComponent parent = null)
|
||||
{
|
||||
Rectangle parentRect = (parent==null) ? new Rectangle(0,0,Game1.GraphicsWidth, Game1.GraphicsHeight) : parent.rect;
|
||||
Rectangle parentRect = (parent==null) ? new Rectangle(0,0,GameMain.GraphicsWidth, GameMain.GraphicsHeight) : parent.rect;
|
||||
|
||||
Vector4 padding = (parent == null) ? Vector4.Zero : parent.padding;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Subsurface
|
||||
monsterTexture = TextureLoader.FromFile("Content/UI/titleMonster.png");
|
||||
titleTexture = TextureLoader.FromFile("Content/UI/titleText.png");
|
||||
|
||||
renderTarget = new RenderTarget2D(graphics, Game1.GraphicsWidth, Game1.GraphicsHeight);
|
||||
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
|
||||
}
|
||||
|
||||
@@ -53,15 +53,15 @@ namespace Subsurface
|
||||
graphics.SetRenderTarget(renderTarget);
|
||||
//Debug.WriteLine(stopwatch.Elapsed.TotalMilliseconds);
|
||||
|
||||
Scale = Game1.GraphicsHeight/1500.0f;
|
||||
Scale = GameMain.GraphicsHeight/1500.0f;
|
||||
|
||||
state += deltaTime;
|
||||
|
||||
if (loadState>-1)
|
||||
{
|
||||
CenterPosition = new Vector2(Game1.GraphicsWidth*0.3f, Game1.GraphicsHeight/2.0f);
|
||||
CenterPosition = new Vector2(GameMain.GraphicsWidth*0.3f, GameMain.GraphicsHeight/2.0f);
|
||||
TitlePosition = CenterPosition + new Vector2(-0.0f + (float)Math.Sqrt(state) * 220.0f, 0.0f) * Scale;
|
||||
TitlePosition.X = Math.Min(TitlePosition.X, (float)Game1.GraphicsWidth / 2.0f);
|
||||
TitlePosition.X = Math.Min(TitlePosition.X, (float)GameMain.GraphicsWidth / 2.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Subsurface
|
||||
loadText = "Loading... " + (int)loadState + " %";
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, loadText, new Vector2(Game1.GraphicsWidth/2.0f - 50.0f, Game1.GraphicsHeight*0.8f), Color.White);
|
||||
spriteBatch.DrawString(GUI.Font, loadText, new Vector2(GameMain.GraphicsWidth/2.0f - 50.0f, GameMain.GraphicsHeight*0.8f), Color.White);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Xml;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
class Game1 : Game
|
||||
class GameMain : Game
|
||||
{
|
||||
public static GraphicsDeviceManager Graphics;
|
||||
static int graphicsWidth, graphicsHeight;
|
||||
@@ -93,7 +93,7 @@ namespace Subsurface
|
||||
get { return NetworkMember as GameClient; }
|
||||
}
|
||||
|
||||
public Game1()
|
||||
public GameMain()
|
||||
{
|
||||
Graphics = new GraphicsDeviceManager(this);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Subsurface
|
||||
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);
|
||||
new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, frame);
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Subsurface
|
||||
endTime = startTime + duration;
|
||||
this.duration = duration;
|
||||
|
||||
timerBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth - 120, 20, 100, 25), Color.Gold, 0.0f, null);
|
||||
timerBar = new GUIProgressBar(new Rectangle(GameMain.GraphicsWidth - 120, 20, 100, 25), Color.Gold, 0.0f, null);
|
||||
}
|
||||
|
||||
endMessage = "The round has ended!";
|
||||
@@ -108,7 +108,7 @@ namespace Subsurface
|
||||
|
||||
if (endMessage != "" || this.endMessage == null) this.endMessage = endMessage;
|
||||
|
||||
Game1.GameSession.EndShift(endMessage);
|
||||
GameMain.GameSession.EndShift(endMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Subsurface
|
||||
{
|
||||
Location[] locations = new Location[2];
|
||||
|
||||
Random rand = new Random(ToolBox.StringToInt(Game1.NetLobbyScreen.LevelSeed));
|
||||
Random rand = new Random(ToolBox.StringToInt(GameMain.NetLobbyScreen.LevelSeed));
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Subsurface
|
||||
|
||||
CargoManager = new CargoManager();
|
||||
|
||||
endShiftButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 220, 20, 200, 25), "End shift", Alignment.TopLeft, GUI.Style);
|
||||
endShiftButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 220, 20, 200, 25), "End shift", Alignment.TopLeft, GUI.Style);
|
||||
endShiftButton.OnClicked = EndShift;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
@@ -101,7 +101,7 @@ namespace Subsurface
|
||||
|
||||
if (!savedOnStart)
|
||||
{
|
||||
SaveUtil.SaveGame(Game1.GameSession.SaveFile);
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
|
||||
savedOnStart = true;
|
||||
}
|
||||
|
||||
@@ -192,9 +192,9 @@ namespace Subsurface
|
||||
sb.Append("Your entire crew has died!");
|
||||
|
||||
var msgBox = new GUIMessageBox("", sb.ToString(), new string[] { "Load game", "Quit" });
|
||||
msgBox.Buttons[0].OnClicked += Game1.GameSession.LoadPrevious;
|
||||
msgBox.Buttons[0].OnClicked += GameMain.GameSession.LoadPrevious;
|
||||
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
||||
msgBox.Buttons[1].OnClicked = Game1.LobbyScreen.QuitToMainMenu;
|
||||
msgBox.Buttons[1].OnClicked = GameMain.LobbyScreen.QuitToMainMenu;
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
}
|
||||
else
|
||||
@@ -217,7 +217,7 @@ namespace Subsurface
|
||||
Map.MoveToNextLocation();
|
||||
}
|
||||
|
||||
SaveUtil.SaveGame(Game1.GameSession.SaveFile);
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SaveFile);
|
||||
}
|
||||
|
||||
CrewManager.EndShift();
|
||||
@@ -226,7 +226,7 @@ namespace Subsurface
|
||||
Character.CharacterList[i].Remove();
|
||||
}
|
||||
|
||||
Game1.GameSession.EndShift("");
|
||||
GameMain.GameSession.EndShift("");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Subsurface
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
if (Game1.Server == null) return;
|
||||
if (GameMain.Server == null) return;
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
@@ -34,21 +34,21 @@ namespace Subsurface
|
||||
|
||||
if (traitor==null || target ==null)
|
||||
{
|
||||
int clientCount = Game1.Server.connectedClients.Count();
|
||||
int clientCount = GameMain.Server.connectedClients.Count();
|
||||
if (clientCount < 2) return;
|
||||
|
||||
int traitorIndex = Rand.Int(clientCount, false);
|
||||
traitor = Game1.Server.connectedClients[traitorIndex];
|
||||
traitor = GameMain.Server.connectedClients[traitorIndex];
|
||||
|
||||
int targetIndex = 0;
|
||||
while (targetIndex == traitorIndex)
|
||||
{
|
||||
targetIndex = Rand.Int(clientCount, false);
|
||||
}
|
||||
target = Game1.Server.connectedClients[targetIndex];
|
||||
target = GameMain.Server.connectedClients[targetIndex];
|
||||
|
||||
|
||||
Game1.Server.NewTraitor(traitor, target);
|
||||
GameMain.Server.NewTraitor(traitor, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace Subsurface
|
||||
{
|
||||
Submarine.Load("Content/Map/TutorialSub.gz");
|
||||
|
||||
Game1.GameSession = new GameSession(Submarine.Loaded, "", GameModePreset.list.Find(gm => gm.Name.ToLower()=="tutorial"));
|
||||
GameMain.GameSession = new GameSession(Submarine.Loaded, "", GameModePreset.list.Find(gm => gm.Name.ToLower()=="tutorial"));
|
||||
|
||||
Game1.GameSession.StartShift(TimeSpan.Zero, "tutorial");
|
||||
GameMain.GameSession.StartShift(TimeSpan.Zero, "tutorial");
|
||||
|
||||
Game1.GameSession.taskManager.Tasks.Clear();
|
||||
GameMain.GameSession.taskManager.Tasks.Clear();
|
||||
|
||||
Game1.GameScreen.Select();
|
||||
GameMain.GameScreen.Select();
|
||||
}
|
||||
|
||||
public TutorialMode(GameModePreset preset)
|
||||
@@ -313,7 +313,7 @@ namespace Subsurface
|
||||
Vector2 steeringDir = windows[0].Position - moloch.Position;
|
||||
if (steeringDir != Vector2.Zero) steeringDir = Vector2.Normalize(steeringDir);
|
||||
|
||||
foreach (Limb limb in moloch.AnimController.limbs)
|
||||
foreach (Limb limb in moloch.AnimController.Limbs)
|
||||
{
|
||||
limb.body.LinearVelocity = new Vector2(limb.LinearVelocity.X, limb.LinearVelocity.Y + steeringDir.Y*10.0f);
|
||||
}
|
||||
@@ -511,7 +511,7 @@ namespace Subsurface
|
||||
float secondsLeft = endPreviewLength;
|
||||
|
||||
Character.Controlled = null;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -522,14 +522,14 @@ namespace Subsurface
|
||||
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
|
||||
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
|
||||
GameMain.GameScreen.Cam.TargetPos = offset * 0.8f;
|
||||
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
} while (secondsLeft > 0.0f);
|
||||
|
||||
Submarine.Unload();
|
||||
Game1.MainMenuScreen.Select();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
@@ -544,7 +544,7 @@ namespace Subsurface
|
||||
messageBox.Buttons[0].OnClicked += messageBox.Close;
|
||||
|
||||
//messageBox.Buttons[1].UserData = MainMenuScreen.Tabs.Main;
|
||||
messageBox.Buttons[1].OnClicked = Game1.MainMenuScreen.SelectTab;
|
||||
messageBox.Buttons[1].OnClicked = GameMain.MainMenuScreen.SelectTab;
|
||||
messageBox.Buttons[1].OnClicked += messageBox.Close;
|
||||
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Subsurface
|
||||
|
||||
this.saveFile = saveFile;
|
||||
|
||||
guiRoot = new GUIFrame(new Rectangle(0,0,Game1.GraphicsWidth,Game1.GraphicsWidth), Color.Transparent);
|
||||
guiRoot = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsWidth), Color.Transparent);
|
||||
|
||||
this.gameMode = gameMode;
|
||||
this.submarine = selectedSub;
|
||||
@@ -107,7 +107,7 @@ namespace Subsurface
|
||||
|
||||
public void StartShift(TimeSpan duration, Level level, bool reloadSub = true)
|
||||
{
|
||||
Game1.LightManager.LosEnabled = (Game1.Server==null || Game1.Server.CharacterInfo!=null);
|
||||
GameMain.LightManager.LosEnabled = (GameMain.Server==null || GameMain.Server.CharacterInfo!=null);
|
||||
|
||||
this.level = level;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Subsurface
|
||||
level.Generate(submarine == null ? 100.0f : Math.Max(Submarine.Borders.Width, Submarine.Borders.Height));
|
||||
submarine.SetPosition(level.StartPosition - new Vector2(0.0f, 2000.0f));
|
||||
|
||||
Game1.GameScreen.BackgroundSpriteManager.SpawnSprites(80);
|
||||
GameMain.GameScreen.BackgroundSpriteManager.SpawnSprites(80);
|
||||
}
|
||||
|
||||
if (Quest!=null) Quest.Start(Level.Loaded);
|
||||
@@ -132,14 +132,14 @@ namespace Subsurface
|
||||
{
|
||||
if (Quest != null) Quest.End();
|
||||
|
||||
if (Game1.Server!=null)
|
||||
if (GameMain.Server!=null)
|
||||
{
|
||||
CoroutineManager.StartCoroutine(Game1.Server.EndGame(endMessage));
|
||||
CoroutineManager.StartCoroutine(GameMain.Server.EndGame(endMessage));
|
||||
|
||||
}
|
||||
else if (Game1.Client==null)
|
||||
else if (GameMain.Client==null)
|
||||
{
|
||||
Game1.LobbyScreen.Select();
|
||||
GameMain.LobbyScreen.Select();
|
||||
}
|
||||
|
||||
taskManager.EndShift();
|
||||
@@ -160,7 +160,7 @@ namespace Subsurface
|
||||
{
|
||||
SaveUtil.LoadGame(saveFile);
|
||||
|
||||
Game1.LobbyScreen.Select();
|
||||
GameMain.LobbyScreen.Select();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,19 +46,19 @@ namespace Subsurface
|
||||
case 2:
|
||||
slotPositions[i] = new Vector2(
|
||||
spacing,
|
||||
Game1.GraphicsHeight - (spacing + rectHeight) * (3 - i));
|
||||
GameMain.GraphicsHeight - (spacing + rectHeight) * (3 - i));
|
||||
break;
|
||||
//lefthand, righthand
|
||||
case 3:
|
||||
case 4:
|
||||
slotPositions[i] = new Vector2(
|
||||
spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 3),
|
||||
Game1.GraphicsHeight - (spacing + rectHeight)*3);
|
||||
GameMain.GraphicsHeight - (spacing + rectHeight)*3);
|
||||
break;
|
||||
default:
|
||||
slotPositions[i] = new Vector2(
|
||||
spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 3)%5),
|
||||
Game1.GraphicsHeight - (spacing + rectHeight) * ((i>9) ? 2 : 1));
|
||||
GameMain.GraphicsHeight - (spacing + rectHeight) * ((i>9) ? 2 : 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Subsurface.Items.Components
|
||||
(int)doorSprite.size.X,
|
||||
(int)doorSprite.size.Y);
|
||||
|
||||
body = new PhysicsBody(BodyFactory.CreateRectangle(Game1.World,
|
||||
body = new PhysicsBody(BodyFactory.CreateRectangle(GameMain.World,
|
||||
ConvertUnits.ToSimUnits(Math.Max(doorRect.Width, 1)),
|
||||
ConvertUnits.ToSimUnits(Math.Max(doorRect.Height, 1)),
|
||||
1.5f));
|
||||
@@ -282,8 +282,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
int dir = Math.Sign(c.AnimController.limbs[0].SimPosition.X - simPos.X);
|
||||
foreach (Limb l in c.AnimController.limbs)
|
||||
int dir = Math.Sign(c.AnimController.Limbs[0].SimPosition.X - simPos.X);
|
||||
foreach (Limb l in c.AnimController.Limbs)
|
||||
{
|
||||
if (l.SimPosition.Y < simPos.Y || l.SimPosition.Y > simPos.Y - simSize.Y) continue;
|
||||
if (Math.Abs(l.SimPosition.X - simPos.X) > simSize.X * 2.0f) continue;
|
||||
@@ -299,7 +299,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
Game1.World.RemoveBody(body.FarseerBody);
|
||||
GameMain.World.RemoveBody(body.FarseerBody);
|
||||
|
||||
if (linkedGap!=null) linkedGap.Remove();
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Subsurface.Items.Components
|
||||
Msg = "";
|
||||
}
|
||||
|
||||
if (attachedByDefault || Screen.Selected == Game1.EditMapScreen) Use(1.0f);
|
||||
if (attachedByDefault || Screen.Selected == GameMain.EditMapScreen) Use(1.0f);
|
||||
|
||||
|
||||
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Subsurface.Items.Components
|
||||
item.body.FarseerBody.CollidesWith = Physics.CollisionCharacter | Physics.CollisionWall;
|
||||
item.body.FarseerBody.OnCollision += OnCollision;
|
||||
|
||||
foreach (Limb l in character.AnimController.limbs)
|
||||
foreach (Limb l in character.AnimController.Limbs)
|
||||
{
|
||||
item.body.FarseerBody.IgnoreCollisionWith(l.body.FarseerBody);
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Subsurface.Items.Components
|
||||
item.body.CollisionCategories = Physics.CollisionMisc;
|
||||
item.body.CollidesWith = Physics.CollisionWall;
|
||||
|
||||
foreach (Limb l in picker.AnimController.limbs)
|
||||
foreach (Limb l in picker.AnimController.Limbs)
|
||||
{
|
||||
item.body.FarseerBody.RestoreCollisionWith(l.body.FarseerBody);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Subsurface.Items.Components
|
||||
bool failed = DoesUseFail(character);
|
||||
|
||||
List<Body> limbBodies = new List<Body>();
|
||||
foreach (Limb l in character.AnimController.limbs)
|
||||
foreach (Limb l in character.AnimController.Limbs)
|
||||
{
|
||||
limbBodies.Add(l.body.FarseerBody);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Subsurface.Items.Components
|
||||
(float)Math.Sin(item.body.Rotation)) * range * item.body.Dir;
|
||||
|
||||
List<Body> ignoredBodies = new List<Body>();
|
||||
foreach (Limb limb in character.AnimController.limbs)
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
{
|
||||
ignoredBodies.Add(limb.body.FarseerBody);
|
||||
}
|
||||
@@ -200,7 +200,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(particles))
|
||||
{
|
||||
Game1.ParticleManager.CreateParticle(particles, ConvertUnits.ToDisplayUnits(TransformedBarrelPos),
|
||||
GameMain.ParticleManager.CreateParticle(particles, ConvertUnits.ToDisplayUnits(TransformedBarrelPos),
|
||||
-item.body.Rotation + ((item.body.Dir>0.0f) ? 0.0f : MathHelper.Pi), 0.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,10 +196,10 @@ namespace Subsurface.Items.Components
|
||||
break;
|
||||
case "guiframe":
|
||||
Vector4 rect = ToolBox.GetAttributeVector4(subElement, "rect", Vector4.One);
|
||||
rect.X *= Game1.GraphicsWidth;
|
||||
rect.Y *= Game1.GraphicsHeight;
|
||||
rect.Z *= Game1.GraphicsWidth;
|
||||
rect.W *= Game1.GraphicsHeight;
|
||||
rect.X *= GameMain.GraphicsWidth;
|
||||
rect.Y *= GameMain.GraphicsHeight;
|
||||
rect.Z *= GameMain.GraphicsWidth;
|
||||
rect.W *= GameMain.GraphicsHeight;
|
||||
|
||||
Vector4 color = ToolBox.GetAttributeVector4(subElement, "color", Vector4.One);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Game1.ParticleManager.CreateParticle("bubbles", item.Position,
|
||||
GameMain.ParticleManager.CreateParticle("bubbles", item.Position,
|
||||
-currForce/5.0f + new Vector2(Rand.Range(-100.0f, 100.0f), Rand.Range(-50f, 50f)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
|
||||
int width = 400, height = 300;
|
||||
itemList = new GUIListBox(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), Color.White * 0.7f);
|
||||
itemList = new GUIListBox(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), Color.White * 0.7f);
|
||||
itemList.OnSelected = SelectItem;
|
||||
//structureList.CheckSelected = MapEntityPrefab.GetSelected;
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Subsurface.Items.Components
|
||||
if (targetItem == null) return false;
|
||||
|
||||
int width = 200, height = 150;
|
||||
selectedItemFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, itemList.Rect.Bottom+20, width, height), Color.Black*0.8f);
|
||||
selectedItemFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, itemList.Rect.Bottom+20, width, height), Color.Black*0.8f);
|
||||
//selectedItemFrame.Padding = GUI.style.smallPadding;
|
||||
|
||||
if (targetItem.TargetItem.sprite != null)
|
||||
|
||||
@@ -150,20 +150,20 @@ namespace Subsurface.Items.Components
|
||||
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X);
|
||||
}
|
||||
|
||||
if (Game1.GameSession == null) return;
|
||||
if (GameMain.GameSession == null) return;
|
||||
|
||||
|
||||
DrawMarker(spriteBatch,
|
||||
(Game1.GameSession.Map == null) ? "Start" : Game1.GameSession.Map.CurrentLocation.Name,
|
||||
(GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name,
|
||||
(Level.Loaded.StartPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f));
|
||||
|
||||
DrawMarker(spriteBatch,
|
||||
(Game1.GameSession.Map == null) ? "End" : Game1.GameSession.Map.SelectedLocation.Name,
|
||||
(GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name,
|
||||
(Level.Loaded.EndPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f));
|
||||
|
||||
if (Game1.GameSession.Quest != null)
|
||||
if (GameMain.GameSession.Quest != null)
|
||||
{
|
||||
var quest = Game1.GameSession.Quest;
|
||||
var quest = GameMain.GameSession.Quest;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
|
||||
{
|
||||
|
||||
@@ -184,8 +184,8 @@ namespace Subsurface.Items.Components
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
int width = 300, height = 200;
|
||||
int x = Game1.GraphicsWidth / 2 - width / 2;
|
||||
int y = Game1.GraphicsHeight / 2 - height / 2;
|
||||
int x = GameMain.GraphicsWidth / 2 - width / 2;
|
||||
int y = GameMain.GraphicsHeight / 2 - height / 2;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Subsurface.Items.Components
|
||||
Vector2 baseVel = Rand.Vector(300.0f);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var particle = Game1.ParticleManager.CreateParticle("spark", pt.item.Position,
|
||||
var particle = GameMain.ParticleManager.CreateParticle("spark", pt.item.Position,
|
||||
baseVel + Rand.Vector(100.0f), 0.0f);
|
||||
|
||||
if (particle != null) particle.Size *= Rand.Range(0.5f,1.0f);
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Subsurface.Items.Components
|
||||
if (stickJoint != null && doesStick)
|
||||
{
|
||||
if (stickTarget!=null) item.body.FarseerBody.RestoreCollisionWith(stickTarget);
|
||||
Game1.World.RemoveJoint(stickJoint);
|
||||
GameMain.World.RemoveJoint(stickJoint);
|
||||
stickJoint = null;
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace Subsurface.Items.Components
|
||||
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
|
||||
}
|
||||
|
||||
Game1.World.RemoveJoint(stickJoint);
|
||||
GameMain.World.RemoveJoint(stickJoint);
|
||||
stickJoint = null;
|
||||
|
||||
isActive = false;
|
||||
@@ -209,7 +209,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
item.body.FarseerBody.IgnoreCollisionWith(targetBody);
|
||||
stickTarget = targetBody;
|
||||
Game1.World.AddJoint(stickJoint);
|
||||
GameMain.World.AddJoint(stickJoint);
|
||||
|
||||
isActive = true;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Subsurface.Items.Components
|
||||
Vertices box = PolygonTools.CreateRectangle(sectionLength, 0.05f);
|
||||
PolygonShape shape = new PolygonShape(box, 5);
|
||||
|
||||
List<Body>ropeList = PathManager.EvenlyDistributeShapesAlongPath(Game1.World, ropePath, shape, BodyType.Dynamic, (int)(length/sectionLength));
|
||||
List<Body>ropeList = PathManager.EvenlyDistributeShapesAlongPath(GameMain.World, ropePath, shape, BodyType.Dynamic, (int)(length/sectionLength));
|
||||
|
||||
ropeBodies = new PhysicsBody[ropeList.Count()];
|
||||
for (int i = 0; i<ropeBodies.Length; i++)
|
||||
@@ -104,14 +104,14 @@ namespace Subsurface.Items.Components
|
||||
ropeBodies[i] = new PhysicsBody(ropeList[i]);
|
||||
}
|
||||
|
||||
List<RevoluteJoint> joints = PathManager.AttachBodiesWithRevoluteJoint(Game1.World, ropeList,
|
||||
List<RevoluteJoint> joints = PathManager.AttachBodiesWithRevoluteJoint(GameMain.World, ropeList,
|
||||
new Vector2(-sectionLength/2, 0.0f), new Vector2(sectionLength/2, 0.0f), false, false);
|
||||
|
||||
ropeJoints = new RevoluteJoint[joints.Count+1];
|
||||
//ropeJoints[0] = JointFactory.CreateRevoluteJoint(Game1.world, item.body, ropeList[0], new Vector2(0f, -0.0f));
|
||||
for (int i = 0; i < joints.Count; i++)
|
||||
{
|
||||
var distanceJoint = JointFactory.CreateDistanceJoint(Game1.World, ropeList[i], ropeList[i + 1]);
|
||||
var distanceJoint = JointFactory.CreateDistanceJoint(GameMain.World, ropeList[i], ropeList[i + 1]);
|
||||
|
||||
distanceJoint.Length = sectionLength;
|
||||
distanceJoint.DampingRatio = 1.0f;
|
||||
@@ -299,8 +299,8 @@ namespace Subsurface.Items.Components
|
||||
ropeBodies[ropeBodies.Length - 1].SetTransform(projectile.body.SimPosition, projectile.body.Rotation);
|
||||
|
||||
//attach projectile to the last section of the rope
|
||||
if (ropeJoints[ropeJoints.Length-1] != null) Game1.World.RemoveJoint(ropeJoints[ropeJoints.Length-1]);
|
||||
ropeJoints[ropeJoints.Length - 1] = JointFactory.CreateRevoluteJoint(Game1.World,
|
||||
if (ropeJoints[ropeJoints.Length-1] != null) GameMain.World.RemoveJoint(ropeJoints[ropeJoints.Length-1]);
|
||||
ropeJoints[ropeJoints.Length - 1] = JointFactory.CreateRevoluteJoint(GameMain.World,
|
||||
projectile.body.FarseerBody, ropeBodies[ropeBodies.Length - 1].FarseerBody,
|
||||
projectileAnchor, new Vector2(sectionLength / 2, 0.0f));
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace Subsurface.Items.Components
|
||||
body.SetTransform(TransformedBarrelPos, rotation);
|
||||
//Vector2 axis = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
|
||||
|
||||
if (gunJoint != null) Game1.World.RemoveJoint(gunJoint);
|
||||
if (gunJoint != null) GameMain.World.RemoveJoint(gunJoint);
|
||||
gunJoint = new DistanceJoint(item.body.FarseerBody, body, BarrelPos,
|
||||
new Vector2(sectionLength / 2, 0.0f));
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace Subsurface.Items.Components
|
||||
//gunJoint.LimitEnabled = true;
|
||||
//gunJoint.ReferenceAngle = 0.0f;
|
||||
|
||||
Game1.World.AddJoint(gunJoint);
|
||||
GameMain.World.AddJoint(gunJoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
|
||||
int width = 400, height = 200;
|
||||
int x = Game1.GraphicsWidth/2 - width/2, y = Game1.GraphicsHeight - height;
|
||||
int x = GameMain.GraphicsWidth/2 - width/2, y = GameMain.GraphicsHeight - height;
|
||||
|
||||
Rectangle panelRect = new Rectangle(x, y, width, height);
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace Subsurface.Items.Components
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 3, (int)-Nodes[i].Y - 3, 6, 6), Color.Red, true, 0.0f);
|
||||
|
||||
if (GUIComponent.MouseOn == null &&
|
||||
Vector2.Distance(Game1.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) < 20.0f)
|
||||
Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) < 20.0f)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 10, (int)-Nodes[i].Y - 10, 20, 20), Color.Red, false, 0.0f);
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace Subsurface.Items.Components
|
||||
if (selectedNodeIndex!=null && item.IsSelected)
|
||||
{
|
||||
MapEntity.DisableSelect = true;
|
||||
Nodes[(int)selectedNodeIndex] = Game1.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
Nodes[(int)selectedNodeIndex] = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
|
||||
Vector2 pos = Nodes[(int)selectedNodeIndex];
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace Subsurface
|
||||
set
|
||||
{
|
||||
centerPos = value;
|
||||
centerPos.X *= Game1.GraphicsWidth;
|
||||
centerPos.Y *= Game1.GraphicsHeight;
|
||||
centerPos.X *= GameMain.GraphicsWidth;
|
||||
centerPos.Y *= GameMain.GraphicsHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,19 @@ namespace Subsurface
|
||||
get { return properties; }
|
||||
}
|
||||
|
||||
private bool? hasInGameEditableProperties;
|
||||
bool HasInGameEditableProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (hasInGameEditableProperties==null)
|
||||
{
|
||||
hasInGameEditableProperties = GetProperties<InGameEditable>().Count>0;
|
||||
}
|
||||
return (bool)hasInGameEditableProperties;
|
||||
}
|
||||
}
|
||||
|
||||
public PhysicsBody body;
|
||||
|
||||
private float condition;
|
||||
@@ -194,7 +207,7 @@ namespace Subsurface
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (Game1.DebugDraw) ? Name +"(ID: "+ID+")" : Name;
|
||||
return (GameMain.DebugDraw) ? Name +"(ID: "+ID+")" : Name;
|
||||
}
|
||||
|
||||
public List<IPropertyObject> AllPropertyObjects
|
||||
@@ -622,7 +635,7 @@ namespace Subsurface
|
||||
private GUIComponent CreateEditingHUD(bool inGame=false)
|
||||
{
|
||||
int width = 500;
|
||||
int x = Game1.GraphicsWidth/2-width/2, y = 10;
|
||||
int x = GameMain.GraphicsWidth/2-width/2, y = 10;
|
||||
|
||||
List<ObjectProperty> editableProperties = inGame ? GetProperties<InGameEditable>() : GetProperties<Editable>();
|
||||
|
||||
@@ -700,27 +713,29 @@ namespace Subsurface
|
||||
|
||||
public virtual void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
if (condition>0.0f)
|
||||
if (condition<=0.0f)
|
||||
{
|
||||
if (editingHUD==null || editingHUD.UserData as Item != this)
|
||||
FixRequirement.DrawHud(spriteBatch, this, character);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasInGameEditableProperties)
|
||||
{
|
||||
if (editingHUD == null || editingHUD.UserData as Item != this)
|
||||
{
|
||||
editingHUD = CreateEditingHUD(true);
|
||||
}
|
||||
|
||||
if (editingHUD.Rect.Height>60)
|
||||
if (editingHUD.Rect.Height > 60)
|
||||
{
|
||||
editingHUD.Update((float)Physics.step);
|
||||
editingHUD.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
ic.DrawHUD(spriteBatch, character);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
FixRequirement.DrawHud(spriteBatch, this, character);
|
||||
ic.DrawHUD(spriteBatch, character);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,15 +53,15 @@ namespace Subsurface
|
||||
{
|
||||
Vector2 displayPosition = ConvertUnits.ToDisplayUnits(simPosition);
|
||||
|
||||
Game1.ParticleManager.CreateParticle("shockwave", displayPosition,
|
||||
GameMain.ParticleManager.CreateParticle("shockwave", displayPosition,
|
||||
Vector2.Zero, 0.0f);
|
||||
|
||||
for (int i = 0; i < range * 10; i++)
|
||||
{
|
||||
Game1.ParticleManager.CreateParticle("spark", displayPosition,
|
||||
GameMain.ParticleManager.CreateParticle("spark", displayPosition,
|
||||
Rand.Vector(Rand.Range(500.0f, 800.0f)), 0.0f);
|
||||
|
||||
Game1.ParticleManager.CreateParticle("explosionfire", displayPosition + Rand.Vector(50f),
|
||||
GameMain.ParticleManager.CreateParticle("explosionfire", displayPosition + Rand.Vector(50f),
|
||||
Rand.Vector(Rand.Range(50f, 100.0f)), 0.0f);
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ namespace Subsurface
|
||||
light = new LightSource(displayPosition, displayRange, Color.LightYellow);
|
||||
CoroutineManager.StartCoroutine(DimLight());
|
||||
|
||||
float cameraDist = Vector2.Distance(Game1.GameScreen.Cam.Position, displayPosition)/2.0f;
|
||||
Game1.GameScreen.Cam.Shake = CameraShake * Math.Max((displayRange - cameraDist)/displayRange, 0.0f);
|
||||
float cameraDist = Vector2.Distance(GameMain.GameScreen.Cam.Position, displayPosition)/2.0f;
|
||||
GameMain.GameScreen.Cam.Shake = CameraShake * Math.Max((displayRange - cameraDist)/displayRange, 0.0f);
|
||||
|
||||
if (structureDamage > 0.0f)
|
||||
{
|
||||
@@ -111,11 +111,11 @@ namespace Subsurface
|
||||
|
||||
float distFactor = 1.0f - dist / range;
|
||||
|
||||
foreach (Limb limb in c.AnimController.limbs)
|
||||
foreach (Limb limb in c.AnimController.Limbs)
|
||||
{
|
||||
distFactor = 1.0f - Vector2.Distance(limb.SimPosition, simPosition)/range;
|
||||
|
||||
c.AddDamage(limb.SimPosition, DamageType.None, damage / c.AnimController.limbs.Length * distFactor, 0.0f, stun * distFactor);
|
||||
c.AddDamage(limb.SimPosition, DamageType.None, damage / c.AnimController.Limbs.Length * distFactor, 0.0f, stun * distFactor);
|
||||
|
||||
if (force>0.0f)
|
||||
{
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Subsurface
|
||||
{
|
||||
pos.Y = MathHelper.Clamp(lowerSurface, rect.Y - rect.Height, rect.Y);
|
||||
|
||||
var particle = Game1.ParticleManager.CreateParticle("watersplash",
|
||||
var particle = GameMain.ParticleManager.CreateParticle("watersplash",
|
||||
new Vector2(pos.X, pos.Y - Rand.Range(0.0f, 10.0f)),
|
||||
new Vector2(
|
||||
MathHelper.Clamp(flowForce.X, -5000.0f, 5000.0f) * Rand.Range(0.5f, 0.7f),
|
||||
@@ -273,7 +273,7 @@ namespace Subsurface
|
||||
|
||||
pos.Y = Rand.Range(lowerSurface, rect.Y - rect.Height);
|
||||
|
||||
Game1.ParticleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
|
||||
GameMain.ParticleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -281,12 +281,12 @@ namespace Subsurface
|
||||
for (int i = 0; i < rect.Width; i += (int)Rand.Range(80, 100))
|
||||
{
|
||||
pos.X = Rand.Range(rect.X, rect.X + rect.Width);
|
||||
Subsurface.Particles.Particle splash = Game1.ParticleManager.CreateParticle("watersplash", pos,
|
||||
Subsurface.Particles.Particle splash = GameMain.ParticleManager.CreateParticle("watersplash", pos,
|
||||
new Vector2(0, Math.Max(flowForce.Y * Rand.Range(0.5f, 0.8f), 0.0f)));
|
||||
|
||||
if (splash != null) splash.Size = splash.Size * MathHelper.Clamp(rect.Width / 50.0f, 0.8f, 4.0f);
|
||||
|
||||
Game1.ParticleManager.CreateParticle("bubbles", pos, flowForce / 2.0f);
|
||||
GameMain.ParticleManager.CreateParticle("bubbles", pos, flowForce / 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Subsurface
|
||||
float maxDelta = Math.Max(Math.Abs(rightDelta[i]), Math.Abs(leftDelta[i]));
|
||||
if (maxDelta > Rand.Range(0.2f,10.0f))
|
||||
{
|
||||
Game1.ParticleManager.CreateParticle("mist",
|
||||
GameMain.ParticleManager.CreateParticle("mist",
|
||||
new Vector2(rect.X + WaveWidth * i,surface + waveY[i]),
|
||||
new Vector2(0.0f, -50.0f));
|
||||
}
|
||||
@@ -276,7 +276,7 @@ namespace Subsurface
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (!editing && !Game1.DebugDraw) return;
|
||||
if (!editing && !GameMain.DebugDraw) return;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(rect.X, -rect.Y),
|
||||
@@ -313,7 +313,7 @@ namespace Subsurface
|
||||
//interpolate the position of the rendered surface towards the "target surface"
|
||||
surface = surface + (surfaceY - surface) / 10.0f;
|
||||
|
||||
Matrix transform = cam.Transform * Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
|
||||
Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
if (bottom > cam.WorldView.Y || top < cam.WorldView.Y - cam.WorldView.Height) return;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Subsurface
|
||||
if (basicEffect==null)
|
||||
{
|
||||
|
||||
basicEffect = new BasicEffect(Game1.CurrGraphicsDevice);
|
||||
basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
||||
basicEffect.VertexColorEnabled = false;
|
||||
|
||||
basicEffect.TextureEnabled = true;
|
||||
@@ -354,7 +354,7 @@ namespace Subsurface
|
||||
Debug.WriteLine("Generatelevel: " + sw2.ElapsedMilliseconds + " ms");
|
||||
sw2.Restart();
|
||||
|
||||
vertexBuffer = new VertexBuffer(Game1.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
||||
vertexBuffer = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
||||
vertexBuffer.SetData(vertices);
|
||||
|
||||
if (mirror)
|
||||
@@ -639,7 +639,7 @@ int currentTargetIndex = 1;
|
||||
|
||||
triangles = MathUtils.TriangulateConvexHull(bodyPoints, cell.Center);
|
||||
|
||||
Body edgeBody = new Body(Game1.World);
|
||||
Body edgeBody = new Body(GameMain.World);
|
||||
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
{
|
||||
@@ -661,7 +661,7 @@ int currentTargetIndex = 1;
|
||||
|
||||
for (int i = 0; i < 2; i++ )
|
||||
{
|
||||
Body shaftBody = BodyFactory.CreateRectangle(Game1.World, 100.0f, 10.0f, 5.0f);
|
||||
Body shaftBody = BodyFactory.CreateRectangle(GameMain.World, 100.0f, 10.0f, 5.0f);
|
||||
shaftBody.BodyType = BodyType.Kinematic;
|
||||
shaftBody.CollisionCategories = Physics.CollisionWall | Physics.CollisionLevel;
|
||||
shaftBody.SetTransform(ConvertUnits.ToSimUnits((i==0) ? startPosition : endPosition), 0.0f);
|
||||
@@ -720,7 +720,7 @@ int currentTargetIndex = 1;
|
||||
|
||||
foreach (Character character in Character.CharacterList)
|
||||
{
|
||||
foreach (Limb limb in character.AnimController.limbs)
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
{
|
||||
if (character.AnimController.CurrentHull != null) continue;
|
||||
|
||||
@@ -762,7 +762,7 @@ int currentTargetIndex = 1;
|
||||
{
|
||||
if (character.AnimController.CurrentHull != null) continue;
|
||||
|
||||
foreach (Limb limb in character.AnimController.limbs)
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
{
|
||||
limb.body.LinearVelocity -= prevVelocity;
|
||||
}
|
||||
@@ -949,7 +949,7 @@ int currentTargetIndex = 1;
|
||||
if (vertices.Length <= 0) return;
|
||||
|
||||
basicEffect.World = Matrix.CreateTranslation(new Vector3(Position, 0.0f)) * cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace Subsurface.Lights
|
||||
{
|
||||
if (shadowEffect == null)
|
||||
{
|
||||
shadowEffect = new BasicEffect(Game1.CurrGraphicsDevice);
|
||||
shadowEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
||||
shadowEffect.VertexColorEnabled = true;
|
||||
}
|
||||
if (penumbraEffect == null)
|
||||
{
|
||||
penumbraEffect = new BasicEffect(Game1.CurrGraphicsDevice);
|
||||
penumbraEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
||||
penumbraEffect.TextureEnabled = true;
|
||||
//shadowEffect.VertexColorEnabled = true;
|
||||
penumbraEffect.LightingEnabled = false;
|
||||
@@ -225,7 +225,7 @@ namespace Subsurface.Lights
|
||||
}
|
||||
|
||||
shadowEffect.World = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
shadowEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Subsurface.Lights
|
||||
|
||||
var pp = graphics.PresentationParameters;
|
||||
|
||||
lightMap = new RenderTarget2D(graphics, Game1.GraphicsWidth, Game1.GraphicsHeight, false,
|
||||
lightMap = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false,
|
||||
pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount,
|
||||
RenderTargetUsage.DiscardContents);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Subsurface.Lights
|
||||
|
||||
texture = lightTexture;
|
||||
|
||||
Game1.LightManager.AddLight(this);
|
||||
GameMain.LightManager.AddLight(this);
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
@@ -59,7 +59,7 @@ namespace Subsurface.Lights
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
Game1.LightManager.RemoveLight(this);
|
||||
GameMain.LightManager.RemoveLight(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace Subsurface
|
||||
{
|
||||
selectedConnection = connection;
|
||||
selectedLocation = highlightedLocation;
|
||||
Game1.LobbyScreen.SelectLocation(highlightedLocation, connection);
|
||||
GameMain.LobbyScreen.SelectLocation(highlightedLocation, connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Subsurface
|
||||
bodies = new List<Body>();
|
||||
//gaps = new List<Gap>();
|
||||
|
||||
Body newBody = BodyFactory.CreateRectangle(Game1.World,
|
||||
Body newBody = BodyFactory.CreateRectangle(GameMain.World,
|
||||
ConvertUnits.ToSimUnits(rect.Width),
|
||||
ConvertUnits.ToSimUnits(rect.Height),
|
||||
1.5f);
|
||||
@@ -206,7 +206,7 @@ namespace Subsurface
|
||||
{
|
||||
bodies = new List<Body>();
|
||||
|
||||
Body newBody = BodyFactory.CreateRectangle(Game1.World,
|
||||
Body newBody = BodyFactory.CreateRectangle(GameMain.World,
|
||||
ConvertUnits.ToSimUnits(rect.Width * Math.Sqrt(2.0) + Submarine.GridSize.X*3.0f),
|
||||
ConvertUnits.ToSimUnits(10),
|
||||
1.5f);
|
||||
@@ -273,7 +273,7 @@ namespace Subsurface
|
||||
if (bodies != null)
|
||||
{
|
||||
foreach (Body b in bodies)
|
||||
Game1.World.RemoveBody(b);
|
||||
GameMain.World.RemoveBody(b);
|
||||
}
|
||||
|
||||
if (convexHull != null) convexHull.Remove();
|
||||
@@ -381,7 +381,7 @@ namespace Subsurface
|
||||
{
|
||||
if (!prefab.HasBody || prefab.IsPlatform) return;
|
||||
|
||||
if (Game1.Client==null)
|
||||
if (GameMain.Client==null)
|
||||
SetDamage(sectionIndex, sections[sectionIndex].damage + damage);
|
||||
|
||||
}
|
||||
@@ -419,7 +419,7 @@ namespace Subsurface
|
||||
int i = FindSectionIndex(ConvertUnits.ToDisplayUnits(position));
|
||||
if (i == -1) return new AttackResult(0.0f, 0.0f);
|
||||
|
||||
Game1.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f);
|
||||
GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f);
|
||||
|
||||
if (playSound && !SectionHasHole(i))
|
||||
{
|
||||
@@ -477,7 +477,7 @@ namespace Subsurface
|
||||
{
|
||||
foreach (Body b in bodies)
|
||||
{
|
||||
Game1.World.RemoveBody(b);
|
||||
GameMain.World.RemoveBody(b);
|
||||
}
|
||||
bodies.Clear();
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace Subsurface
|
||||
|
||||
private Body CreateRectBody(Rectangle rect)
|
||||
{
|
||||
Body newBody = BodyFactory.CreateRectangle(Game1.World,
|
||||
Body newBody = BodyFactory.CreateRectangle(GameMain.World,
|
||||
ConvertUnits.ToSimUnits(rect.Width),
|
||||
ConvertUnits.ToSimUnits(rect.Height),
|
||||
1.5f);
|
||||
|
||||
@@ -152,8 +152,8 @@ namespace Subsurface
|
||||
|
||||
sprite.DrawTiled(spriteBatch, new Vector2(newRect.X, -newRect.Y), new Vector2(newRect.Width, newRect.Height), Color.White);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X - Game1.GraphicsWidth, -newRect.Y, newRect.Width + Game1.GraphicsWidth*2, newRect.Height), Color.White);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - Game1.GraphicsHeight, newRect.Width, newRect.Height + Game1.GraphicsHeight*2), Color.White);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X - GameMain.GraphicsWidth, -newRect.Y, newRect.Width + GameMain.GraphicsWidth*2, newRect.Height), Color.White);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight*2), Color.White);
|
||||
|
||||
if (PlayerInput.GetMouseState.RightButton == ButtonState.Pressed) selected = null;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Subsurface
|
||||
|
||||
float closestFraction = 1.0f;
|
||||
Body closestBody = null;
|
||||
Game1.World.RayCast((fixture, point, normal, fraction) =>
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
if (fixture == null || fixture.CollisionCategories == Category.None) return -1;
|
||||
if (ignoredBodies != null && ignoredBodies.Contains(fixture.Body)) return -1;
|
||||
@@ -363,7 +363,7 @@ namespace Subsurface
|
||||
return null;
|
||||
}
|
||||
|
||||
Game1.World.RayCast((fixture, point, normal, fraction) =>
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
if (fixture == null || fixture.CollisionCategories != Physics.CollisionWall) return -1;
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace Subsurface
|
||||
Body foundBody = null;
|
||||
AABB aabb = new AABB(point, point);
|
||||
|
||||
Game1.World.QueryAABB(p =>
|
||||
GameMain.World.QueryAABB(p =>
|
||||
{
|
||||
foundBody = p.Body;
|
||||
|
||||
@@ -406,16 +406,16 @@ namespace Subsurface
|
||||
return foundBody;
|
||||
}
|
||||
|
||||
public static bool InsideWall(Vector2 point)
|
||||
{
|
||||
Body foundBody = PickBody(point);
|
||||
if (foundBody==null) return false;
|
||||
//public static bool InsideWall(Vector2 point)
|
||||
//{
|
||||
// Body foundBody = PickBody(point);
|
||||
// if (foundBody==null) return false;
|
||||
|
||||
Structure wall = foundBody.UserData as Structure;
|
||||
if (wall == null || wall.IsPlatform) return false;
|
||||
// Structure wall = foundBody.UserData as Structure;
|
||||
// if (wall == null || wall.IsPlatform) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
//}
|
||||
|
||||
//movement ----------------------------------------------------
|
||||
|
||||
@@ -436,8 +436,10 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
Translate(translateAmount);
|
||||
|
||||
//-------------------------
|
||||
|
||||
ApplyForce(CalculateBuoyancy());
|
||||
Vector2 totalForce = CalculateBuoyancy();
|
||||
|
||||
float dragCoefficient = 0.00001f;
|
||||
|
||||
@@ -446,8 +448,11 @@ namespace Subsurface
|
||||
|
||||
if (speed != Vector2.Zero)
|
||||
{
|
||||
ApplyForce(-Vector2.Normalize(speed) * drag);
|
||||
totalForce += -Vector2.Normalize(speed) * drag;
|
||||
}
|
||||
|
||||
ApplyForce(totalForce);
|
||||
|
||||
//hullBodies[0].body.LinearVelocity = -hullBodies[0].body.Position;
|
||||
|
||||
//hullBody.SetTransform(Vector2.Zero , 0.0f);
|
||||
@@ -462,8 +467,8 @@ namespace Subsurface
|
||||
foreach (GraphEdge ge in collidingCell.edges)
|
||||
{
|
||||
Body body = PickBody(
|
||||
ConvertUnits.ToSimUnits(ge.point1+ Game1.GameSession.Level.Position),
|
||||
ConvertUnits.ToSimUnits(ge.point2 + Game1.GameSession.Level.Position), new List<Body>(){collidingCell.body});
|
||||
ConvertUnits.ToSimUnits(ge.point1+ GameMain.GameSession.Level.Position),
|
||||
ConvertUnits.ToSimUnits(ge.point2 + GameMain.GameSession.Level.Position), new List<Body>(){collidingCell.body});
|
||||
if (body == null || body.UserData == null) continue;
|
||||
|
||||
Structure structure = body.UserData as Structure;
|
||||
@@ -471,6 +476,8 @@ namespace Subsurface
|
||||
structure.AddDamage(lastPickedPosition, DamageType.Blunt, 50.0f, 0.0f, 0.0f, true);
|
||||
}
|
||||
|
||||
collidingCell = null;
|
||||
|
||||
//hullBodies[0].body.SetTransform(Vector2.Zero, 0.0f);
|
||||
|
||||
//position = hullBodies[0].body.Position;
|
||||
@@ -528,15 +535,41 @@ namespace Subsurface
|
||||
VoronoiCell cell = f2.Body.UserData as VoronoiCell;
|
||||
if (cell==null) return true;
|
||||
|
||||
Vector2 normal = -contact.Manifold.LocalNormal;
|
||||
Vector2 normal = contact.Manifold.LocalNormal;
|
||||
Vector2 simSpeed = ConvertUnits.ToSimUnits(speed);
|
||||
float impact = -Vector2.Dot(simSpeed, normal);
|
||||
float impact = Vector2.Dot(simSpeed, normal);
|
||||
|
||||
Vector2 u = Vector2.Dot(simSpeed, normal)*normal;
|
||||
Vector2 u = Vector2.Dot(simSpeed, -normal)*-normal;
|
||||
Vector2 w = simSpeed - u;
|
||||
|
||||
Vector2 limbForce = normal * impact;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("IMPACT:"+impact);
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (c.AnimController.CurrentHull == null) continue;
|
||||
|
||||
if (impact > 2.0f) c.AnimController.StunTimer = (impact - 2.0f) * 0.1f;
|
||||
|
||||
foreach (Limb limb in c.AnimController.Limbs)
|
||||
{
|
||||
limb.body.ApplyLinearImpulse(limb.Mass * limbForce);
|
||||
}
|
||||
}
|
||||
|
||||
if (impact >= 1.0f)
|
||||
{
|
||||
AmbientSoundManager.PlayDamageSound(DamageSoundType.StructureBlunt, impact * 10.0f, cell.body);
|
||||
|
||||
FixedArray2<Vector2> worldPoints;
|
||||
contact.GetWorldManifold(out normal, out worldPoints);
|
||||
|
||||
|
||||
AmbientSoundManager.PlayDamageSound(DamageSoundType.StructureBlunt, impact * 10.0f, ConvertUnits.ToDisplayUnits(worldPoints[0]));
|
||||
|
||||
GameMain.GameScreen.Cam.Shake = impact*2.0f;
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("IMPACT: "+impact + " normal: "+normal+" simspeed: "+simSpeed+" u: "+u+" w: " +w);
|
||||
if (impact < 4.0f)
|
||||
{
|
||||
speed = ConvertUnits.ToDisplayUnits(w * 0.9f - u * 0.2f);
|
||||
@@ -547,13 +580,6 @@ namespace Subsurface
|
||||
speed = ConvertUnits.ToDisplayUnits(w * 0.9f + u * 0.5f);
|
||||
}
|
||||
|
||||
if (contact.Manifold.PointCount >= 1)
|
||||
{
|
||||
FixedArray2<Vector2> worldPoints;
|
||||
contact.GetWorldManifold(out normal, out worldPoints);
|
||||
|
||||
Game1.GameScreen.Cam.Shake = impact;
|
||||
}
|
||||
|
||||
collisionRigidness = 0.8f;
|
||||
|
||||
@@ -828,7 +854,7 @@ namespace Subsurface
|
||||
|
||||
var triangulatedVertices = Triangulate.ConvexPartition(shapevertices, TriangulationAlgorithm.Bayazit);
|
||||
|
||||
hullBody = BodyFactory.CreateCompoundPolygon(Game1.World, triangulatedVertices, 5.0f);
|
||||
hullBody = BodyFactory.CreateCompoundPolygon(GameMain.World, triangulatedVertices, 5.0f);
|
||||
hullBody.BodyType = BodyType.Dynamic;
|
||||
|
||||
hullBody.CollisionCategories = Physics.CollisionMisc;
|
||||
@@ -880,7 +906,7 @@ namespace Subsurface
|
||||
|
||||
private void Clear()
|
||||
{
|
||||
if (Game1.GameScreen.Cam != null) Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
if (GameMain.GameScreen.Cam != null) GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
Entity.RemoveAll();
|
||||
|
||||
@@ -888,7 +914,7 @@ namespace Subsurface
|
||||
|
||||
Ragdoll.list.Clear();
|
||||
|
||||
Game1.World.Clear();
|
||||
GameMain.World.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Subsurface
|
||||
|
||||
if (basicEffect==null)
|
||||
{
|
||||
basicEffect = new BasicEffect(Game1.CurrGraphicsDevice);
|
||||
basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
||||
basicEffect.VertexColorEnabled = false;
|
||||
|
||||
basicEffect.TextureEnabled = true;
|
||||
@@ -58,7 +58,7 @@ namespace Subsurface
|
||||
wavePos.X += 0.0001f;
|
||||
wavePos.Y += 0.0001f;
|
||||
|
||||
spriteBatch.Draw(waterTexture, new Rectangle(0,0,Game1.GraphicsWidth, Game1.GraphicsHeight), Color.White);
|
||||
spriteBatch.Draw(waterTexture, new Rectangle(0,0,GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace Subsurface
|
||||
|
||||
basicEffect.View = Matrix.Identity;
|
||||
basicEffect.World = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Subsurface
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (!editing && !Game1.DebugDraw) return;
|
||||
if (!editing && !GameMain.DebugDraw) return;
|
||||
|
||||
Point pos = new Point((int)Position.X, (int)Position.Y);
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Subsurface
|
||||
private GUIComponent CreateEditingHUD(bool inGame = false)
|
||||
{
|
||||
int width = 500;
|
||||
int x = Game1.GraphicsWidth / 2 - width / 2, y = 10;
|
||||
int x = GameMain.GraphicsWidth / 2 - width / 2, y = 10;
|
||||
|
||||
editingHUD = new GUIFrame(new Rectangle(x, y, width, 150), Color.Black * 0.5f);
|
||||
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
||||
|
||||
@@ -76,9 +76,9 @@ namespace Subsurface.Networking
|
||||
|
||||
outmsg.Write((byte)PacketTypes.Login);
|
||||
outmsg.Write(password);
|
||||
outmsg.Write(Game1.Version.ToString());
|
||||
outmsg.Write(Game1.SelectedPackage.Name);
|
||||
outmsg.Write(Game1.SelectedPackage.MD5hash.Hash);
|
||||
outmsg.Write(GameMain.Version.ToString());
|
||||
outmsg.Write(GameMain.SelectedPackage.Name);
|
||||
outmsg.Write(GameMain.SelectedPackage.MD5hash.Hash);
|
||||
outmsg.Write(name);
|
||||
|
||||
// Connect client, to ip previously requested from user
|
||||
@@ -124,8 +124,8 @@ namespace Subsurface.Networking
|
||||
private bool SelectMainMenu(GUIButton button, object obj)
|
||||
{
|
||||
Disconnect();
|
||||
Game1.NetworkMember = null;
|
||||
Game1.MainMenuScreen.Select();
|
||||
GameMain.NetworkMember = null;
|
||||
GameMain.MainMenuScreen.Select();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -159,12 +159,12 @@ namespace Subsurface.Networking
|
||||
if (packetType == (byte)PacketTypes.LoggedIn)
|
||||
{
|
||||
myID = inc.ReadInt32();
|
||||
if (inc.ReadBoolean() && Screen.Selected != Game1.GameScreen)
|
||||
if (inc.ReadBoolean() && Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
new GUIMessageBox("Please wait", "A round is already running. You will have to wait for a new round to start.");
|
||||
}
|
||||
|
||||
Game1.NetLobbyScreen.ClearPlayers();
|
||||
GameMain.NetLobbyScreen.ClearPlayers();
|
||||
|
||||
//add the names of other connected clients to the lobby screen
|
||||
int existingClients = inc.ReadInt32();
|
||||
@@ -172,12 +172,12 @@ namespace Subsurface.Networking
|
||||
{
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient);
|
||||
GameMain.NetLobbyScreen.AddPlayer(otherClient);
|
||||
otherClients.Add(otherClient);
|
||||
}
|
||||
|
||||
//add the name of own client to the lobby screen
|
||||
Game1.NetLobbyScreen.AddPlayer(new Client(name, myID));
|
||||
GameMain.NetLobbyScreen.AddPlayer(new Client(name, myID));
|
||||
|
||||
CanStart = true;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ namespace Subsurface.Networking
|
||||
string msg = inc.ReadString();
|
||||
DebugConsole.ThrowError(msg);
|
||||
|
||||
Game1.MainMenuScreen.Select();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
}
|
||||
break;
|
||||
case NetIncomingMessageType.StatusChanged:
|
||||
@@ -229,7 +229,7 @@ namespace Subsurface.Networking
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Screen.Selected != Game1.GameScreen) Game1.NetLobbyScreen.Select();
|
||||
if (Screen.Selected != GameMain.GameScreen) GameMain.NetLobbyScreen.Select();
|
||||
connected = true;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace Subsurface.Networking
|
||||
if (myCharacter.IsDead)
|
||||
{
|
||||
Character.Controlled = null;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
}
|
||||
else if (gameStarted)
|
||||
{
|
||||
@@ -327,15 +327,15 @@ namespace Subsurface.Networking
|
||||
string mapName = inc.ReadString();
|
||||
string mapHash = inc.ReadString();
|
||||
|
||||
Game1.NetLobbyScreen.TrySelectMap(mapName, mapHash);
|
||||
GameMain.NetLobbyScreen.TrySelectMap(mapName, mapHash);
|
||||
|
||||
double durationMinutes = inc.ReadDouble();
|
||||
|
||||
TimeSpan duration = new TimeSpan(0,(int)durationMinutes,0);
|
||||
Rand.SetSyncedSeed(seed);
|
||||
//int gameModeIndex = inc.ReadInt32();
|
||||
Game1.GameSession = new GameSession(Submarine.Loaded, "", Game1.NetLobbyScreen.SelectedMode);
|
||||
Game1.GameSession.StartShift(duration, levelSeed);
|
||||
GameMain.GameSession = new GameSession(Submarine.Loaded, "", GameMain.NetLobbyScreen.SelectedMode);
|
||||
GameMain.GameSession.StartShift(duration, levelSeed);
|
||||
|
||||
//myCharacter = ReadCharacterData(inc);
|
||||
//Character.Controlled = myCharacter;
|
||||
@@ -353,7 +353,7 @@ namespace Subsurface.Networking
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
Game1.GameScreen.Select();
|
||||
GameMain.GameScreen.Select();
|
||||
|
||||
AddChatMessage("Press TAB to chat", ChatMessageType.Server);
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace Subsurface.Networking
|
||||
|
||||
Client otherClient = new Client(inc.ReadString(), inc.ReadInt32());
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(otherClient);
|
||||
GameMain.NetLobbyScreen.AddPlayer(otherClient);
|
||||
otherClients.Add(otherClient);
|
||||
|
||||
AddChatMessage(otherClient.name + " has joined the server", ChatMessageType.Server);
|
||||
@@ -378,7 +378,7 @@ namespace Subsurface.Networking
|
||||
int leavingID = inc.ReadInt32();
|
||||
|
||||
AddChatMessage(inc.ReadString(), ChatMessageType.Server);
|
||||
Game1.NetLobbyScreen.RemovePlayer(otherClients.Find(c => c.ID==leavingID));
|
||||
GameMain.NetLobbyScreen.RemovePlayer(otherClients.Find(c => c.ID==leavingID));
|
||||
break;
|
||||
|
||||
case (byte)PacketTypes.KickedOut:
|
||||
@@ -386,7 +386,7 @@ namespace Subsurface.Networking
|
||||
|
||||
new GUIMessageBox("KICKED", msg);
|
||||
|
||||
Game1.MainMenuScreen.Select();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
|
||||
break;
|
||||
case (byte)PacketTypes.Chatmessage:
|
||||
@@ -400,7 +400,7 @@ namespace Subsurface.Networking
|
||||
break;
|
||||
case (byte)PacketTypes.UpdateNetLobby:
|
||||
if (gameStarted) continue;
|
||||
Game1.NetLobbyScreen.ReadData(inc);
|
||||
GameMain.NetLobbyScreen.ReadData(inc);
|
||||
break;
|
||||
case (byte)PacketTypes.Traitor:
|
||||
string targetName = inc.ReadString();
|
||||
@@ -421,7 +421,7 @@ namespace Subsurface.Networking
|
||||
var messageBox = new GUIMessageBox("The round has ended", endMessage);
|
||||
|
||||
Character.Controlled = null;
|
||||
Game1.LightManager.LosEnabled = false;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
|
||||
float endPreviewLength = 10.0f;
|
||||
|
||||
@@ -437,7 +437,7 @@ namespace Subsurface.Networking
|
||||
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
|
||||
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
|
||||
GameMain.GameScreen.Cam.TargetPos = offset * 0.8f;
|
||||
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
|
||||
@@ -448,9 +448,9 @@ namespace Subsurface.Networking
|
||||
|
||||
Submarine.Unload();
|
||||
|
||||
Game1.NetLobbyScreen.Select();
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
|
||||
if (Game1.GameSession!=null) Game1.GameSession.EndShift("");
|
||||
if (GameMain.GameSession!=null) GameMain.GameSession.EndShift("");
|
||||
|
||||
myCharacter = null;
|
||||
|
||||
@@ -462,10 +462,10 @@ namespace Subsurface.Networking
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (!Game1.DebugDraw) return;
|
||||
if (!GameMain.DebugDraw) return;
|
||||
|
||||
int width = 200, height = 300;
|
||||
int x = Game1.GraphicsWidth - width, y = (int)(Game1.GraphicsHeight * 0.3f);
|
||||
int x = GameMain.GraphicsWidth - width, y = (int)(GameMain.GraphicsHeight * 0.3f);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black * 0.7f, true);
|
||||
spriteBatch.DrawString(GUI.Font, "Network statistics:", new Vector2(x + 10, y + 10), Color.White);
|
||||
@@ -497,7 +497,7 @@ namespace Subsurface.Networking
|
||||
msg.Write(characterInfo.Gender == Gender.Male);
|
||||
msg.Write(characterInfo.HeadSpriteId);
|
||||
|
||||
var jobPreferences = Game1.NetLobbyScreen.JobPreferences;
|
||||
var jobPreferences = GameMain.NetLobbyScreen.JobPreferences;
|
||||
int count = Math.Min(jobPreferences.Count, 3);
|
||||
msg.Write(count);
|
||||
for (int i = 0; i < count; i++ )
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Subsurface.Networking
|
||||
|
||||
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
|
||||
{
|
||||
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
|
||||
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
|
||||
endRoundButton.OnClicked = EndButtonHit;
|
||||
|
||||
this.name = name;
|
||||
@@ -116,7 +116,7 @@ namespace Subsurface.Networking
|
||||
|
||||
DebugConsole.NewMessage("Server started", Color.Green);
|
||||
|
||||
Game1.NetLobbyScreen.Select();
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
started = true;
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
@@ -312,21 +312,21 @@ namespace Subsurface.Networking
|
||||
|
||||
break;
|
||||
}
|
||||
else if (version != Game1.Version.ToString())
|
||||
else if (version != GameMain.Version.ToString())
|
||||
{
|
||||
inc.SenderConnection.Deny("Subsurface version " + Game1.Version + " required to connect to the server (Your version: " + version + ")");
|
||||
inc.SenderConnection.Deny("Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + version + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong game version", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (packageName != Game1.SelectedPackage.Name)
|
||||
else if (packageName != GameMain.SelectedPackage.Name)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + Game1.SelectedPackage.Name + ")");
|
||||
inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong content package name", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (packageHash != Game1.SelectedPackage.MD5hash.Hash)
|
||||
else if (packageHash != GameMain.SelectedPackage.MD5hash.Hash)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + Game1.SelectedPackage.MD5hash.Hash + ")");
|
||||
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong content package hash", Color.Red);
|
||||
break;
|
||||
}
|
||||
@@ -365,10 +365,10 @@ namespace Subsurface.Networking
|
||||
|
||||
if (sender == null) break;
|
||||
|
||||
if (sender.version != Game1.Version.ToString())
|
||||
if (sender.version != GameMain.Version.ToString())
|
||||
{
|
||||
DisconnectClient(sender, sender.name+" was unable to connect to the server (nonmatching game version)",
|
||||
"Subsurface version " + Game1.Version + " required to connect to the server (Your version: " + sender.version + ")");
|
||||
"Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + sender.version + ")");
|
||||
}
|
||||
else if (connectedClients.Find(x => x.name == sender.name && x != sender)!=null)
|
||||
{
|
||||
@@ -379,7 +379,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
//AssignJobs();
|
||||
|
||||
Game1.NetLobbyScreen.AddPlayer(sender);
|
||||
GameMain.NetLobbyScreen.AddPlayer(sender);
|
||||
|
||||
// Notify the client that they have logged in
|
||||
outmsg = server.CreateMessage();
|
||||
@@ -538,11 +538,11 @@ namespace Subsurface.Networking
|
||||
|
||||
public bool StartGame(GUIButton button, object obj)
|
||||
{
|
||||
Submarine selectedMap = Game1.NetLobbyScreen.SelectedMap as Submarine;
|
||||
Submarine selectedMap = GameMain.NetLobbyScreen.SelectedMap as Submarine;
|
||||
|
||||
if (selectedMap == null)
|
||||
{
|
||||
Game1.NetLobbyScreen.SubList.Flash();
|
||||
GameMain.NetLobbyScreen.SubList.Flash();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -552,8 +552,8 @@ namespace Subsurface.Networking
|
||||
|
||||
int seed = DateTime.Now.Millisecond;
|
||||
Rand.SetSyncedSeed(seed);
|
||||
Game1.GameSession = new GameSession(selectedMap, "", Game1.NetLobbyScreen.SelectedMode);
|
||||
Game1.GameSession.StartShift(Game1.NetLobbyScreen.GameDuration, Game1.NetLobbyScreen.LevelSeed);
|
||||
GameMain.GameSession = new GameSession(selectedMap, "", GameMain.NetLobbyScreen.SelectedMode);
|
||||
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.GameDuration, GameMain.NetLobbyScreen.LevelSeed);
|
||||
//EventManager.SelectEvent(Game1.netLobbyScreen.SelectedEvent);
|
||||
|
||||
List<CharacterInfo> characterInfos = new List<CharacterInfo>();
|
||||
@@ -573,7 +573,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (characterInfo != null)
|
||||
{
|
||||
characterInfo.Job = new Job(Game1.NetLobbyScreen.JobPreferences[0]);
|
||||
characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]);
|
||||
characterInfos.Add(characterInfo);
|
||||
}
|
||||
|
||||
@@ -604,12 +604,12 @@ namespace Subsurface.Networking
|
||||
|
||||
msg.Write(seed);
|
||||
|
||||
msg.Write(Game1.NetLobbyScreen.LevelSeed);
|
||||
msg.Write(GameMain.NetLobbyScreen.LevelSeed);
|
||||
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.Name);
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.MD5Hash.Hash);
|
||||
msg.Write(GameMain.NetLobbyScreen.SelectedMap.Name);
|
||||
msg.Write(GameMain.NetLobbyScreen.SelectedMap.MD5Hash.Hash);
|
||||
|
||||
msg.Write(Game1.NetLobbyScreen.GameDuration.TotalMinutes);
|
||||
msg.Write(GameMain.NetLobbyScreen.GameDuration.TotalMinutes);
|
||||
|
||||
msg.Write((myCharacter == null) ? connectedClients.Count : connectedClients.Count+1);
|
||||
foreach (Client client in connectedClients)
|
||||
@@ -628,9 +628,9 @@ namespace Subsurface.Networking
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
Game1.GameScreen.Select();
|
||||
GameMain.GameScreen.Select();
|
||||
|
||||
CreateCrewFrame(crew);
|
||||
|
||||
@@ -639,7 +639,7 @@ namespace Subsurface.Networking
|
||||
|
||||
private bool EndButtonHit(GUIButton button, object obj)
|
||||
{
|
||||
Game1.GameSession.gameMode.End("Server admin has ended the round");
|
||||
GameMain.GameSession.gameMode.End("Server admin has ended the round");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -651,8 +651,8 @@ namespace Subsurface.Networking
|
||||
|
||||
|
||||
Character.Controlled = null;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
Game1.LightManager.LosEnabled = false;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
|
||||
gameStarted = false;
|
||||
|
||||
@@ -688,7 +688,7 @@ namespace Subsurface.Networking
|
||||
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
|
||||
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
|
||||
GameMain.GameScreen.Cam.TargetPos = offset * 0.8f;
|
||||
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
|
||||
@@ -698,7 +698,7 @@ namespace Subsurface.Networking
|
||||
|
||||
Submarine.Unload();
|
||||
|
||||
Game1.NetLobbyScreen.Select();
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
|
||||
@@ -731,7 +731,7 @@ namespace Subsurface.Networking
|
||||
outmsg.Write(client.ID);
|
||||
outmsg.Write(msg);
|
||||
|
||||
Game1.NetLobbyScreen.RemovePlayer(client);
|
||||
GameMain.NetLobbyScreen.RemovePlayer(client);
|
||||
|
||||
if (server.Connections.Count > 0)
|
||||
{
|
||||
@@ -775,10 +775,10 @@ namespace Subsurface.Networking
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (!Game1.DebugDraw) return;
|
||||
if (!GameMain.DebugDraw) return;
|
||||
|
||||
int width = 200, height = 300;
|
||||
int x = Game1.GraphicsWidth - width, y = (int)(Game1.GraphicsHeight*0.3f);
|
||||
int x = GameMain.GraphicsWidth - width, y = (int)(GameMain.GraphicsHeight*0.3f);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(x,y,width,height), Color.Black*0.7f, true);
|
||||
spriteBatch.DrawString(GUI.Font, "Network statistics:", new Vector2(x+10, y+10), Color.White);
|
||||
@@ -809,7 +809,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
NetOutgoingMessage msg = server.CreateMessage();
|
||||
msg.Write((byte)PacketTypes.UpdateNetLobby);
|
||||
Game1.NetLobbyScreen.WriteData(msg);
|
||||
GameMain.NetLobbyScreen.WriteData(msg);
|
||||
|
||||
if (server.Connections.Count > 0)
|
||||
{
|
||||
@@ -912,7 +912,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (characterInfo!=null)
|
||||
{
|
||||
assignedClientCount[JobPrefab.List.FindIndex(jp => jp == Game1.NetLobbyScreen.JobPreferences[0])]=1;
|
||||
assignedClientCount[JobPrefab.List.FindIndex(jp => jp == GameMain.NetLobbyScreen.JobPreferences[0])]=1;
|
||||
}
|
||||
|
||||
//if any of the players has chosen a job that is Always Allowed, give them that job
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Subsurface.Networking
|
||||
//UpdateEntity networkevents aren't sent to clients if they're further than this from the entity
|
||||
public const float UpdateEntityDistance = 2500.0f;
|
||||
|
||||
public static string MasterServerUrl = Game1.Config.MasterServerUrl;
|
||||
public static string MasterServerUrl = GameMain.Config.MasterServerUrl;
|
||||
|
||||
//if a ragdoll is further than this from the correct position, teleport it there
|
||||
//(in sim units)
|
||||
|
||||
@@ -59,11 +59,11 @@ namespace Subsurface.Networking
|
||||
{
|
||||
if (isClient)
|
||||
{
|
||||
if (Game1.Server != null && Game1.Server.Character == null) return;
|
||||
if (GameMain.Server != null && GameMain.Server.Character == null) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Game1.Server == null) return;
|
||||
if (GameMain.Server == null) return;
|
||||
}
|
||||
|
||||
eventType = type;
|
||||
|
||||
@@ -93,8 +93,8 @@ namespace Subsurface.Networking
|
||||
|
||||
int width = 350, height = 100;
|
||||
chatBox = new GUIListBox(new Rectangle(
|
||||
Game1.GraphicsWidth - 20 - width,
|
||||
Game1.GraphicsHeight - 40 - 25 - height,
|
||||
GameMain.GraphicsWidth - 20 - width,
|
||||
GameMain.GraphicsHeight - 40 - 25 - height,
|
||||
width, height),
|
||||
Color.White * 0.5f, GUI.Style, inGameHUD);
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
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 = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.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);
|
||||
@@ -135,7 +135,7 @@ namespace Subsurface.Networking
|
||||
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);
|
||||
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);
|
||||
@@ -171,7 +171,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(message)) return false;
|
||||
|
||||
SendChatMessage(Game1.NetworkMember.Name + ": " + message);
|
||||
SendChatMessage(GameMain.NetworkMember.Name + ": " + message);
|
||||
|
||||
textBox.Deselect();
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Subsurface.Networking
|
||||
|
||||
public void AddChatMessage(string message, ChatMessageType messageType)
|
||||
{
|
||||
Game1.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
|
||||
GameMain.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
|
||||
|
||||
while (chatBox.CountChildren > 20)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Subsurface.Particles
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
|
||||
particlePrefab = Game1.ParticleManager.FindPrefab(ToolBox.GetAttributeString(element, "particle", ""));
|
||||
particlePrefab = GameMain.ParticleManager.FindPrefab(ToolBox.GetAttributeString(element, "particle", ""));
|
||||
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace Subsurface.Particles
|
||||
float angle = Rand.Range(AngleMin, AngleMax);
|
||||
Vector2 velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Rand.Range(VelocityMin, VelocityMax);
|
||||
|
||||
Game1.ParticleManager.CreateParticle(particlePrefab, position, velocity);
|
||||
GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,17 +197,17 @@ namespace Subsurface
|
||||
|
||||
if (width != 0.0f && height != 0.0f)
|
||||
{
|
||||
body = BodyFactory.CreateRectangle(Game1.World, width, height, density);
|
||||
body = BodyFactory.CreateRectangle(GameMain.World, width, height, density);
|
||||
bodyShape = Shape.Rectangle;
|
||||
}
|
||||
else if (radius != 0.0f && height != 0.0f)
|
||||
{
|
||||
body = BodyFactory.CreateCapsule(Game1.World, height, radius, density);
|
||||
body = BodyFactory.CreateCapsule(GameMain.World, height, radius, density);
|
||||
bodyShape = Shape.Capsule;
|
||||
}
|
||||
else if (radius != 0.0f)
|
||||
{
|
||||
body = BodyFactory.CreateCircle(Game1.World, radius, density);
|
||||
body = BodyFactory.CreateCircle(GameMain.World, radius, density);
|
||||
bodyShape = Shape.Circle;
|
||||
}
|
||||
else
|
||||
@@ -346,7 +346,7 @@ namespace Subsurface
|
||||
public void Remove()
|
||||
{
|
||||
list.Remove(this);
|
||||
Game1.World.RemoveBody(body);
|
||||
GameMain.World.RemoveBody(body);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Subsurface
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
using (var game = new Game1())
|
||||
using (var game = new GameMain())
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
@@ -44,7 +44,7 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
static void CrashDump(Game1 game, string filePath, Exception exception)
|
||||
static void CrashDump(GameMain game, string filePath, Exception exception)
|
||||
{
|
||||
StreamWriter sw = new StreamWriter(filePath);
|
||||
|
||||
@@ -54,19 +54,19 @@ namespace Subsurface
|
||||
sb.AppendLine("Subsurface seems to have crashed. Sorry for the inconvenience! ");
|
||||
sb.AppendLine("If you'd like to help fix the bug that caused the crash, please send this file to the developers on the Undertow Games forums.");
|
||||
sb.AppendLine("\n");
|
||||
sb.AppendLine("Subsurface version " + Game1.Version);
|
||||
sb.AppendLine("Selected content package: "+Game1.SelectedPackage.Name);
|
||||
sb.AppendLine("Subsurface version " + GameMain.Version);
|
||||
sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
|
||||
sb.AppendLine("Level seed: "+ ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
|
||||
sb.AppendLine("Loaded submarine: " + ((Submarine.Loaded == null) ? "none" : Submarine.Loaded.Name +" ("+Submarine.Loaded.MD5Hash+")"));
|
||||
sb.AppendLine("Selected screen: " + Screen.Selected.ToString());
|
||||
|
||||
if (Game1.Server != null)
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
sb.AppendLine("Server (" +(Game1.Server.GameStarted ? "Round had started)" : "Round hand't been started)"));
|
||||
sb.AppendLine("Server (" + (GameMain.Server.GameStarted ? "Round had started)" : "Round hand't been started)"));
|
||||
}
|
||||
else if (Game1.Client != null)
|
||||
else if (GameMain.Client != null)
|
||||
{
|
||||
sb.AppendLine("Client (" +(Game1.Client.GameStarted ? "Round had started)" : "Round hand't been started)"));
|
||||
sb.AppendLine("Client (" + (GameMain.Client.GameStarted ? "Round had started)" : "Round hand't been started)"));
|
||||
}
|
||||
|
||||
sb.AppendLine("\n");
|
||||
|
||||
@@ -39,11 +39,11 @@ namespace Subsurface
|
||||
{
|
||||
base.Select();
|
||||
|
||||
Game1.DebugDraw = true;
|
||||
GameMain.DebugDraw = true;
|
||||
|
||||
cam = new Camera();
|
||||
|
||||
GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, Game1.GraphicsHeight), GUI.Style);
|
||||
GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, GameMain.GraphicsHeight), GUI.Style);
|
||||
GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
|
||||
physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Alignment.Left, GUI.Style, GUIpanel);
|
||||
@@ -66,7 +66,7 @@ namespace Subsurface
|
||||
if (editingCharacter != Character.CharacterList[0]) UpdateLimbLists(Character.CharacterList[0]);
|
||||
editingCharacter = Character.CharacterList[0];
|
||||
|
||||
Vector2 camPos = editingCharacter.AnimController.limbs[0].body.SimPosition;
|
||||
Vector2 camPos = editingCharacter.AnimController.Limbs[0].body.SimPosition;
|
||||
camPos = ConvertUnits.ToDisplayUnits(camPos);
|
||||
camPos.Y = -camPos.Y;
|
||||
cam.TargetPos = camPos;
|
||||
@@ -83,7 +83,7 @@ namespace Subsurface
|
||||
|
||||
textures = new List<Texture2D>();
|
||||
texturePaths = new List<string>();
|
||||
foreach (Limb limb in editingCharacter.AnimController.limbs)
|
||||
foreach (Limb limb in editingCharacter.AnimController.Limbs)
|
||||
{
|
||||
if (texturePaths.Contains(limb.sprite.FilePath)) continue;
|
||||
textures.Add(limb.sprite.Texture);
|
||||
@@ -112,7 +112,7 @@ namespace Subsurface
|
||||
|
||||
Ragdoll.UpdateAll((float)Physics.step);
|
||||
|
||||
Game1.World.Step((float)Physics.step);
|
||||
GameMain.World.Step((float)Physics.step);
|
||||
|
||||
Physics.accumulator -= Physics.step;
|
||||
}
|
||||
@@ -169,10 +169,10 @@ namespace Subsurface
|
||||
int x = 0, y = 0;
|
||||
for (int i = 0; i < textures.Count; i++ )
|
||||
{
|
||||
x = Game1.GraphicsWidth - textures[i].Width;
|
||||
x = GameMain.GraphicsWidth - textures[i].Width;
|
||||
spriteBatch.Draw(textures[i], new Vector2(x, y), Color.White);
|
||||
|
||||
foreach (Limb limb in editingCharacter.AnimController.limbs)
|
||||
foreach (Limb limb in editingCharacter.AnimController.Limbs)
|
||||
{
|
||||
if (limb.sprite.FilePath != texturePaths[i]) continue;
|
||||
Rectangle rect = limb.sprite.SourceRect;
|
||||
@@ -219,7 +219,7 @@ namespace Subsurface
|
||||
private void UpdateLimbLists(Character character)
|
||||
{
|
||||
limbList.ClearChildren();
|
||||
foreach (Limb limb in character.AnimController.limbs)
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
{
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(0,0,0,25),
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Subsurface
|
||||
|
||||
private string GetPhysicsBodyCount()
|
||||
{
|
||||
return "Physics bodies: " + Game1.World.BodyList.Count;
|
||||
return "Physics bodies: " + GameMain.World.BodyList.Count;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Subsurface
|
||||
|
||||
selectedTab = -1;
|
||||
|
||||
GUIpanel = new GUIFrame(new Rectangle(0, 0, 150, Game1.GraphicsHeight), GUI.Style);
|
||||
GUIpanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), GUI.Style);
|
||||
GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
//GUIListBox constructionList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUIpanel);
|
||||
//constructionList.OnSelected = MapEntityPrefab.SelectPrefab;
|
||||
@@ -84,13 +84,13 @@ namespace Subsurface
|
||||
|
||||
GUItabs = new GUIComponent[2];
|
||||
int width = 400, height = 400;
|
||||
GUItabs[0] = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-width/2, Game1.GraphicsHeight/2-height/2, width, height), GUI.Style);
|
||||
GUItabs[0] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth/2-width/2, GameMain.GraphicsHeight/2-height/2, width, height), GUI.Style);
|
||||
GUItabs[0].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.Style, GUItabs[0]);
|
||||
itemList.OnSelected = SelectPrefab;
|
||||
itemList.CheckSelected = MapEntityPrefab.GetSelected;
|
||||
|
||||
GUItabs[1] = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
|
||||
GUItabs[1] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
|
||||
GUItabs[1].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.Style, GUItabs[1]);
|
||||
structureList.OnSelected = SelectPrefab;
|
||||
@@ -143,7 +143,7 @@ namespace Subsurface
|
||||
{
|
||||
dummyCharacter.Remove();
|
||||
dummyCharacter = null;
|
||||
Game1.World.ProcessChanges();
|
||||
GameMain.World.ProcessChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Subsurface
|
||||
|
||||
dummyCharacter = new Character(Character.HumanConfigFile, Vector2.Zero);
|
||||
Character.Controlled = dummyCharacter;
|
||||
Game1.World.ProcessChanges();
|
||||
GameMain.World.ProcessChanges();
|
||||
}
|
||||
|
||||
private bool SelectTab(GUIButton button, object obj)
|
||||
@@ -218,7 +218,7 @@ namespace Subsurface
|
||||
if (dummyCharacter.SelectedConstruction==null)
|
||||
{
|
||||
Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(cam.ScreenToWorld(PlayerInput.MousePosition));
|
||||
foreach (Limb limb in dummyCharacter.AnimController.limbs)
|
||||
foreach (Limb limb in dummyCharacter.AnimController.Limbs)
|
||||
{
|
||||
limb.body.SetTransform(mouseSimPos, 0.0f);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace Subsurface
|
||||
cam = new Camera();
|
||||
cam.Translate(new Vector2(-10.0f, 50.0f));
|
||||
|
||||
renderTarget = new RenderTarget2D(graphics, Game1.GraphicsWidth, Game1.GraphicsHeight);
|
||||
renderTargetWater = new RenderTarget2D(graphics, Game1.GraphicsWidth, Game1.GraphicsHeight);
|
||||
renderTargetAir = new RenderTarget2D(graphics, Game1.GraphicsWidth, Game1.GraphicsHeight);
|
||||
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
|
||||
background = new Sprite("Content/Map/background.png", Vector2.Zero);
|
||||
backgroundTop = new Sprite("Content/Map/background2.png", Vector2.Zero);
|
||||
@@ -70,14 +70,14 @@ namespace Subsurface
|
||||
// Game1.GameSession.Submarine.ApplyForce(targetMovement * 100000.0f);
|
||||
//}
|
||||
|
||||
if (Game1.GameSession!=null) Game1.GameSession.Update((float)deltaTime);
|
||||
if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime);
|
||||
//EventManager.Update(gameTime);
|
||||
|
||||
Character.UpdateAll(cam, (float)deltaTime);
|
||||
|
||||
BackgroundSpriteManager.Update((float)deltaTime);
|
||||
|
||||
Game1.ParticleManager.Update((float)deltaTime);
|
||||
GameMain.ParticleManager.Update((float)deltaTime);
|
||||
|
||||
StatusEffect.UpdateAll((float)deltaTime);
|
||||
|
||||
@@ -98,9 +98,9 @@ namespace Subsurface
|
||||
|
||||
Ragdoll.UpdateAll((float)Physics.step);
|
||||
|
||||
if (Game1.GameSession != null && Game1.GameSession.Level != null) Game1.GameSession.Submarine.Update((float)Physics.step);
|
||||
if (GameMain.GameSession != null && GameMain.GameSession.Level != null) GameMain.GameSession.Submarine.Update((float)Physics.step);
|
||||
|
||||
Game1.World.Step((float)Physics.step);
|
||||
GameMain.World.Step((float)Physics.step);
|
||||
|
||||
Level.AfterWorldStep();
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
if (Game1.GameSession != null) Game1.GameSession.Draw(spriteBatch);
|
||||
if (GameMain.GameSession != null) GameMain.GameSession.Draw(spriteBatch);
|
||||
|
||||
GUI.Draw((float)deltaTime, spriteBatch, cam);
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Subsurface
|
||||
|
||||
public void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
Game1.LightManager.DrawLightmap(graphics, spriteBatch, cam);
|
||||
GameMain.LightManager.DrawLightmap(graphics, spriteBatch, cam);
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//1. draw the background, characters and the parts of the submarine that are behind them
|
||||
@@ -167,14 +167,14 @@ namespace Subsurface
|
||||
background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024);
|
||||
background.DrawTiled(spriteBatch,
|
||||
(backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero,
|
||||
new Vector2(Game1.GraphicsWidth, 1024 - backgroundPos.Y),
|
||||
new Vector2(GameMain.GraphicsWidth, 1024 - backgroundPos.Y),
|
||||
Vector2.Zero, Color.White);
|
||||
}
|
||||
|
||||
if (backgroundPos.Y < 0)
|
||||
{
|
||||
backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, 1024, (int)Math.Min(-backgroundPos.Y, 1024));
|
||||
backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(Game1.GraphicsWidth, Math.Min(-backgroundPos.Y, Game1.GraphicsHeight)),
|
||||
backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)),
|
||||
Vector2.Zero, Color.White);
|
||||
}
|
||||
}
|
||||
@@ -208,7 +208,7 @@ namespace Subsurface
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
BlendState.AlphaBlend);
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, Game1.GraphicsWidth, Game1.GraphicsHeight), new Color(0.75f, 0.8f, 0.9f, 1.0f));
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), new Color(0.75f, 0.8f, 0.9f, 1.0f));
|
||||
spriteBatch.End();
|
||||
|
||||
BlendState blend = new BlendState();
|
||||
@@ -219,7 +219,7 @@ namespace Subsurface
|
||||
BlendState.AlphaBlend,
|
||||
null, DepthStencilState.DepthRead, null, null,
|
||||
cam.Transform);
|
||||
Game1.ParticleManager.Draw(spriteBatch, true);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Subsurface
|
||||
graphics.SetRenderTarget(renderTargetAir);
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
BlendState.AlphaBlend);
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, Game1.GraphicsWidth, Game1.GraphicsHeight), Color.White);
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
@@ -237,7 +237,7 @@ namespace Subsurface
|
||||
null, DepthStencilState.DepthRead, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Game1.ParticleManager.Draw(spriteBatch, false);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false);
|
||||
spriteBatch.End();
|
||||
|
||||
graphics.SetRenderTarget(null);
|
||||
@@ -257,17 +257,17 @@ namespace Subsurface
|
||||
|
||||
Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform);
|
||||
|
||||
if (Game1.GameSession != null && Game1.GameSession.Level != null)
|
||||
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
|
||||
{
|
||||
Game1.GameSession.Level.Render(graphics, cam);
|
||||
Game1.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
|
||||
GameMain.GameSession.Level.Render(graphics, cam);
|
||||
GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
|
||||
}
|
||||
|
||||
if (Game1.LightManager.LightingEnabled)
|
||||
if (GameMain.LightManager.LightingEnabled)
|
||||
{
|
||||
//multiply scene with lightmap
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
|
||||
spriteBatch.Draw(Game1.LightManager.LightMap, Vector2.Zero, Color.White);
|
||||
spriteBatch.Draw(GameMain.LightManager.LightMap, Vector2.Zero, Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
@@ -284,15 +284,15 @@ namespace Subsurface
|
||||
|
||||
foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch);
|
||||
|
||||
if (Game1.GameSession != null && Game1.GameSession.Level != null)
|
||||
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
|
||||
{
|
||||
Game1.GameSession.Level.Draw(spriteBatch);
|
||||
GameMain.GameSession.Level.Draw(spriteBatch);
|
||||
//Game1.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
Game1.LightManager.DrawLOS(graphics, cam, LightManager.ViewPos);
|
||||
GameMain.LightManager.DrawLOS(graphics, cam, LightManager.ViewPos);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Subsurface
|
||||
Rectangle panelRect = new Rectangle(
|
||||
40, 40,
|
||||
180,
|
||||
Game1.GraphicsHeight - 80);
|
||||
GameMain.GraphicsHeight - 80);
|
||||
|
||||
leftPanel = new GUIFrame(panelRect, GUI.Style);
|
||||
//leftPanel.Padding = GUI.style.smallPadding;
|
||||
@@ -92,8 +92,8 @@ namespace Subsurface
|
||||
panelRect = new Rectangle(
|
||||
panelRect.X + panelRect.Width + 40,
|
||||
40,
|
||||
Game1.GraphicsWidth - panelRect.Width - 120,
|
||||
Game1.GraphicsHeight - 80);
|
||||
GameMain.GraphicsWidth - panelRect.Width - 120,
|
||||
GameMain.GraphicsHeight - 80);
|
||||
|
||||
rightPanel = new GUIFrame[4];
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Subsurface
|
||||
{
|
||||
base.Select();
|
||||
|
||||
gameMode = Game1.GameSession.gameMode as SinglePlayerMode;
|
||||
gameMode = GameMain.GameSession.gameMode as SinglePlayerMode;
|
||||
|
||||
selectedRightPanel = (int)PanelTab.Crew;
|
||||
|
||||
@@ -210,9 +210,9 @@ namespace Subsurface
|
||||
|
||||
new GUITextBlock(new Rectangle(0,0,0,0), location.Name, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel);
|
||||
|
||||
if (Game1.GameSession.Map.SelectedConnection != null && Game1.GameSession.Map.SelectedConnection.Quest != null)
|
||||
if (GameMain.GameSession.Map.SelectedConnection != null && GameMain.GameSession.Map.SelectedConnection.Quest != null)
|
||||
{
|
||||
var quest = Game1.GameSession.Map.SelectedConnection.Quest;
|
||||
var quest = GameMain.GameSession.Map.SelectedConnection.Quest;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 40, 0, 20), "Quest: "+quest.Name, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel);
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace Subsurface
|
||||
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
Game1.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
GameMain.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
@@ -353,16 +353,16 @@ namespace Subsurface
|
||||
|
||||
if (selectedRightPanel == (int)PanelTab.Map)
|
||||
{
|
||||
Game1.GameSession.Map.Draw(spriteBatch, new Rectangle(
|
||||
GameMain.GameSession.Map.Draw(spriteBatch, new Rectangle(
|
||||
rightPanel[selectedRightPanel].Rect.X + 20,
|
||||
rightPanel[selectedRightPanel].Rect.Y + 20,
|
||||
rightPanel[selectedRightPanel].Rect.Width - 280,
|
||||
rightPanel[selectedRightPanel].Rect.Height - 40), mapZoom);
|
||||
}
|
||||
|
||||
if (rightPanel[(int)selectedRightPanel].UserData as Location != Game1.GameSession.Map.CurrentLocation)
|
||||
if (rightPanel[(int)selectedRightPanel].UserData as Location != GameMain.GameSession.Map.CurrentLocation)
|
||||
{
|
||||
UpdateLocationTab(Game1.GameSession.Map.CurrentLocation);
|
||||
UpdateLocationTab(GameMain.GameSession.Map.CurrentLocation);
|
||||
}
|
||||
|
||||
GUI.Draw((float)deltaTime, spriteBatch, null);
|
||||
@@ -380,7 +380,7 @@ namespace Subsurface
|
||||
|
||||
private string GetMoney()
|
||||
{
|
||||
return "Money: " + ((Game1.GameSession == null) ? "" : gameMode.CrewManager.Money.ToString());
|
||||
return "Money: " + ((GameMain.GameSession == null) ? "" : gameMode.CrewManager.Money.ToString());
|
||||
}
|
||||
|
||||
private bool SelectCharacter(GUIComponent component, object selection)
|
||||
@@ -416,9 +416,9 @@ namespace Subsurface
|
||||
CharacterInfo characterInfo = selection as CharacterInfo;
|
||||
if (characterInfo == null) return false;
|
||||
|
||||
if (gameMode.TryHireCharacter(Game1.GameSession.Map.CurrentLocation.HireManager, characterInfo))
|
||||
if (gameMode.TryHireCharacter(GameMain.GameSession.Map.CurrentLocation.HireManager, characterInfo))
|
||||
{
|
||||
UpdateLocationTab(Game1.GameSession.Map.CurrentLocation);
|
||||
UpdateLocationTab(GameMain.GameSession.Map.CurrentLocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -428,15 +428,15 @@ namespace Subsurface
|
||||
|
||||
private bool StartShift(GUIButton button, object selection)
|
||||
{
|
||||
Game1.GameSession.StartShift(TimeSpan.Zero, selectedLevel, false);
|
||||
Game1.GameScreen.Select();
|
||||
GameMain.GameSession.StartShift(TimeSpan.Zero, selectedLevel, false);
|
||||
GameMain.GameScreen.Select();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool QuitToMainMenu(GUIButton button, object selection)
|
||||
{
|
||||
Game1.MainMenuScreen.Select();
|
||||
GameMain.MainMenuScreen.Select();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace Subsurface
|
||||
private GUITextBox serverNameBox, portBox, passwordBox, maxPlayersBox;
|
||||
private GUITickBox isPublicBox, useUpnpBox;
|
||||
|
||||
private Game1 game;
|
||||
private GameMain game;
|
||||
|
||||
int selectedTab;
|
||||
|
||||
public MainMenuScreen(Game1 game)
|
||||
public MainMenuScreen(GameMain game)
|
||||
{
|
||||
menuTabs = new GUIFrame[Enum.GetValues(typeof(Tabs)).Length+1];
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Subsurface
|
||||
//menuTabs[(int)Tabs.Main].Padding = GUI.style.smallPadding;
|
||||
|
||||
Rectangle panelRect = new Rectangle(
|
||||
Game1.GraphicsWidth / 2 - 250,
|
||||
GameMain.GraphicsWidth / 2 - 250,
|
||||
buttonsTab.Rect.Y,
|
||||
500, 360);
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Subsurface
|
||||
minusPlayersBox.OnClicked = ChangeMaxPlayers;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 150, 0, 30), "Password (optional):", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
|
||||
passwordBox = new GUITextBox(new Rectangle(160, 170, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tabs.HostServer]);
|
||||
passwordBox = new GUITextBox(new Rectangle(160, 150, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tabs.HostServer]);
|
||||
|
||||
isPublicBox = new GUITickBox(new Rectangle(10, 200, 20, 20), "Public server", Alignment.TopLeft, menuTabs[(int)Tabs.HostServer]);
|
||||
isPublicBox.ToolTip = "Public servers are shown in the list of available servers in the ''Join Server'' -tab";
|
||||
@@ -189,7 +189,7 @@ namespace Subsurface
|
||||
|
||||
private bool JoinServerClicked(GUIButton button, object obj)
|
||||
{
|
||||
Game1.ServerListScreen.Select();
|
||||
GameMain.ServerListScreen.Select();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -223,9 +223,9 @@ namespace Subsurface
|
||||
return false;
|
||||
}
|
||||
|
||||
Game1.NetworkMember = new GameServer(name, port, isPublicBox.Selected, passwordBox.Text, useUpnpBox.Selected, int.Parse(maxPlayersBox.Text));
|
||||
GameMain.NetworkMember = new GameServer(name, port, isPublicBox.Selected, passwordBox.Text, useUpnpBox.Selected, int.Parse(maxPlayersBox.Text));
|
||||
|
||||
Game1.NetLobbyScreen.IsServer = true;
|
||||
GameMain.NetLobbyScreen.IsServer = true;
|
||||
//Game1.NetLobbyScreen.Select();
|
||||
return true;
|
||||
}
|
||||
@@ -340,10 +340,10 @@ namespace Subsurface
|
||||
buttonsTab.Update((float)deltaTime);
|
||||
if (selectedTab>0) menuTabs[selectedTab].Update((float)deltaTime);
|
||||
|
||||
Game1.TitleScreen.TitlePosition =
|
||||
Vector2.Lerp(Game1.TitleScreen.TitlePosition, new Vector2(
|
||||
Game1.TitleScreen.TitleSize.X / 2.0f * Game1.TitleScreen.Scale + 30.0f,
|
||||
Game1.TitleScreen.TitleSize.Y / 2.0f * Game1.TitleScreen.Scale + 30.0f),
|
||||
GameMain.TitleScreen.TitlePosition =
|
||||
Vector2.Lerp(GameMain.TitleScreen.TitlePosition, new Vector2(
|
||||
GameMain.TitleScreen.TitleSize.X / 2.0f * GameMain.TitleScreen.Scale + 30.0f,
|
||||
GameMain.TitleScreen.TitleSize.Y / 2.0f * GameMain.TitleScreen.Scale + 30.0f),
|
||||
0.1f);
|
||||
|
||||
}
|
||||
@@ -352,7 +352,7 @@ namespace Subsurface
|
||||
{
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
Game1.TitleScreen.Draw(spriteBatch, graphics, -1.0f, (float)deltaTime);
|
||||
GameMain.TitleScreen.Draw(spriteBatch, graphics, -1.0f, (float)deltaTime);
|
||||
|
||||
//Game1.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace Subsurface
|
||||
|
||||
GUI.Draw((float)deltaTime, spriteBatch, null);
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Subsurface v"+Game1.Version, new Vector2(10, Game1.GraphicsHeight-20), Color.White);
|
||||
spriteBatch.DrawString(GUI.Font, "Subsurface v"+GameMain.Version, new Vector2(10, GameMain.GraphicsHeight-20), Color.White);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
@@ -383,10 +383,10 @@ namespace Subsurface
|
||||
Submarine selectedSub = mapList.SelectedData as Submarine;
|
||||
if (selectedSub == null) return false;
|
||||
|
||||
Game1.GameSession = new GameSession(selectedSub, saveNameBox.Text, GameModePreset.list.Find(gm => gm.Name == "Single Player"));
|
||||
(Game1.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text);
|
||||
GameMain.GameSession = new GameSession(selectedSub, saveNameBox.Text, GameModePreset.list.Find(gm => gm.Name == "Single Player"));
|
||||
(GameMain.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text);
|
||||
|
||||
Game1.LobbyScreen.Select();
|
||||
GameMain.LobbyScreen.Select();
|
||||
|
||||
new GUIMessageBox("Welcome to Subsurface!", "Please note that the single player mode is very unfinished at the moment; "+
|
||||
"for example, the NPCs don't have an AI yet and there are only a couple of different quests to complete. The multiplayer "+
|
||||
@@ -420,7 +420,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
Game1.LobbyScreen.Select();
|
||||
GameMain.LobbyScreen.Select();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ namespace Subsurface
|
||||
|
||||
public NetLobbyScreen()
|
||||
{
|
||||
int width = Math.Min(Game1.GraphicsWidth - 80, 1500);
|
||||
int height = Math.Min(Game1.GraphicsHeight - 80, 800);
|
||||
int width = Math.Min(GameMain.GraphicsWidth - 80, 1500);
|
||||
int height = Math.Min(GameMain.GraphicsHeight - 80, 800);
|
||||
|
||||
Rectangle panelRect = new Rectangle(0,0,width,height);
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Subsurface
|
||||
|
||||
var serverName = new GUITextBox(new Rectangle(0, 0, 200, 20), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.Style, infoFrame);
|
||||
serverName.TextGetter = GetServerName;
|
||||
serverName.Enabled = Game1.Server != null;
|
||||
serverName.Enabled = GameMain.Server != null;
|
||||
serverName.OnTextChanged = ChangeServerName;
|
||||
|
||||
serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.Style, infoFrame);
|
||||
@@ -248,50 +248,50 @@ namespace Subsurface
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
Game1.LightManager.LosEnabled = false;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
|
||||
//infoFrame.ClearChildren();
|
||||
|
||||
textBox.Select();
|
||||
|
||||
Character.Controlled = null;
|
||||
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
subList.Enabled = Game1.Server != null;
|
||||
modeList.Enabled = Game1.Server != null;
|
||||
durationBar.Enabled = Game1.Server != null;
|
||||
seedBox.Enabled = Game1.Server != null;
|
||||
serverMessage.Enabled = Game1.Server != null;
|
||||
ServerName = (Game1.Server==null) ? "Server" : Game1.Server.Name;
|
||||
subList.Enabled = GameMain.Server != null;
|
||||
modeList.Enabled = GameMain.Server != null;
|
||||
durationBar.Enabled = GameMain.Server != null;
|
||||
seedBox.Enabled = GameMain.Server != null;
|
||||
serverMessage.Enabled = GameMain.Server != null;
|
||||
ServerName = (GameMain.Server==null) ? "Server" : GameMain.Server.Name;
|
||||
|
||||
modeList.OnSelected += SelectMode;
|
||||
|
||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton"));
|
||||
|
||||
if (IsServer && Game1.Server != null)
|
||||
if (IsServer && GameMain.Server != null)
|
||||
{
|
||||
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
startButton.OnClicked = Game1.Server.StartGame;
|
||||
startButton.OnClicked = GameMain.Server.StartGame;
|
||||
startButton.UserData = "startButton";
|
||||
|
||||
//mapList.OnSelected = new GUIListBox.OnSelectedHandler(Game1.server.UpdateNetLobby);
|
||||
modeList.OnSelected += Game1.Server.UpdateNetLobby;
|
||||
durationBar.OnMoved = Game1.Server.UpdateNetLobby;
|
||||
modeList.OnSelected += GameMain.Server.UpdateNetLobby;
|
||||
durationBar.OnMoved = GameMain.Server.UpdateNetLobby;
|
||||
|
||||
if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(-1);
|
||||
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(-1);
|
||||
|
||||
if (infoFrame.children.Find(c => c.UserData as string == "playyourself") == null)
|
||||
{
|
||||
var playYourself = new GUITickBox(new Rectangle(0, -20, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame);
|
||||
playYourself.Selected = Game1.Server.CharacterInfo != null;
|
||||
var playYourself = new GUITickBox(new Rectangle(-30, -30, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame);
|
||||
playYourself.Selected = GameMain.Server.CharacterInfo != null;
|
||||
playYourself.OnSelected = TogglePlayYourself;
|
||||
playYourself.UserData = "playyourself";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePlayerFrame(Game1.Client.CharacterInfo);
|
||||
UpdatePlayerFrame(GameMain.Client.CharacterInfo);
|
||||
}
|
||||
|
||||
base.Select();
|
||||
@@ -303,10 +303,10 @@ namespace Subsurface
|
||||
{
|
||||
playerFrame.ClearChildren();
|
||||
|
||||
if (IsServer && Game1.Server != null)
|
||||
if (IsServer && GameMain.Server != null)
|
||||
{
|
||||
var playYourself = new GUITickBox(new Rectangle(0, -20, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame);
|
||||
playYourself.Selected = Game1.Server.CharacterInfo != null;
|
||||
playYourself.Selected = GameMain.Server.CharacterInfo != null;
|
||||
playYourself.OnSelected = TogglePlayYourself;
|
||||
playYourself.UserData = "playyourself";
|
||||
}
|
||||
@@ -364,17 +364,17 @@ namespace Subsurface
|
||||
GUITickBox tickBox = obj as GUITickBox;
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
Game1.Server.CharacterInfo = new CharacterInfo(Character.HumanConfigFile, Game1.Server.Name);
|
||||
UpdatePlayerFrame(Game1.Server.CharacterInfo);
|
||||
GameMain.Server.CharacterInfo = new CharacterInfo(Character.HumanConfigFile, GameMain.Server.Name);
|
||||
UpdatePlayerFrame(GameMain.Server.CharacterInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerFrame.ClearChildren();
|
||||
|
||||
if (IsServer && Game1.Server != null)
|
||||
if (IsServer && GameMain.Server != null)
|
||||
{
|
||||
Game1.Server.CharacterInfo = null;
|
||||
Game1.Server.Character = null;
|
||||
GameMain.Server.CharacterInfo = null;
|
||||
GameMain.Server.Character = null;
|
||||
|
||||
var playYourself = new GUITickBox(new Rectangle(0, -20, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame);
|
||||
playYourself.OnSelected = TogglePlayYourself;
|
||||
@@ -385,7 +385,7 @@ namespace Subsurface
|
||||
|
||||
private bool SelectMap(GUIComponent component, object obj)
|
||||
{
|
||||
if (Game1.Server != null) Game1.Server.UpdateNetLobby(obj);
|
||||
if (GameMain.Server != null) GameMain.Server.UpdateNetLobby(obj);
|
||||
|
||||
Submarine sub = (Submarine)obj;
|
||||
|
||||
@@ -399,18 +399,18 @@ namespace Subsurface
|
||||
|
||||
public bool ChangeServerName(GUITextBox textBox, string text)
|
||||
{
|
||||
if (Game1.Server == null) return false;
|
||||
if (GameMain.Server == null) return false;
|
||||
ServerName = text;
|
||||
Game1.Server.UpdateNetLobby(null, null);
|
||||
GameMain.Server.UpdateNetLobby(null, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UpdateServerMessage(GUITextBox textBox, string text)
|
||||
{
|
||||
if (Game1.Server == null) return false;
|
||||
if (GameMain.Server == null) return false;
|
||||
ServerMessage = text;
|
||||
Game1.Server.UpdateNetLobby(null, null);
|
||||
GameMain.Server.UpdateNetLobby(null, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -456,8 +456,8 @@ namespace Subsurface
|
||||
|
||||
pos += offset * 0.8f;
|
||||
|
||||
Game1.GameScreen.Cam.TargetPos = pos;
|
||||
Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
GameMain.GameScreen.Cam.TargetPos = pos;
|
||||
GameMain.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
menu.Update((float)deltaTime);
|
||||
|
||||
@@ -468,7 +468,7 @@ namespace Subsurface
|
||||
{
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
Game1.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
GameMain.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
@@ -507,7 +507,7 @@ namespace Subsurface
|
||||
|
||||
public bool StartGame(object obj)
|
||||
{
|
||||
Game1.Server.StartGame(null, obj);
|
||||
GameMain.Server.StartGame(null, obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ namespace Subsurface
|
||||
{
|
||||
if (String.IsNullOrEmpty(message)) return false;
|
||||
|
||||
Game1.NetworkMember.SendChatMessage(Game1.NetworkMember.Name + ": " + message);
|
||||
GameMain.NetworkMember.SendChatMessage(GameMain.NetworkMember.Name + ": " + message);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -534,14 +534,14 @@ namespace Subsurface
|
||||
try
|
||||
{
|
||||
Gender gender = (Gender)obj;
|
||||
Game1.Client.CharacterInfo.Gender = gender;
|
||||
Game1.Client.SendCharacterData();
|
||||
GameMain.Client.CharacterInfo.Gender = gender;
|
||||
GameMain.Client.SendCharacterData();
|
||||
|
||||
//CreatePreviewCharacter();
|
||||
}
|
||||
catch {}
|
||||
|
||||
UpdatePreviewPlayer(Game1.Client.CharacterInfo);
|
||||
UpdatePreviewPlayer(GameMain.Client.CharacterInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ namespace Subsurface
|
||||
//textBox.Text = LevelSeed;
|
||||
//textBox.Selected = false;
|
||||
|
||||
if (Game1.Server != null) Game1.Server.UpdateNetLobby(null);
|
||||
if (GameMain.Server != null) GameMain.Server.UpdateNetLobby(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -579,13 +579,13 @@ namespace Subsurface
|
||||
{
|
||||
if (string.IsNullOrEmpty(newName)) return false;
|
||||
|
||||
if (Game1.NetworkMember == null || Game1.NetworkMember.CharacterInfo == null) return true;
|
||||
if (GameMain.NetworkMember == null || GameMain.NetworkMember.CharacterInfo == null) return true;
|
||||
|
||||
Game1.NetworkMember.CharacterInfo.Name = newName;
|
||||
if (Game1.Client != null)
|
||||
GameMain.NetworkMember.CharacterInfo.Name = newName;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
Game1.Client.Name = newName;
|
||||
Game1.Client.SendCharacterData();
|
||||
GameMain.Client.Name = newName;
|
||||
GameMain.Client.SendCharacterData();
|
||||
}
|
||||
|
||||
textBox.Text = newName;
|
||||
@@ -628,7 +628,7 @@ namespace Subsurface
|
||||
(listBox.children[i] as GUITextBlock).Text = (i+1) + ". " + (listBox.children[i].UserData as JobPrefab).Name;
|
||||
}
|
||||
|
||||
if (Game1.Client!=null) Game1.Client.SendCharacterData();
|
||||
if (GameMain.Client!=null) GameMain.Client.SendCharacterData();
|
||||
}
|
||||
|
||||
public bool TrySelectMap(string mapName, string md5Hash)
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Subsurface
|
||||
|
||||
public ServerListScreen()
|
||||
{
|
||||
int width = Math.Min(Game1.GraphicsWidth - 160, 1000);
|
||||
int height = Math.Min(Game1.GraphicsHeight - 160, 700);
|
||||
int width = Math.Min(GameMain.GraphicsWidth - 160, 1000);
|
||||
int height = Math.Min(GameMain.GraphicsHeight - 160, 700);
|
||||
|
||||
Rectangle panelRect = new Rectangle(0, 0, width, height);
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Subsurface
|
||||
|
||||
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.Style, menu);
|
||||
button.UserData = 0;
|
||||
button.OnClicked = Game1.MainMenuScreen.SelectTab;
|
||||
button.OnClicked = GameMain.MainMenuScreen.SelectTab;
|
||||
|
||||
|
||||
refreshDisableTimer = DateTime.Now;
|
||||
@@ -302,8 +302,8 @@ namespace Subsurface
|
||||
selectedPassword = passwordBox.Text;
|
||||
}
|
||||
|
||||
Game1.NetworkMember = new GameClient(clientNameBox.Text);
|
||||
Game1.Client.ConnectToServer(ip, selectedPassword);
|
||||
GameMain.NetworkMember = new GameClient(clientNameBox.Text);
|
||||
GameMain.Client.ConnectToServer(ip, selectedPassword);
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ namespace Subsurface
|
||||
{
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
Game1.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
GameMain.GameScreen.DrawMap(graphics, spriteBatch);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Subsurface
|
||||
if (animController.HeadInWater)
|
||||
{
|
||||
ambienceVolume = 0.5f;
|
||||
ambienceVolume += animController.limbs[0].LinearVelocity.Length();
|
||||
ambienceVolume += animController.Limbs[0].LinearVelocity.Length();
|
||||
|
||||
lowpassHFGain = 0.2f;
|
||||
}
|
||||
@@ -185,9 +185,9 @@ namespace Subsurface
|
||||
if (musicClips == null) return;
|
||||
|
||||
Task criticalTask = null;
|
||||
if (Game1.GameSession!=null)
|
||||
if (GameMain.GameSession!=null)
|
||||
{
|
||||
foreach (Task task in Game1.GameSession.taskManager.Tasks)
|
||||
foreach (Task task in GameMain.GameSession.taskManager.Tasks)
|
||||
{
|
||||
if (!task.IsStarted) continue;
|
||||
if (criticalTask == null || task.Priority > criticalTask.Priority)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Subsurface
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Copy(Game1.GameSession.Submarine.FilePath, tempPath + "\\map.gz");
|
||||
File.Copy(GameMain.GameSession.Submarine.FilePath, tempPath + "\\map.gz");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -48,7 +48,7 @@ namespace Subsurface
|
||||
|
||||
try
|
||||
{
|
||||
Game1.GameSession.Save(tempPath + "\\gamesession.xml");
|
||||
GameMain.GameSession.Save(tempPath + "\\gamesession.xml");
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
@@ -76,7 +76,7 @@ namespace Subsurface
|
||||
DecompressToDirectory(filePath, tempPath, null);
|
||||
|
||||
Submarine selectedMap = Submarine.Load(tempPath +"\\map.gz");
|
||||
Game1.GameSession = new GameSession(selectedMap, fileName, tempPath + "\\gamesession.xml");
|
||||
GameMain.GameSession = new GameSession(selectedMap, fileName, tempPath + "\\gamesession.xml");
|
||||
|
||||
//Directory.Delete(tempPath, true);
|
||||
}
|
||||
|
||||
@@ -177,5 +177,31 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void CleanOldFiles()
|
||||
{
|
||||
string currentDir = Directory.GetCurrentDirectory();
|
||||
|
||||
string[] files = Directory.GetFiles(currentDir, "*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (file.Length<4 || file.Substring(0,4)!="OLD_") continue;
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("deleting file " + file);
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(currentDir + "\\" + file);
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Could not delete file ''" + file + "'' (" + e.Message + ")");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Source\Camera.cs" />
|
||||
<Compile Include="Source\Characters\AICharacter.cs" />
|
||||
<Compile Include="Source\Characters\AI\AIController.cs" />
|
||||
<Compile Include="Source\Characters\AI\AITarget.cs" />
|
||||
<Compile Include="Source\Characters\AI\PathFinder.cs" />
|
||||
|
||||
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "Lidgren.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher2", "Launcher2\Launcher2.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashReporter", "CrashReporter\CrashReporter.csproj", "{6BE950CD-9A34-49C9-939A-786AC89C287E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Android|Any CPU = Android|Any CPU
|
||||
@@ -345,6 +347,51 @@ Global
|
||||
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
||||
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|x86.ActiveCfg = Release|x86
|
||||
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|x86.Build.0 = Debug|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|x86.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|Any CPU.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|x86.ActiveCfg = Release|x86
|
||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user