@@ -10,8 +10,8 @@ public class GunController : NetworkBehaviour {
private float angleX = 0;
private float angleY = 0;

public PlayerController Shooter;
public ShipController Ship;
public IPlayer Shooter;
public IShip Ship;

//space positions
public GameObject CannonBallSpawnPosition;
@@ -50,7 +50,7 @@ void CmdFire()
// Update is called once per frame
void FixedUpdate () {
if (Ship != null) {
this.transform.position = Ship.TurretAttachPosition.transform.position;
this.transform.position = ((ShipController)Ship).TurretAttachPosition.transform.position;
}
if (Shooter == null) {
return;
@@ -18,15 +18,15 @@ public class DeckTrigger : MonoBehaviour {
}

void OnTriggerEnter(Collider collider) {
var player = collider.gameObject.GetComponent<ThirdPersonUserControl> ();
var player = collider.gameObject.GetComponent<ThirdPersonPlayerController> ();
if (player == null) {
return;
}
player.transform.parent = gameObject.transform;
}

void OnTriggerExit(Collider collider) {
var player = collider.gameObject.GetComponent<ThirdPersonUserControl> ();
var player = collider.gameObject.GetComponent<ThirdPersonPlayerController> ();

if (player == null) {
return;
File renamed without changes.
@@ -5,16 +5,8 @@

[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(Camera))]
public class ShipController : NetworkBehaviour
public class ShipController : NetworkBehaviour , IShip
{

public PlayerController Driver { get; set; }

public PlayerController Shooter { get; set; }

public GunController GunController { get; set; }

public Camera ShipCamera;
private Rigidbody rb;

//Axis movement
@@ -53,22 +45,38 @@ public class ShipController : NetworkBehaviour
//space anchors
public GameObject TurretAttachPosition;

#region IShip implementation
public Camera Camera { get; set;}
public IPlayer Driver {
get;
set;
}
public IPlayer Shooter {
get;
set;
}
public GunController GunController {
get;
set;
}
#endregion

// Use this for initialization
void Start ()
{
rb = gameObject.GetComponent<Rigidbody> ();
ShipCamera = GetComponentInChildren<Camera> ();

if (GunPrefab != null) {
var gun = (GameObject)Instantiate (
GunPrefab,
TurretAttachPosition.transform.position,
Quaternion.Euler (0, 0, 0));
GunPrefab,
TurretAttachPosition.transform.position,
Quaternion.Euler (0, 0, 0));
GunController = gun.GetComponentInChildren<GunController> ();
GunController.Ship = this;
}


GunController = GetComponentInChildren<GunController> ();

// save default rotation
angleX = this.transform.rotation.eulerAngles.x;
angleY = this.transform.rotation.eulerAngles.y;
@@ -147,10 +155,10 @@ void Move ()
void OnDestroy ()
{
if (Shooter != null) {
Destroy (Shooter.gameObject);
//todo kill shooter
}
if (Driver != null) {
Destroy (Driver.gameObject);
//todo kill driver
}
if (GunController != null) {
Destroy (GunController.gameObject);