public void ControlPrevLane(int playerIndex) { var currLane = GetMapUtil(playerIndex); SelectedLane.Remove(playerIndex); var prevLane = (currLane == 0 ? numLane - 1 : (currLane - 1) % numLane); SelectedLane.Add(playerIndex, prevLane); }
public void ControlNextLane(int playerIndex) { var currLane = GetMapUtil(playerIndex); SelectedLane.Remove(playerIndex); var nextLane = (currLane + 1) % numLane; SelectedLane.Add(playerIndex, nextLane); }
public override void execute() { // after animation resolve if (!CardUtils.isCardPlaying(SelectedLane.PlayerCard) && !CardUtils.isCardPlaying(SelectedLane.OpponentCard)) { waitTime += Time.deltaTime; } if (waitTime >= 1.5f) { bool destroy = true; // resolve CardScript playerCardScript = SelectedLane.PlayerCard.GetComponent <CardScript>(); CardScript opponentCardScript = SelectedLane.OpponentCard.GetComponent <CardScript>(); resolution = CardRuleUtils.Resolve(playerCardScript.Card, opponentCardScript.Card); if (resolution > 0) { SelectedLane.playerPoints += SelectedLane.playerStockpile.childCount + 1; } else if (resolution < 0) { SelectedLane.opponentPoints += SelectedLane.opponentStockpile.childCount + 1; } else if (StockpileRule) { // handle stockpile maneuver here destroy = false; ArenaManager.placeStockpile(SelectedLane.removeCard(Lane.Slot.PLAYER), SelectedLane.playerStockpile); ArenaManager.placeStockpile(SelectedLane.removeCard(Lane.Slot.OPPONENT), SelectedLane.opponentStockpile); } //TODO it'd be cool to have a fade animation // remove cards from lane slots if (destroy) { GameObject.Destroy(SelectedLane.removeCard(Lane.Slot.PLAYER)); GameObject.Destroy(SelectedLane.removeCard(Lane.Slot.OPPONENT)); foreach (Transform child in SelectedLane.playerStockpile) { GameObject.Destroy(child.gameObject); } foreach (Transform child in SelectedLane.opponentStockpile) { GameObject.Destroy(child.gameObject); } } } }
public int GetMapUtil(int player) { int val; return((SelectedLane.TryGetValue(player, out val)) ? val : 0); }