Skip to content

Commit

Permalink
enemy rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
itsDario committed Oct 30, 2014
1 parent 9458bfe commit 1ae81e1
Show file tree
Hide file tree
Showing 36 changed files with 180 additions and 7 deletions.
2 changes: 1 addition & 1 deletion BulletHell/Assets/Scripts/SpawnWaves.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function SpawnWaves () {
{
var spawnPosition : Vector3 = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
//var spawnRotation : Quaternion= Quaternion.identity;
var spawnRotation : Quaternion = Quaternion.AngleAxis(-90, Vector3.forward);
var spawnRotation : Quaternion = Quaternion.AngleAxis(-90, Vector3.forward);
Instantiate (redEnemy1, spawnPosition, spawnRotation);
yield WaitForSeconds (spawnWait);
}
Expand Down
51 changes: 51 additions & 0 deletions BulletHell/Assets/Scripts/baseEnemy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma strict

private var health: int;
private var moveSpeed: float;
private var blinkSpeed: float;
private var color: Vector4;
var enemyExplosion: GameObject;

function move(){
transform.position.y -= moveSpeed * Time.deltaTime;
if(transform.position.y <= -5){
Destroy(gameObject);
}
}

function blink(){
renderer.GetComponent(SpriteRenderer).color = Color.white;
yield WaitForSeconds(blinkSpeed);
renderer.GetComponent(SpriteRenderer).color = color;
}

function setHealth(newHealth: int){
Debug.Log("health set");
health = newHealth;
}

function setColor(newColor:Vector4){
color = newColor;
renderer.GetComponent(SpriteRenderer).color = color;
}

function setMoveSpeed(newSpeed:float){
moveSpeed = newSpeed;
}

function setBlinkSpeed(newBlinkSpeed:float){
blinkSpeed = newBlinkSpeed;
}

function OnTriggerEnter2D (other: Collider2D){
if(other.gameObject.tag == "Shot"){
//Script_gameManager.score += 10;
blink();
health--;
if(health <= 0){
Instantiate(enemyExplosion, transform.position, transform.rotation);
Destroy(gameObject);
}
Destroy(other.gameObject);
}
}
9 changes: 9 additions & 0 deletions BulletHell/Assets/Scripts/baseEnemy.js.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ function Start () {
}

function Update () {
transform.Rotate (Vector3.forward * -90 * Time.deltaTime);
rigidbody2D.velocity.y = -speed;
//transform.Rotate (Vector3.forward * -90 * Time.deltaTime);
//rigidbody2D.velocity.y = -speed;
rigidbody2D.velocity = transform.right * speed;
Debug.Log(rigidbody2D.velocity);
if(gameObject.transform.position.y < -5){
Destroy(gameObject);
}
Expand Down
File renamed without changes.
7 changes: 6 additions & 1 deletion BulletHell/Assets/Scripts/redEnemy1.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ function Update () {

function shoot(){ // Shooting
if(Mathf.FloorToInt(Random.value * 10000.0) % 200 == 0){
Instantiate(
/* Instantiate(
shot,
this.transform.position + Vector2(0,-0.5),
Quaternion.identity
); */
Instantiate(
shot,
this.transform.position + Vector2(0,-0.5),
Quaternion.Euler(0.0,0.0,0.0)
);
}
/*
Expand Down
26 changes: 26 additions & 0 deletions BulletHell/Assets/Scripts/triangleEnemy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma strict

var shot: GameObject;
var FireRate : float = 10;
var spawnRotation : Quaternion = Quaternion.AngleAxis(-90, Vector3.forward);

public class triangleEnemy extends baseEnemy
{
function Start(){
setHealth(2);
setColor(Color.red);
setMoveSpeed(4);
setBlinkSpeed(0.1);
}

function Update(){
shoot();
move();
}

function shoot(){ // Shooting
if(Mathf.FloorToInt(Random.value * 10000.0) % 200 == 0){
Instantiate(shot,this.transform.position, spawnRotation);
}
}
}
8 changes: 8 additions & 0 deletions BulletHell/Assets/Scripts/triangleEnemy.js.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed BulletHell/Assets/Texture/Bullet.png
Binary file not shown.
Binary file added BulletHell/Assets/Texture/circleEnemy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added BulletHell/Assets/Texture/circleammo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions BulletHell/Assets/Texture/circleammo.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified BulletHell/Assets/_Scenes/scene1.unity
Binary file not shown.
Binary file modified BulletHell/Assets/prefabs/Bullet.prefab
Binary file not shown.
Binary file not shown.
Binary file modified BulletHell/Assets/prefabs/redEnemy1.prefab
Binary file not shown.
Binary file modified BulletHell/ProjectSettings/QualitySettings.asset
Binary file not shown.
13 changes: 13 additions & 0 deletions touchControls/Assets/TouchTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma strict

function Start () {

}

function Update () {
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
Debug.Log(touch.position);
}
}
}
8 changes: 8 additions & 0 deletions touchControls/Assets/TouchTest.js.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added touchControls/Assets/scene1.unity
Binary file not shown.
4 changes: 4 additions & 0 deletions touchControls/Assets/scene1.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added touchControls/ProjectSettings/AudioManager.asset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added touchControls/ProjectSettings/InputManager.asset
Binary file not shown.
Binary file added touchControls/ProjectSettings/NavMeshLayers.asset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added touchControls/ProjectSettings/TagManager.asset
Binary file not shown.
Binary file added touchControls/ProjectSettings/TimeManager.asset
Binary file not shown.

0 comments on commit 1ae81e1

Please sign in to comment.