/// <summary> /// Only use this when copying existing gameobjects /// Use copyInitialization() for copies of /// existing gameobjects /// </summary> public virtual void copyInitialization() { for (int i = 0; i < canonMountCapacity; i++) { Weapons_Base wScript = canonMounted[i].GetComponent <Weapons_Base>(); Player_Charactor hScript = GameObject.Find("ARCamera").GetComponent <Player_Charactor>(); wScript.forceStart(); for (int j = 0; j < hScript.hangar.canonTypes.Count; j++) { if (hScript.hangar.canonTypes[j] == canonTypes[i]) { wScript.setUpStates(hScript.hangar.canonUpgrade1[j], hScript.hangar.canonUpgrade2[j], hScript.hangar.canonUpgrade3[j]); wScript.canShoot = true; } } } mountMagasinCapacity1 = canonMounted[0].GetComponent <Weapons_Base>().weaponCapacity() * 2; if (canonMountCapacity > 2) { mountMagasinCapacity2 = canonMounted[2].GetComponent <Weapons_Base>().weaponCapacity() * 2; } shipInGameHealth = shipHealth(); shipInGameShield = shipShield(); }
public override void initializeCanon(Transform scale, int i) { canonMounted[i] = (GameObject)Object.Instantiate(Resources.Load(canonTypes[i])); Transform thisTrans = canonMounted[i].transform; //canonMounted[i].transform.localScale = new Vector3(thisTrans.localScale.x * scale.localScale.x ,thisTrans.localScale.y * scale.localScale.y , thisTrans.localScale.z * scale.localScale.z); canonMounted[i].transform.position = canonMount[i].position; canonMounted[i].transform.rotation = canonMount[i].rotation; canonMounted[i].transform.parent = canonMount[i].transform; Weapons_Base wScript = canonMounted[i].GetComponent <Weapons_Base>(); Player_Charactor hScript = GameObject.Find("ARCamera").GetComponent <Player_Charactor>(); wScript.forceStart(); for (int j = 0; j < hScript.hangar.canonTypes.Count; j++) { if (hScript.hangar.canonTypes[j] == canonTypes[i]) { wScript.setUpStates(hScript.hangar.canonUpgrade1[j], hScript.hangar.canonUpgrade2[j], hScript.hangar.canonUpgrade3[j]); } } }
/* * private void pcControls(int shipCapacity){ * float sideSpeed; * * if(Input.GetKey("left")){ * sideSpeed = -1; * }else if(Input.GetKey("right")){ * sideSpeed = 1; * }else{ * sideSpeed = 0; * } * // moves the player * if(sideSpeed > 0){ * if(transform.position.x < 250.0f){ * moveShip (sideSpeed * maneuverSpeed); * if(transform.rotation.y > -0.3){ * transform.Rotate(new Vector3(0,0,1) * -maneuverSpeed * 2 * Time.deltaTime); * } * } * } * if(sideSpeed < 0){ * if(transform.position.x > -250.0f ){ * moveShip (sideSpeed * maneuverSpeed); * if(transform.rotation.z < 0.3){ * transform.Rotate(new Vector3(0,0,1) * maneuverSpeed * 2 * Time.deltaTime); * } * } * } * if(sideSpeed == 0){ * if (transform.rotation.z < -0.02f){ * transform.Rotate(new Vector3(0,0,1) * maneuverSpeed * 2 * Time.deltaTime); * }else if(transform.rotation.z > 0.02f){ * transform.Rotate(new Vector3(0,0,1) * -maneuverSpeed * 2 * Time.deltaTime); * } * } * * // fire weapons * if(Input.GetButton("Fire1")){ * for(int i = 0; i < shipCapacity; i++){ * Weapons_Base script = canonMounted[i].GetComponent<Weapons_Base>(); * mountMagasinCapacity -= script.fireWeapon(); * } * } * * * } */ private void androidControls(int shipCapacity) { if (dir < 0.01 && dir > -0.01) { dir = 0; } if (transform.position.x < 250.0f && dir > 0) { moveShip(shipManeuverSpeed() * dir); if (transform.rotation.z > -0.1) { transform.Rotate(new Vector3(0, 0, 1) * -dir * shipManeuverSpeed() * 2 * Time.deltaTime); } } else if (transform.position.x > -250.0f && dir < 0) { moveShip(shipManeuverSpeed() * dir); if (transform.rotation.z < 0.1) { transform.Rotate(new Vector3(0, 0, 1) * -dir * shipManeuverSpeed() * 2 * Time.deltaTime); } } else { if (transform.rotation.z < -0.02f) { transform.Rotate(new Vector3(0, 0, 1) * shipManeuverSpeed() * 2 * Time.deltaTime); } else if (transform.rotation.z > 0.02f) { transform.Rotate(new Vector3(0, 0, 1) * -shipManeuverSpeed() * 2 * Time.deltaTime); } } if (fire1 && mountMagasinCapacity1 > 0 && canonMountCapacity == 2) { Weapons_Base script = canonMounted[0].GetComponent <Weapons_Base>(); mountMagasinCapacity1 -= script.fireWeapon(); script = canonMounted[1].GetComponent <Weapons_Base>(); mountMagasinCapacity1 -= script.fireWeapon(); } if (canonMountCapacity / 2 == 2) { //fire two in the following if two buttons. if (fire1 && mountMagasinCapacity2 > 0) { Weapons_Base script = canonMounted[2].GetComponent <Weapons_Base>(); mountMagasinCapacity2 -= script.fireWeapon(); script = canonMounted[3].GetComponent <Weapons_Base>(); mountMagasinCapacity2 -= script.fireWeapon(); } if (fire1 && mountMagasinCapacity1 > 0) { Weapons_Base script = canonMounted[0].GetComponent <Weapons_Base>(); mountMagasinCapacity1 -= script.fireWeapon(); script = canonMounted[1].GetComponent <Weapons_Base>(); mountMagasinCapacity1 -= script.fireWeapon(); } } }