Instantly share code, notes, and snippets.

View RandomShrub for Pixel Sprite Generator Unity
using UnityEngine;
using System.Collections;
using PixelSpriteGenerator;
public class RandomShrub : MonoBehaviour {
private PsgMask mask;
private PsgSprite sprite;
private SpriteRenderer sr;
View .gitignore
# Unity generated and a few customs #
# ================================= #
Temp/*
Library/*
Build/*
Obj/*
WebBuild/*
WindowsBuild/*
# ===================================== #
View ExampleLaserHit.cs
private void OnLaserHitTriggered(RaycastHit2D hitInfo)
{
if (hitInfo.collider.gameObject == gameObject)
{
if (bloodParticleSystem != null)
{
bloodParticleSystem.Play();
HealthPoints --;
}
}
View ExampleLaserStuff.cs
public delegate void LaserHitTriggerHandler(RaycastHit2D hitInfo);
/// <summary>
/// Event that fires whenever the laser collides with an object (requires ignoreCollisions to be false). Subscribe to this event to be notified when the laser is hitting an object. The RaycastHit2D info will be sent through the event.
/// </summary>
public event LaserHitTriggerHandler OnLaserHitTriggered;
/// <summary>
/// Fires the OnLaserHitTriggered event every triggerInterval seconds.
/// </summary>
View gist:6587adafbaa3bac05be9
// Setup our credentials which will use our Cognito identity pool to hand us short-term session credentials,
// giving us access to what we have provided access to with our IAM role policies, in this case, access to our
// DynamoDB table.
credentials = new CognitoAWSCredentials(cognitoIdentityPoolString, RegionEndpoint.USEast1);
credentials.GetIdentityIdAsync(delegate(AmazonCognitoIdentityResult<string> result)
{
if (result.Exception != null)
{
Debug.LogError("exception hit: " + result.Exception.Message);
}
View gist:7bb02ff347cdc94ea069
private void CreateCharacterInTable()
{
var newCharacter = new CharacterEntity
{
CharacterID = Guid.NewGuid().ToString(),
BodySpriteName = selectedBody,
FaceSpriteName = selectedFace,
ShirtSpriteName = selectedShirt,
HairSpriteName = selectedHair,
PantsSpriteName = selectedPants,
View gist:853ee54b3ec0a405ef0e
private void FetchAllCharactersFromAWS()
{
resultText.text = "\n***LoadTable***";
Table.LoadTableAsync(_client, "CharacterCreator", (loadTableResult) =>
{
if (loadTableResult.Exception != null)
{
resultText.text += "\n failed to load characters table";
}
else
View gist:aae54252966804fba1a4
createOperation.onClick.AddListener(CreateCharacterInTable);
refreshOperation.onClick.AddListener(FetchAllCharactersFromAWS);
NextCharacterButton.onClick.AddListener(CycleNextCharacter);
PrevCharacterButton.onClick.AddListener(CyclePrevCharacter);
View gist:e22d2336248af28aa465
private void LoadCharacter(CharacterEntity characterEntity)
{
// Update the selected body component values stored as field values
selectedBody = characterEntity.BodySpriteName;
selectedFace = characterEntity.FaceSpriteName;
selectedHair = characterEntity.HairSpriteName;
selectedShirt = characterEntity.ShirtSpriteName;
selectedPants = characterEntity.PantsSpriteName;
selectedShoes = characterEntity.ShoesSpriteName;
View gist:ff42193696541e8ec646
private DynamoDBContext Context
{
get
{
if (_context == null)
_context = new DynamoDBContext(_client);
return _context;
}
}