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 Powerups (MonoBehaviour):
- // Setting Minimum and Maximum speeds as Floats
- public MinSpeed as single = 0.0F
- public MaxSpeed as single = 0.0F
- private curSpeed as single = 0.0F
- private x as single = 0.0F
- private y as single = 0.0F
- private z as single = 0.0F
- // Variation in the meteors.
- private minRotateSpeed as single = 60f
- private maxRotateSpeed as single = 120f
- private currentRotateSpeed as single = 0.0f
- // Set up explosionPrefab as GameObject. SET IN EDITOR
- public explosionPrefab as GameObject
- def Start ():
- // Setting Start Positions
- y = 4.8F
- z = 0.0F
- // Redirect to "def ranSpotSpeed():"
- ranSpotSpeed()
- def Update ():
- if Enemy.curMeteorFallen >= 12:
- // Setting up the "animation." deltaTime sets the speed to real-world 1s.
- rotationSpeed as single = currentRotateSpeed * Time.deltaTime
- amtToMove = curSpeed * Time.deltaTime
- // Move DOWN the screen.
- transform.Translate(Vector3.down * amtToMove, Space.World)
- // Rotate on the X axis.
- transform.Rotate(Vector3(-1, 0, 0) * rotationSpeed)
- // In case the meteor goes off the bottom of the screen.
- if transform.position.y <= -7.5:
- // Call ranSpotSpeed()
- ranSpotSpeed()
- Enemy.curMeteorFallen = 0
- def ranSpotSpeed():
- // Causing the variables to change the asteroids size/rotate speed.
- currentRotateSpeed = Random.Range(minRotateSpeed, maxRotateSpeed)
- // Setting the x to be random from -5.5, and 5.5 on the screen.
- x = Random.Range(-5.5F, 5.5F)
- // Setting up the vector
- newPos = Vector3(x,y,z)
- // Setting the Enemy to start at newPos, our vector
- transform.position = newPos
- // Setting speed to be random between MinSpeed and MaxSpeed as set in the Editor
- curSpeed = Random.Range(MinSpeed, MaxSpeed)
- // If something enters the collider, (must be PRIMITIVE collider, not MESH collider).
- def OnTriggerEnter(thisObject as Collider):
- // Call ranSpotSpeed to "rebuild" (although it is never actually destroyed) at the top.
- ranSpotSpeed()
- Enemy.curMeteorFallen = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement