// Start is called before the first frame update void Start() { itemIndexMAX = 5; itemIndex = 1; blueAudio = bluePlayer.GetComponent <BlueAudioManager>(); }
// Update is called once per frame void Update() { if (blueGun.isFiringLaser == true /*&& bluePlayer.canShoot == false*/ && fired == false) { transform.position = blueGun.orbPoint.position; // Lock to Blue while Chargine float actualLocalScaleMagnitude = transform.localScale.magnitude; if (actualLocalScaleMagnitude < maxlocalScaleMagnitude) { transform.localScale += new Vector3(0.005F, 0, 0.005F); } } if (blueGun.isFiringLaser == false) { fired = true; } if (fired == true) { //moveInput = new Vector3(Input.GetAxisRaw("RHorizontal"), 0f, -Input.GetAxisRaw("RVertical")); // CONTROL Orb //moveVelocity = moveInput * speed; // CONTROL BULLET if (bluePlayer.useController == true) { if (_direction == Vector3.zero) { _direction = (gameObject.transform.position - bluePlayer.transform.position).normalized; } } else { if (_direction == Vector3.zero) { _direction = (gameObject.transform.position - bluePlayer.transform.position).normalized; } } moveVelocity = _direction * speed; // Shoot Orb lifeTime -= Time.deltaTime; // Destroy over time } if (lifeTime <= 0) { fired = false; // Added later Destroy(gameObject); } // DESTROY IF BLUE ENTERS PARTICULAR STATES if (bluePlayer.GetComponent <Blue_Warp>().enabled & fired == false) { bluePlayer.canShoot = true; Destroy(gameObject); } // Arc FX //startPosition = transform.position; }
// Update is called once per frame void Update() { //====================================== KEYBOARD CONTROLLER // Fire and Rotate with Mouse if (!bluePlayerController.useController) { Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition); Plane groundPlane = new Plane(Vector3.up, Vector3.zero); float rayLength; if (groundPlane.Raycast(cameraRay, out rayLength)) { Vector3 pointToLook = cameraRay.GetPoint(rayLength); Debug.DrawLine(cameraRay.origin, pointToLook, Color.blue); transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z)); } if (bluePlayerController.canShoot == true) { // Fire Laser // - Primary 1 if (Input.GetMouseButtonDown(0)) { bluePlayerController.theGun.isFiringLaser = true; } if (Input.GetMouseButtonUp(0)) { bluePlayerController.theGun.isFiringLaser = false; } // Laser - Alt Fire if (bluePlayerController.GetComponent <Blue_Warp>().enabled == false) { if (Input.GetKeyDown("q")) { bluePlayerController.theGun.altFire = !bluePlayerController.theGun.altFire; } } // Barrier if (Input.GetMouseButtonDown(1) & (bluePlayerController.theGun.canDeploy == true)) { bluePlayerController.theGun.canHoldBarrier = true; } // Turret if (Input.GetMouseButtonDown(2) & (bluePlayerController.theGun.canDeploy == true)) { bluePlayerController.theGun.canHoldTurret = true; } } //====================================== // Animate Sprite if (Input.GetKey("w")) { otherAnimator.SetBool("isRunning", true); otherAnimator.SetFloat("Move_X", 0); otherAnimator.SetFloat("Move_Y", 1); } if (Input.GetKey("d")) { otherAnimator.SetBool("isRunning", true); otherAnimator.SetFloat("Move_X", 1); otherAnimator.SetFloat("Move_Y", 0); } if (Input.GetKey("s")) { otherAnimator.SetBool("isRunning", true); otherAnimator.SetFloat("Move_X", 0); otherAnimator.SetFloat("Move_Y", -1); } if (Input.GetKey("a")) { otherAnimator.SetBool("isRunning", true); otherAnimator.SetFloat("Move_X", -1); otherAnimator.SetFloat("Move_Y", 0); } if (!Input.GetKey("w") & !Input.GetKey("a") & !Input.GetKey("s") & !Input.GetKey("d")) { otherAnimator.SetBool("isRunning", false); } } //====================================== GAMEPAD CONTROLLER // Fire and Rotate with Controller if (bluePlayerController.useController) { // Movement // //Debug.Log("RH " + CrossPlatformInputManager.GetAxis("RHorizontal") + "RV " + CrossPlatformInputManager.GetAxis("RVertical")); Vector3 playerDirection = Vector3.right * Input.GetAxisRaw("RHorizontal") + Vector3.forward * -Input.GetAxisRaw("RVertical"); if (playerDirection.sqrMagnitude > 0.0f) { transform.rotation = Quaternion.LookRotation(playerDirection, Vector3.up); } //====================================== // Animate Sprite if ((Input.GetAxisRaw("Horizontal") != 0) || (Input.GetAxisRaw("Vertical") != 0)) { otherAnimator.SetBool("isRunning", true); otherAnimator.SetFloat("Move_X", Input.GetAxis("Horizontal")); otherAnimator.SetFloat("Move_Y", Input.GetAxis("Vertical")); } else { otherAnimator.SetBool("isRunning", false); } //====================================== // Inputs // // Right Trigger - Laser FIRING if (bluePlayerController.canShoot == true) { if (Input.GetKey(KeyCode.Joystick1Button7)) { bluePlayerController.theGun.isFiringLaser = true; } // Right Bumper - Barrier if ((Input.GetKeyDown(KeyCode.Joystick1Button5)) & (bluePlayerController.theGun.canDeploy == true)) { bluePlayerController.theGun.canHoldBarrier = true; //!bluePlayerController.theGun.canHoldBarrier;//true; } // Left Bumper - Turret if ((Input.GetKeyDown(KeyCode.Joystick1Button4)) & (bluePlayerController.theGun.canDeploy == true)) { bluePlayerController.theGun.canHoldTurret = true; //!bluePlayerController.theGun.canHoldBarrier;//true; } // Y Button - Alt Fire if (bluePlayerController.GetComponent <Blue_Warp>().enabled == false) { if (Input.GetKeyDown(KeyCode.Joystick1Button3)) { bluePlayerController.theGun.altFire = !bluePlayerController.theGun.altFire; } } } // Right Trigger - Laser NOT FIRING if (!Input.GetKey(KeyCode.Joystick1Button7)) { bluePlayerController.theGun.isFiringLaser = false; } //====================================== Formatted to Have Both GamePad and KeyBoard Controls Together - WILL NEED TO SEPARATE // X Button - Heal if ((bluePlayerController.canShoot == true) & (bluePlayerController.blueHeals >= 1)) { if ((Input.GetKeyDown(KeyCode.Keypad1)) || (Input.GetKeyDown(KeyCode.Joystick1Button2))) { bluePlayerController.blueHeals -= 1; blueHealthController.currentHealth += 25; } } } }
void Update() { // Blue Has Deployable Armed if (holding == true) { transform.position = blueGun.barrierDeployPoint.position; // Lock to Blue while Chargine var lookPos = bluePlayer.transform.position - transform.position; lookPos.y = 0; var rotation = Quaternion.LookRotation(lookPos); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, 1); } // Deploy if ((!Input.GetMouseButton(1) & !Input.GetKey(KeyCode.Joystick1Button5)) & holding == true) { holding = false; // Turn On Blue Can Shoot bluePlayer.canShoot = true; // Turn On Can Orb if (GameObject.Find("Blue_Orb(Clone)") == null) { blueGun.canOrb = true; } // Set Warp Points _position = warpPoint.transform.position; if (bluePlayer.deploy_1 == Vector3.zero) { bluePlayer.deploy_1 = _position; bluePlayer.deploy_1_ID = instance; } else { bluePlayer.deploy_2 = _position; bluePlayer.deploy_2_ID = instance; } // Reset Can Deploy Variable if (blueGun.barrierCounter < 2) { blueGun.canDeploy = true; // Reset Can Deply for Blue Gun } anim.SetTrigger("Active"); } // Warp Indicator On if ((bluePlayer.GetComponent <Blue_Warp>().enabled == true) & _selected == true) { warpSelectionOn = true; warpLight.enabled = true; } else { warpSelectionOn = false; warpLight.enabled = false; } // Change Color if (bluePlayer.GetComponent <Blue_Warp>().altWarp == true) { warpLight.color = Color.yellow; } else { warpLight.color = warpColor; } }
public void Update() { // Count Down for Sprite Interaction if (counterCanInteract > 0) { //counterCanInteract -= Time.deltaTime; } // Count Down for Double Tap Return Deploy if (returnDeployDoubleTapCounter > 0) { returnDeployDoubleTapCounter -= Time.deltaTime; } if (returnDeployDoubleTapCounter < 0) { returnDeployDoubleTapCounter = 0; buttonPresses = 0; } // In Upgrade State if (bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled == true & blueUpgrading == true & blueUpgradeLevel < blueUpgradeLevelMAX) { Debug.Log("UPGRADE_DEPLOYABLE_State"); if (Input.GetKeyDown(KeyCode.Joystick1Button0)) { if (blueUpgradeMeter > 1f) // Fail { Debug.Log("UPGRADE FAILED"); bluePlayer.GetComponent <BlueAudioManager>().AudioSource_04.Play(); bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled = false; bluePlayer.GetComponent <Blue_Idle>().enabled = true; blueUpgradeMeterCounter = 0; blueUpgradeMeter = 0; blueUpgrading = false; } if (blueUpgradeMeter <= 1f & blueUpgrading == true) // Success { Debug.Log("UPGRADE +"); blueUpgradeMeterCounter += 1; particleCountDown = .5f; particleEffect.Play(); // Particles particleLight.enabled = true; // Light if (blueUpgradeMeterCounter < 3) { bluePlayer.GetComponent <BlueAudioManager>().AudioSource_02.Play(); } blueUpgradeMeter = blueUpgradeMeterMAX; } } } // Upgrade Mini Game Meter // Double Tap "A" Counter if (touchingBlue == true) { // A Button - Take Back Deploy // Upgrade Deploy // NOT IN UPGRADE STATE if (blueUpgrading == false) { // Take Back Initiated if (Input.GetKeyDown(KeyCode.Joystick1Button0) || (Input.GetKeyDown("space")) & ((buttonPresses <= 1) & (bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled = false))) { if (deployTurret != null) { if (deployTurret.holding == false) { returnDeployDoubleTapCounter = .35f; } } if (deployBarrier != null) { if (deployBarrier.holding == false) { returnDeployDoubleTapCounter = .35f; } } buttonPresses += 1; // Upgrade Meter Timing if (blueUpgradeMeter == 0 & blueUpgradeLevel < blueUpgradeLevelMAX) { blueUpgradeMeter = blueUpgradeMeterMAX; } } // Destroy Object if ((buttonPresses == 2) & (returnDeployDoubleTapCounter > 0)) { //bluePlayer.deploy_1 = Vector3.zero; //bluePlayer.deploy_2 = Vector3.zero; bluePlayer.theGun.barrierCounter -= 1; bluePlayer.theGun.canDeploy = true; buttonPresses = 0; Destroy(gameObject); } // Upgrade Deployable if (bluePlayer.useController == true) { if (Input.GetKeyDown(KeyCode.Joystick1Button0) & (blueUpgradeMeter <= 1f) & blueUpgradeLevel < blueUpgradeLevelMAX) { blueUpgrading = true; blueUpgradeMeter = blueUpgradeMeterMAX; blueUpgradeMeterCounter += 1; particleCountDown = .5f; particleEffect.Play(); // Particles particleLight.enabled = true; // Light bluePlayer.GetComponent <BlueAudioManager>().AudioSource_02.Play(); bluePlayer.GetComponent <Blue_Idle>().enabled = false; bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled = true; } } if (bluePlayer.useController == false) { if (Input.GetKeyDown("space") & (blueUpgradeMeter <= 1f)) { Debug.Log("SPACE PRESSED"); blueUpgrading = true; blueUpgradeMeter = blueUpgradeMeterMAX; blueUpgradeMeterCounter += 1; bluePlayer.GetComponent <BlueAudioManager>().AudioSource_02.Play(); bluePlayer.GetComponent <Blue_Idle>().enabled = false; bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled = true; } } } // Reset Upgrading Variable // Cancel Upgrade if (Input.GetKeyDown(KeyCode.Joystick1Button1)) { bluePlayer.GetComponent <BlueAudioManager>().AudioSource_04.Play(); bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled = false; bluePlayer.GetComponent <Blue_Idle>().enabled = true; blueUpgradeMeterCounter = 0; blueUpgradeMeter = 0; blueUpgrading = false; } // Upgrade Meter Countdown if (blueUpgradeMeter > 0) { blueUpgradeMeter -= Time.deltaTime; } if (blueUpgradeMeter < 0) { blueUpgradeMeterCounter = 0; blueUpgradeMeter = 0f; bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled = false; bluePlayer.GetComponent <Blue_Idle>().enabled = true; } } // 3 PRESSES to UPGRADE if (blueUpgradeMeterCounter == 3) { emissionModule.rateOverTime = 100f; blueUpgrading = false; bluePlayer.GetComponent <BlueAudioManager>().AudioSource_03.Play(); blueUpgradeMeterCounter = 0; blueUpgradeMeter = 0f; blueUpgradeLevel += 1; bluePlayer.GetComponent <Blue_Upgrade_Deployable>().enabled = false; bluePlayer.GetComponent <Blue_Idle>().enabled = true; } // UPGRADED if (blueUpgradeLevel > 0) { if (deployTurret != null) { deployTurret.upgradeLevel = blueUpgradeLevel; } if (deployBarrier != null) { deployBarrier.upgradeLevel = blueUpgradeLevel; } } // Particle Effects if (particleCountDown > 0) { particleCountDown -= Time.deltaTime; } if (particleCountDown <= 0) { particleEffect.Stop(); // Particles particleLight.enabled = false; // Light } }