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/Legosteroid.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (43 sloc)
2.52 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 Legosteroid : MonoBehaviour { | |
public GameObject legosteroid; | |
public GameObject piece1; | |
public GameObject piece2; | |
public GameObject piece3; | |
public GameObject piece4; | |
public GameObject brick1; | |
public GameObject brick2; | |
public GameObject brick3; | |
public GameObject brick4; | |
void Awake() | |
{ | |
} | |
void OnCollisionEnter(Collision collision) | |
{ | |
if (collision.gameObject.tag == "Bullet") | |
{ | |
brick1 = (GameObject)Instantiate(piece1, new Vector3(gameObject.transform.position.x + 1, gameObject.transform.position.y - 2, 5), Quaternion.identity); | |
brick2 = (GameObject)Instantiate(piece2, new Vector3(gameObject.transform.position.x - 2, gameObject.transform.position.y + 1, 5), Quaternion.identity); | |
brick3 = (GameObject)Instantiate(piece3, new Vector3(gameObject.transform.position.x - 1.4f, gameObject.transform.position.y + 2, 5), Quaternion.identity); | |
brick4 = (GameObject)Instantiate(piece4, new Vector3(gameObject.transform.position.x + 3, gameObject.transform.position.y + 1, 5), Quaternion.identity); | |
iTween.MoveTo(brick1, new Vector3(brick1.transform.position.x + 20, brick1.transform.position.y - 17, 5), 15); | |
iTween.MoveTo(brick2, new Vector3(brick1.transform.position.x - 22, brick1.transform.position.y + 35, 5), 16); | |
iTween.MoveTo(brick3, new Vector3(brick1.transform.position.x - 35, brick1.transform.position.y - 22, 5), 17); | |
iTween.MoveTo(brick4, new Vector3(brick1.transform.position.x + 40, brick1.transform.position.y + 20, 5), 16); | |
Destroy(gameObject); | |
} | |
//if (brick1.transform.position.z != 5) | |
// brick1.transform.position = new Vector3(brick1.transform.position.x, brick1.transform.position.y, 5); | |
//if (brick2.transform.position.z != 5) | |
// brick2.transform.position = new Vector3(brick2.transform.position.x, brick2.transform.position.y, 5); | |
//if (brick3.transform.position.z != 5) | |
// brick3.transform.position = new Vector3(brick3.transform.position.x, brick3.transform.position.y, 5); | |
//if (brick4.transform.position.z != 5) | |
// brick4.transform.position = new Vector3(brick4.transform.position.x, brick4.transform.position.y, 5); | |
} | |
void Update() | |
{ | |
// gameObject.transform.eulerAngles = new Vector3(gameObject.transform.eulerAngles.x + 5, gameObject.transform.eulerAngles.y, gameObject.transform.eulerAngles.z); | |
} | |
} |