diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Orchestland/Assets/Scripts/NatureSpawner.cs	Fri Jul 17 23:09:20 2015 +0900
@@ -0,0 +1,34 @@
+using UnityEngine;
+using System.Collections;
+
+public class NatureSpawner : MonoBehaviour {
+	public Camera main_camera;
+	public GameObject[] nature_prefab;
+	public float distance = 15f;
+	public Vector2 random_spawn = new Vector2(10,10);
+	public TerrainDeformation terrain;
+
+	// Use this for initialization
+	void Start () {
+	}
+	
+	// Update is called once per frame
+	void Update () {
+	
+	}
+
+
+	public void OnShake(){
+		int rand = Random.Range (0, nature_prefab.Length);
+		GameObject obj = (GameObject)Instantiate (nature_prefab [rand]);
+		Vector3 pos = main_camera.transform.position + main_camera.transform.forward * distance;
+		pos.x += Random.Range (-random_spawn.x, random_spawn.x);
+		pos.y = 0;
+		pos.z += Random.Range (-random_spawn.y, random_spawn.y);
+		obj.transform.position = pos;
+		Vector3 angles = obj.transform.eulerAngles;
+
+		Vector3 map_pos = terrain.WorldToMap (transform.position);
+		terrain.HeapMap (Random.value, Random.Range (0.45f, 0.8f), 0.5f);
+	}
+}