private bool ProcessTrap()
{
if(ItemManager.FindItemInInventory("Necklace") != null)
{
return false;
}
GameResult = GameResult.Failed;
// Draw Walls
foreach(Point wallPoint in currentRoom.Trap.WallPoints)
{
SetGlyph(wallPoint.X, wallPoint.Y, 178, Color.White);
}
waterXStart = currentRoom.Trap.WaterFlowXStart;
waterXEnd = currentRoom.Trap.WaterFlowXEnd - 1;
waterYStart = currentRoom.Trap.WaterFlowYStart;
waterYEnd = currentRoom.Trap.WaterFlowYEnd;
// Animate the water
animation = new InstructionSet();
animation.Instructions.AddLast(new Wait() { Duration = 0.2f });
var waterFillInstruction = new CodeInstruction();
waterFillInstruction.CodeCallback = (inst) =>
{
waterXStart += 1;
if (waterXStart > waterXEnd)
{
inst.IsFinished = true;
gameOver = true;
}
SetGlyph(waterXStart, waterYStart, 176, Color.White);
SetGlyph(waterXStart, waterYEnd, 176, Color.White);
};
animation.Instructions.AddLast(waterFillInstruction);
UserMessage userMessage = new UserMessage();
userMessage.AddLine("You have");
userMessage.AddLine("sprung a Trap!");
userMessage.AddLine("The room has");
userMessage.AddLine("filled with");
userMessage.AddLine("water and you");
userMessage.AddLine("drowned!");
// Kill Character
this.player.Kill();
PrintUserMessage(userMessage);
EndGame();
return true;
}