Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public class DudeDeathController : MonoBehaviour {
...
public void Die() {
DudeMotionArrester.SlowToStop();
Animator.Play("DudeDie");
@mikelovesrobots
mikelovesrobots / AccelerometerAdapter.cs
Last active August 29, 2015 13:57
Adapter for Unity that uses the mouse for input if the current device (e.g., the editor) doesn't support acceleration. MIT license, so go nuts.
using UnityEngine;
using System.Collections;
public class AccelerometerAdapter : MonoBehaviour {
public const float TILT_SENSITIVITY = 1.5f;
public Vector3 Input {
get {
if (SystemInfo.supportsAccelerometer) {
return UnityEngine.Input.acceleration * TILT_SENSITIVITY;
@mikelovesrobots
mikelovesrobots / Character.cs
Created March 28, 2014 00:13
Dungeon Highway Character Model
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Character {
public CharacterType CharacterType;
public Sprite DefaultSprite;
public string PortraitSpriteName;
public string WalkAnimationName {
@mikelovesrobots
mikelovesrobots / gist:42cfc1938f72a1d44591
Created April 8, 2015 23:13
Dungeon Highway Adventures - Speed Dungeon - Very Hard Level
r
OXO
[N]
$P$
$P$
$$$
$
fff
222
eEe
@mikelovesrobots
mikelovesrobots / gist:60830f18c3422a517b3e
Created April 10, 2015 20:01
Dungeon Highway Level Layout "Miniboss and Friends"
|
|
|
CC |
|
|
CC |
|
|
CC |
@mikelovesrobots
mikelovesrobots / gist:274b40c23d64a09d58c3
Created April 17, 2015 18:41
ParseSafeInitializeBehaviour
using UnityEngine;
using System.Collections;
using Parse;
// Parse stops responding if it gets initialized twice or the original initialization goes away (e.g., you leave the scene)
// so use this instead of the regular ParseInitializeBehaviour, and throw it in every scene that you access Parse from
public class ParseSafeInitializeBehaviour : ParseInitializeBehaviour {
public static bool IsAlreadyAlive;
named_scope :sort_string, lambda do |type|
order_string = case type
when 'score'
"score desc"
when 'date'
"created_at desc"
else
raise "Unknown type passed into sort_string: #{type.inspect}"
end
// the node OOP-way
function Awake () {
var networkConnector = NetworkConnector(isHost());
networkConnector.connect(function() {
spawnPlayer();
});
}
// the unity3d-ish way
@mikelovesrobots
mikelovesrobots / jasmine_pretty_print_monkeypatch.coffee
Created July 24, 2012 18:53
Jasmine pretty print monkeypatch for sane test failure messages (dump in spec/javascripts/helpers)
jasmine.PrettyPrinter.prototype.iterateObject = (obj, fn) ->
for own property, _ of obj
if property == '__Jasmine_been_here_before__'
continue
fn(property, if obj.__lookupGetter__ then (obj.__lookupGetter__(property) != jasmine.undefined && obj.__lookupGetter__(property) != null) else false)
jasmine.StringPrettyPrinter::originalEmitObject = jasmine.StringPrettyPrinter::emitObject
jasmine.StringPrettyPrinter::emitObject = (obj) ->
if obj instanceof jQuery
@mikelovesrobots
mikelovesrobots / gist:f8aeb8cc5ccb1b97bc61
Created April 17, 2015 18:42
ParseSafeInitializeBehaviour
using UnityEngine;
using System.Collections;
using Parse;
// Parse for Unity3d stops responding if it gets initialized twice
// or the original initialization goes away (e.g., you leave the scene)
// so use this instead of the regular ParseInitializeBehaviour, and
// throw it in every scene that you need to talk to Parse in
public class ParseSafeInitializeBehaviour : ParseInitializeBehaviour {