Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Devine Lu Linvega committed Jun 7, 2012
1 parent 8ce5c4f commit dba886a
Show file tree
Hide file tree
Showing 814 changed files with 4,638 additions and 0 deletions.
Binary file added Assets/.DS_Store
Binary file not shown.
Binary file added Assets/Default.unity
Binary file not shown.
Binary file added Assets/Fonts/ff_din_regular-webfont.ttf
Binary file not shown.
Binary file added Assets/Ground 360.anim
Binary file not shown.
Binary file added Assets/Materials/Accumulator-empty.mat
Binary file not shown.
Binary file added Assets/Materials/Accumulator.mat
Binary file not shown.
Binary file added Assets/Materials/All White.mat
Binary file not shown.
Binary file added Assets/Materials/Black.mat
Binary file not shown.
Binary file added Assets/Materials/DialogMat.mat
Binary file not shown.
Binary file added Assets/Materials/FaceHighlight.mat
Binary file not shown.
Binary file added Assets/Materials/Shadow.mat
Binary file not shown.
Binary file added Assets/Materials/Transparent.mat
Binary file not shown.
Binary file added Assets/Materials/WireLines.mat
Binary file not shown.
Binary file added Assets/Materials/YellowTint.mat
Binary file not shown.
Binary file added Assets/Materials/bluetint.mat
Binary file not shown.
Binary file added Assets/Meshes/CubeEmpty.c4d
Binary file not shown.
Binary file added Assets/Meshes/CubeInsideout.c4d
Binary file not shown.
Binary file added Assets/Meshes/Materials/CubeEmpty-No Name.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/CubeInsideout-No Name.mat
Binary file not shown.
45 changes: 45 additions & 0 deletions Assets/Meshes/Materials/Glass.shader
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 added Assets/Meshes/Materials/cubeempty-boole.2mat.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/cubeempty-boolemat.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/cubeempty-cube.2mat.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/cubeempty-cube.3mat.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/cubeempty-cubemat.mat
Binary file not shown.
Binary file not shown.
Binary file added Assets/Meshes/Materials/ground-No Name.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/ground-landscapemat.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/piramyd-No Name.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/piramyd-pyramidmat.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/plane (fbx)-planemat.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/plane-No Name.mat
Binary file not shown.
Binary file added Assets/Meshes/Materials/plane-planemat.mat
Binary file not shown.
Binary file added Assets/Meshes/ground.c4d
Binary file not shown.
Binary file added Assets/Meshes/piramyd.c4d
Binary file not shown.
Binary file added Assets/Meshes/plane (fbx).fbx
Binary file not shown.
Binary file added Assets/Meshes/plane.c4d
Binary file not shown.
Binary file added Assets/Plugins/XInputDotNetPure.dll
Binary file not shown.
Binary file added Assets/Prefabs/Accumulator.prefab
Binary file not shown.
Binary file added Assets/Prefabs/Emitter.prefab
Binary file not shown.
Binary file added Assets/Prefabs/Energy.prefab
Binary file not shown.
Binary file added Assets/Prefabs/Projector.prefab
Binary file not shown.
Binary file added Assets/Prefabs/Receiver.prefab
Binary file not shown.
Binary file added Assets/Prefabs/ReceiverOld.prefab
Binary file not shown.
Binary file added Assets/Prefabs/WireLines.prefab
Binary file not shown.
Binary file added Assets/Scenes/Default.unity
Binary file not shown.
Binary file added Assets/Scripts/.DS_Store
Binary file not shown.
172 changes: 172 additions & 0 deletions Assets/Scripts/AccumulatorBehaviour.cs
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();
}
}
}
}
167 changes: 167 additions & 0 deletions Assets/Scripts/ArrayHelper.cs
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)];
}
}
Loading

0 comments on commit dba886a

Please sign in to comment.