Skip to content
Permalink
Browse files

enemyy 2 still doesn't die

  • Loading branch information
smz11006 committed Nov 10, 2015
1 parent 1d0e265 commit 399042d8ea5d7e19fde29d10c270716d534ff5c6
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,6 @@ public class BackgroundScroll : MonoBehaviour {

void Start ()
{
iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("BackgroundTrack"), "time", 30, "transition", "easeinSine"));
iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("BackgroundTrack"), "time", 60));
}
}
@@ -31,7 +31,7 @@ void Update()
testInt = Mathf.RoundToInt(test);
//shooting---------------------------------------------------------------------------------
posCanon = new Vector3(turret.transform.position.x, turret.transform.position.y - 0.5f, turret.transform.position.z);
if (testInt % 2 == 0)
if (testInt % 4 == 0)
{
newBullet = (GameObject)Instantiate(bullet, posCanon, transform.rotation);
iTween.MoveTo(newBullet, new Vector3(newBullet.transform.position.x, newBullet.transform.position.y - 40, 5), 1);
@@ -13,23 +13,42 @@ public class Enemy2 : MonoBehaviour {
public GameObject turret;
public GameObject bullet;
public Vector3 posCanon;


public float test;
public int testInt;
public GameObject newBullet;

public Vector3 playerPos;
public GameObject player;

void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Bullet")
{
Destroy(gameObject);

health = health - 1;
}
}

void Update()
{


playerPos = new Vector3(player.transform.position.x, player.transform.position.y - 30, player.transform.position.z);

//Shooting ===================================================
posCanon = new Vector3(turret.transform.position.x, turret.transform.position.y - 0.5f, turret.transform.position.z);
posCanon = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y - 0.5f, gameObject.transform.position.z);
test = gameObject.transform.position.y;
testInt = Mathf.RoundToInt(test);
//shooting---------------------------------------------------------------------------------
if (testInt % 4 == 0)
{
newBullet = (GameObject)Instantiate(bullet, posCanon, transform.rotation);
iTween.MoveTo(newBullet, playerPos, 1);

}

//Health-----------------------------------------------------------------------------------
//Health-----------------------------------------------------------------------------------
if (health == 0)
Destroy(gameObject);
if (health == 1)
@@ -56,15 +56,15 @@ public void Onslaught()
public void EdgeSpawn()
{
enemy1_left1 = (GameObject)Instantiate(enemy1, spawn1, Quaternion.Euler(enemyAngle));
enemy1_right1 = (GameObject)Instantiate(enemy1, spawn1, Quaternion.Euler(enemyAngle));
enemy1_right1 = (GameObject)Instantiate(enemy1, spawn12, Quaternion.Euler(enemyAngle));
iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("LeftCurve1"), "time", 10));
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("RightCurve1"), "time", 10));

}
public void EdgeSpawnIn()
{
enemy1_left2 = (GameObject)Instantiate(enemy1, spawn2, Quaternion.Euler(enemyAngle));
enemy1_right2 = (GameObject)Instantiate(enemy1, spawn2, Quaternion.Euler(enemyAngle));
enemy1_right2 = (GameObject)Instantiate(enemy1, spawn11, Quaternion.Euler(enemyAngle));

iTween.MoveTo(enemy1_left2, iTween.Hash("path", iTweenPath.GetPath("LeftCurve2"), "time", 10));
iTween.MoveTo(enemy1_right2, iTween.Hash("path", iTweenPath.GetPath("RightCurve2"), "time", 10));
@@ -74,13 +74,30 @@ public void EdgeSpawnIn()
public void EdgeSpawnLast()
{
enemy1_left3 = (GameObject)Instantiate(enemy1, spawn3, Quaternion.Euler(enemyAngle));
enemy1_right3 = (GameObject)Instantiate(enemy1, spawn3, Quaternion.Euler(enemyAngle));
enemy1_right3 = (GameObject)Instantiate(enemy1, spawn10, Quaternion.Euler(enemyAngle));

iTween.MoveTo(enemy1_left3, iTween.Hash("path", iTweenPath.GetPath("LeftCurve3"), "time", 10));
iTween.MoveTo(enemy1_right3, iTween.Hash("path", iTweenPath.GetPath("RightCurve3"), "time", 10));

}

public void MidSpawnEdges()
{
enemy1_left1 = (GameObject)Instantiate(enemy2, spawn4, Quaternion.Euler(enemyAngle));
enemy1_right1 = (GameObject)Instantiate(enemy2, spawn9, Quaternion.Euler(enemyAngle));

iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Left 1"), "time", 10));
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Right 1"), "time", 10));
}
public void MidSpawnMids()
{
enemy1_left1 = (GameObject)Instantiate(enemy2, spawn5, Quaternion.Euler(enemyAngle));
enemy1_right1 = (GameObject)Instantiate(enemy2, spawn8, Quaternion.Euler(enemyAngle));

iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Left 2"), "time", 10));
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Right 2"), "time", 10));
}

//IEnumerator
IEnumerator EnemySpawn()
{
@@ -91,7 +108,7 @@ IEnumerator EnemySpawn()
Debug.Log("Enumerator Starts");
enemy1count = 1;
enemy1_left1 = (GameObject)Instantiate(enemy1, spawn1, Quaternion.Euler(enemyAngle));
enemy1_right1 = (GameObject)Instantiate(enemy1, spawn1, Quaternion.Euler(enemyAngle));
enemy1_right1 = (GameObject)Instantiate(enemy1, spawn12, Quaternion.Euler(enemyAngle));

iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("LeftCurve1"), "time", 10));
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("RightCurve1"), "time", 10));
@@ -100,7 +117,7 @@ IEnumerator EnemySpawn()

