private void SetTarget(LifeObjectCollider target) { LifeObjectCollider newLOC = target; if (target.GetPlayer() != MainScreenManager_GameScene.Instance.GetPlayer()) { if (this.previousLOC != null) { previousLOC.EnableOutline(false); } if (this.previousSoldier != null) { previousSoldier.EnableOutline(false); } // Check if no soldiers before enabling outline? if (!target.GetPlayer().GetCardManager().GetDefenseManager().HasFrontDefense()) { newLOC.EnableOutline(true); } else { newLOC.EnableOutline(false); } previousLOC = newLOC; previousSoldier = null; } }
// Update is called once per frame void Update() { PlayerManager curPlayer = MainScreenManager_GameScene.Instance.GetPlayer(); RaycastHit hit; Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); Debug.DrawRay(ray.origin, ray.direction * 1000, Color.red, .2f); // If hit if (Physics.Raycast(ray, out hit, float.PositiveInfinity)) { // If the AttackManager Panel is shown if (inAttackMode) { // If game object hit contains SoldierCollider.cs, enable the outline for the target soldier if (hit.collider.gameObject.GetComponent <SoldierCollider>() != null) { Debug.Log("<color=red>Soldier HIT </color>"); SetTarget(hit.collider.gameObject.GetComponent <SoldierCollider>()); } else if (hit.collider.GetComponent <LifeObjectCollider>() != null) { LifeObjectCollider targetLOC = hit.collider.GetComponent <LifeObjectCollider>(); if (targetLOC.GetPlayer() != curPlayer) { Debug.Log("<color=red>targetLOC HIT </color>"); SetTarget(targetLOC); } } else { // If no hit during attack mode RemoveTarget(); } } //// If game object hit contains BackupMatCollider.cs, open the Backup Mat Drawer and flip all backup cards up. //else if (hit.collider.gameObject.GetComponent<BackupMatCollider>() != null) { // //targetBackup = hit.collider.gameObject.GetComponent<SoldierBackupCollider>().GetSoldierBackup(); // if (bmcReference == null) { // BackupMatCollider bmc = hit.collider.gameObject.GetComponent<BackupMatCollider>(); // if (bmc.GetPlayer() == curPlayer) { // bmcReference = bmc; // bmc.GetParent().OpenBackupMat(true); // } // } // //curMatShown = 0f; //} //// If Backup mat is not hit and the backup mat is opened //else if (hit.collider.gameObject.GetComponent<SoldierBackupCollider>() == null && hit.collider.gameObject.GetComponent<BackupMatCollider>() == null && bmcReference != null) { // curMatShown += Time.deltaTime; // // If the backup mat has not been hit for X duration, hide the backup mat // if (curMatShown >= backupMatShowDuration) { // curMatShown = 0f; // bmcReference.GetParent().OpenBackupMat(false); // bmcReference = null; // } //} // If player hit // If others hit } else { // If no hit } }