C# 클래스 Stochasteroid, GameProject

Stochasteroid is a script for creating randomized asteroid fields. Simply place this script on a cube GameObject named "StochasteroidPen," set the asteroid scale, rotation, velocity, count, select desired trajectories, and assign asteroid prefabs and the class will automatically fill the cube with randomly placed asteroids. Each asteroid requires a rigid body to realistically simulate motion. Each asteroid is generated randomly by selecting values within the given ranges. When an asteroid reaches the edge of the cube it is automatically respawned on a new trajectory.
상속: MonoBehaviour
파일 보기 프로젝트 열기: EECS390IndieTeam/GameProject

공개 프로퍼티들

프로퍼티 타입 설명
asteroidCount int
asteroidMaxRotation int
asteroidMaxScale int
asteroidMaxVelocity int
asteroidMinRotation int
asteroidMinScale int
asteroidMinVelocity int
asteroidTemplates List
negativeXTrajectory bool
negativeYTrajectory bool
negativeZTrajectory bool
positiveXTrajectory bool
positiveYTrajectory bool
positiveZTrajectory bool

공개 메소드들

메소드 설명
Start ( ) : void

Initialize script.

Update ( ) : void

Per frame update. Performs asteroid update.

비공개 메소드들

메소드 설명
CreateAsteroid ( ) : GameObject

Creates a new Asteroid object randomly from the avaiable templates.

IsAsteroidInCube ( GameObject asteroid ) : bool

Checks if asteroid is in cube.

PlaceAsteroid ( GameObject asteroid ) : void

Picks a random trajectory through the cube of those allowed by the script parameters and applies a random force and rotation on the asteroid in that direction.

RandomFacePoint ( ) : Vector3

Randomly selects a point from one of the six cube faces. If a selected face is one that is deactivated by the trajectory params for the script then selects again.

UpdateAsteroid ( GameObject asteroid ) : void

Performs asteroid frame update. We use physics to move asteroids so this function merely picks a new trajectory for the asteroid if we reach the edge of the cube.

메소드 상세

Start() 공개 메소드

Initialize script.
public Start ( ) : void
리턴 void

Update() 공개 메소드

Per frame update. Performs asteroid update.
public Update ( ) : void
리턴 void

프로퍼티 상세

asteroidCount 공개적으로 프로퍼티

The number of asteroids to spawn.
public int asteroidCount
리턴 int

asteroidMaxRotation 공개적으로 프로퍼티

The maximum rotation that a particular asteroid may exhibit. This is an upper bound and is unitless. The actual value will be selected at random.
public int asteroidMaxRotation
리턴 int

asteroidMaxScale 공개적으로 프로퍼티

The maximum scale factor of each asteroid. Actual value is randomly selected.
public int asteroidMaxScale
리턴 int

asteroidMaxVelocity 공개적으로 프로퍼티

The max velocity for an asteroid. This velocity is a multiplier and is unitless.
public int asteroidMaxVelocity
리턴 int

asteroidMinRotation 공개적으로 프로퍼티

The minimum amount of rotation for a particular asteroid. This is a lower bound and is unitless. The actual value will be selected at random.
public int asteroidMinRotation
리턴 int

asteroidMinScale 공개적으로 프로퍼티

The minimum scale factor of each asteroid. 1.0 is the model's initial size as imported by Unity. Actual value is randomly selected.
public int asteroidMinScale
리턴 int

asteroidMinVelocity 공개적으로 프로퍼티

The minimum velocity for an asteroid. This velocity is simply a multiplier and is unitless.
public int asteroidMinVelocity
리턴 int

asteroidTemplates 공개적으로 프로퍼티

A list of GameObjects that will act as randomly chosen templates for the asteroids.
public List asteroidTemplates
리턴 List

negativeXTrajectory 공개적으로 프로퍼티

Enables asteroids with trajectories beginning or ending on the negative X pane of the cube.
public bool negativeXTrajectory
리턴 bool

negativeYTrajectory 공개적으로 프로퍼티

Enables asteroids with trajectories beginning or ending on the negative Y pane of the cube.
public bool negativeYTrajectory
리턴 bool

negativeZTrajectory 공개적으로 프로퍼티

Enables asteroids with trajectories beginning or ending on the negative Z pane of the cube.
public bool negativeZTrajectory
리턴 bool

positiveXTrajectory 공개적으로 프로퍼티

Enables asteroids with trajectories beginning or ending on the positive X pane of the cube.
public bool positiveXTrajectory
리턴 bool

positiveYTrajectory 공개적으로 프로퍼티

Enables asteroids with trajectories beginning or ending on the positive Y pane of the cube.
public bool positiveYTrajectory
리턴 bool

positiveZTrajectory 공개적으로 프로퍼티

Enables asteroids with trajectories beginning or ending on the positive Z pane of the cube.
public bool positiveZTrajectory
리턴 bool