Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .~lock.Lab12.docx#
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Darrick Hilburn,REGIGIGAS/Darrick,Regigigas,22.11.2015 11:51,file:///C:/Users/Darrick/AppData/Roaming/OpenOffice/4;
Binary file added Lab12.docx
Binary file not shown.
9 changes: 9 additions & 0 deletions Lab12/Assets/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab12/Assets/Materials/AI0Material.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab12/Assets/Materials/AI0Material.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab12/Assets/Materials/AI1Material.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab12/Assets/Materials/AI1Material.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab12/Assets/Materials/AI2Material.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab12/Assets/Materials/AI2Material.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab12/Assets/Materials/DamagerMaterial.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab12/Assets/Materials/DamagerMaterial.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab12/Assets/Materials/FloorMaterial.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab12/Assets/Materials/FloorMaterial.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Lab12/Assets/Scenes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab12/Assets/Scenes/OnOwnScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab12/Assets/Scenes/OnOwnScene.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Lab12/Assets/Scenes/TestScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab12/Assets/Scenes/TestScene.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Lab12/Assets/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Lab12/Assets/Scripts/CapturePitfall.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using UnityEngine;
using System.Collections;
using System.Threading;

public class CapturePitfall : MonoBehaviour
{
// Use this for initialization
void Start ()
{
Debug.Log("Variable Capturing");
Debug.Log("------------------");
for(int i = 1; i <= 10; i++)
{
int temp = i;
// With no temp variable declared, Debug.Log calls a constantly changing variable
new Thread(() => Debug.Log(temp)).Start();
}
}
}
12 changes: 12 additions & 0 deletions Lab12/Assets/Scripts/CapturePitfall.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions Lab12/Assets/Scripts/ForegroundBackgroundDifferences.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEngine;
using System.Collections;
using System.Threading;

public class ForegroundBackgroundDifferences : MonoBehaviour {

// Use this for initialization
void Start ()
{
Debug.Log("Foreground vs Background");
Debug.Log("------------------------");
Thread worker = new Thread(Go);
worker.Name = "worker";
Debug.Log("Is " + worker.Name + " a background thread? " + worker.IsBackground);
worker.IsBackground = true;
Debug.Log("Is " + worker.Name + " a background thread? " + worker.IsBackground);
worker.Start();
}

// Update is called once per frame
void Go()
{
Debug.Log("This is here for thread functionality.");
}
}
12 changes: 12 additions & 0 deletions Lab12/Assets/Scripts/ForegroundBackgroundDifferences.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions Lab12/Assets/Scripts/LambdaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using UnityEngine;
using System.Collections;

public class LambdaTest : MonoBehaviour
{
class Student
{
public int age;

public Student() { age = 10; }

public Student(int age) { this.age = age; }
}

delegate bool isTeenager(Student student);

// Use this for initialization
void Start()
{
Debug.Log("Lambda Example");
Debug.Log("--------------");

Student student1 = new Student(5);
Student student2 = new Student(10);
Student student3 = new Student(15);
Student student4 = new Student(20);

Debug.Log("Function student1 teenager? : " + funcIsATeen(student1));
Debug.Log("Function student2 teenager? : " + funcIsATeen(student2));
Debug.Log("Function student3 teenager? : " + funcIsATeen(student3));
Debug.Log("Function student4 teenager? : " + funcIsATeen(student4));

isTeenager isATeen = s => s.age > 12 && s.age < 20;

Debug.Log("Lambda student1 teenager? : " + isATeen(student1));
Debug.Log("Lambda student2 teenager? : " + isATeen(student2));
Debug.Log("Lambda student3 teenager? : " + isATeen(student3));
Debug.Log("Lambda student4 teenager? : " + isATeen(student4));
}

bool funcIsATeen(Student currStudent)
{
return (currStudent.age > 12 && currStudent.age < 20);
}
}
12 changes: 12 additions & 0 deletions Lab12/Assets/Scripts/LambdaTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Lab12/Assets/Scripts/OnOwn.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Lab12/Assets/Scripts/OnOwn/HealthScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class HealthScript : MonoBehaviour
{
[Tooltip("Character Health.")]
public int health;
[Tooltip("Area to display character health.")]
public Text healthDisplay;

void Start()
{
healthDisplay.text = health.ToString();
}

void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag.Equals("Damager"))
Damage();
}

public void Damage()
{
if (health > 1)
{
health--;
healthDisplay.text = health.ToString();
}
else
{
healthDisplay.text = "DEAD";
}
}
}
12 changes: 12 additions & 0 deletions Lab12/Assets/Scripts/OnOwn/HealthScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions Lab12/Assets/Scripts/OnOwn/MoveScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using UnityEngine;
using System.Collections;
using System.Threading;

public enum MoveType
{
MoveForward,
MoveBack,
MoveLeft,
MoveRight
}

public class MoveScript : MonoBehaviour
{
const int MAX_X = 10;
const int MAX_Z = 10;

Thread moveThread;

bool moving = false;

void Start ()
{

}


void Update ()
{

}

void SetupMove()
{
float moveTime = 5;

Vector3 start = transform.position;
Vector3 target = transform.position;

int movement = Random.Range(0, 4);

moving = true;

switch (movement)
{
case ((int)MoveType.MoveForward):
target = target + (Vector3.forward * moveTime);
break;
case ((int)MoveType.MoveBack):
target = target + (Vector3.back * moveTime);
break;
case ((int)MoveType.MoveRight):
target = target + (Vector3.right * moveTime);
break;
case ((int)MoveType.MoveLeft):
target = target + (Vector3.left * moveTime);
break;
}
moveThread = new Thread(() => Move(moveTime, start, target));
moveThread.Start();
}

void Move(float moveTime, Vector3 startPos, Vector3 endPos)
{
float elapsedTime = 0;

while (elapsedTime < moveTime)
{
transform.position = Vector3.Lerp(startPos, endPos, (elapsedTime / moveTime));
CheckBounds();
elapsedTime += Time.deltaTime;
}
moving = false;
Debug.Log("Movement complete");
}

void CheckBounds()
{
Vector3 mirrorPos = transform.position;

if (transform.position.x > MAX_X)
{
mirrorPos.x = -MAX_X;
transform.position = mirrorPos;
}
if (transform.position.x < -MAX_X)
{
mirrorPos.x = MAX_X;
transform.position = mirrorPos;
}
if (transform.position.z > MAX_Z)
{
mirrorPos.z = -MAX_Z;
transform.position = mirrorPos;
}
if (transform.position.z < -MAX_Z)
{
mirrorPos.z = MAX_Z;
transform.position = mirrorPos;
}
}
}
Loading