Skip to content

Commit

Permalink
Merge pull request #42 from Talberon/SOL-43_new_entities_and_maps
Browse files Browse the repository at this point in the history
Sol 43 new entities and maps
  • Loading branch information
Talberon authored Aug 1, 2019
2 parents 119833f + 8aac793 commit adcd1d1
Show file tree
Hide file tree
Showing 61 changed files with 13,320 additions and 389 deletions.
2 changes: 1 addition & 1 deletion SolStandard/Containers/Contexts/ControlContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ private static void ResolvingTurnControl(ControlMapper controlMapper)
{
if (controlMapper.Press(Input.Confirm, PressType.Single))
{
GlobalEventQueue.QueueSingleEvent(new ResolveTurnEvent());
GlobalEventQueue.QueueSingleEvent(new ResolveNetworkTurnEvent());
}
}

Expand Down
72 changes: 43 additions & 29 deletions SolStandard/Containers/Contexts/GameMapContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.Xna.Framework;
Expand Down Expand Up @@ -45,6 +46,8 @@ public enum TurnState
public int RoundCounter { get; private set; }
public bool CanCancelAction { get; set; }
private GameUnit HoverUnit { get; set; }
private TerrainEntity LastHoverEntity { get; set; }
private TerrainEntity LastHoverItem { get;set; }

private readonly Dictionary<Direction, UnitAnimationState> directionToAnimation =
new Dictionary<Direction, UnitAnimationState>
Expand Down Expand Up @@ -86,7 +89,6 @@ public void ResolveTurn()
{
if (GameContext.CurrentGameState == GameContext.GameState.Results) return;

TriggerEffectTilesTurnEnd();
GameContext.Scenario.CheckForWinState();
UpdateUnitMorale(Team.Blue);
UpdateUnitMorale(Team.Red);
Expand Down Expand Up @@ -473,6 +475,8 @@ public void UpdateHoverContextWindows()
GameMapView.SetEntityWindow(hoverSlice);

HoverUnit = hoverMapUnit;
LastHoverEntity = hoverSlice.TerrainEntity;
LastHoverItem = hoverSlice.ItemEntity;
}

private void UpdateThreatRangePreview(GameUnit hoverMapUnit, MapSlice hoverSlice)
Expand All @@ -487,8 +491,8 @@ private void UpdateThreatRangePreview(GameUnit hoverMapUnit, MapSlice hoverSlice
}
else if (hoverSlice.TerrainEntity is IThreatRange entityThreat)
{
if (LastHoverEntity == hoverSlice.TerrainEntity && LastHoverItem == hoverSlice.ItemEntity) return;
MapContainer.ClearDynamicAndPreviewGrids();

new UnitTargetingContext(MapDistanceTile.GetTileSprite(MapDistanceTile.TileType.Attack))
.GenerateThreatGrid(hoverSlice.MapCoordinates, entityThreat);
}
Expand Down Expand Up @@ -566,49 +570,58 @@ private static IIncrementableAction CurrentIncrementableAction()
return currentActionOption.Action as IIncrementableAction;
}

public static void TriggerEffectTilesTurnStart()
/// <summary>
/// Trigger all effect tiles that are set to trigger at the specified time.
/// </summary>
/// <param name="effectTriggerTime"></param>
/// <returns>True if any tile can trigger this phase.</returns>
public static bool TriggerEffectTiles(EffectTriggerTime effectTriggerTime)
{
List<IEffectTile> effectTiles = MapContainer.GameGrid[(int) Layer.Entities].OfType<IEffectTile>().ToList();
List<IEffectTile> triggerTiles = effectTiles.Where(tile => tile.WillTrigger(effectTriggerTime)).ToList();

if (effectTiles.Count <= 0) return;
if (triggerTiles.Count <= 0)
{
effectTiles.ForEach(tile => tile.HasTriggered = false);
return false;
}

Queue<IEvent> startOfTurnEffectTileEvents = new Queue<IEvent>();
startOfTurnEffectTileEvents.Enqueue(
Queue<IEvent> effectTileEvents = new Queue<IEvent>();
effectTileEvents.Enqueue(new WaitFramesEvent(10));
effectTileEvents.Enqueue(
new ToastAtCursorEvent(
"Resolving Tile Effects...",
"Resolving " + effectTriggerTime + " Tile Effects...",
AssetManager.MenuConfirmSFX,
100
)
);
startOfTurnEffectTileEvents.Enqueue(new WaitFramesEvent(50));
effectTileEvents.Enqueue(new WaitFramesEvent(50));

foreach (IEffectTile tile in effectTiles.Where(tile => tile.WillTrigger(EffectTriggerTime.StartOfTurn)))
foreach (IEffectTile tile in triggerTiles)
{
startOfTurnEffectTileEvents.Enqueue(new TriggerEffectTileEvent(tile, EffectTriggerTime.StartOfTurn,
50));
effectTileEvents.Enqueue(new CameraCursorPositionEvent(tile.MapCoordinates));
effectTileEvents.Enqueue(
new TriggerSingleEffectTileEvent(tile, effectTriggerTime, 60)
);
}

startOfTurnEffectTileEvents.Enqueue(new RemoveExpiredEffectTilesEvent(effectTiles));

GlobalEventQueue.QueueEvents(startOfTurnEffectTileEvents);
}

private static void TriggerEffectTilesTurnEnd()
{
List<IEffectTile> effectTiles = MapContainer.GameGrid[(int) Layer.Entities].OfType<IEffectTile>().ToList();

if (effectTiles.Count <= 0) return;
effectTileEvents.Enqueue(new RemoveExpiredEffectTilesEvent(triggerTiles));

Queue<IEvent> endOfTurnEffectTileEvents = new Queue<IEvent>();
foreach (IEffectTile tile in effectTiles.Where(tile => tile.WillTrigger(EffectTriggerTime.EndOfTurn)))
switch (effectTriggerTime)
{
endOfTurnEffectTileEvents.Enqueue(
new TriggerEffectTileEvent(tile, EffectTriggerTime.EndOfTurn, 80)
);
case EffectTriggerTime.StartOfRound:
effectTileEvents.Enqueue(new EffectTilesStartOfRoundEvent());
break;
case EffectTriggerTime.EndOfTurn:
effectTileEvents.Enqueue(new EndTurnEvent());
break;
default:
throw new ArgumentOutOfRangeException(nameof(effectTriggerTime), effectTriggerTime, null);
}

endOfTurnEffectTileEvents.Enqueue(new RemoveExpiredEffectTilesEvent(effectTiles));
GlobalEventQueue.QueueEvents(endOfTurnEffectTileEvents);
GlobalEventQueue.QueueEvents(effectTileEvents);

return true;
}

public static void RemoveExpiredEffectTiles(IEnumerable<IEffectTile> effectTiles)
Expand Down Expand Up @@ -643,6 +656,7 @@ public void SelectDraftMenuOption()
public void ClearDraftMenu()
{
GameMapView.CloseAdHocDraftMenu();
MapContainer.ClearDynamicAndPreviewGrids();
}

public void ToggleActionInventoryMenu()
Expand Down
2 changes: 1 addition & 1 deletion SolStandard/Containers/Contexts/InitiativeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void StartNewRound()
GlobalEventQueue.QueueEvents(newRoundEvents);

RefreshAllUnits();
GameMapContext.TriggerEffectTilesTurnStart();
GlobalEventQueue.QueueSingleEvent(new EffectTilesStartOfRoundEvent());

GlobalEventQueue.QueueSingleEvent(new UpdateTurnOrderEvent(this));
}
Expand Down
8 changes: 6 additions & 2 deletions SolStandard/Containers/Contexts/UnitMovingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,19 @@ private static void AddVisitedTilesToGameGrid(IEnumerable<MapDistanceTile> visit
}
}


