// Update is called once per frame void Update() { if (!GameMaster.Instance.IsInActionPhase()) { return; } if (isHeld) { if (Input.GetMouseButtonUp(0)) { isHeld = false; this.selectedCard = null; UIHandCardManager.Instance.RemovePreview(); PlayerManager curPlayer = MainScreenManager_GameScene.Instance.GetPlayer(); SoldierPlacementManager.Instance.SetTargetable(curPlayer, false); Card finalCard = UIHandCardManager.Instance.GetSelectedCard(); bool replenishDefenseMode = GameMaster.Instance.IsReplenishMode(); if (this.GRGeneral("OutZone")) { UIHandCardManager.Instance.StopDragging(); // Hearts card was dropped -- Special Interaction if (finalCard.GetCardSuit() == Card.Suit.HEARTS) { // Special interaction int rank = finalCard.GetCardRank(); switch (rank) { case 1: // +1 move curPlayer.IncrementMove(); ActionsLeftPanel.Instance.Show(); Debug.Log("<color='green'> move incremented by 1 </color>"); break; case 2: // Swap rule // Show Rule (higher/lower) has been swapped UI bool prevRule = GameMaster.Instance.IsRuleHigher; GameMaster.Instance.SwapHigherLower(); PlayerPanel.Instance.UpdateRuleIcon(!prevRule); ActionsLeftPanel.Instance.ShowReverseRule(!prevRule); Debug.Log("<color='green'> RULE SWAPPED: " + prevRule + "->" + GameMaster.Instance.IsRuleHigher + " </color>"); break; default: //Do nothing break; } curPlayer.GetCardManager().GetHandManager().RemoveFromHand(finalCard); Debug.Log("<color='blue'> Hearts removed from hand </color>"); return; } // Differentiate Defense interactions w/ Bullet-loadings GameObject hit = PRGeneral("Soldier"); if (replenishDefenseMode) // REPLENISH DEFENSE MDOE INTERACTIONS ((TODO: might want to remove this)) { if (hit != null) { // Replenish Soldier Soldier hitSoldier = hit.GetComponent <SoldierCollider>().GetSoldier(); SoldierPlacementManager.Instance.ReplenishDefense(curPlayer, finalCard, hitSoldier); Debug.Log("Soldier replenish HIT: " + hitSoldier.name); } else { hit = PRGeneral("Backup"); if (hit != null) { // Replenish Backup SoldierBackup hitBackup = hit.GetComponent <SoldierBackupCollider>().GetSoldierBackup(); SoldierPlacementManager.Instance.ReplenishDefense(curPlayer, finalCard, hitBackup); Debug.Log("Backup replenish HIT: " + hitBackup.name); } } } else { hit = PRGeneral("Backup"); if (hit != null) { SoldierBackup hitBackup = hit.GetComponent <SoldierBackupCollider>().GetSoldierBackup(); if (hitBackup.GetPlayer() == curPlayer && !hitBackup.IsHidden) { // Swap backup / place new backup SoundManager.Instance.Play(AudibleNames.Button.SWITCH); Debug.Log("Backup HIT: " + hitBackup.name); SoldierPlacementManager.Instance.ReplenishDefense(curPlayer, finalCard, hitBackup); } else { //Load Bullet if (curPlayer.GetMovesLeft() > 0) { if (GameMaster.Instance.IsValidCard(finalCard)) { // If card passes the current rule AttackManager.Instance.LoadCard(finalCard); //UIHandCardManager.Instance.ShowHand(false); } else { RuleManager.Instance.GetRulePanelAnimatable().Shake(); } } else { PlayerPanel.Instance.GetMovesLeftAnimatable().Shake(); } } } else { // Load bullet if (curPlayer.GetMovesLeft() > 0) { if (GameMaster.Instance.IsValidCard(finalCard)) { // If card passes the current rule AttackManager.Instance.LoadCard(finalCard); //UIHandCardManager.Instance.ShowHand(false); } else { RuleManager.Instance.GetRulePanelAnimatable().Shake(); } } else { PlayerPanel.Instance.GetMovesLeftAnimatable().Shake(); } } } } else { SoundManager.Instance.Play(AudibleNames.Button.RELEASE); UIHandCardManager.Instance.StopDragging(); } return; } } else { bool hasSelected = this.HandCardGR("UIHandCard"); if (!hasSelected) { this.selectedCard = null; UIHandCardManager.Instance.RemovePreview(); if (Input.GetMouseButtonDown(0)) { if (this.GRGeneral("OutZone")) { UIHandCardManager.Instance.PeekDown(true); } } } else if (hasSelected && Input.GetMouseButtonDown(0)) { isHeld = UIHandCardManager.Instance.BeginDragging(); SoldierPlacementManager.Instance.SetTargetable(MainScreenManager_GameScene.Instance.GetPlayer(), true); } // Miscellaneous handling if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); if (Physics.Raycast(ray, out hit, float.PositiveInfinity)) { // If Backupmat is pressed on screen, show. GameObject mat = PRGeneral("BMC"); if (!isHeld && mat != null) { BackupMatCollider bmc = mat.GetComponent <BackupMatCollider>(); if (bmc.GetPlayer() == MainScreenManager_GameScene.Instance.GetPlayer()) { bmc.GetParent().ToggleBackupMat(); } } } } } }