public bool DropItem() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject.CompareTag("Ground")) { transform.position = hit.point; gameObject.SetActive(true); PlaceBarricade(); hapticFeedback = GetComponent <HapticFeedback>(); hapticFeedback?.Activate(); return(true); } else { ServiceLocator.Get <GameManager>().barricadeSpawner?.ResetBarricade(); Destroy(gameObject); return(false); } } return(false); }
public void restoring() { Player player = ServiceLocator.Get <LevelManager>().playerInstance.GetComponent <Player>(); if (!player) { return; } if (fullHealth < minimumTowerHealth) { return; } // Lose Tower's health fullHealth -= towerLostCostValue; uiManager.UpdateTowerHealth(fullHealth); // Heal Player's health player.restoringHealth(towerHealCostValue); uiManager.UpdatePlayerHealth(player.health, player._maxHealth); hapticFeedback?.Activate(); // Update tutorial2 if (tutorial2) { tutorial2.usedHeal = true; } }
public void GettingResource() { if (coolTimeImage.fillAmount >= 1) { Tower tower = ServiceLocator.Get <LevelManager>().towerInstance.GetComponent <Tower>(); tower.GetComponent <Tower>().HealTower(healValue); coolTimeImage.fillAmount = 0; hapticFeedback = GetComponent <HapticFeedback>(); hapticFeedback?.Activate(); // For tutorial if (tutorial2) { tutorial2.usedTrashToHeal = true; } } }
private void Update() { //if (stunTime < Time.time) //{ // agent.isStopped = false; //} //else //{ // agent.isStopped = true; // return; //} if (isStunned) { agent.isStopped = true; if (stunTime < Time.time) { isStunned = false; } else { return; } } if (!_player.isAlive || !enableControls) { return; } if (_lockedOnEnemyGO) { if (_lockedOnEnemyGO.CompareTag("Enemy")) { if (_lockedOnEnemyGO.GetComponent <Enemy>().IsDead) { _lockedOnEnemyGO = null; _isTargetLockedOn = false; } } else if (_lockedOnEnemyGO.CompareTag("Boss")) { if (_lockedOnEnemyGO.GetComponent <Boss>().IsDead) { _lockedOnEnemyGO = null; _isTargetLockedOn = false; } } } ActivateTargetLockedOn(); if (!UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) { CalculateMovement(); } if (_isRepairing) { _isRepairing = _RepairBarricade.GetComponent <Barricade>().CheckRepairValid(transform); } UpdateUI(); if (isUsingAbility) { agent.isStopped = true; } CheckMoveIndicatorActive(); if (Input.GetMouseButtonDown(0)) { CheckSpawnBarricade(); CheckSpawnResource(); } if (Input.GetMouseButton(0)) { CheckRestoring(); } //if (Input.GetKeyDown(_PickUpButton) || CheckHoldDownClick("BarricadeSpawner")) //{ // if (!_isHoldingItem) // { // _Barricade = _player.DetectBarricadeSpawner(); // if (_Barricade == null) // _isHoldingItem = false; // else if (_Barricade.GetComponent<Barricade>().CanBePickedUp()) // { // _Barricade.GetComponent<Barricade>().PickUp(gameObject); // _isHoldingItem = true; // } // } // else if (!CheckBarricadePickUp()) // { // StartCoroutine(PlaceBarricade()); // } //} //if (Input.GetKeyDown(_PickUpButton) || CheckHoldDownClick("ResourceSpawner")) //{ // if(!_isDigging) // { // _isDigging = true; // StartCoroutine(DiggingTrash()); // } //} //if (placeUIbutton.isButtonPressed || CheckHoldDownClick("Ground")) //{ // if (_isHoldingItem && _Barricade != null) // { // _isHoldingItem = false; // StartCoroutine(PlaceBarricade()); // } //} if (_isHoldingItem) { return; } //if (Input.GetKeyDown(_RepairButton) || CheckHoldDownClick("Barricade") || repairUIbutton.isButtonPressed) //{ // _RepairBarricade = _player.DetectBarricade(); // if (_RepairBarricade == null) // _isHoldingItem = false; // else if (!_isRepairing) // { // _isRepairing = true; // _RepairBarricade.GetComponent<Barricade>().inRangeRepair = true; // StartCoroutine(_RepairBarricade.GetComponent<Barricade>().Repair()); // } //} if (/*(Input.GetKeyDown(_AttackButton) && attackEnabled) ||*/ (autoAttack /*&& CheckCoolDownTimes()*/ && _isTargetLockedOn)) { if (currentAttackCoolDown < Time.time) { StartCoroutine(_player.Attack()); currentAttackCoolDown = Time.time + attackCoolDown; } } if ((Input.GetKeyDown(_PoisonAttackButton) || poisonUIbutton.isButtonPressed) && poisonAttackEnabled) { if (currentPoisonAttackCoolDown < Time.time) { if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Fleas") && !isUsingUltimate) { usedFleasAbility = true; agent.isStopped = true; isUsingAbility = true; animator.SetTrigger("Fleas"); StartCoroutine(_player.PoisonAttack()); hapticPoisonAbility?.Activate(); currentPoisonAttackCoolDown = Time.time + poisonAttackCoolDown; } } } if (Input.GetKeyDown(_LockTargetButton)) { if (_isTargetLockedOn && !_lockedOnEnemyGO) { _isTargetLockedOn = false; } if (_isTargetLockedOn) { GameObject prevTarget = _lockedOnEnemyGO; CheckTargetLockedOn(); if (_lockedOnEnemyGO != null && prevTarget != _lockedOnEnemyGO) { //Deselect if (prevTarget.CompareTag("Boss") && _lockedOnEnemyGO.CompareTag("Enemy")) { prevTarget?.GetComponent <Boss>().SwitchOnTargetIndicator(false); _lockedOnEnemyGO?.GetComponent <Enemy>().SwitchOnTargetIndicator(true); } else if (prevTarget.CompareTag("Enemy") && _lockedOnEnemyGO.CompareTag("Enemy")) { prevTarget?.GetComponent <Enemy>().SwitchOnTargetIndicator(false); _lockedOnEnemyGO?.GetComponent <Enemy>().SwitchOnTargetIndicator(true); } else if (prevTarget.CompareTag("Enemy") && _lockedOnEnemyGO.CompareTag("Boss")) { prevTarget?.GetComponent <Enemy>().SwitchOnTargetIndicator(false); _lockedOnEnemyGO?.GetComponent <Boss>().SwitchOnTargetIndicator(true); } } else { _lockedOnEnemyGO = prevTarget; } } else { CheckTargetLockedOn(); if (_lockedOnEnemyGO) { //Select _isTargetLockedOn = true; if (_lockedOnEnemyGO.CompareTag("Enemy")) { _lockedOnEnemyGO.GetComponent <Enemy>()?.SwitchOnTargetIndicator(true); } else if (_lockedOnEnemyGO.CompareTag("Boss")) { _lockedOnEnemyGO.GetComponent <Boss>()?.SwitchOnTargetIndicator(true); } } else { _isTargetLockedOn = false; } } } if ((Input.GetKeyDown(_UltimateButton) || ultUIbutton.isButtonPressed) && ultimateAttackEnabled) { //_player.UltimateAttack(); //if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Ultimate")) // animator.SetTrigger("Ultimate"); ultUIbutton.isButtonPressed = false; if (_player._ultimateCharge >= 100.0f) { hapticUltAbility?.Activate(); } StartCoroutine(_player.UltimateAttack()); } if (Input.GetKeyDown(_ReleaseLockButton)) { if (_isTargetLockedOn) { //Deselect _isTargetLockedOn = false; _lockedOnEnemyGO.GetComponent <Enemy>().SwitchOnTargetIndicator(false); _lockedOnEnemyGO = null; } } if ((Input.GetKeyDown(_Intimidate) || intimidateUIbutton.isButtonPressed) && intimidateAttackEnabled) { if (currentIntimidateAttackCoolDown < Time.time) { if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Intimidate") && !isUsingUltimate) { usedStunAbility = true; isUsingAbility = true; agent.isStopped = true; animator.SetTrigger("Intimidate"); hapticIntimidateAbility?.Activate(); StartCoroutine(_player.IntimidateAttack(/*_lockedOnEnemyGO*/)); } currentIntimidateAttackCoolDown = Time.time + intimidateAttackCoolDown; } } //ActivateTargetLockedOn(); }