Skip to content

Instantly share code, notes, and snippets.

using Amazon;
using Amazon.CognitoIdentity;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DataModel;
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.DynamoDBv2.Model;
@Shogan
Shogan / gist:9f075f43ac789d8520c3
Last active August 29, 2015 14:21
CharacterEntityClass
using System.Collections.Generic;
using Amazon.DynamoDBv2.DataModel;
namespace Assets.CharacterCreatorAWSDynamoDB.Scripts
{
[DynamoDBTable("CharacterCreator")]
public class CharacterEntity
{
[DynamoDBHashKey] // Hash key.
public string CharacterID { get; set; }
@Shogan
Shogan / gist:be44b29f7b8e18832bc8
Last active August 29, 2015 14:21
character-creator-fields
public string cognitoIdentityPoolString;
private CognitoAWSCredentials credentials;
private IAmazonDynamoDB _client;
private DynamoDBContext _context;
private List<CharacterEntity> characterEntities = new List<CharacterEntity>();
private int currentCharacterIndex;
@Shogan
Shogan / gist:ff42193696541e8ec646
Last active August 29, 2015 14:21
DynamoDB-context
private DynamoDBContext Context
{
get
{
if (_context == null)
_context = new DynamoDBContext(_client);
return _context;
}
}
@Shogan
Shogan / gist:e22d2336248af28aa465
Last active August 29, 2015 14:21
CharacterOperations-for-UI
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;
@Shogan
Shogan / gist:aae54252966804fba1a4
Created May 25, 2015 10:09
character-creator-button-operation-listeners
createOperation.onClick.AddListener(CreateCharacterInTable);
refreshOperation.onClick.AddListener(FetchAllCharactersFromAWS);
NextCharacterButton.onClick.AddListener(CycleNextCharacter);
PrevCharacterButton.onClick.AddListener(CyclePrevCharacter);
@Shogan
Shogan / gist:853ee54b3ec0a405ef0e
Last active August 29, 2015 14:21
FetchAllCharactersFromAWS
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
private void CreateCharacterInTable()
{
var newCharacter = new CharacterEntity
{
CharacterID = Guid.NewGuid().ToString(),
BodySpriteName = selectedBody,
FaceSpriteName = selectedFace,
ShirtSpriteName = selectedShirt,
HairSpriteName = selectedHair,
PantsSpriteName = selectedPants,
@Shogan
Shogan / gist:6587adafbaa3bac05be9
Created May 25, 2015 12:46
CharacterCreator-startup-and-initialisation
// 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);
}
@Shogan
Shogan / ExampleLaserStuff.cs
Created August 18, 2015 08:57
Example of laser damage event with interval
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>