Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This script is licensed under the BSD license.
- Author: Cody Dostal
- Author Email: allysman21@gmail.com
- Date Written: 4/22/2012
- Date Last Edited: 4/24/2012
- Engine Version: 3.5.1f2
- Script Version: v1.1
- */
- /* NOTE: With good chance, you may have to change any hard-coded values in these scripts.
- These values work with my version, and may not with your version. */
- import UnityEngine
- class projectile (MonoBehaviour):
- public projSpeed as single = 0.0F
- public explosionPrefab as GameObject
- def Update ():
- // Set the speed (projSpeed... set in editor) and use deltaTime to make it in 1 sec.
- amtToMove = projSpeed * Time.deltaTime
- // Cause bullet to go UP screen.
- transform.Translate(Vector3.up * amtToMove)
- // Destroy the projectile if it goes off screen.
- if transform.position.y >= 3.65:
- Destroy(gameObject)
- def OnTriggerEnter(otherObject as Collider):
- // So the bullet does NOT collide with the player. Tag on player gameObject MUST BE SET to Player.
- if otherObject.tag != "Player":
- if otherObject.tag == "Enemy":
- // Set Explosion position, and Instantiate(create) it
- exploPos = Vector3(transform.position.x, transform.position.y, transform.position.z)
- Instantiate(explosionPrefab, exploPos, Quaternion.identity)
- // Destroy the projectile if it hits the enemy.
- Destroy(gameObject)
- // Increase the player score for each Enemy hit.
- if player.score < 5000:
- player.score += 100
- if otherObject.tag == "health":
- exploPos = Vector3(transform.position.x, transform.position.y, transform.position.z)
- Instantiate(explosionPrefab, exploPos, Quaternion.identity)
- player.lives++
- Destroy(gameObject)
- // If player.score is equal to 5000pts
- if player.score >= 5000:
- // Wait for 2 seconds to finish the last explosion animation.
- WaitForSeconds(2.0F)
- // Load the win screen.
- Application.LoadLevel(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement