Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Intro_Scritping/ShipShooter/Assets/Scripts/Enemy1.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
47 lines (34 sloc)
1.22 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Enemy1 : MonoBehaviour { | |
public int health = 1; | |
public Vector3 enemyAngle = new Vector3(0, 90, 270); | |
public float test; | |
//shooting ----------------------- | |
public GameObject turret; | |
public GameObject bullet; | |
public Vector3 posCanon; | |
public GameObject newBullet; | |
void OnCollisionEnter(Collision collision) | |
{ | |
if (collision.gameObject.tag == "Bullet") | |
{ | |
Destroy(gameObject); | |
} | |
} | |
void Update() | |
{ | |
test = gameObject.transform.position.y; | |
//shooting--------------------------------------------------------------------------------- | |
posCanon = new Vector3(turret.transform.position.x, turret.transform.position.y - 0.5f, turret.transform.position.z); | |
if (test % 2 == 0) | |
{ | |
newBullet = (GameObject)Instantiate(bullet, posCanon, transform.rotation); | |
iTween.MoveTo(posCanon, new Vector3(posCanon.transform.position.x, posCanon.transform.position.y - 20, 5), 1); | |
} | |
if (health == 0) | |
Destroy(gameObject); | |
if (transform.eulerAngles != enemyAngle) | |
transform.eulerAngles = enemyAngle; | |
} | |
} |