﻿using UnityEngine;
using System.Collections;

public class SniperRifle : Weapon, IPunObservable {
	public Projectile bullet;
	public Transform exitPoint;

	private AudioSource shootSound;

	// Use this for initialization
	void Start () {
		shootSound = this.gameObject.GetComponent<AudioSource> ();

		base.fireRate = 0.8f;
		base.ammunition = Random.Range(12, 24);
	}
	
	// Update is called once per frame
	new void Update () {
		base.Update ();
	}

	public override void Fire () {
		if (CanFire ()) {
			base.Fire ();
			bullet.GetComponent<Projectile>().owner = base.ownedPlayer.GetComponent<PlayerController>();

			Projectile obj = GameObject.Instantiate(bullet, 
			           	           exitPoint.position, 
				exitPoint.rotation * base.AccuracyVariation());
			obj.speed = 40.0f;
		}
	}

	public void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info)
	{

	}
}
