forked from JXPorter/OkitaUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.cs
More file actions
118 lines (113 loc) · 3.08 KB
/
Example.cs
File metadata and controls
118 lines (113 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
void Start()
{
}
public float NextTime = 0f;
public float Timer = 0.5f;
public int Counter = 10;
public int MinHeight = 1;
public int MaxHeight = 10;
public float HorizontalSpacing = 2f;
public float VerticalSpacing = 1.1f;
void Update()
{
//print (Time.fixedTime);
if (Counter > 0 && Time.fixedTime > NextTime)
{
// since we only want one thing to happen when our if statement is executed, we should add in some way to increment
// the number we're comparing to Time.fixedTime.
NextTime = Time.fixedTime + Timer;
for (int j = 10; j > 0; j--)
{
int randomNumber = Random.Range (MinHeight, MaxHeight);
for (int i = 0; i < randomNumber; i++)
{
CustomBox cBox = new CustomBox ();
cBox.box.transform.position = new Vector3 (Counter * HorizontalSpacing, i * VerticalSpacing, j * HorizontalSpacing);
cBox.PickRandomColor ();
}
}
Counter--;
}
}
class CustomBox
{
public GameObject box = GameObject.CreatePrimitive (PrimitiveType.Cube);
public void PickRandomColor ()
{
Color rc =
new Color(Random.value, Random.value, Random.value, 1);
box.GetComponent<Renderer>().material.color = rc;
}
}
}
//// MY TIMER CODE Building a simple timer and a counter.
//public float NextTime = 0f;
//public float Timer = 0.5f;
//public int Counter = 10;
//void Update()
//{
// print (Time.fixedTime);
// if (Counter > 0 && Time.fixedTime > NextTime)
// {
// // since we only want one thing to happen when our if statement is executed, we should add in some way to increment
// // the number we're comparing to Time.fixedTime.
// NextTime = Time.fixedTime + Timer;
// //print ("Time's Up!");
// GameObject box = GameObject.CreatePrimitive(PrimitiveType.Cube);
// box.transform.position = new Vector3 (Counter * 2f, 0, 0);
// Counter--;
// }
//}
//// Original Code
//public class Example : MonoBehaviour
//{
// // Use this for initialization
// void Start()
// {
// }
// // Update is called once per frame
// public float NextTime = 0f;
// public float Timer = 0.5f;
// public int Counter = 10;
// public int MinHeight = 1;
// public int MaxHeight = 10;
// public float HorizontalSpacing = 2f;
// public float VerticalSpacing = 1f;
// void Update()
// {
// if (Counter > 0 && Time.fixedTime > NextTime)
// {
// NextTime = Time.fixedTime + Timer;
// for (int j = 10; j > 0; j--)
// {
// int randomNumber = Random.Range(MinHeight, MaxHeight);
// for (int i = 0; i < randomNumber; i++)
// {
// CustomBox box = new CustomBox();
// box.box.transform.position =
// new Vector3(Counter * HorizontalSpacing,
// i * VerticalSpacing,
// j * HorizontalSpacing);
// box.PickRandomColor();
// }
// }
// Counter--;
// }
// }
// class CustomBox
// {
// public GameObject box =
// GameObject.CreatePrimitive(PrimitiveType.Cube);
// public void PickRandomColor()
// {
// Color rc =
// new Color(Random.value, Random.value, Random.value, 1);
// box.GetComponent<Renderer>().material.color = rc;
// }
// }
//
//}