public virtual void useAbility(MouseState mouseState, BoardFunctionality boardFunc) { if (INITIALCARD.cardProps.type == CardType.General) { if (exchangeValue < 0) { if (INITIALCARD.cardProps.defense >= GameComponent.ToAbsolute(exchangeValue)) { INITIALCARD.cardProps.defense += exchangeValue; abilityImplementation(mouseState, boardFunc); boardFunc.cardViewer.NextSelection(); } else { boardFunc.BOARDMESSAGE.addMessage(INITIALCARD.cardProps.name + " does not have enough power yet."); clickedInAbilityBox = false; resetAllCards(boardFunc); boardFunc.cardViewer.hardResetSelection(boardFunc); } } else { INITIALCARD.cardProps.defense += exchangeValue; abilityImplementation(mouseState, boardFunc); boardFunc.cardViewer.NextSelection(); } } else if (INITIALCARD.cardProps.type == CardType.Manuever) { abilityImplementation(mouseState, boardFunc); manueverImplementation(boardFunc); } else { abilityImplementation(mouseState, boardFunc); boardFunc.cardViewer.NextSelection(); } }
public void generalAbiltiies(MouseState mouseState, BoardFunctionality boardFunc) { foreach (Card friendlyCard in boardFunc.friendlySide.Rows[Side.General].cardsInContainer) { List <Ability> usableAbilities = new List <Ability>(); foreach (Ability ability in friendlyCard.cardProps.abilities) { if (ability.exchangeValue < 0) { if (GameComponent.ToAbsolute(ability.exchangeValue) <= friendlyCard.cardProps.defense) { usableAbilities.Add(ability); } } else { usableAbilities.Add(ability); } } Random random = new Random(); int selector = random.Next(0, usableAbilities.Count); usableAbilities[selector].useAbility(mouseState, boardFunc); } }
public void movementLogic(CardContainer startingContainer, CardContainer endingContainer, Card card, BoardFunctionality boardFunc) { card.makingAction = true; Vector2 newPosition = endingContainer.getEntrancePosition(card); if (newPosition.X > Game1.windowW || newPosition.X < -100) { throw new Exception(endingContainer.getPosition().ToString()); } if (newPosition.Y > Game1.windowH || newPosition.Y < -200) { throw new Exception(endingContainer.getPosition().ToString()); } int timeUntilArrival = 3; int speedX = (int)GameComponent.ToAbsolute((newPosition.X - card.getPosition().X)) / timeUntilArrival; if (speedX < 1) { speedX = 1; } int speedY = (int)GameComponent.ToAbsolute((newPosition.Y - card.getPosition().Y)) / timeUntilArrival; if (speedY < 1) { speedY = 1; } Vector2 adjustingPosition; bool xAxisFinished = false; bool yAxisFinished = false; if (card.getPosition().X < newPosition.X) { adjustingPosition = new Vector2(card.getPosition().X + speedX, card.getPosition().Y); card.setPos(adjustingPosition); } else if (card.getPosition().X > newPosition.X) { adjustingPosition = new Vector2(card.getPosition().X - speedX, card.getPosition().Y); card.setPos(adjustingPosition); } else { xAxisFinished = true; } if (card.getPosition().Y < newPosition.Y) { adjustingPosition = new Vector2(card.getPosition().X, card.getPosition().Y + speedY); card.setPos(adjustingPosition); } else if (card.getPosition().Y > newPosition.Y) { adjustingPosition = new Vector2(card.getPosition().X, card.getPosition().Y - speedY); card.setPos(adjustingPosition); } else { yAxisFinished = true; } if (xAxisFinished && yAxisFinished) { try { startingContainer.moveCard(endingContainer, card); } catch (Exception e) { Console.WriteLine(e); } card.makingAction = false; boardFunc.boardPosLogic.updateBoard(boardFunc); MouseTransformer.Set(MouseTransformer.State.Reg); boardFunc.boardActions.nextAction(); } }