// Update is called once per frame void Update() { if (shotDelay > 0f) { shotDelay -= Time.deltaTime; } if (shoting) { if (shotDelay <= 0f) { for (int i = 0; i < amount; i++) { float angle = SNMovementController.Angle(direction); if (randomSpread) { angle += Random.Range(-(spread / 2f), (spread / 2f)); } else { if (amount > 1) { float anglePiece = spread / (amount - 1); angle = angle - (spread / 2f) + (anglePiece * i); } } float radian = angle * Mathf.Deg2Rad; Vector3 bDir = new Vector3(Mathf.Sin(radian), Mathf.Cos(radian), 0); Shot(bDir); shotDelay = fireRate; } if (!fullAuto) { StopShoting(); } } } }
public void SetDirection(Vector2 dir) { if (aiming && animator) { if (owner.movementController.armsAnimationController) { float angle = SNMovementController.Angle(dir); direction = dir; /*if (animator != null) { * animator.SetFloat ("Horizontal", dir.x); * animator.SetFloat ("Vertical", dir.y); * }*/ //Debug.Log ("angle " + angle); //angle = -(angle - 90); Quaternion newRot = Quaternion.Euler(0, 0, -(angle - 90)); SpriteRenderer rendrer = animator.GetComponent <SpriteRenderer> (); SpriteRenderer rendrer2 = rendrer; //Debug.Log ("angle2 " + angle); rendrer2 = owner.movementController.armsAnimationController.GetComponent <SpriteRenderer> (); owner.movementController.armsAnimationController.transform.parent.localRotation = newRot; if (angle >= 45 && angle < 135) { //right horizontal = true; rendrer.flipY = false; rendrer2.flipY = false; gunTransform.localPosition = owner.movementController.gunPositionR; } else if (angle >= 135 && angle < 225) { //down horizontal = false; rendrer.flipY = false; rendrer2.flipY = false; gunTransform.localPosition = owner.movementController.gunPositionD; } else if (angle >= 225 && angle < 315) { //left horizontal = true; rendrer.flipY = true; rendrer2.flipY = true; gunTransform.localPosition = owner.movementController.gunPositionL; } else if (angle >= 315) { //up horizontal = false; rendrer.flipY = false; rendrer2.flipY = false; gunTransform.localPosition = owner.movementController.gunPositionU; } else //&& angle < 45) //up { horizontal = false; rendrer.flipY = false; rendrer2.flipY = false; gunTransform.localPosition = owner.movementController.gunPositionU; } //transform.localRotation = newRot; owner.movementController.armsAnimationController.Play("Aim" + GetAnimationMode()); //SNWeapon.SetAnimationDirection (owner.movementController.animationController, dir); //animator.Play ("Hold" + GetAnimationMode ()); if (!shotProceed) { PlayAnimation("Hold" + GetAnimationMode()); } } } }