yield return new WaitForSeconds(0.2f);
enemy1_left2 = (GameObject)Instantiate(enemy1, spawn2, Quaternion.Euler(enemyAngle));
enemy1_right2 = (GameObject)Instantiate(enemy1, spawn2, Quaternion.Euler(enemyAngle));
enemy1_right2 = (GameObject)Instantiate(enemy1, spawn11, Quaternion.Euler(enemyAngle));

iTween.MoveTo(enemy1_left2, iTween.Hash("path", iTweenPath.GetPath("LeftCurve2"), "time", 10));
iTween.MoveTo(enemy1_right2, iTween.Hash("path", iTweenPath.GetPath("RightCurve2"), "time", 10));
@@ -113,9 +130,22 @@ IEnumerator EnemySpawn()
iTween.MoveTo(enemy1_left3, iTween.Hash("path", iTweenPath.GetPath("LeftCurve3"), "time", 10));
iTween.MoveTo(enemy1_right3, iTween.Hash("path", iTweenPath.GetPath("RightCurve3"), "time", 10));
// EdgeSpawnLast();

yield return new WaitForSeconds(2f);
MidSpawnEdges();

yield return new WaitForSeconds(2f);
MidSpawnMids();
yield return new WaitForSeconds(2f);

EdgeSpawn();
MidSpawnEdges();
yield return new WaitForSeconds(2f);



Debug.Log("enumerator Ends");
//randomNum = Random.Range(1, 3);
//enemy1count = 0;

}

}
@@ -0,0 +1,11 @@
using UnityEngine;
using System.Collections;

public class Legosteroid : MonoBehaviour {

public gameObject legosteroid;
public gameObject piece1;
public gameObject piece2;
public gameObject piece3;
public gameObject piece4;
}

Some generated files are not rendered by default. Learn more.

@@ -26,6 +26,12 @@ public class PlayerHealth : MonoBehaviour {
public GameObject shieldbar9;
public GameObject shieldbar10;

//Player Position =====================
public Vector3 playerPos;
public Vector3 staticPos;

public float distance;
public int distanceInt;


public int playerHealth = 100;
@@ -62,21 +68,39 @@ void OnCollisionEnter(Collision collision)
}
}

if (playerHealth == 0)
{
}


//Start-----------------------------------------------------------
void Start()
{

staticPos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
}

// Update----------------------------------------------------------
void Update ()
{
//Death Condition ----------------------------
if (playerHealth <= 0)
{
Application.LoadLevel(2);
}
//Shield Regen
playerPos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
distance = Vector3.Distance(playerPos, staticPos);
distanceInt = Mathf.RoundToInt(distance);

if (playerShields < 100)
{
if (distanceInt % 10 == 0)
{
playerShields = playerShields + 10;
// staticPos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
staticPos = playerPos;
}
}

//Shield Switch ------------------------------
switch(playerShields)
switch (playerShields)
{
case 0:
shieldbar1.SetActive(false);
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN +260 Bytes (100%) ShipShooter/Library/assetDatabase3
Binary file not shown.
BIN +72 Bytes (100%) ShipShooter/Library/expandedItems
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -73,6 +73,7 @@
<Compile Include="Assets\Scripts\Enemy1.cs" />
<Compile Include="Assets\Scripts\Enemy2.cs" />
<Compile Include="Assets\Scripts\EnemySpawner.cs" />
<Compile Include="Assets\Scripts\Legosteroid.cs" />
<Compile Include="Assets\Scripts\PlayerControls.cs" />
<Compile Include="Assets\Scripts\PlayerHealth.cs" />
<Compile Include="Assets\iTweenEditor\Examples\StartAndStopTween.cs" />

0 comments on commit 399042d

Please sign in to comment.
You can’t perform that action at this time.