// Use this for initialization void Start() { BlastZones = new List <BlastZone>(); Enemies = new List <BlastEnemy>(); controller = GetComponent <BlastController>(); spawnPoint = GameObject.Find("SpawnPoint").GetComponent <Transform>(); blastZoneParent = GameObject.Find("BlastZones").GetComponent <Transform>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <BlastPlayer>(); }
private void Explode() { if (destructionBlastPrefab != null) { BlastController blastController = Instantiate(destructionBlastPrefab, transform.position, destructionBlastPrefab.transform.rotation); Destroy(gameObject); } else if (animator != null) { animator.SetTrigger("Explode"); } else { Destroy(gameObject); Debug.LogWarning(gameObject.name + " has no explosion effect!"); } }
// Update is called once per frame void Update() { timer += Time.deltaTime; if (setDestruct) { destroyTimer -= Time.deltaTime; if (destroyTimer < 0) { Destroy(this.gameObject); } } else if (timer > fireInterval) { shotAngle = (shotAngle + 10) % 360; Vector3 shotVector = new Vector3(Mathf.Cos((float)shotAngle * Mathf.PI / 180), 0, Mathf.Sin((float)shotAngle * Mathf.PI / 180)); BlastController blast = Instantiate(shot, transform.position + shotVector, Quaternion.identity).GetComponent <BlastController> () as BlastController; blast.setDir(shotVector); timer = 0f; } }