Skip to content

Instantly share code, notes, and snippets.

function ValidateGooglePlaySignature( $responseData, $signature, $publicKey, &$status, &$response )
{
$responseData = trim( $responseData );
$signature = trim( $signature );
$response = json_decode( $responseData );
// Create an RSA key compatible with openssl_verify from our Google Play sig
$key = "-----BEGIN PUBLIC KEY-----\n".
chunk_split($publicKey, 64,"\n").
'-----END PUBLIC KEY-----';
@prime31
prime31 / ParticleFlock.cs
Created May 1, 2014 17:42
Simple (unoptimized!) particle flock. Stick it on a GameObject with a ParticleSystem and play with inspector for some interesting results. Clicking anywhere on screen will set the target position for all boids.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[RequireComponent( typeof( ParticleSystem ) )]
public class ParticleFlock : MonoBehaviour
{
public Vector3 targetPosition;
public int totalBoids = 15;
const int C2_GJK_ITERS = 20;
public const int C2_MAX_POLYGON_VERTS = 8;
// position of impact p = ray.p + ray.d * raycast.t
public static c2v c2Impact(c2Ray ray, float t) => c2Add(ray.p, c2Mulvs(ray.d, t));
#region Wrapper Methods
public static unsafe bool c2Collided(void* A, c2x* ax, C2_TYPE typeA, void* B, c2x* bx, C2_TYPE typeB)
@prime31
prime31 / MiniJSON.cs
Created October 30, 2012 01:44 — forked from Borluse/MiniJSON.cs
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2012 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@prime31
prime31 / Vector3Editor.cs
Last active August 23, 2018 20:27
Ever get tired of creating piles of GameObjects just because you want a Vector3 position? Those days are over. The Vector3Editor will let you edit single Vector3 properties and arrays of Vector3's without having to create a plethora of GameObjects.
// Usage:
// - stick the Vector3Editor.cs file in the Editor folder of your project
// - create a class with a Vector3 or Vector3[] property (you probably already have plenty of them. The WarpZone class below is a simple example)
// - create an editor script for any the class that you want to be able to edit extending Vector3Editor (see WarpZoneEditor below)
// - in OnEnable simply call setup() with your property names and optional labels
using UnityEngine;
using UnityEditor;
@prime31
prime31 / Unity2Dframeworks.txt
Created August 12, 2012 19:22
Unity 2D framework comparison
Key:
"-" negative point
"+" positive point
"+-" could go either way depending on your opinion or if it functions or not
Background Info: the last project we worked on needed basic 2D functionality (sprites and animations) and SpriteKit was born to fill this need (http://www.youtube.com/watch?v=cabAr2CdLmc). It has no fancy editors and was really made to fit a specific need and as of yet it has not been extended much further than the video shows. Something a bit more full featured is required for a new prototype and instead of spending a bunch of time extending SpriteKit we went on a search for alternatives. None of the below frameworks are perfect and they all have pluses and minuses. One thing SpriteKit had that none of the others do is automatic texture selection based on screen resolution. That is one thing I would like to see incorporated in every 2D framework and it kind of surprises me that it isn't one of the first features added when making a 2D framework.
@prime31
prime31 / Game2.cs
Last active December 16, 2016 04:50
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Nez;
namespace TheWall
{
public class Game2 : Game
{
@prime31
prime31 / prime[31] + Vuforia
Last active September 8, 2016 17:50
Activity override system that will work with Vuforia. Note that this is provided as-is and we do not provide support for working with Vuforia.
- download the jar file from here: https://mega.co.nz/#!pd81gYBA!ui33ktU2xDqmcsYOv5oSZ6v-niPp1ofwh02naT7Vqbs Note that anytime you import any other plugins make sure that file doesn't get overwritten!
- overwrite the file with the same name in the Plugins/Android folder with the downloaded jar
- generate an AndroidManifest.xml file
- add the required permissions for Vuforia to the generated AndroidManifest.xml (see their docs for the details)
using Microsoft.Xna.Framework;
using Nez;
using Nez.Sprites;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vapor.Code.Utility;
@prime31
prime31 / 2DDeferredLighting.fx
Last active April 15, 2016 05:33
2D deferred lighting implementation (first pass, not optimized)
// ##### ##### ##### ##### ##### ##### #####
// ##### ##### Common Uniforms ##### #####
// ##### ##### ##### ##### ##### ##### #####
float4x4 _objectToWorld;
float4x4 _worldToView;
float4x4 _projection; // viewToCamera?
float4x4 _screenToWorld; // this is used to compute the world-position
// color of the light