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]); } } }
public void PlacePlayersWithState(StateDelta.AgentInfo leaderInfo, StateDelta.AgentInfo followerInfo) { // Destroy the previous leader and follower HexCell leaderCell = hexgrid.GetCell(leaderInfo.pos[0], leaderInfo.pos[1]); props[props.Count - 2].transform.position = leaderCell.transform.localPosition; props[props.Count - 2].transform.eulerAngles = new Vector3(0, leaderInfo.rot, 0); props[props.Count - 2].GetComponent <HexToHexControl>().currentLocation = leaderCell; props[props.Count - 2].GetComponent <HexQueuedCntrl>().currentLocation = leaderCell; props[props.Count - 2].GetComponent <TurnBasedControl>().currentLocation = leaderCell; props[props.Count - 2].GetComponent <SimulatedControl>().currentLocation = leaderCell; props[props.Count - 2].GetComponent <ReplayControl>().currentLocation = leaderCell; int leaderDirection = (leaderInfo.rot - 30) / 60; props[props.Count - 2].GetComponent <SimulatedControl>().directionIndex = leaderDirection; // Set the follower HexCell followerCell = hexgrid.GetCell(followerInfo.pos[0], followerInfo.pos[1]); int followerDirection = (followerInfo.rot - 30) / 60; props[props.Count - 1].GetComponent <SimulatedControl>().directionIndex = followerDirection; props[props.Count - 1].transform.position = followerCell.transform.localPosition; props[props.Count - 1].transform.eulerAngles = new Vector3(0, followerInfo.rot, 0); props[props.Count - 1].GetComponent <SimulatedControl>().currentLocation = followerCell; // Set their prop info human.GetComponent <HexToHexControl>().currentLocation = props[props.Count - 2].GetComponent <HexToHexControl>().currentLocation; human.GetComponent <HexQueuedCntrl>().currentLocation = props[props.Count - 2].GetComponent <HexQueuedCntrl>().currentLocation; human.GetComponent <SimulatedControl>().currentLocation = props[props.Count - 2].GetComponent <SimulatedControl>().currentLocation; human.GetComponent <ReplayControl>().currentLocation = props[props.Count - 2].GetComponent <ReplayControl>().currentLocation; human.GetComponent <SimulatedControl>().directionIndex = props[props.Count - 2].GetComponent <SimulatedControl>().directionIndex; // Set their prop info agent.GetComponent <HexToHexControl>().currentLocation = props[props.Count - 1].GetComponent <HexToHexControl>().currentLocation; agent.GetComponent <HexQueuedCntrl>().currentLocation = props[props.Count - 1].GetComponent <HexQueuedCntrl>().currentLocation; agent.GetComponent <SimulatedControl>().currentLocation = props[props.Count - 1].GetComponent <SimulatedControl>().currentLocation; agent.GetComponent <ReplayControl>().currentLocation = props[props.Count - 1].GetComponent <ReplayControl>().currentLocation; agent.GetComponent <SimulatedControl>().directionIndex = props[props.Count - 1].GetComponent <SimulatedControl>().directionIndex; }