public static bool CanEndMoveAtCoordinates(Vector2 coordinates)
{
return CanEndMoveAtCoordinates(GameContext.ActiveUnit?.UnitEntity, coordinates);
}

public static bool CanEndMoveAtCoordinates(UnitEntity unitEntityEndingMove, Vector2 coordinates)
{
if (!GameMapContext.CoordinatesWithinMapBounds(coordinates)) return false;

MapSlice slice = MapContainer.GetMapSliceAtCoordinates(coordinates);

if (slice.UnitEntity != null &&
(GameContext.ActiveUnit == null || slice.UnitEntity != GameContext.ActiveUnit.UnitEntity)) return false;
(GameContext.ActiveUnit == null || slice.UnitEntity != unitEntityEndingMove)) return false;

if (slice.TerrainEntity != null)
{
Expand Down
8 changes: 7 additions & 1 deletion SolStandard/Containers/View/GameMapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ public static Window GenerateEntityWindow(MapSlice hoverSlice)
WindowContentGrid noEntityContent = new WindowContentGrid(
new IRenderable[,]
{
{
new RenderText(AssetManager.WindowFont,
$"[ X: {GameContext.MapCursor.MapCoordinates.X}, Y: {GameContext.MapCursor.MapCoordinates.Y} ]"),
new RenderBlank()
},
{
new RenderText(AssetManager.WindowFont, "None"),
new RenderBlank()
Expand All @@ -404,7 +409,8 @@ public static Window GenerateEntityWindow(MapSlice hoverSlice)
(canMove) ? TerrainEntity.PositiveColor : TerrainEntity.NegativeColor)
}
},
1
1,
HorizontalAlignment.Centered
);

terrainContentGrid = new WindowContentGrid(
Expand Down
84 changes: 84 additions & 0 deletions SolStandard/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,18 @@
/processorParam:TextureFormat=Color
/build:Graphics/Images/Dice/AttackDiceAtlas.png

#begin Graphics/Images/Icons/Misc/CliffJump.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Misc/CliffJump.png

#begin Graphics/Images/Icons/Misc/clock.png
/importer:TextureImporter
/processor:TextureProcessor
Expand Down Expand Up @@ -1826,6 +1838,30 @@
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Misc/Interact.png

#begin Graphics/Images/Icons/Misc/Launchpad.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Misc/Launchpad.png

#begin Graphics/Images/Icons/Misc/Lock.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Misc/Lock.png

#begin Graphics/Images/Icons/Misc/old_spoils.png
/importer:TextureImporter
/processor:TextureProcessor
Expand All @@ -1838,6 +1874,30 @@
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Misc/old_spoils.png

#begin Graphics/Images/Icons/Misc/open.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Misc/open.png

#begin Graphics/Images/Icons/Misc/Piston.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Misc/Piston.png

#begin Graphics/Images/Icons/Misc/RecoverArmor.png
/importer:TextureImporter
/processor:TextureProcessor
Expand Down Expand Up @@ -2198,6 +2258,18 @@
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Skill/Intervention.png

#begin Graphics/Images/Icons/Skill/Jump.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Skill/Jump.png

#begin Graphics/Images/Icons/Skill/Kingslayer.png
/importer:TextureImporter
/processor:TextureProcessor
Expand Down Expand Up @@ -2306,6 +2378,18 @@
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Skill/Recover.png

#begin Graphics/Images/Icons/Skill/Rescue.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Graphics/Images/Icons/Skill/Rescue.png

#begin Graphics/Images/Icons/Skill/Shove.png
/importer:TextureImporter
/processor:TextureProcessor
Expand Down
Loading

0 comments on commit adcd1d1

Please sign in to comment.