This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Update () | |
{ | |
if (running == true) | |
{ | |
updateCubePosition (-4.0f, 0f, -22, "Cube1"); | |
//Keep adding for new cubes, make sure tag name matches, and change the range for the X axis | |
updateCubePosition (0f, 4.0f, -22, "Cube2"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionZ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void OnCollisionEnter (Collision collision) | |
{ | |
Rigidbody body = collision.rigidbody; | |
if (body != null) | |
{ | |
if (body.tag == "Cube1") | |
{ | |
MovingObstacles movingObstacles = GameObject.FindObjectOfType(typeof(MovingObstacles)) as MovingObstacles; | |
movingObstacles.running = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public float speed = 0.1f; | |
public bool running = true; | |
private void updateCubePosition(float min, float max, float startZ, string id) | |
{ | |
GameObject cube1 = GameObject.FindGameObjectWithTag (id); | |
Vector3 currentPosition = cube1.transform.position; | |
//Reset the cube's position once it has passed the player |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CloudKit | |
class CloudKitManager : NSObject | |
{ | |
var container : CKContainer? | |
let privateDB : CKDatabase? | |
override init() { | |
container = CKContainer.defaultContainer() | |
privateDB = container!.privateCloudDatabase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func load(service: NSString, userName:String) -> NSString? | |
{ | |
//Create the query keychain | |
var keychainQuery: NSMutableDictionary = NSMutableDictionary(objects: [kSecClassGenericPasswordValue, service, userName, kCFBooleanTrue, kSecMatchLimitOneValue], forKeys: [kSecClassValue, kSecAttrServiceValue, kSecAttrAccountValue, kSecReturnDataValue, kSecMatchLimitValue]) | |
var dataTypeRef :Unmanaged<AnyObject>? | |
// Search for the keychain items | |
let status: OSStatus = SecItemCopyMatching(keychainQuery, &dataTypeRef) | |
let opaque = dataTypeRef?.toOpaque() | |
var contentsOfKeychain: NSString? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Don't forget to add the Security.framework to your project. | |
import Security | |
private let kSecClassValue = NSString(format: kSecClass) | |
private let kSecAttrAccountValue = NSString(format: kSecAttrAccount) | |
private let kSecValueDataValue = NSString(format: kSecValueData) | |
private let kSecClassGenericPasswordValue = NSString(format: kSecClassGenericPassword) | |
private let kSecAttrServiceValue = NSString(format: kSecAttrService) | |
private let kSecMatchLimitValue = NSString(format: kSecMatchLimit) | |
private let kSecReturnDataValue = NSString(format: kSecReturnData) | |
private let kSecMatchLimitOneValue = NSString(format: kSecMatchLimitOne) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getProductIdFromReceipt(data:NSData) -> String? | |
{ | |
var p = UnsafePointer<UInt8>(data.bytes) | |
var dataLength = data.length | |
var type:Int32 = 0 | |
var tag:Int32 = 0 | |
var length = 0 | |
var end = p + dataLength | |
ASN1_get_object(&p, &length, &type, &tag, end - p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let octets = pkcs7_d_data(pkcs7_d_sign(receiptPKCS7).memory.contents) | |
var ptr = UnsafePointer<UInt8>(octets.memory.data) | |
let end = ptr.advancedBy(Int(octets.memory.length)) | |
var type: Int32 = 0 | |
var xclass: Int32 = 0 | |
var length = 0 | |
ASN1_get_object(&ptr, &length, &type, &xclass, end - ptr) | |
if (type != V_ASN1_SET) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Load in the receipt | |
var receipt: NSData = NSData(contentsOfURL:receiptUrl!, options: nil, error: nil)! | |
var receiptBio = BIO_new(BIO_s_mem()) | |
BIO_write(receiptBio, receipt.bytes, Int32(receipt.length)) | |
var receiptPKCS7 = d2i_PKCS7_bio(receiptBio, nil) | |
//Read in Apple's Root CA | |
var appleRoot = NSBundle.mainBundle().URLForResource("AppleIncRootCertificate", withExtension: "cer") | |
var caData = NSData(contentsOfURL: appleRoot!) | |
var caBIO = BIO_new(BIO_s_mem()) |
NewerOlder