public void Shot(BulletMovement.ShootDirectionType shootDir, BulletMovement.WalkDirection walkDir) { shooting = true; BulletMovement bullet = Instantiate(bulletPrefab, bulletSpawnPos, Quaternion.identity); bullet.SetDirectionType(shootDir); bullet.SetWalkDirectionType(walkDir); }
public void Shot(BulletMovement.ShootDirectionType shootDir, BulletMovement.WalkDirection walkDir) { AudioSource.PlayClipAtPoint(_shootSound.clip, new Vector3(5, 1, 2)); shooting = true; BulletMovement bullet = Instantiate(bulletPrefab, _bulletSpawnPos, Quaternion.identity); bullet.SetDirectionType(shootDir); bullet.SetWalkDirectionType(walkDir); }
void Update() { if (CanShoot()) { if (movement.velocity.y > maxVelocity) { walkDirection = BulletMovement.WalkDirection.Up; } else if (movement.velocity.y < -maxVelocity) { walkDirection = BulletMovement.WalkDirection.Down; } if (movement.velocity.x > maxVelocity) { walkDirection = BulletMovement.WalkDirection.Right; } else if (movement.velocity.x < -maxVelocity) { walkDirection = BulletMovement.WalkDirection.Left; } if (movement.velocity.y < maxVelocity && movement.velocity.y > -maxVelocity && movement.velocity.x < maxVelocity && movement.velocity.x > -maxVelocity) { walkDirection = BulletMovement.WalkDirection.None; } //Debug.Log(movement.velocity.x); if (im.ShootUp()) { if (leftEye) { bulletSpawnPos = new Vector3(gameObject.transform.position.x - 0.2f, gameObject.transform.position.y + 0.1f, gameObject.transform.position.z); leftEye = false; } else if (!leftEye) { bulletSpawnPos = new Vector3(gameObject.transform.position.x + 0.2f, gameObject.transform.position.y + 0.1f, gameObject.transform.position.z); leftEye = true; } Shot(BulletMovement.ShootDirectionType.Up, walkDirection); timer = initialTimer; } else if (im.ShootDown()) { if (leftEye) { bulletSpawnPos = new Vector3(gameObject.transform.position.x - 0.2f, gameObject.transform.position.y - 0.3f, gameObject.transform.position.z); leftEye = false; } else if (!leftEye) { bulletSpawnPos = new Vector3(gameObject.transform.position.x + 0.2f, gameObject.transform.position.y - 0.3f, gameObject.transform.position.z); leftEye = true; } Shot(BulletMovement.ShootDirectionType.Down, walkDirection); timer = initialTimer; } else if (im.ShootLeft()) { bulletSpawnPos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z); Shot(BulletMovement.ShootDirectionType.Left, walkDirection); timer = initialTimer; } else if (im.ShootRight()) { bulletSpawnPos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z); Shot(BulletMovement.ShootDirectionType.Right, walkDirection); timer = initialTimer; } } }