Switch to Barotrauma & too many misc changes to remember

This commit is contained in:
Regalis
2015-10-16 18:11:58 +03:00
parent 2bb5d41836
commit 838022fcd5
203 changed files with 540 additions and 419 deletions

View File

@@ -1,13 +1,13 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Subsurface.Items.Components;
using Barotrauma.Items.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface
namespace Barotrauma
{
class TutorialMode : GameMode
{
@@ -17,7 +17,7 @@ namespace Subsurface
public static void Start()
{
Submarine.Load("Content/Map/TutorialSub.gz", "");
Submarine.Load("Content/Map/TutorialSub.sub", "");
GameMain.GameSession = new GameSession(Submarine.Loaded, "", GameModePreset.list.Find(gm => gm.Name.ToLower()=="tutorial"));
@@ -86,12 +86,15 @@ namespace Subsurface
private IEnumerable<object> UpdateState()
{
Submarine.Loaded.SetPosition(new Vector2(Submarine.Loaded.Position.X, 38500.0f));
GameMain.GameScreen.BackgroundSpriteManager.SpawnSprites(1, Submarine.Loaded.Position + Character.Controlled.Position);
//spawn some fish next to the player
GameMain.GameScreen.BackgroundSpriteManager.SpawnSprites(2,
Submarine.Loaded.Position + Character.Controlled.Position);
yield return new WaitForSeconds(4.0f);
infoBox = CreateInfoFrame("Use WASD to move and mouse to look around");
infoBox = CreateInfoFrame("Use WASD to move and the mouse to look around");
yield return new WaitForSeconds(5.0f);
@@ -110,9 +113,19 @@ namespace Subsurface
//-----------------------------------
infoBox = CreateInfoFrame("Now it's time to power up the submarine. Go to the upper left corner of the submarine, where you'll find a nuclear reactor.");
infoBox = CreateInfoFrame("Hold W or S to walk up or down stairs. Use shift to run.", true);
while (infoBox!=null)
{
yield return CoroutineStatus.Running;
}
//-----------------------------------
infoBox = CreateInfoFrame("At the moment the submarine has no power, which means that crucial systems such as the oxygen generator or the engine aren't running. Let's fix this: go to the upper left corner of the submarine, where you'll find a nuclear reactor.");
Reactor reactor = Item.itemList.Find(i => i.HasTag("tutorialreactor")).GetComponent<Reactor>();
reactor.MeltDownTemp = 20000.0f;
while (Vector2.Distance(Character.Controlled.Position, reactor.Item.Position)>200.0f)
{
@@ -135,28 +148,39 @@ namespace Subsurface
}
yield return new WaitForSeconds(0.5f);
infoBox = CreateInfoFrame("The reactor core has started generating heat, which in turn generates power for the submarine. It won't generate much power at the moment, "
+" because the shutdown temperature is set to 500. When the temperature of the reactor raises higher than the shutdown temperature, the reactor will automatically start to cool itself down."
+ " You should increase it to somewhere around 5000.");
infoBox = CreateInfoFrame("The reactor core has started generating heat, which in turn generates power for the submarine. The power generation is very low at the moment,"
+" because the reactor is set to shut itself down when the temperature rises above 500 degrees Celsius. You can adjust the temperature limit by changing the ''Shutdown Temperature'' in the control panel.", true);
while (Math.Abs(reactor.ShutDownTemp-5000.0f) > 400.0f)
while (infoBox!=null)
{
reactor.ShutDownTemp = Math.Min(reactor.ShutDownTemp, 5000.0f);
yield return CoroutineStatus.Running;
}
yield return new WaitForSeconds(0.5f);
infoBox = CreateInfoFrame("The amount of power generated by the reactor should be kept close to the amount of power consumed by the devices in the submarine. "
+"If there's not enough power, devices won't function properly, and if there's too much power, some devices may be damaged. Turn on ''Automatic temperature control'' to "
+"make the reactor automatically adjust the temperature to a suitable level.");
+"If there isn't enough power, devices won't function properly (or at all), and if there's too much power, some devices may be damaged."
+" Try to raise the temperature of the reactor close to 3000 degrees by adjusting the fission and cooling rates.");
while (Math.Abs(reactor.Temperature-3000.0f) > 100.0f)
{
reactor.ShutDownTemp = Math.Min(reactor.ShutDownTemp, 5000.0f);
yield return CoroutineStatus.Running;
}
yield return new WaitForSeconds(0.5f);
infoBox = CreateInfoFrame("Looks like we're up and running! Now you should turn on the ''Automatic temperature control'', which will make the reactor "
+"automatically adjust the temperature to a suitable level. Even though it's an easy way to keep the reactor up and running most of the time, "
+"you should keep in mind that it changes the temperature very slowly and carefully, which may cause issues if there are sudden changes in grid load.");
while (!reactor.AutoTemp)
{
yield return CoroutineStatus.Running;
}
yield return new WaitForSeconds(0.5f);
infoBox = CreateInfoFrame("That's the basics you need to know to power up the reactor! Now that there's power available for the engines, let's try steering the sub. "
+"Deselect the reactor by pressing E and head to the command room at the left edge of the vessel.");
infoBox = CreateInfoFrame("That's the basics of operating the reactor! Now that there's power available for the engines, it's time to get the submarine moving. "
+"Deselect the reactor by pressing E and head to the command room at the right edge of the vessel.");
Steering steering = Item.itemList.Find(i => i.HasTag("tutorialsteering")).GetComponent<Steering>();
Radar radar = steering.Item.GetComponent<Radar>();
@@ -165,6 +189,8 @@ namespace Subsurface
{
yield return CoroutineStatus.Running;
}
CoroutineManager.StartCoroutine(KeepReactorRunning(reactor));
infoBox = CreateInfoFrame("Select the navigation terminal by walking next to it and pressing E.");
@@ -183,7 +209,7 @@ namespace Subsurface
{
yield return CoroutineStatus.Running;
}
yield return new WaitForSeconds(1.0f);
yield return new WaitForSeconds(5.0f);
infoBox = CreateInfoFrame("You need a screwdriver to check the wiring of the terminal."
+ " Equip a screwdriver by pulling it to either of the slots with a hand symbol, and then select the terminal again by pressing E.");
@@ -272,14 +298,21 @@ namespace Subsurface
yield return new WaitForSeconds(0.5f);
infoBox = CreateInfoFrame("The white box in the middle is the submarine, and the white lines outside it are the walls of an underwater cavern. "
+ "Try moving the submarine by clicking somewhere inside the rectangle and draggind the pointer to the direction you want to go to.");
+ "Try moving the submarine by clicking somewhere on the monitor and dragging the pointer to the direction you want to go to.");
while (steering.CurrTargetVelocity == Vector2.Zero && steering.CurrTargetVelocity.Length() < 50.0f)
{
yield return CoroutineStatus.Running;
}
yield return new WaitForSeconds(4.0f);
infoBox = CreateInfoFrame("The submarine moves up and down by pumping water in and out of the two ballast tanks at the bottom of the submarine. "
+"The engine at the back of the sub moves it forwards and backwards.", true);
while (infoBox!=null)
{
yield return CoroutineStatus.Running;
}
infoBox = CreateInfoFrame("Steer the submarine downwards, heading further into the cavern.");
@@ -287,10 +320,7 @@ namespace Subsurface
{
yield return CoroutineStatus.Running;
}
yield return new WaitForSeconds(8.0f);
infoBox = CreateInfoFrame("The submarine moves up and down by pumping water in and out of the two ballast tanks at the bottom of the submarine. "
+"The engine at the back of the sub moves it forwards and backwards.");
yield return new WaitForSeconds(1.0f);
var moloch = new AICharacter("Content/Characters/Moloch/moloch.xml", steering.Item.SimPosition + Vector2.UnitX * 25.0f);
moloch.PlaySound(AIController.AiState.Attack);
@@ -318,7 +348,7 @@ namespace Subsurface
foreach (Limb limb in moloch.AnimController.Limbs)
{
limb.body.LinearVelocity = new Vector2(limb.LinearVelocity.X, limb.LinearVelocity.Y + steeringDir.Y*10.0f);
limb.body.LinearVelocity = new Vector2(limb.LinearVelocity.X*2.0f, limb.LinearVelocity.Y + steeringDir.Y*10.0f);
}
moloch.AIController.Steering = steeringDir;
@@ -338,17 +368,15 @@ namespace Subsurface
yield return new WaitForSeconds(1.0f);
} while (!broken);
yield return new WaitForSeconds(1.0f);
yield return new WaitForSeconds(0.5f);
var capacitor1 = Item.itemList.Find(i => i.HasTag("capacitor1")).GetComponent<PowerContainer>();
var capacitor2 = Item.itemList.Find(i => i.HasTag("capacitor1")).GetComponent<PowerContainer>();
CoroutineManager.StartCoroutine(KeepEnemyAway(moloch, new PowerContainer[] { capacitor1, capacitor2 }));
infoBox = CreateInfoFrame("The hull has been breached! Close all the doors to the command room to stop the water from flooding the entire sub!");
Door commandDoor1 = Item.itemList.Find(i => i.HasTag("commanddoor1")).GetComponent<Door>();
Door commandDoor2 = Item.itemList.Find(i => i.HasTag("commanddoor2")).GetComponent<Door>();
Door commandDoor3 = Item.itemList.Find(i => i.HasTag("commanddoor3")).GetComponent<Door>();
@@ -358,7 +386,7 @@ namespace Subsurface
yield return CoroutineStatus.Running;
}
infoBox = CreateInfoFrame("You should find yourself an diving mask or a diving suit, in case the creature causes more damage. "+
infoBox = CreateInfoFrame("You should quickly find yourself a diving mask or a diving suit. "+
"There are some in the room next to the airlock.");
while (!HasItem("Diving Mask") && !HasItem("Diving Suit"))
@@ -386,7 +414,7 @@ namespace Subsurface
yield return new WaitForSeconds(5.0f);
infoBox = CreateInfoFrame("Now it's time to stop the creature attacking the submarine. Head to the railgun room at the upper right corner of the sub.");
infoBox = CreateInfoFrame("Now you should stop the creature attacking the submarine before it does any more damage. Head to the railgun room at the upper right corner of the sub.");
var railGun = Item.itemList.Find(i => i.GetComponent<Turret>()!=null);
@@ -515,6 +543,7 @@ namespace Subsurface
Character.Controlled = null;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.LightManager.LosEnabled = false;
do
{
@@ -590,6 +619,19 @@ namespace Subsurface
yield return CoroutineStatus.Success;
}
private IEnumerable<object> KeepReactorRunning(Reactor reactor)
{
do
{
reactor.AutoTemp = true;
reactor.ShutDownTemp = 5000.0f;
yield return CoroutineStatus.Running;
} while (Item.itemList.Contains(reactor.Item));
yield return CoroutineStatus.Success;
}
public override void Draw(SpriteBatch spriteBatch)
{
base.Draw(spriteBatch);
@@ -598,10 +640,17 @@ namespace Subsurface
if (infoBox != null) infoBox.Draw(spriteBatch);
}
private GUIComponent CreateInfoFrame(string text)
private bool CloseInfoFrame(GUIButton button, object userData)
{
infoBox = null;
return true;
}
private GUIComponent CreateInfoFrame(string text, bool hasButton = false)
{
int width = 300;
int height = 80;
int height = hasButton ? 110 : 80;
string wrappedText = ToolBox.WrapText(text, width, GUI.Font);
@@ -612,7 +661,13 @@ namespace Subsurface
infoBlock.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
infoBlock.Flash(Color.Green);
new GUITextBlock(new Rectangle(10, 10, width - 40, height), text, GUI.Style, infoBlock, true);
var textBlock = new GUITextBlock(new Rectangle(10, 10, width - 40, height), text, GUI.Style, infoBlock, true);
if (hasButton)
{
var okButton = new GUIButton(new Rectangle(0,-40,80,25), "OK", Alignment.BottomCenter, GUI.Style, textBlock);
okButton.OnClicked = CloseInfoFrame;
}
GUI.PlayMessageSound();