Skip to content

Instantly share code, notes, and snippets.

View runewake2's full-sized avatar

Sam Wronski runewake2

View GitHub Profile
public static int Compare<TCompare>(TCompare first, TCompare second) where TCompare : IComparable
{
return first.CompareTo(second);
}
@runewake2
runewake2 / FallingBox.cs
Created November 6, 2016 02:14
An excerpt from the World of Zero Physics Playground. A 2D controller to handle boxes accurately falling into precise holes.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody2D))]
public class FallingBox : MonoBehaviour {
public float width = 1;
private new Rigidbody2D rigidbody;
private RaycastHit2D hit;
public Transform origin;
@runewake2
runewake2 / Blizzard.cs
Created December 17, 2016 01:42
Simulate occluded particle systems in Unity 3D.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Blizzard : MonoBehaviour {
public float verticleCeiling = 100;
public ParticleSystem[] blizzardEmitters;
// Use this for initialization
void Start () {
@runewake2
runewake2 / GeneratePlaneMesh.cs
Created December 20, 2016 06:48
Build a 3D Plane mesh with dynamic number of grid tiles.
// This code was built as part of World of Zero: https://youtu.be/iwsZAg7dReM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter))]
public class GeneratePlaneMesh : MonoBehaviour {
public float size = 1;
@runewake2
runewake2 / PhysicsDeformer.cs
Created December 21, 2016 04:40
Physics based mesh deformation. This is the physics system.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PhysicsDeformer : MonoBehaviour {
public float collisionRadius = 0.1f;
public DeformableMesh deformableMesh;
// Use this for initialization
@runewake2
runewake2 / DeformableMesh.cs
Created December 21, 2016 04:42
Physically simulated mesh deformation. This file handles the mesh updates.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
[RequireComponent(typeof(GeneratePlaneMesh))]
public class DeformableMesh : MonoBehaviour {
public float maximumDepression;
public List<Vector3> originalVertices;
@runewake2
runewake2 / OctreeComponent.cs
Created December 22, 2016 06:52
Work in progress Octree implementation for Unity 3D.
using System.Collections;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using UnityEngine;
public class OctreeComponent : MonoBehaviour {
public float size = 5;
public int depth = 2;
@runewake2
runewake2 / PhilosophersWithWaiter.cs
Created December 23, 2016 03:50
Solution for the dining philosophers in C# - Solution uses a waiter to oversee acquiring of chopsticks
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DiningPhilosophers
{
class Program
@runewake2
runewake2 / PhilosophersWithOrderAlteration
Created December 23, 2016 04:01
Solution to the Dining Philosophers problem - Solves the deadlock problem by alternating the order the philosophers select their chopsticks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DiningPhilosophers
{
class Program
@runewake2
runewake2 / DynamicProgrammingChangeProblem.cs
Created January 24, 2017 05:15
Solution to dynamic programming problem of creating optimal change with least number of coins. Solution includes greedy and dynamic problems as well as comparisons between them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
// The change problem :D
namespace DynamicProgramming
{