// Spawn all objects for specified Hazard void SpawnHazard(Hazard hazard) { for (int objectIndex = 0; objectIndex < hazard.hazardObjects.Count; ++objectIndex) { Vector3 spawnPosition = new Vector3(); Vector3 spawnRotation = new Vector3(); HazardObject tempHazardObject = (HazardObject)hazard.hazardObjects[objectIndex]; // Gets origin side and adjusts spawn rotation switch (tempHazardObject.spawnSide) { case "top": spawnRotation = new Vector3(0, 0, 180); spawnPosition = new Vector3(tempHazardObject.spawnPosition, 6, 0); break; case "right": spawnRotation = new Vector3(0, 0, 90); spawnPosition = new Vector3(6, tempHazardObject.spawnPosition, 0); break; case "bottom": spawnRotation = new Vector3(0, 0, 0); spawnPosition = new Vector3(tempHazardObject.spawnPosition, -6, 0); break; case "left": spawnRotation = new Vector3(0, 0, 270); spawnPosition = new Vector3(-6, tempHazardObject.spawnPosition, 0); break; default: Debug.Log("Wrong side : " + tempHazardObject.spawnSide); break; } Quaternion spawnQuaternion = Quaternion.Euler(spawnRotation); // Instantiate object at right position and rotation GameObject instance = Instantiate(Resources.Load(tempHazardObject.objectName, typeof(GameObject)), spawnPosition, spawnQuaternion) as GameObject; if (tempHazardObject.color != null) { Color newColor; ColorUtility.TryParseHtmlString("#" + tempHazardObject.color, out newColor); instance.GetComponent <MeshRenderer>().material.SetColor("_Color", newColor); } if (tempHazardObject.speed > 0) { instance.GetComponent <SimpleMove>().speed = tempHazardObject.speed; } if ((tempHazardObject.rotation > 0) && (instance.GetComponent <SimpleRotator>() != null)) { instance.GetComponent <SimpleRotator>().speed.z = tempHazardObject.rotation; } } }
public void SetButton(HazardObject ho) { m_button = ho; }
public void AddToScore(HazardObject hazard) { m_scoreValue += hazard.m_scoreValue; }
void Awake() { m_hazardObject = gameObject.GetComponent <HazardObject>(); }