public Trap(string name, Texture2D cardTexture, Texture2D cardBack, Dictionary <string, Button> buttons, Dictionary <string, Texture2D> dieTextures, Dictionary <string, SoundEffect> dieSounds) : base(name, cardTexture, cardBack, buttons) { trapTurnState = TrapTurnState.ROLL_FOR_TRAP; CurrentButtons = new List <Button>(); DieTextures = dieTextures; DieSounds = dieSounds; TrapDie = new Die(DieTextures, 840, 400); }
public void HandleButtons(Player player) { if (SingleMouseClick()) { switch (trapTurnState) { case TrapTurnState.ROLL_FOR_TRAP: if (XPos > 770 && XPos < 1018 && YPos > 600 && YPos < 672) { trapTurnState = TrapTurnState.ROLLANIMATION; } break; case TrapTurnState.SKILL_CHECK: if (XPos > 770 && XPos < 1018 && YPos > 600 && YPos < 672) { trapTurnState = TrapTurnState.ROLLANIMATION; SkillCheck = true; } break; case TrapTurnState.REVIEW: if (XPos > 770 && XPos < 1018 && YPos > 600 && YPos < 672) { trapTurnState = TrapTurnState.COMPLETE; } break; case TrapTurnState.COMPLETE: break; default: break; } } }
//---------------------- METHODS ----------------------------- public override bool HandleCard(Player player, MouseState current, MouseState previous, float xPos, float yPos) { XPos = xPos; YPos = yPos; CurrentMouseState = current; PreviousMouseState = previous; switch (trapTurnState) { case TrapTurnState.ROLL_FOR_TRAP: SkillCheck = false; HandleButtons(player); return(false); case TrapTurnState.ROLLANIMATION: if (AnimationCounter < 60) { RollAnimation(); } else { DieSoundPlayed = false; if (SkillCheck) { SkillCheckResult = player.playerDice.RollDice(); TrapDie.CurrentTexture = TrapDie.DieTextures["Roll " + SkillCheckResult]; if (SkillCheckResult <= player.Rank) { success = true; trapTurnState = TrapTurnState.REVIEW; } else { success = false; switch (TrapResult) { case 1: if (player.Food > 0) { player.Food -= 1; } else { player.Health -= 2; } break; case 2: if (player.Gold > 0) { player.Gold -= 1; } else { player.Health -= 2; } break; case 3: if (player.Armor > 0) { player.Armor -= 1; } else { player.Health -= 2; } break; case 4: player.Health -= 1; break; case 5: if (player.Experience > 1) { player.Experience -= 1; } else { player.Health -= 2; } break; case 6: player.FallBelow(); break; default: break; } trapTurnState = TrapTurnState.REVIEW; } } else { TrapResult = player.playerDice.RollDice(); TrapDie.CurrentTexture = TrapDie.DieTextures["Roll " + TrapResult]; trapTurnState = TrapTurnState.SKILL_CHECK; } } return(false); case TrapTurnState.SKILL_CHECK: DieSoundPlayed = false; AnimationCounter = 0; HandleButtons(player); return(false); case TrapTurnState.RESOLVE_TRAP: HandleButtons(player); return(false); case TrapTurnState.REVIEW: AnimationCounter = 0; HandleButtons(player); return(false); case TrapTurnState.COMPLETE: HandleButtons(player); return(true); default: return(false); } }