Dirty workaround for background music breaking during loading (the music is switched when a round starts), the "wall" at the top of the levels is drawn on top of the lightmap, small fixes in AIObjectiveGetItem and BackGroundSpriteManager

This commit is contained in:
Regalis
2016-05-15 17:58:56 +03:00
parent 4a54788d7b
commit be72fee824
8 changed files with 66 additions and 43 deletions

View File

@@ -117,7 +117,7 @@
<Compile Include="Source\GameSession\ShiftSummary.cs" />
<Compile Include="Source\GUI\GUIDropDown.cs" />
<Compile Include="Source\GUI\GUIMessage.cs" />
<Compile Include="Source\GUI\TitleScreen.cs" />
<Compile Include="Source\GUI\LoadingScreen.cs" />
<Compile Include="Source\Items\Components\Holdable\MeleeWeapon.cs" />
<Compile Include="Source\Items\Components\Holdable\Propulsion.cs" />
<Compile Include="Source\Items\Components\Machines\Deconstructor.cs" />

View File

@@ -58,6 +58,8 @@ namespace Barotrauma
if (targetItem == null) return;
}
if (moveToTarget == null) return;
if (Vector2.Distance(character.Position, moveToTarget.Position) < targetItem.PickDistance*2.0f)
{
int targetSlot = -1;

View File

@@ -92,7 +92,7 @@ namespace Barotrauma
int x = (int)Math.Floor(((Vector2)pos).X / GridSize);
if (x<0 || x >= sprites.GetLength(0)) continue;
int y = (int)Math.Floor(((Vector2)pos).Y / GridSize);
if (y<0 || 1 >= sprites.GetLength(1)) continue;
if (y<0 || y >= sprites.GetLength(1)) continue;
sprites[x,y].Add(newSprite);
}

View File

@@ -146,6 +146,7 @@ namespace Barotrauma
TaskManager.StartShift(level);
GameMain.GameScreen.ColorFade(Color.Black, Color.TransparentBlack, 5.0f);
SoundPlayer.SwitchMusic();
}
public void EndShift(string endMessage)

View File

@@ -182,7 +182,7 @@ namespace Barotrauma
spriteBatch.Draw(shaftTexture,
new Rectangle((int)(MathUtils.Round(pos.X, 512.0f)), (int)pos.Y, width, 512),
new Rectangle(0, 0, width, 256),
Color.White, 0.0f,
level.BackgroundColor, 0.0f,
Vector2.Zero,
SpriteEffects.None, 0.0f);
}

View File

@@ -310,12 +310,19 @@ namespace Barotrauma
Submarine.DrawFront(spriteBatch);
if (Level.Loaded!=null) Level.Loaded.DrawFront(spriteBatch);
spriteBatch.End();
GameMain.LightManager.DrawLightMap(spriteBatch, cam, lightBlur.Effect);
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend, SamplerState.LinearWrap,
null, null, null,
cam.Transform);
if (Level.Loaded!=null) Level.Loaded.DrawFront(spriteBatch);
spriteBatch.End();
if (Character.Controlled != null)
{
GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam, lightBlur.Effect);

View File

@@ -229,44 +229,7 @@ namespace Barotrauma
{
if (musicClips == null) return;
Task criticalTask = null;
if (GameMain.GameSession!=null && GameMain.GameSession.TaskManager != null)
{
foreach (Task task in GameMain.GameSession.TaskManager.Tasks)
{
if (!task.IsStarted) continue;
if (criticalTask == null || task.Priority > criticalTask.Priority)
{
criticalTask = task;
}
}
}
List<BackgroundMusic> suitableMusic = null;
if (OverrideMusicType != null)
{
suitableMusic = musicClips.Where(x => x != null && x.type == OverrideMusicType).ToList();
}
else if (Character.Controlled != null && Level.Loaded != null && Level.Loaded.Ruins.Any(r => r.Area.Contains(Character.Controlled.WorldPosition)))
{
suitableMusic = musicClips.Where(x => x != null && x.type == "ruins").ToList();
}
else if (Submarine.Loaded != null && Submarine.Loaded.AtDamageDepth)
{
suitableMusic = musicClips.Where(x => x != null && x.type == "deep").ToList();
}
else if (criticalTask == null)
{
suitableMusic = musicClips.Where(x => x != null && x.type == "default").ToList();
}
else
{
suitableMusic = musicClips.Where(x =>
x != null &&
x.type == criticalTask.MusicType &&
x.priorityRange.X < criticalTask.Priority &&
x.priorityRange.Y > criticalTask.Priority).ToList();
}
List<BackgroundMusic> suitableMusic = GetSuitableMusicClips();
if (suitableMusic.Count > 0 && !suitableMusic.Contains(currentMusic))
{
@@ -297,6 +260,56 @@ namespace Barotrauma
}
}
public static void SwitchMusic()
{
var suitableMusic = GetSuitableMusicClips();
if (suitableMusic.Count > 1)
{
targetMusic = suitableMusic.Find(m => m != currentMusic);
}
}
private static List<BackgroundMusic> GetSuitableMusicClips()
{
Task criticalTask = null;
if (GameMain.GameSession != null && GameMain.GameSession.TaskManager != null)
{
foreach (Task task in GameMain.GameSession.TaskManager.Tasks)
{
if (!task.IsStarted) continue;
if (criticalTask == null || task.Priority > criticalTask.Priority)
{
criticalTask = task;
}
}
}
if (OverrideMusicType != null)
{
return musicClips.Where(x => x != null && x.type == OverrideMusicType).ToList();
}
else if (Character.Controlled != null && Level.Loaded != null && Level.Loaded.Ruins.Any(r => r.Area.Contains(Character.Controlled.WorldPosition)))
{
return musicClips.Where(x => x != null && x.type == "ruins").ToList();
}
else if (Submarine.Loaded != null && Submarine.Loaded.AtDamageDepth)
{
return musicClips.Where(x => x != null && x.type == "deep").ToList();
}
else if (criticalTask == null)
{
return musicClips.Where(x => x != null && x.type == "default").ToList();
}
return musicClips.Where(x =>
x != null &&
x.type == criticalTask.MusicType &&
x.priorityRange.X < criticalTask.Priority &&
x.priorityRange.Y > criticalTask.Priority).ToList();
}
public static void PlaySplashSound(Vector2 worldPosition, float strength)
{
int splashIndex = MathHelper.Clamp((int)(strength + Rand.Range(-2,2)), 0, SplashSounds.Length-1);