public void SetShipMode(Ship ship, ShipControlMode mode) { if (ship == null) { return; } if (ship == currentControl) { SetCurrentShipMode(mode); return; } ship.control.mode = mode; if (mode == ShipControlMode.Player) { if (controllingShip != null) { if (controllingShip != ship) { controllingShip.control.mode = ShipControlMode.AIDefense; } } controllingShip = currentControl; } }
public void SetCurrentShipMode(ShipControlMode mode) { currentControl.control.mode = mode; if (mode == ShipControlMode.Player) { if (controllingShip != null) { controllingShip.control.mode = ShipControlMode.AIDefense; } controllingShip = currentControl; } }
public Ship LoadShipAtTransform(string shipName, Transform theTransform, GameCamp camp, ShipControlMode mode = ShipControlMode.Building) { byte[] shipBytes = SerializeHelp.ReadFile(Application.dataPath + "/Resources/Ship/" + camp.ToString() + shipName + ".ship"); ShipData shipData = SerializeHelp.ReadObjectData <ShipData>(shipBytes); GameObject shipObject = Instantiate(EmptyShip, theTransform.position, theTransform.rotation); Ship ship = shipObject.GetComponent <Ship>(); ship.ShipName = ship.name = shipData.ShipName; foreach (var component in shipData.Records) { ship.AddComponent(component.id, component.level, new Vector2Int((int)component.pos.x, (int)component.pos.y), (ShipEnum.ShipUnitRotation)Enum.ToObject(typeof(ShipEnum.ShipUnitRotation), component.rotation), (ShipEnum.ShipUnitMirror)Enum.ToObject(typeof(ShipEnum.ShipUnitMirror), component.mirror)); } ship.SetCamp(camp); ShipManager.Instance.ships[camp].Add(ship); ship.control.mode = mode; return(ship); }