private void Update() { Vector2 input = _rigidBodyController.GetInput(); Debug.Log("Horizontal: " + input.x); Debug.Log("Vertical: " + input.y); _animator.SetFloat("Horizontal", input.x); _animator.SetFloat("Vertical", input.y); if (_rigidBodyController.Running) { _animator.SetBool("IsRunning", true); //Debug.Log("RUNNING"); } else { _animator.SetBool("IsRunning", false); } if (_rigidBodyController.GetButtonDown("Fire1")) { _shootingScript.Fire(); } if (_rigidBodyController.GetButtonDown("Jump")) { Debug.Log("Jump"); } }
// Update is called once per frame void Update() { velocityX = Input.GetAxis("Horizontal"); velocityY = Input.GetAxis("Vertical"); anim.SetFloat("velocityX", velocityX); anim.SetFloat("velocityY", velocityY); if (Input.GetButton("Fire1")) { shoot.Fire(); } if (Input.GetButtonDown("Fire2")) { if (GameManager.shieldCount > 0) { shield.ShieldUp(); } } if (Input.GetKeyDown(KeyCode.Q)) { if (GameManager.pillCount > 0) { gManager.ActiveSlowMo(); } } }
IEnumerator Attack() { yield return(new WaitForSeconds(startDelay)); while (true) { shooting.Fire(); yield return(new WaitForSeconds(delay)); } }
IEnumerator Behave() { /* * // XXX: Temporary entrance! Refactor later * rb.velocity = transform.up * 0.3f; * yield return new WaitForSeconds(4f); * rb.velocity = Vector2.zero; * yield return new WaitForSeconds(1f); * // ------------------------------ */ yield return(new WaitForSeconds(5f)); while (true) { Move(true); for (float t = 0f; t < moveDuration; t += attackInterval) { shooting.Fire(); yield return(new WaitForSeconds(Mathf.Min(moveDuration - t, attackInterval))); } yield return(new WaitForSeconds(waitTime)); Move(true); float interval = moveDuration / 8f; for (float t = 0f; t < moveDuration; t += interval) { shooting.Fire(); yield return(new WaitForSeconds(Mathf.Min(moveDuration - t, interval))); } yield return(new WaitForSeconds(waitTime)); } }
IEnumerator Behave() { while (true) { Rotate(); int attacksPerCycle = (int)(cycleDuration / attackInterval); for (int i = 0; i < attacksPerCycle; i++) { shooting.Fire(); yield return(new WaitForSeconds(attackInterval)); } Invert(); } }
void Aim() { // http://wiki.unity3d.com/index.php?title=Calculating_Lead_For_Projectiles&_ga=2.235450625.1677248304.1577098127-707113775.1576845268 target = rangeFinder.targets[0]; // Debug.Log("Location Turret, Turret Base: " + turretBase.position + " " + this.gameObject.transform.position); // Debug.Log("Location Target: " + target.gameObject.transform.position); // formula for leading turret Aim /* * float distance = Vector3.Distance(turretPos, targetPos);//distance in between in meters * float travelTime = distance/turretMuzzleVelocity;//time in seconds the shot would need to arrive at the target * Vector3 aimPoint = target.position +targetVelocity*travelTime; */ Vector2 turretPosition = turretBase.gameObject.transform.position; Vector2 targetPosition = target.gameObject.transform.position; float distance = Vector2.Distance(turretPosition, targetPosition); float travelTime = distance / (shooting.bulletForce); Vector2 otherCalculatedVector = targetPosition + target.gameObject.GetComponent <Rigidbody2D>().velocity *travelTime; Vector2 calculatedPosition = targetPosition - turretPosition; Vector2 calculatedPositionWithVelocity = (targetPosition + (target.gameObject.GetComponent <Rigidbody2D>().velocity *angleOffset /* /(angleOffset + shooting.bulletForce*Time.deltaTime )*/)) - turretPosition; // use latter if these are same when not moving // Debug.Log("Vectors manual subtaction: "+ calculatedPosition+ " Vectors from Distance()"+ Vector2.Distance(targetPosition,turretPosition)); float distanceFormulaAngle = AngleBetweenTwoVectors(calculatedPositionWithVelocity); float targetAngle = AngleBetweenTwoVectors(calculatedPosition); Vector2 interception = SmartAim(); // minus to turretPosition float interceptAngle = AngleBetweenTwoVectors(interception - turretPosition); // Debug.Log("Default Target Position: " + targetPosition+ "Intercepted Point: "+ interception); // Debug.Log("Default Angle Computation: " + targetAngle+ "Intercepted Angle: "+ interceptAngle); // float velocityAngle = AngleBetweenTwoVectors(target.GetComponent<Rigidbody2D>().magnitude); // Debug.Log(" Target Angle: " + targetAngle + "\" Advanced Angle: \""+ distanceFormulaAngle ); // Vector2 advancedPosition = SmartAim(target); // float advancedPositionAngle = AngleBetweenTwoVectors(advancedPosition); this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.Euler(0, 0, interceptAngle), turnSpeed * Time.deltaTime); shooting.Fire(); }
private void Awake() { playerMovementController = GetComponent <PlayerMovementController>(); shooting = GetComponent <Shooting>(); if (photonView.IsMine) { playerControlsUIInstance = Instantiate(playerControlsUI); playerControlsUIInstance.transform.Find("Fire Button Right").GetComponent <Button>().onClick.AddListener(() => shooting.Fire()); playerControlsUIInstance.transform.Find("Fire Button Left").GetComponent <Button>().onClick.AddListener(() => shooting.Fire()); playerControlsUIInstance.transform.Find("Info").GetComponent <TextMeshProUGUI>().text = "Player Alive: " + PhotonNetwork.CurrentRoom.PlayerCount.ToString(); playerMovementController.joystick = playerControlsUIInstance.transform.Find("Fixed Joystick").GetComponent <Joystick>(); playerMovementController.fixedTouchField = playerControlsUIInstance.transform.Find("Rotation Touch Field").GetComponent <FixedTouchField>(); fpsCamera.enabled = true; } else { fpsCamera.enabled = false; playerMovementController.enabled = false; GetComponent <RigidbodyFirstPersonController>().enabled = false; } }
// Start is called before the first frame update void Start() { shooter = GetComponent <Shooting>(); animator = GetComponent <Animator>(); playerMovementController = GetComponent <PlayerMovementController>(); if (photonView.IsMine) { //Activate fps soldier,deactivate hands foreach (GameObject gameObject in FPS_Hands_ChildGameObject) { gameObject.SetActive(true); } foreach (GameObject gameObject in Soldier_ChildGameObject) { gameObject.SetActive(false); } //Instantiate PlayerUI GameObject playerUIGameObject = Instantiate(PlayerUIPrefab); playerMovementController.joyStick = playerUIGameObject.transform.Find("Fixed Joystick").GetComponent <Joystick>(); playerMovementController.fixedTouchField = playerUIGameObject.transform.Find("RotationTouchField").GetComponent <FixedTouchField>(); playerUIGameObject.transform.Find("FireButton").GetComponent <Button>().onClick.AddListener(() => shooter.Fire()); FPSCamera.enabled = true; animator.SetBool("IsSoldier", false); } else { //activate hands,deactivate soldier foreach (GameObject gameObject in FPS_Hands_ChildGameObject) { gameObject.SetActive(false); } foreach (GameObject gameObject in Soldier_ChildGameObject) { gameObject.SetActive(true); } playerMovementController.enabled = false; GetComponent <RigidbodyFirstPersonController>().enabled = false; FPSCamera.enabled = false; animator.SetBool("IsSoldier", true); } }
// Update is called once per frame void Update() { _shoot.Fire(); }
void Attack(Vector2 direction) { Shooting.Fire(direction); StartCoroutine(Reload()); }
void Shoot() { shoot.Fire(); }
private void FixedUpdate() { _motor.Move(Speed); _shooting.Fire(); }