public void Apply(StateMessage msg) { foreach (ShipMessage shipMessage in msg.Ships) { Transform childTransform = transform.Find(shipMessage.Id); if (childTransform == null) { GameObject shipObject = CreateCapitalShip(shipMessage.Id, shipMessage.Model); childTransform = shipObject.transform; CapitalShip ship = childTransform.GetComponent <CapitalShip>(); ship.FromProtobuf(shipMessage); if (client != null && client.guid == ship.ownerGuid) { GameObject camera = CreateCamera(shipObject, shipMessage.Model); } } else { childTransform.GetComponent <CapitalShip>().FromProtobuf(shipMessage); } childTransform.hasChanged = false; } }
public void SpawnShip(ShipType shipType) { Ship ship = null; switch (shipType) { case ShipType.Capital: ship = new CapitalShip(this.spawnerPosition, this); break; case ShipType.Test: ship = new TestShip(this.spawnerPosition, this); break; } this.world.AddShip(ship); }
public void Initiate() { ship = focus.GetComponent <CapitalShip>(); initialPoint = focus.InverseTransformPoint(transform.position); initialRotation = Quaternion.Inverse(focus.localRotation) * transform.localRotation; }