public void PlaceCardsWithState(StateDelta.CardInfo[] newCards, StateDelta.AgentInfo lead, StateDelta.AgentInfo follow) { // Clear all cards setGame = FindObjectOfType <SetGame>(); setGame.activeCards.Clear(); ClearCards(); for (int i = 0; i < cards.Length; i++) { string cardColor = newCards[i].color; string cardShape = newCards[i].shape; int cardCount = newCards[i].count; int[] cardPosition = newCards[i].pos; bool cardSelection = newCards[i].sel; bool agentOnTop = false; // Reverse the card selection if the agent is on top, because the agent // will later collide with the object. if (newCards[i].pos[0] == lead.pos[0] && newCards[i].pos[1] == lead.pos[1]) { agentOnTop = true; } else if (newCards[i].pos[0] == follow.pos[0] && newCards[i].pos[1] == follow.pos[1]) { agentOnTop = true; } if (agentOnTop) { cardSelection = !cardSelection; } cards[i] = cardGenerator.GenCardWithProperties(cardColor, cardShape, cardCount, cardPosition[0], cardPosition[1], cardSelection); // If the card was not unselected, then add it to the set of selected cards if (cardSelection) { setGame.ForceCardActivation(cards[i]); } else { setGame.ForceCardDeactivation(cards[i]); } } }