comparison Orchestland/Assets/LeapMotion+OVR/DemoResources/Scripts/BlocksPlaneGenerator.cs @ 1:f7675884f2a1

Add Orchestland project
author Daiki OYAKAWA <e135764@ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2015 23:09:20 +0900
parents
children
comparison
equal deleted inserted replaced
0:347d21cdfc22 1:f7675884f2a1
1 using UnityEngine;
2 using System.Collections;
3 using System.Linq;
4
5 public class BlocksPlaneGenerator : MonoBehaviour
6 {
7 public GameObject CubePrimitive;
8 public float minRadius;
9 public float maxRadius;
10 public int numberOfBlocks;
11 public float size;
12
13 private Color[] list_of_colors =
14 {
15 //new Color(1.00f, 1.00f, 0.94f), // (255,255,240) Ivory
16 //new Color(0.96f, 0.96f, 0.86f), // (245,245,220) Beige
17 //new Color(0.96f, 0.87f, 0.70f), // (245,222,179) Wheat
18 //new Color(0.82f, 0.71f, 0.55f), // (210,180,140) Tan
19 //new Color(0.76f, 0.69f, 0.57f), // (195,176,145) Khaki
20 //new Color(0.75f, 0.75f, 0.75f), // (192,192,192) Silver
21 //new Color(0.50f, 0.50f, 0.50f), // (128,128,128) Gray
22 //new Color(0.27f, 0.27f, 0.27f), // (070,070,070) Charcoal
23 new Color(0.00f, 0.00f, 1.00f), // (000,000,255) Navy Blue
24 new Color(0.02f, 0.30f, 0.62f), // (008,076,158) Royal Blue
25 new Color(0.00f, 0.00f, 0.80f), // (000,000,205) Medium Blue
26 new Color(0.00f, 0.50f, 1.00f), // (000,127,255) Azure
27 new Color(0.00f, 1.00f, 1.00f), // (000,255,255) Cyan
28 new Color(0.50f, 1.00f, 0.83f), // (127,255,212) Aquamarine
29 new Color(0.00f, 0.50f, 0.50f), // (000,127,127) Teal
30 new Color(0.13f, 0.55f, 0.13f), // (034,139,034) Forest Green
31 new Color(0.50f, 0.50f, 0.00f), // (127,127,000) Olive
32 new Color(0.50f, 1.00f, 0.00f), // (127,255,000) Chartreuse
33 new Color(0.75f, 1.00f, 0.00f), // (192,255,000) Lime
34 new Color(1.00f, 0.84f, 0.00f), // (255,215,000) Golden
35 new Color(0.85f, 0.65f, 0.13f), // (218,165,032) Goldenrod
36 new Color(1.00f, 0.50f, 0.31f), // (255,127,080) Coral
37 new Color(0.98f, 0.50f, 0.45f), // (250,128,114) Salmon
38 new Color(0.99f, 0.06f, 0.75f), // (252,015,192) Hot Pink
39 new Color(1.00f, 0.47f, 1.00f), // (255,119,255) Fuchsia
40 new Color(0.80f, 0.53f, 0.60f), // (204,136,153) Puce
41 new Color(0.88f, 0.69f, 1.00f), // (224,176,225) Mauve
42 new Color(0.71f, 0.49f, 0.86f), // (181,126,220) Lavender
43 new Color(0.52f, 0.19f, 0.47f), // (132,049,121) Plum
44 new Color(0.29f, 0.00f, 0.51f), // (075,000,130) Indigo
45 new Color(0.50f, 0.00f, 0.00f), // (127,000,000) Maroon
46 new Color(0.86f, 0.08f, 0.24f) // (220,020,060) Crimson
47 };
48
49 private void Reset()
50 {
51 if (maxRadius < minRadius)
52 return;
53
54 for (int i = 0; i < numberOfBlocks; ++i)
55 {
56 float radius = Random.Range(minRadius, maxRadius);
57 float theta = Random.Range(0.0f, 2 * Mathf.PI);
58
59 Vector3 position = new Vector3(
60 radius * Mathf.Sin(theta),
61 size * 3.0f,
62 radius * Mathf.Cos(theta)
63 );
64
65 GameObject cube = GameObject.Instantiate(CubePrimitive) as GameObject;
66 cube.transform.parent = transform;
67 cube.transform.rotation = Quaternion.Euler(Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f));
68 cube.transform.localScale = Vector3.one * Random.Range(0.1f, size);
69 cube.transform.localPosition = position;
70 cube.SetActive(true);
71 cube.AddComponent<Rigidbody>();
72
73 cube.GetComponent<Renderer>().material.color = list_of_colors[Random.Range(0, list_of_colors.Length - 1)];
74 }
75 }
76
77 // Use this for initialization
78 void Start()
79 {
80 Reset();
81 }
82
83 // Update is called once per frame
84 void Update()
85 {
86 }
87 }