-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Devine Lu Linvega
committed
Jun 7, 2012
1 parent
8ce5c4f
commit dba886a
Showing
814 changed files
with
4,638 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Shader "Simple Glass" { | ||
Properties { | ||
_Color ("Main Color", Color) = (1,1,1,0) | ||
_SpecColor ("Spec Color", Color) = (1,1,1,1) | ||
_Emission ("Emmisive Color", Color) = (0,0,0,0) | ||
_Shininess ("Shininess", Range (0.01, 1)) = 0.7 | ||
_MainTex ("Base (RGB)", 2D) = "white" { } | ||
} | ||
|
||
SubShader { | ||
// We use the material in many passes by defining them in the subshader. | ||
// Anything defined here becomes default values for all contained passes. | ||
Material { | ||
Diffuse [_Color] | ||
Ambient [_Color] | ||
Shininess [_Shininess] | ||
Specular [_SpecColor] | ||
Emission [_Emission] | ||
} | ||
Lighting On | ||
SeparateSpecular On | ||
|
||
// Set up alpha blending | ||
Blend SrcAlpha OneMinusSrcAlpha | ||
|
||
// Render the back facing parts of the object. | ||
// If the object is convex, these will always be further away | ||
// than the front-faces. | ||
Pass { | ||
Cull Front | ||
SetTexture [_MainTex] { | ||
Combine Primary * Texture | ||
} | ||
} | ||
// Render the parts of the object facing us. | ||
// If the object is convex, these will be closer than the | ||
// back-faces. | ||
Pass { | ||
Cull Back | ||
SetTexture [_MainTex] { | ||
Combine Primary * Texture | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
public class AccumulatorBehaviour : MonoBehaviour | ||
{ | ||
readonly float FallDownSpeed = UnityEngine.Random.Range(0.25f, 2); | ||
|
||
public bool FallingDown; | ||
|
||
GameObject[] Halves; | ||
GameObject Inner; | ||
bool Full, Incubated; | ||
|
||
Direction LastDirection; | ||
readonly List<EnergyInfo> TemporaryEnergy = new List<EnergyInfo>(); | ||
Color? ContainedEnergy; | ||
|
||
void Start() | ||
{ | ||
Halves = new [] | ||
{ | ||
gameObject.FindChild("First Half"), | ||
gameObject.FindChild("Second Half") | ||
}; | ||
|
||
Inner = gameObject.FindChild("Inner"); | ||
Inner.renderer.enabled = false; | ||
|
||
foreach (var half in Halves) | ||
half.renderer.enabled = false; | ||
|
||
SetAlpha(); | ||
} | ||
|
||
void SetAlpha() | ||
{ | ||
var eased = Easing.EaseInOut(Mathf.Clamp01(Pico.Level.SinceAlive), EasingType.Sine); | ||
var r = gameObject.FindChild("Empty-Second Half").renderer; | ||
var c = r.material.GetColor("_TintColor"); | ||
r.material.SetColor("_TintColor", new Color(c.r, c.g, c.b, eased * (14 / 255f))); | ||
r = gameObject.FindChild("Empty-First Half").renderer; | ||
c = r.material.GetColor("_TintColor"); | ||
r.material.SetColor("_TintColor", new Color(c.r, c.g, c.b, eased * (14 / 255f))); | ||
r = gameObject.FindChild("CubeInsideout").renderer; | ||
c = r.material.GetColor("_TintColor"); | ||
r.material.SetColor("_TintColor", new Color(c.r, c.g, c.b, eased * (13 / 255f))); | ||
} | ||
|
||
public bool AddEnergy(EnergyInfo energy) | ||
{ | ||
TemporaryEnergy.Add(energy); | ||
return true; | ||
} | ||
|
||
public void Empty() | ||
{ | ||
TemporaryEnergy.Clear(); | ||
ContainedEnergy = null; | ||
|
||
Inner.renderer.enabled = false; | ||
|
||
foreach (var half in Halves) | ||
half.renderer.enabled = false; | ||
} | ||
|
||
void Update() | ||
{ | ||
SetAlpha(); | ||
|
||
if (FallingDown) | ||
{ | ||
transform.position += Vector3.down * Pico.FallDistance * FallDownSpeed; | ||
} | ||
} | ||
|
||
public void LateUpdate() | ||
{ | ||
if (Pico.Heartbeat) | ||
{ | ||
// Projection | ||
if (Incubated) | ||
{ | ||
var go = Instantiate(Pico.EnergyTemplate) as GameObject; | ||
go.transform.position = transform.position; | ||
go.renderer.material.color = ContainedEnergy.Value; | ||
var behaviour = go.GetComponent<EnergyBehaviour>(); | ||
behaviour.Direction = LastDirection; | ||
behaviour.Destination = transform.position; | ||
behaviour.Update(); // Force move & test | ||
|
||
// Reset | ||
ContainedEnergy = null; | ||
Incubated = false; | ||
Inner.renderer.enabled = false; | ||
|
||
//if (behaviour.ScheduleDestroy) // Well, shit | ||
//{ | ||
// foreach (var projector in FindObjectsOfType(typeof(ProjectorBehaviour)).Cast<ProjectorBehaviour>()) | ||
// projector.LateUpdate(); | ||
// foreach (var otherAccumulator in FindObjectsOfType(typeof(AccumulatorBehaviour)).Cast<AccumulatorBehaviour>()) | ||
// if (otherAccumulator != this) | ||
// otherAccumulator.LateUpdate(); | ||
//} | ||
} | ||
} | ||
|
||
if (Pico.PostHeartbeat) | ||
{ | ||
// Incubate | ||
if (Full && !Incubated) | ||
{ | ||
Inner.renderer.enabled = true; | ||
Inner.renderer.material.color = ContainedEnergy.Value; | ||
|
||
foreach (var half in Halves) | ||
half.renderer.enabled = false; | ||
|
||
Full = false; | ||
Incubated = true; | ||
} | ||
|
||
// Blend & digest energy | ||
if (TemporaryEnergy.Count > 1) | ||
{ | ||
// Reject (re-create input) | ||
foreach (var energy in TemporaryEnergy) | ||
{ | ||
var go = Instantiate(Pico.EnergyTemplate) as GameObject; | ||
go.renderer.material.color = energy.Color; | ||
go.transform.position = transform.position - energy.Direction.ToVector(); | ||
var behaviour = go.GetComponent<EnergyBehaviour>(); | ||
behaviour.Direction = energy.Direction; | ||
behaviour.Destination = transform.position; | ||
} | ||
|
||
TemporaryEnergy.Clear(); | ||
} | ||
else if (TemporaryEnergy.Count == 1) | ||
{ | ||
var blend = TemporaryEnergy[0].Color.Saturate(); | ||
if (ContainedEnergy.HasValue && blend != ContainedEnergy.Value) | ||
{ | ||
// Reject (re-create input) | ||
foreach (var energy in TemporaryEnergy) | ||
{ | ||
var go = Instantiate(Pico.EnergyTemplate) as GameObject; | ||
go.renderer.material.color = energy.Color; | ||
go.transform.position = transform.position - energy.Direction.ToVector(); | ||
var behaviour = go.GetComponent<EnergyBehaviour>(); | ||
behaviour.Direction = energy.Direction; | ||
behaviour.Destination = transform.position; | ||
} | ||
} | ||
else | ||
{ | ||
// Accept | ||
Full = ContainedEnergy.HasValue; | ||
var newHalfIndex = Full ? 1 : 0; | ||
Halves[newHalfIndex].renderer.enabled = true; | ||
Halves[newHalfIndex].renderer.material.color = blend; | ||
ContainedEnergy = blend; | ||
|
||
LastDirection = TemporaryEnergy[0].Direction; | ||
} | ||
|
||
TemporaryEnergy.Clear(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public static class ArrayHelper | ||
{ | ||
#region In | ||
|
||
public static bool In<T>(IEqualityComparer<T> comparer, T value, params T[] values) | ||
{ | ||
foreach (var v in values) | ||
if (comparer.Equals(value, v)) return true; | ||
return false; | ||
} | ||
public static bool In<T>(IEqualityComparer<T> comparer, T value, T value1, T value2) | ||
{ | ||
return (comparer.Equals(value, value1) || comparer.Equals(value, value2)); | ||
} | ||
public static bool In<T>(IEqualityComparer<T> comparer, T value, T value1, T value2, T value3) | ||
{ | ||
return In(comparer, value, value1, value2) || comparer.Equals(value, value3); | ||
} | ||
public static bool In<T>(IEqualityComparer<T> comparer, T value, T value1, T value2, T value3, T value4) | ||
{ | ||
return In(comparer, value, value1, value2, value3) || comparer.Equals(value, value4); | ||
} | ||
public static bool In<T>(IEqualityComparer<T> comparer, T value, T value1, T value2, T value3, T value4, T value5) | ||
{ | ||
return In(comparer, value, value1, value2, value3, value4) || comparer.Equals(value, value5); | ||
} | ||
public static bool In<T>(IEqualityComparer<T> comparer, T value, T value1, T value2, T value3, T value4, T value5, T value6) | ||
{ | ||
return In(comparer, value, value1, value2, value3, value4, value5) || comparer.Equals(value, value6); | ||
} | ||
|
||
public static bool In<T>(T value, params T[] values) where T : IEquatable<T> | ||
{ | ||
foreach (var v in values) | ||
if (value.Equals(v)) return true; | ||
return false; | ||
} | ||
public static bool In<T>(T value, T value1, T value2) where T : IEquatable<T> | ||
{ | ||
return (value.Equals(value1) || value.Equals(value2)); | ||
} | ||
public static bool In<T>(T value, T value1, T value2, T value3) where T : IEquatable<T> | ||
{ | ||
return In(value, value1, value2) || value.Equals(value3); | ||
} | ||
public static bool In<T>(T value, T value1, T value2, T value3, T value4) where T : IEquatable<T> | ||
{ | ||
return In(value, value1, value2, value3) || value.Equals(value4); | ||
} | ||
public static bool In<T>(T value, T value1, T value2, T value3, T value4, T value5) where T : IEquatable<T> | ||
{ | ||
return In(value, value1, value2, value3, value4) || value.Equals(value5); | ||
} | ||
public static bool In<T>(T value, T value1, T value2, T value3, T value4, T value5, T value6) where T : IEquatable<T> | ||
{ | ||
return In(value, value1, value2, value3, value4, value5) || value.Equals(value6); | ||
} | ||
|
||
#endregion | ||
|
||
#region Coalesce | ||
|
||
public static T Coalesce<T>(IEqualityComparer<T> comparer, T first, T second) where T : struct | ||
{ | ||
T defaultValue = default(T); | ||
|
||
if (!comparer.Equals(defaultValue, first)) return first; | ||
if (!comparer.Equals(defaultValue, second)) return second; | ||
|
||
return defaultValue; | ||
} | ||
public static T Coalesce<T>(IEqualityComparer<T> comparer, T first, T second, T third) where T : struct | ||
{ | ||
T defaultValue = default(T); | ||
|
||
if (!comparer.Equals(defaultValue, first)) return first; | ||
if (!comparer.Equals(defaultValue, second)) return second; | ||
if (!comparer.Equals(defaultValue, third)) return third; | ||
|
||
return defaultValue; | ||
} | ||
public static T Coalesce<T>(IEqualityComparer<T> comparer, T first, T second, T third, T fourth) where T : struct | ||
{ | ||
T defaultValue = default(T); | ||
|
||
if (!comparer.Equals(defaultValue, first)) return first; | ||
if (!comparer.Equals(defaultValue, second)) return second; | ||
if (!comparer.Equals(defaultValue, third)) return third; | ||
if (!comparer.Equals(defaultValue, fourth)) return fourth; | ||
|
||
return defaultValue; | ||
} | ||
public static T Coalesce<T>(IEqualityComparer<T> comparer, params T[] values) where T : struct, IEquatable<T> | ||
{ | ||
return Coalesce(comparer, values as IEnumerable<T>); | ||
} | ||
public static T Coalesce<T>(IEqualityComparer<T> comparer, IEnumerable<T> values) where T : struct | ||
{ | ||
T defaultValue = default(T); | ||
|
||
foreach (var value in values) | ||
if (!comparer.Equals(defaultValue, value)) return value; | ||
|
||
return defaultValue; | ||
} | ||
|
||
public static T Coalesce<T>(T first, T second) where T : struct, IEquatable<T> | ||
{ | ||
T defaultValue = default(T); | ||
|
||
if (!first.Equals(defaultValue)) return first; | ||
if (!second.Equals(defaultValue)) return second; | ||
|
||
return defaultValue; | ||
} | ||
public static T Coalesce<T>(T first, T second, T third) where T : struct, IEquatable<T> | ||
{ | ||
T defaultValue = default(T); | ||
|
||
if (!first.Equals(defaultValue)) return first; | ||
if (!second.Equals(defaultValue)) return second; | ||
if (!third.Equals(defaultValue)) return third; | ||
|
||
return defaultValue; | ||
} | ||
public static T Coalesce<T>(T first, T second, T third, T fourth) where T : struct, IEquatable<T> | ||
{ | ||
T defaultValue = default(T); | ||
|
||
if (!first.Equals(defaultValue)) return first; | ||
if (!second.Equals(defaultValue)) return second; | ||
if (!third.Equals(defaultValue)) return third; | ||
if (!fourth.Equals(defaultValue)) return fourth; | ||
|
||
return defaultValue; | ||
} | ||
public static T Coalesce<T>(params T[] values) where T : struct, IEquatable<T> | ||
{ | ||
return Coalesce(values as IEnumerable<T>); | ||
} | ||
public static T Coalesce<T>(IEnumerable<T> values) where T : struct, IEquatable<T> | ||
{ | ||
T defaultValue = default(T); | ||
|
||
foreach (var value in values) | ||
if (!value.Equals(defaultValue)) return value; | ||
|
||
return defaultValue; | ||
} | ||
|
||
#endregion | ||
|
||
public static T Next<T>(this T[] values, T current) | ||
{ | ||
var currentIndex = Array.IndexOf(values, current); | ||
return values[Math.Min(currentIndex + 1, values.Length - 1)]; | ||
} | ||
|
||
public static T Previous<T>(this T[] values, T current) | ||
{ | ||
var currentIndex = Array.IndexOf(values, current); | ||
return values[Math.Max(currentIndex - 1, 0)]; | ||
} | ||
} |
Oops, something went wrong.