private void UpdateShooting() { if (Input.GetMouseButtonDown(0) && Input.GetMouseButton(1)) { m_movingAgent.pullTrigger(); } if (Input.GetMouseButtonUp(0) && Input.GetMouseButton(1)) { m_movingAgent.releaseTrigger(); } }
private void controllerUpdate() { if (!m_movingAgent.isEquiped()) { switch (selectedWeaponType) { case Weapon.WEAPONTYPE.primary: m_movingAgent.togglePrimaryWeapon(); break; case Weapon.WEAPONTYPE.secondary: m_movingAgent.togglepSecondaryWeapon(); break; } } else { if (!m_movingAgent.isEquipingWeapon()) { m_movingAgent.aimWeapon(); } else { m_movingAgent.stopAiming(); } } if (moveCounter > 0.2f) { moveDirection = Random.insideUnitSphere; moveDirection.y = 0; moveCounter = 0; } Vector3 targetPostion = enemy.transform.position; targetPostion.y = 1.5f; m_movingAgent.setTargetPoint(targetPostion); if (isInScreenLimit() && enableFire) { //if (shootingCounter > 1) //{ // targetPostion = player.transform.position; // targetPostion = new Vector3(targetPostion.x, 1.2f + targetPostion.y, targetPostion.z); // m_movingAgent.setTargetPoint(targetPostion); // m_movingAgent.weaponFireForAI(); // shootingCounter = -Random.value * 3; //} //shootingCounter += Time.deltaTime * 2; if (!triggerPulled) { if (shootingCounter > 0.5f) { m_movingAgent.pullTrigger(); triggerPulled = true; shootingCounter = 0; } } else { if (shootingCounter > 0.5f) { m_movingAgent.releaseTrigger(); triggerPulled = false; shootingCounter = 0; tempFloat = Random.value * 10 + 1; } } } shootingCounter += Time.deltaTime; moveCounter += Time.deltaTime; // m_movingAgent.moveCharacter(moveDirection.normalized); }
protected void updateSelfAgentFromInput() { #region get control input float inputHorizontal = SimpleInput.GetAxis("Horizontal"); float inputVertical = SimpleInput.GetAxis("Vertical"); float aimInputHorizontal = SimpleInput.GetAxis("HorizontalAim"); float aimInputVertical = SimpleInput.GetAxis("VerticalAim"); Vector3 aimDirection = getDirectionRelativeToCamera(new Vector3(aimInputVertical, 0, -aimInputHorizontal)); bool runPressed = SimpleInput.GetButton("Run"); bool crouchPressed = SimpleInput.GetButtonDown("Crouch"); bool dodge = SimpleInput.GetButtonDown("Dodge"); bool rifle = SimpleInput.GetButtonDown("Rifle"); bool pistol = SimpleInput.GetButtonDown("Pistol"); #endregion #region control agent from input #region movment control if (rifle) { m_selfAgent.togglePrimaryWeapon(); } if (pistol) { m_selfAgent.togglepSecondaryWeapon(); } if (crouchPressed) { m_selfAgent.toggleHide(); m_crouched = !m_crouched; } if (dodge) { m_selfAgent.dodgeAttack(getDirectionRelativeToCamera((new Vector3(inputVertical, 0, -inputHorizontal).normalized) * 1.5f)); } if (runPressed) { if (m_selfAgent.isCrouched()) { m_selfAgent.toggleHide(); } m_selfAgent.moveCharacter(getDirectionRelativeToCamera((new Vector3(inputVertical, 0, -inputHorizontal).normalized) * 1.5f)); } else { if (m_crouched && !m_selfAgent.isCrouched()) { m_selfAgent.toggleHide(); } m_selfAgent.moveCharacter(getDirectionRelativeToCamera(new Vector3(inputVertical, 0, -inputHorizontal).normalized)); } #endregion #region aiming and fire control if (aimDirection.normalized.magnitude > 0) { m_selfAgent.aimWeapon(); m_targetFinder.updateTargetFinder(aimDirection, this.transform.position); m_selfAgent.setTargetPoint(m_targetFinder.getCalculatedTargetPosition()); if (m_targetFinder.canFireAtTargetAgent()) { m_selfAgent.pullTrigger(); } else { m_selfAgent.releaseTrigger(); } } else { m_selfAgent.stopAiming(); m_selfAgent.releaseTrigger(); m_targetFinder.disableTargetIndicator(); } #endregion #endregion }