Large diffs are not rendered by default.

@@ -14,10 +14,12 @@ public class UFOHandler : MonoBehaviour {
public GameObject hitTarget;
public GameObject abductRays;
public GameObject bullet;
public GameObject fireLocation;
public float distanceThreshold;

private GameObject instantiatedTarget;
private hitTarget targetScript;
RaycastHit rayHit;

bool unlockedA = false;
bool canFireA = true;
@@ -30,6 +32,8 @@ public class UFOHandler : MonoBehaviour {

bool canFireRight = true;

public Vector3 PrintingIsDumb;

//Abduct Rays values
private bool keepAbductAlive = false;
void Start () {
@@ -93,10 +97,9 @@ public class UFOHandler : MonoBehaviour {

//Cast Target Object
Ray rayfire = new Ray(OVRCamera.transform.position, OVRCamera.transform.forward);
RaycastHit rayHit;
//10000000011 in base 10
int mask = 1027;
if (Physics.Raycast(rayfire, out rayHit, 15, mask, QueryTriggerInteraction.Ignore)) {
if (Physics.Raycast(rayfire, out rayHit, 100, mask, QueryTriggerInteraction.Ignore)) {
if (rayHit.collider.gameObject.layer == 8) {
Debug.Log("Hit UFO");
}
@@ -222,6 +225,15 @@ public class UFOHandler : MonoBehaviour {
ammoCount = HUDInfo.setAmmo(XboxAxis.RightTrigger, ammoCount - 1);
Debug.Log("setAmmo(): " + ammoCount);
//Do fire
GameObject instantiated = (GameObject)Instantiate(bullet, fireLocation.transform.position, Quaternion.identity);
Rigidbody instantiatedRigid = instantiated.GetComponent<Rigidbody>();
//THANKS TO WEI
instantiatedRigid.AddForce((rayHit.point- instantiated.transform.position).normalized * (float)instantiated.GetComponent<bullet>().getFireForce());

//instantiatedRigid.AddForceAtPosition(rayHit.point * instantiated.GetComponent<bullet>().getFireForce(), transform.forward);
// PrintingIsDumb =

//wait Fire
StartCoroutine(waitRight());

if (HUDInfo.getAmmo(XboxAxis.RightTrigger) == 0) {
@@ -0,0 +1,34 @@
using UnityEngine;
using System.Collections;

public class lazerBullet : MonoBehaviour, bullet {

public int bulletType;
public float fireForce;
public float timeSpan;
// Use this for initialization
void Start () {
StartCoroutine(destroyAfterTime());
}

// Update is called once per frame
void Update () {

}

public int getType() {
return bulletType;
}
public float getFireForce() {
return fireForce;
}

public void OnCollided(Collision coll) {
Destroy(gameObject);
}

IEnumerator destroyAfterTime() {
yield return new WaitForSeconds(timeSpan);
Destroy(gameObject);
}
}
@@ -0,0 +1,35 @@
using UnityEngine;
using System.Collections;

public class buildDestruct : MonoBehaviour {

// Use this for initialization
public float radius = 0;
public float force = 0;
void Start () {

}

// Update is called once per frame
void Update () {

}
public void hugeExplosion() {
Debug.Log("huge ass explosion");
Rigidbody rigid = GetComponent<Rigidbody>();
Renderer render = GetComponent<Renderer>();
//rigid.AddExplosionForce(force, render.bounds.center, radius);
}

/*void OnCollisionEnter(Collision col) {
if (col.gameObject.layer == 11) {
bullet bulletScript = col.gameObject.GetComponent<bullet>();
if (bulletScript != null) {
bulletScript.OnCollided(col);
Rigidbody rigid = GetComponent<Rigidbody>();
Debug.Log("Exploding");
rigid.AddExplosionForce(2, col.transform.position, 5);
}
}
}*/
}
@@ -13,55 +13,77 @@ public class building : MonoBehaviour {
int weapon2HitCount = 0;
int weapon3HitCount = 0;
int weapon4HitCount = 0;
public Vector3 scale;
public bool debug = false;
// Use this for initialization
void Start () {
citizenCount = Random.Range(0, 200);
if (scale.x == 0) {
scale = new Vector3(1, 1, 1);
}
StartCoroutine(generateColliders());
}

IEnumerator generateColliders() {
Vector3 rotation = gameObject.transform.rotation.eulerAngles;
rotation.x = 0;
destructMesh = (GameObject)Instantiate(DM_prefab, gameObject.transform.position, QuanternionHelper.Euler(rotation.x, rotation.y, rotation.z));
//destructMesh.transform.SetParent(gameObject.transform);
destructMesh.transform.localScale = scale;
destructMesh.transform.position = gameObject.transform.position;
//destructMesh.AddComponent<buildDestruct>();

int childCount = destructMesh.transform.childCount;
for (int i = 0; i < childCount; i++) {
Transform childT = destructMesh.transform.GetChild(i);
MeshCollider collider = childT.gameObject.AddComponent<MeshCollider>();
//Rigidbody rigid = childT.gameObject.AddComponent<Rigidbody>();
Rigidbody rigid = childT.gameObject.AddComponent<Rigidbody>();
//GameObject buildDestructObject = GameObject.Find("buildDestructGet");
//buildDestruct buildDestuctScript = buildDestructObject.GetComponent<buildDestruct>();
collider.convex = true;
//rigid.drag = 1;
//collider.enabled = false;
//rigid.Sleep();
rigid.drag = 1;
rigid.isKinematic = true; //set to false, when actually do simulations
//childT.gameObject.SetActive(false);

yield return null;
}
destructMesh.SetActive(false);
for (int i = 0; i < childCount; i++) {
Transform childT = destructMesh.transform.GetChild(i);
Rigidbody rigid = childT.GetComponent<Rigidbody>();
rigid.isKinematic = false;
}
}

void OnCollisionEnter(Collision col) {
Debug.Log("Colliding!");
//Debug.Log("Colliding!");
if (col.rigidbody.gameObject.name == gameObject.name) {
//colliding with ourselves, ignore
Debug.Log("Colliding with ourselves");
}
else {
//Colliding on impactable
if (col.gameObject.layer == 11) {
Debug.Log(gameObject.name + " collided with " + col.gameObject.name);
//Debug.Log(gameObject.name + " collided with " + col.gameObject.name);
bullet bulletScript = col.gameObject.GetComponent<bullet>();
int bType = bulletScript.getType();
switch (bType) {
int weaponType = -2;
if (bulletScript != null) {
weaponType = bulletScript.getType();
}
switch (weaponType) {
case -1:
//Left Trigger
//do abducting shit
break;
case 0:
//Right Trigger
rightBulletHitCount++;
if (bulletScript != null) bulletScript.OnCollided(col);
if (rightBulletHitCount >= 5) {
//do destruction
Debug.Log("Destroying the building");
destructMesh.SetActive(true);
GameObject.Destroy(gameObject);
//buildDestruct destruct = destructMesh.GetComponent<buildDestruct>();
//destruct.hugeExplosion();
}
break;
case 1:
@@ -72,7 +94,11 @@ public class building : MonoBehaviour {
break;
case 4:
break;
default:
Debug.Log("building collision: unsupported weaponType. Type: " + weaponType);
break;
}
bulletScript.OnCollided(col);
}
Debug.Log("Colliding with " + col.collider.gameObject.name);
}
@@ -1,16 +1,16 @@
using UnityEngine;
using System.Collections;

public class bullet : MonoBehaviour {
public interface bullet {

//-1 - abduct, 0 - lazerFire, 1 - special1, 2 - special2, 3 - special3, 4- special4
int bulletType = 0;
int getType();

public void updateDetails(int type) {
bulletType = type;
}
//How much force we should fire the bullet with
float getFireForce();

public int getType() {
return bulletType;
}
//
// Kinematic bullets will not recieve collision updates, so we have to transfer collison
//
void OnCollided(Collision coll);
}
@@ -1,2 +1,2 @@
m_EditorVersion: 5.3.4f1
m_EditorVersion: 5.3.1f1
m_StandardAssetsVersion: 0