public bool AttachCardToSquare(HackCard hackCard, string[] tempCircuitConnections) { int timesToRotate = GetCountToNextLegalRotation(hackCard); if (timesToRotate != -1) { HackCard newHackCard = Instantiate(hackCard, new Vector2(hackholder.transform.position.x, hackholder.transform.position.y), Quaternion.identity); newHackCard.SetModifiedCircuit(tempCircuitConnections); newHackCard.transform.SetParent(hackholder.transform); newHackCard.transform.localScale = new Vector3(1, 1, 1); newHackCard.SetGridSquareHolder(this); for (int i = 0; i < timesToRotate; i++) { RotateCardNinetyDegrees(newHackCard); newHackCard.RotateCircuitsAndSpikesNinetyDegrees(); } HackBattleData hackBattleData = FindObjectOfType <HackBattleData>(); hackBattleData.SetStateToCardUI(); newHackCard.SetupUI(GetCountToPreviousLegalRotation(newHackCard, 1), GetCountToNextLegalRotation(newHackCard, 1)); attachedHackCard = newHackCard; UpdateSecurityRating(); return(true); } else { return(false); } }
public void RotateButtonPressed(int timesToRotate, string directionToRotate) { if (directionToRotate == "left") { timesToRotate = 4 - timesToRotate; } for (int i = 0; i < timesToRotate; i++) { RotateCardNinetyDegrees(attachedHackCard); attachedHackCard.RotateCircuitsAndSpikesNinetyDegrees(); } attachedHackCard.SetupUI(GetCountToPreviousLegalRotation(attachedHackCard, 1), GetCountToNextLegalRotation(attachedHackCard, 1)); }