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
Binary file added Lab 12 Report.docx
Binary file not shown.
Binary file added Lab 12.docx
Binary file not shown.
9 changes: 9 additions & 0 deletions Lab 12/Assets/Materials.meta

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

Binary file added Lab 12/Assets/Materials/Black.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Materials/Black.mat.meta

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

Binary file added Lab 12/Assets/Materials/Blue.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Materials/Blue.mat.meta

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

Binary file added Lab 12/Assets/Materials/Green.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Materials/Green.mat.meta

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

Binary file added Lab 12/Assets/Materials/Orange.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Materials/Orange.mat.meta

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

Binary file added Lab 12/Assets/Materials/Purple.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Materials/Purple.mat.meta

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

Binary file added Lab 12/Assets/Materials/Red.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Materials/Red.mat.meta

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

Binary file added Lab 12/Assets/Materials/Yellow.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Materials/Yellow.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 Lab 12/Assets/Prefabs.meta

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

Binary file added Lab 12/Assets/Prefabs/CubePrefab.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Prefabs/CubePrefab.prefab.meta

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

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

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

Binary file added Lab 12/Assets/Scenes/MainScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/Assets/Scenes/MainScene.unity.meta

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

Binary file added Lab 12/Assets/Scenes/TestScene.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab 12/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 Lab 12/Assets/Scripts.meta

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

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

public class Arguments : MonoBehaviour {

void Start()
{
Thread thread = new Thread (() => DisplayMessage("Hello from the thread!"));
thread.Start ();

new Thread ( () =>
{
Debug.Log ("I'm running on another thread!");
Debug.Log ("This is so cool!");
}
).Start();

}

void DisplayMessage(string message)
{
Debug.Log (message);
}

}
12 changes: 12 additions & 0 deletions Lab 12/Assets/Scripts/Arguments.cs.meta

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

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

public class Captured : MonoBehaviour {

// Use this for initialization
void Start ()
{
Debug.Log("First for loop:");
for(int i = 1; i <= 10; i++)
{
new Thread( ()=> Debug.Log (i)).Start();
}

Thread.Sleep(1000);
Debug.Log("Second for loop:");

for(int i = 11; i <= 20; i++)
{
int temp = i;
new Thread( ()=> Debug.Log (temp)).Start();
}
}

// Update is called once per frame
void Update () {

}
}
12 changes: 12 additions & 0 deletions Lab 12/Assets/Scripts/Captured.cs.meta

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

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

public class ForegroundBackground : MonoBehaviour {

// Use this for initialization
void Start ()
{
Thread worker = new Thread (Go);
worker.Name = "worker";
Debug.Log ("is worker background? " + worker.IsBackground);
worker.IsBackground = true;
Debug.Log ("is worker background? " + worker.IsBackground);
worker.Start ();
}

void Go()
{
Debug.Log ("Hello from " + Thread.CurrentThread.Name);
}

// Update is called once per frame
void Update () {

}
}
12 changes: 12 additions & 0 deletions Lab 12/Assets/Scripts/ForegroundBackground.cs.meta

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

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

public class HealthScript : MonoBehaviour {
private const int STARTING_HEALTH = 5;

public int health;
public Text healthDisplay;

// Use this for initialization
void Start ()
{
health = STARTING_HEALTH;
healthDisplay.text = "Health: " + health.ToString();
}

void OnTriggerEnter(Collider hitter)
{
health--;
healthDisplay.text = "Health: " + health.ToString();
}
} // end class HealthScript
12 changes: 12 additions & 0 deletions Lab 12/Assets/Scripts/HealthScript.cs.meta

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

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

public class LambdaTest : MonoBehaviour {

delegate bool isTeenager(Student student);

// Use this for initialization
void Start () {

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);
}

// Update is called once per frame
void Update () {

}

class Student
{
public int age;

public Student()
{
age = 10;
}

public Student(int age)
{
this.age =age;
}
}
}
12 changes: 12 additions & 0 deletions Lab 12/Assets/Scripts/LambdaTest.cs.meta

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

Loading