Mercurial > hg > Game > Games
comparison Orchestland/Assets/Scripts/NatureSpawner.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 | |
4 public class NatureSpawner : MonoBehaviour { | |
5 public Camera main_camera; | |
6 public GameObject[] nature_prefab; | |
7 public float distance = 15f; | |
8 public Vector2 random_spawn = new Vector2(10,10); | |
9 public TerrainDeformation terrain; | |
10 | |
11 // Use this for initialization | |
12 void Start () { | |
13 } | |
14 | |
15 // Update is called once per frame | |
16 void Update () { | |
17 | |
18 } | |
19 | |
20 | |
21 public void OnShake(){ | |
22 int rand = Random.Range (0, nature_prefab.Length); | |
23 GameObject obj = (GameObject)Instantiate (nature_prefab [rand]); | |
24 Vector3 pos = main_camera.transform.position + main_camera.transform.forward * distance; | |
25 pos.x += Random.Range (-random_spawn.x, random_spawn.x); | |
26 pos.y = 0; | |
27 pos.z += Random.Range (-random_spawn.y, random_spawn.y); | |
28 obj.transform.position = pos; | |
29 Vector3 angles = obj.transform.eulerAngles; | |
30 | |
31 Vector3 map_pos = terrain.WorldToMap (transform.position); | |
32 terrain.HeapMap (Random.value, Random.Range (0.45f, 0.8f), 0.5f); | |
33 } | |
34 } |