void Update() { if (Vector3.Distance(FPSMainScript.playerPos, transform.position) < 1.5f) { //Get ammo if (type == Type.ShotgunAmmo) { FPSMainScript.FPSPlayerScript.shotgunAmmo += 8; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.GetShotgunAmmo); } if (type == Type.RocketAmmo) { FPSMainScript.FPSPlayerScript.rocketAmmo += 3; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.GetShotgunAmmo); } if (type == Type.HealthPack) { FPSMainScript.FPSPlayerScript.healthScript.health = 100; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Checkpoint, 1.5f); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.GetShotgunAmmo); } Destroy(this.gameObject); } }
void Update() { if (xa.player != null && !rescued) { if (Vector2.Distance(xa.player.transform.position, transform.position) < 2) { rescued = true; aniScript.PlayAnimation(1); iTween.FadeTo(text, iTween.Hash("alpha", 1, "time", 0.4f, "easetype", iTween.EaseType.easeOutSine)); iTween.MoveBy(text, iTween.Hash("y", 1, "time", 0.4f, "easetype", iTween.EaseType.easeOutSine)); fadeText = true; timeSet = fa.time; GameObject go = Instantiate(freedomExplo, transform.position, transform.rotation); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.ElfSound); } } if (rescued) { if (fadeText) { if (fa.time > (timeSet + 3)) { fadeText = false; iTween.FadeTo(text, iTween.Hash("alpha", 0, "time", 1f, "easetype", iTween.EaseType.easeOutSine)); } } } }
// Update is called once per frame void Update() { if (fa.timeInSeconds > (switchDelay + switchSet) && blinkDelay != -1) { blinkDelay = -1; santaPuppet.SetActive(false); satanPuppet.SetActive(true); portal.SetActive(true); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.MegaSatan_Scream); //iTween.MoveTo(santaPuppet, iTween.Hash("y", -13.5f, "time", 0.2f, "easetype", iTween.EaseType.easeInSine)); iTween.MoveTo(portal, iTween.Hash("x", 20, "y", -7.7, "delay", 3f, "time", 3f, "easetype", iTween.EaseType.easeOutSine)); } float localDelay = blinkDelay; if (!blinkState) { localDelay = blinkDelayOff; } if (fa.timeInSeconds > (blinkSet + localDelay) && blinkDelay != -1) { blinkState = !blinkState; santaPuppet.SetActive(blinkState); blinkDelay -= 0.05f; if (blinkDelay < 0.1f) { blinkDelay = 0.1f; } blinkSet = fa.timeInSeconds; } if (fa.timeInSeconds > (timeset + delay) && delay != -1) { delay = -1; fire1.Play(); fire2.Play(); fire3.Play(); hellflakes.Play(); snowflakes.Stop(); //iTween.MoveTo(sky2, iTween.Hash("y", 200, "time", 0.5f, "easetype", iTween.EaseType.easeInSine)); iTween.FadeTo(sky2, iTween.Hash("alpha", 1, "time", 1f, "easetype", iTween.EaseType.easeInSine)); iTween.MoveTo(N, iTween.Hash("x", 6, "time", 1, "islocal", true, "easetype", iTween.EaseType.easeInOutSine)); iTween.MoveTo(T, iTween.Hash("x", 0, "time", 1, "islocal", true, "easetype", iTween.EaseType.easeInOutSine)); iTween.MoveTo(A2, iTween.Hash("x", 3, "time", 1, "islocal", true, "easetype", iTween.EaseType.easeInOutSine)); iTween.RotateBy(S, iTween.Hash("z", 1, "time", 1.5f, "easetype", iTween.EaseType.easeInOutSine)); iTween.RotateBy(A, iTween.Hash("z", 1, "time", 1f, "easetype", iTween.EaseType.easeInOutSine)); iTween.RotateBy(N, iTween.Hash("z", 1, "time", 0.8f, "easetype", iTween.EaseType.easeInOutSine)); iTween.RotateBy(T, iTween.Hash("z", 1, "time", 1f, "easetype", iTween.EaseType.easeInOutSine)); iTween.RotateBy(A2, iTween.Hash("z", 1, "time", 1.2f, "easetype", iTween.EaseType.easeInOutSine)); } }
public static void PopupAchivo(Achivos achivo) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Achivo); GameObject go = null; if (achivo == Achivos.Achivo_AllasKlar) { go = Instantiate(xa.de.AchivoPopup_AllasKlar, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_DaddysLove) { go = Instantiate(xa.de.AchivoPopup_DaddyLove, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_DontStompa) { go = Instantiate(xa.de.AchivoPopup_DontStomp, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_MagicMonk) { go = Instantiate(xa.de.AchivoPopup_MagicMonk, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_Routes66) { go = Instantiate(xa.de.AchivoPopup_Routes66, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_Cheater) { go = Instantiate(xa.de.AchivoPopup_Cheater, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_Reverso) { go = Instantiate(xa.de.AchivoPopup_Reverso, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_Champion) { go = Instantiate(xa.de.AchivoPopup_Champion, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_NoThanksImGood) { go = Instantiate(xa.de.AchivoPopup_NoThanks, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_MitLiebeGemacht) { go = Instantiate(xa.de.AchivoPopup_MitLiebe, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (achivo == Achivos.Achivo_GoinFastImTowerBound) { go = Instantiate(xa.de.AchivoPopup_GoingFast, xa.de.AchivoPopupSpawnPoint.transform.position, xa.de.AchivoPopupSpawnPoint.transform.rotation); } if (go != null) { DontDestroyOnLoad(go); iTween.MoveTo(go, iTween.Hash("x", 9, "time", 1f, "easetype", iTween.EaseType.easeOutSine)); iTween.MoveTo(go, iTween.Hash("delay", 4, "y", 15, "time", 1f, "easetype", iTween.EaseType.easeInSine)); } }
void Update() { if (Input.GetKeyUp(KeyCode.Escape)) { xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, "ESJ2Title"); } if (allowClick != -1 && Time.timeSinceLevelLoad > allowClick) { allowClick = -1; } if (allowClick == -1) { if (Controls.GetAnyKeyDown() || Input.GetMouseButtonDown(0)) { xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, "StartMenu"); } } if (shake1 != -1 && Time.timeSinceLevelLoad > shake1) { shake1 = -1; //ScreenShakeCamera.Screenshake(1, 0.15f, ScreenShakeCamera.ScreenshakeMethod.Basic); } if (swearingTime != -1 && Time.timeSinceLevelLoad > swearingTime) { swearingTime = -1; iTween.MoveTo(swearing1, iTween.Hash("x", 0, "y", 0, "time", 0.2f, "easetype", iTween.EaseType.easeOutSine)); iTween.MoveTo(swearing2, iTween.Hash("x", 0, "y", 0, "time", 0.2f, "easetype", iTween.EaseType.easeOutSine)); } if (blood != -1 && Time.timeSinceLevelLoad > blood) { blood = -1; bloodPS.Play(); } if (fart != -1 && Time.timeSinceLevelLoad > fart) { fart = -1; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Fart); iTween.MoveTo(tentacles1, iTween.Hash("x", 0, "y", 0, "time", 0.2f, "easetype", iTween.EaseType.easeOutSine)); iTween.MoveTo(tentacles2, iTween.Hash("x", 0, "y", 0, "time", 0.2f, "easetype", iTween.EaseType.easeOutSine)); //ScreenShakeCamera.Screenshake(1, 0.15f, ScreenShakeCamera.ScreenshakeMethod.Basic); } if (o****m != -1 && Time.timeSinceLevelLoad > o****m) { o****m = -1; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Checkpoint); } if (satan != -1 && Time.timeSinceLevelLoad > satan) { satan = -1; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.MegaSatan_Scream); iTween.MoveTo(satanObj, iTween.Hash("x", 0, "y", 0, "time", 0.2f, "easetype", iTween.EaseType.easeOutSine)); } }
public void FireUzi() { if (fa.time > (uzi_timeSet + uzi_firingDelay)) { uziBulletsLeftToFire--; uzi_timeSet = fa.time; // Debug.Log("BANG! " + fa.timeInSeconds); if (bulletCount == 0) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.UziFiring); } //bulletCount++; //if (bulletCount == 3) { bulletCount = 0; } Ray ray = new Ray(); RaycastHit hit; LayerMask mask = 1 << 19; muzzlePoint.transform.AddAngX(Random.Range(-uzi_accuracy, uzi_accuracy)); muzzlePoint.transform.AddAngY(Random.Range(-uzi_accuracy, uzi_accuracy)); ray.origin = muzzlePoint.transform.position; ray.direction = muzzlePoint.transform.forward; muzzlePoint.transform.localEulerAngles = Vector3.zero; //Debug.DrawLine(muzzlePoint.transform.position, ray.GetPoint(100),Color.red, 12); // muzzlePoint.transform.AddAngY(Random.Range(-uzi_accuracy, uzi_accuracy)); Vector3 hitPos; if (Physics.Raycast(ray, out hit, uzi_raycastDist, mask)) { hitPos = hit.point; Info info = hit.transform.gameObject.GetComponent <Info>(); if (info != null) { info.healthScript.health -= Random.Range(shotgunMinDam, shotgunMaxDam + 1); } } else { hitPos = ray.GetPoint(uzi_raycastDist); } GameObject go; go = Instantiate(uzi_exploPrefab, hitPos, uzi_exploPrefab.transform.rotation); /* * float dist = Vector3.Distance(muzzlePoint.transform.position, hitPos); * Vector3 halfway = ray.GetPoint(dist * 0.5f); * go = Instantiate(uzi_beamPrefab); * go.transform.position = halfway; * go.transform.LookAt(hitPos); * go.transform.SetScaleZ(dist); * */ } }
public void GetHurt() { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Fart); daddysLove--; ReadOnly_DaddysLove = daddysLove; if (daddysLove >= 0) { Speak("Disappointing!"); Instantiate(heartDeathExplo, hearts[daddysLove].transform.position, hearts[daddysLove].transform.rotation); hearts[daddysLove].SetActive(false); } }
public void FireRocketLauncher() { if (fa.time > (rl_timeSet + rl_firingDelay)) { if (rocketAmmo <= 0) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RocketLauncherEmpty); } else { rocketAmmo--; rl_timeSet = fa.time; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.UziFiring); GameObject go = Instantiate(rocketPrefab, fakeMuzzlePoint.transform.position, muzzlePoint.transform.rotation); } } }
public void FireShotgun() { if (fa.time > (sg_timeSet + sg_firingDelay)) { if (shotgunAmmo <= 0) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.ShotgunEmpty); } else { shotgunAmmo--; sg_timeSet = fa.time; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.ShotgunFiring); for (int i = 0; i < 6; i++) { FireShotgunPellet(); } } } }
void Update() { if (Vector3.Distance(transform.position, lastPos) > maxDist) { if (!silent) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Fart); } lastPos = transform.position; //Don't poop off-screen if (poopAnywhere || (transform.position.x < 14 && transform.position.x > -22 && transform.position.y > -8 && transform.position.y < 8)) { GameObject go = Instantiate(poop, transform.position, transform.rotation); if (makeChild) { go.transform.SetParent(this.transform); } } } }
void Update() { if (!pickedUp) { if (xa.player) { Vector3 vec1 = xa.player.transform.position; vec1.z = transform.position.z; if (Vector3.Distance(vec1, transform.position) < 1) { //Is this a unique collection? int uniqueID = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex; if (!PlayerPrefs.HasKey("goldenButt" + uniqueID)) { int goldenButtsAmount = 0; if (PlayerPrefs.HasKey("goldenButtsCollected")) { goldenButtsAmount = PlayerPrefs.GetInt("goldenButtsCollected", 0); } goldenButtsAmount++; PlayerPrefs.SetInt("goldenButtsCollected", goldenButtsAmount); PlayerPrefs.SetInt("goldenButt" + uniqueID, 1); PlayerPrefs.Save(); fa.goldenButtsCollected = goldenButtsAmount; } pickedUp = true; stars.Stop(); stars.transform.SetParent(null); GameObject go = Instantiate(explo); go.transform.position = transform.position; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Butt); portal.SetActive(true); Destroy(this.gameObject); } } } }
void Update() { if (fa.time >= (timeSet + delay)) { switch (state) { case State.Prepping_MovingDown: iTween.MoveBy(this.gameObject, iTween.Hash("y", -verDist, "time", speedDown, "easetype", iTween.EaseType.easeInCirc)); delay = speedDown; timeSet = fa.time; state = State.Prepping_WatingAtBottom; break; case State.Prepping_WatingAtBottom: delay = pauseAtBottom; timeSet = fa.time; state = State.Prepping_MovingUp; if (Setup.checkVecOnScreen(transform.position, false)) { ScreenShakeCamera.Screenshake(1, 0.15f, ScreenShakeCamera.ScreenshakeMethod.Basic); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact); } break; case State.Prepping_MovingUp: iTween.MoveBy(this.gameObject, iTween.Hash("y", verDist, "time", speedUp, "easetype", iTween.EaseType.easeInOutSine)); delay = speedUp; timeSet = fa.time; state = State.Prepping_WaitingAtTop; break; case State.Prepping_WaitingAtTop: delay = pauseAtTop; timeSet = fa.time; state = State.Prepping_MovingDown; break; } } }
void Update() { if (infoScript.triggered == true) { infoScript.triggered = false; moving = true; } if (moving) { if (fa.time >= (timeSet + delay)) { switch (state) { case State.Prepping_MovingDown: iTween.MoveBy(this.gameObject, iTween.Hash("y", -verDist, "time", speedDown, "easetype", iTween.EaseType.easeInCirc)); delay = speedDown; timeSet = fa.time; state = State.Prepping_WatingAtBottom; break; case State.Prepping_WatingAtBottom: delay = pauseAtBottom; timeSet = fa.time; state = State.None; if (Setup.checkVecOnScreen(transform.position, false)) { ScreenShakeCamera.Screenshake(1, 0.95f, ScreenShakeCamera.ScreenshakeMethod.Basic); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact); } moving = false; break; } } } }
public void PunchUpdate() { if (Controls.GetInputDown(Controls.Type.Jump, novaPlayerScript.playerNumber) && !xa.playerHasJetpack) { storedJump = true; } switch (swordState) { case SwordState.Setup: { distSoFar = 0; startPos = transform.position; hitDeadlyBoxCollider = false; swordDir = Vector3.zero; if (xa.playerControlsHeldDir < 0) { swordDir.x = -1; } if (xa.playerControlsHeldDir >= 0) { swordDir.x = 1; } swordState = SwordState.Charge; //play sound effect Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.SwordSlice); //ScreenSlash.ScreenSlashOn(transform.position.y); //previousTime = Time.timeScale; //Time.timeScale = timeSlowEffect; xa.playerAirSwording = true; //gotBoost = false; novaPlayerScript.Unstick(); } break; case SwordState.Charge: { float dist = punchSpeed * fa.deltaTime; distSoFar += dist; //raycast for blocks LayerMask swordMask = 1 << 19 | 1 << 21; //Only hits hitboxes on the NovaBlock layer Ray ray = new Ray(); RaycastHit hit1 = new RaycastHit(); RaycastHit hit2 = new RaycastHit(); RaycastHit hit3 = new RaycastHit(); ray.direction = swordDir; float tempSpeed = punchSpeed * fa.deltaTime; bool hitSomething = false; bool raycastsHitSomething = false; float half = (novaPlayerScript.plHeight * 0.5f); // + 0.1f;//ghx Vector3 v1 = Vector3.zero; Vector3 v2 = Vector3.zero; float raycastLayer = xa.GetLayer(xa.layers.RaycastLayer); ray.origin = new Vector3(transform.position.x, transform.position.y, raycastLayer); v1 = ray.origin; v1.z = 33; if (Physics.Raycast(ray, out hit1, dist, swordMask)) { /* v2 = hit1.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/ raycastsHitSomething = true; } ray.origin = new Vector3(transform.position.x, transform.position.y + half, raycastLayer); v1 = ray.origin; v1.z = 33; if (Physics.Raycast(ray, out hit2, dist, swordMask)) { /* v2 = hit2.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/ raycastsHitSomething = true; } ray.origin = new Vector3(transform.position.x, transform.position.y - half, raycastLayer); v1 = ray.origin; v1.z = 33; if (Physics.Raycast(ray, out hit3, dist, swordMask)) { /* v2 = hit3.point; v2.z = 33;Debug.DrawLine(v1, v2, Color.yellow, 5); */ raycastsHitSomething = true; } if (raycastsHitSomething) { float finalDist = punchDist; Vector3 finalPoint = Vector3.zero; Collider finalCollider = null; int hitChoice = 0; float dist1 = punchDist; float dist2 = punchDist; float dist3 = punchDist; if (hit1.collider != null) { dist1 = hit1.distance; } if (hit2.collider != null) { dist2 = hit2.distance; } if (hit3.collider != null) { dist3 = hit3.distance; } hitChoice = 3; if (dist1 <= dist2 && dist1 <= dist3) { hitChoice = 1; } if (dist2 <= dist1 && dist2 <= dist3) { hitChoice = 2; } if (dist3 <= dist1 && dist3 <= dist2) { hitChoice = 3; } //Debug.Log("Hit choice: " + hitChoice + ", D1: " + dist1 + ", D2: " + dist2 + ", D3: " + dist3); if (hitChoice == 1) { finalDist = hit1.distance; finalPoint = hit1.point; finalCollider = hit1.collider; } if (hitChoice == 2) { finalDist = hit2.distance; finalPoint = hit2.point; finalCollider = hit2.collider; } if (hitChoice == 3) { finalDist = hit3.distance; finalPoint = hit3.point; finalCollider = hit3.collider; } // Debug.Log("HIT SOMETHING"); tempSpeed = finalDist; hitSomething = true; transform.SetX(finalPoint.x); Info infoScript = null; if (hitChoice == 1) { infoScript = hit1.collider.GetComponent <Info>(); } if (hitChoice == 2) { infoScript = hit2.collider.GetComponent <Info>(); } if (hitChoice == 3) { infoScript = hit3.collider.GetComponent <Info>(); } if (infoScript != null) { if (infoScript.killPlayer) { hitDeadlyBoxCollider = true; } } HittableByAirsword hittableScript = finalCollider.gameObject.GetComponent <HittableByAirsword>(); if (hittableScript != null) { hittableScript.HitByPlayer(); /*if (hittableScript.giveAirswordBoost) * { * gotBoost = true; * }*/ } } float distCheck = Vector3.Distance(startPos, transform.position); if (hitSomething || distCheck > punchDist) { swordState = SwordState.WrapUp; if (distCheck > punchDist) //if you moved too far (too little, you probably hit something) { if (startPos.x < transform.position.x) { float moveBack = punchDist - distCheck; Debug.Log(moveBack); transform.Translate(new Vector3(moveBack, 0, 0)); } else { float moveBack = punchDist - distCheck; Debug.Log(moveBack); transform.Translate(new Vector3(-moveBack, 0, 0)); } } //Debug.Log(Vector3.Distance(startPos,transform.position)); } else { Vector3 swordVel = new Vector3(); swordVel.x = (swordDir.x * tempSpeed); swordVel.y = (swordDir.y * tempSpeed); //transform.SetX(ray.GetPoint(dist).x); int split = 15; for (int m = split; m > 0; m--) { CheckForItems(dist * 1f, transform.position); CheckHurtZones(); transform.Translate(swordVel / split); if (Vector3.Distance(startPos, transform.position) > punchDist) { // Debug.Log(m); //float d = Vector3.Distance(startPos, transform.position) - punchDist; //transform.Translate(new Vector3(-d,0,0)); break; } } //transform.Translate(swordVel); } if (!NovaPlayerScript.checkPlayerDeathBox(transform.position) && !novaPlayerScript.ThreeDee) { novaPlayerScript.hpScript.health = 0; swordState = SwordState.WrapUp; } if (novaPlayerScript.hpScript.health <= 0) { swordState = SwordState.WrapUp; } } break; case SwordState.WrapUp: { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact); xa.playerAirSwording = false; swordState = SwordState.Setup; novaPlayerScript.state = NovaPlayerScript.State.NovaPlayer; novaPlayerScript.DidAirSwordImpact = true; novaPlayerScript.vel.y = 0; if (hitDeadlyBoxCollider) { novaPlayerScript.hpScript.health = 0; } if (novaPlayerScript.hpScript.health <= 0) { if (novaPlayerScript.hpScript.setPosWhenKilled) { transform.SetX(novaPlayerScript.hpScript.posWhenKilled.x); transform.SetY(novaPlayerScript.hpScript.posWhenKilled.y); } } /*if (gotBoost) * { * novaPlayerScript.GotAirswordBoost(); * }*/ if (storedJump) { storedJump = false; novaPlayerScript.ExternalPossibleJump(); } } break; } }
void Update() { if (fa.paused) { return; } playerPos = transform.position; if (healthScript.health > 30 && healthScript.health <= 60) { hurtOverlay1.SetActive(true); hurtOverlay2.SetActive(false); hurtOverlay3.SetActive(false); } if (healthScript.health > 0 && healthScript.health <= 30) { hurtOverlay1.SetActive(false); hurtOverlay2.SetActive(true); hurtOverlay3.SetActive(false); } if (healthScript.health < 0) { hurtOverlay1.SetActive(false); hurtOverlay2.SetActive(false); hurtOverlay3.SetActive(true); } if (healthScript.health > 60) { hurtOverlay1.SetActive(false); hurtOverlay2.SetActive(false); } if (Controls.GetInputDown(Controls.Type.FPSCycleWeapon, 0)) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.BaseballBat); shotgunModel.SetActive(false); rocketLauncherModel.SetActive(false); if (weapon == Weapon.Shotgun) { rocketLauncherModel.SetActive(true); weapon = Weapon.RocketLauncher; } else { shotgunModel.SetActive(true); weapon = Weapon.Shotgun; } } if (weapon == Weapon.Shotgun) { ammo = shotgunAmmo; } else { ammo = rocketAmmo; } if (!dead) { if (healthScript.health <= 0) { deadTimeset = fa.time; dead = true; iTween.MoveBy(camControllerObj, iTween.Hash("y", -1.8f, "time", 1.5f, "easetype", iTween.EaseType.easeInOutSine)); iTween.RotateTo(camControllerObj, iTween.Hash("x", -45, "time", 1.5f, "easetype", iTween.EaseType.easeInOutSine)); } } else { if (fa.time > (deadTimeset + 2)) { if (!respawned) { respawned = true; xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, SceneManager.GetActiveScene().name); } } } if (!dead) { HandleMovement(); HandleWeapon(); HandleCameraLook(); } int hp = Mathf.RoundToInt(healthScript.health); if (hp < 0) { hp = 0; } if (healthScript.health > 0 && hp <= 0) { hp = 1; } /* if (Fresh_InGameMenus.self != null) * { * Fresh_InGameMenus.self.FPS_HealthText.text = "" + hp; * int ammo = 0; * if (weapon == Weapon.Shotgun) { ammo = shotgunAmmo; } * if (weapon == Weapon.RocketLauncher) { ammo = rocketAmmo; } * Fresh_InGameMenus.self.FPS_AmmoText.text = "" + ammo;// + "/" + maxAmmo; * * if (hp > 30) { hurtOverlay_max = 0; hurtOverlay_min = 0; } * else if (hp > 20) { hurtOverlay_max = 0.3f; hurtOverlay_min = 0.1f; } * else if (hp > 10) { hurtOverlay_max = 0.5f; hurtOverlay_min = 0.3f; } * else if (hp > 0) { hurtOverlay_max = 1f; hurtOverlay_min = 0.7f; } * else { hurtOverlay_max = 1f; hurtOverlay_min = 0.9f; } * * Image i = Fresh_InGameMenus.self.FPS_HurtOverlay; * float a = i.material.color.a; * if (hurtOverlayDir) * { * if (a < hurtOverlay_max) { a += hurtOverlaySpeed * fa.deltaTime; } else { hurtOverlayDir = false; } * } * else * { * if (a > hurtOverlay_min) { a -= hurtOverlaySpeed * fa.deltaTime; } else { hurtOverlayDir = true; } * } * * if (hurtOverlay_max == 0) { a = 0; } * i.material.color = new Color(i.material.color.r, i.material.color.g, i.material.color.b, a); * } */ }
public static bool GetInputDown(Type type, int playerNum) { if (type == Type.OpenMenu) { if (Input.GetKeyDown(KeyCode.Escape)) { return(true); } } if (fa.forceAltMenuControls) { if (type == Type.MenuSelect) { if (Input.GetKeyDown(KeyCode.M)) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Coin); return(true); } } //hardcoded, remove at future date } if (Recon.useRecon) { if (!customControls[(int)type]) { return(Recon.Translation(type, Recon.ControlState.Down, playerNum)); } } bool result = false; for (int i = 0; i < controls.Count; i++) { if (controls[i].type == type && controls[i].player == playerNum) { Control control = controls[i]; //is it a key, or an axis? if (control.keyInt != -1) { if (Input.GetKeyDown((KeyCode)control.keyInt)) { result = true; } } else { //handle axis if (control.posAxis) { //if this axis is correct, AND it doesn't equal what it used to be. if (axes[control.joyNum, control.axisNum] > deadzone && axesOld[control.joyNum, control.axisNum] != axes[control.joyNum, control.axisNum]) { result = true; } } else { if (axes[control.joyNum, control.axisNum] < -deadzone && axesOld[control.joyNum, control.axisNum] != axes[control.joyNum, control.axisNum]) { result = true; } } } } } return(result); }
void Update() { currentDaddysLove = daddysLove; if (externalAmount != -1) { External_UpdateDaddysLove(); } /* * if (WriteOnly_DaddysLove != -1) * { * while (daddysLove > WriteOnly_DaddysLove) * { * daddysLove--; * hearts[daddysLove].SetActive(false); * } * * WriteOnly_DaddysLove = -1; * }*/ //ReadOnly_DaddysLove = daddysLove; /* * switch(daddysLove) * { * case 0: daddysLoveLabelText.text = "Daddy's Bitter Disappointment:";break; * case 1: daddysLoveLabelText.text = "Daddy's Bitter Disappointment:";break; * case 2: daddysLoveLabelText.text = "Daddy's Pain-In-The-Ass:";break; * case 3: daddysLoveLabelText.text = "Daddy's Love:";break; * case 4: daddysLoveLabelText.text = "Daddy's Love:";break; * case 5: daddysLoveLabelText.text = "Daddy's Love:";break; * } */ // if(Input.GetKeyDown(KeyCode.B)) {GetHurt(); } //Checking for catches & highfives (has to be outside the statemachine) if (currentBall != null) { if (Vector2.Distance(currentBall.transform.position, xa.player.transform.position) < 2) { caught = true; Speak("Nice one!"); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.BaseballBat); GameObject go = Instantiate(ballDeathExplo, currentBall.transform.position, currentBall.transform.rotation); go.transform.SetAngZ(414); Destroy(currentBall); } } if (currentHighfiveMuzzle != null && !highfived) { if (Vector2.Distance(currentHighfiveMuzzle.transform.position, xa.player.transform.position) < 2) { highfived = true; Speak("Right on!"); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Highfive); Instantiate(highfiveDeathExplo, currentHighfiveMuzzle.transform.position, currentHighfiveMuzzle.transform.rotation); } } //state machine switch (state) { case State.StartThrowing: { timeset = fa.time; delay = 0.3f; state = State.WaitBeforeThrowing; iTween.MoveTo(ThrowingTentacle, iTween.Hash("islocal", true, "x", 7.41f, "y", -6.58f, "time", 0.1f, "easetype", iTween.EaseType.easeInOutSine)); Speak("Batter up!"); break; } case State.WaitBeforeThrowing: { if (fa.time > (timeset + delay)) { state = State.WaitThrowing; timeset = fa.time; delay = 0.3f; currentBall = Instantiate(ballBullet, ThrowingTentacleMuzzlePoint.transform.position, ThrowingTentacleMuzzlePoint.transform.rotation); currentBall.transform.SetAngZ(165); caught = false; } break; } case State.WaitThrowing: { if (fa.time > (timeset + delay)) { state = State.EndThrowing; } break; } case State.EndThrowing: { iTween.MoveTo(ThrowingTentacle, iTween.Hash("islocal", true, "x", 7.41f, "y", -17, "time", 0.1f, "easetype", iTween.EaseType.easeInOutSine)); state = State.WaitAfterThrowing; timeset = fa.time; delay = 2; break; } case State.WaitAfterThrowing: { if (fa.time > (timeset + delay)) { state = State.StartHighfive; } break; } case State.StartHighfive: { Speak("Slap me five!"); highfived = false; timeset = fa.time; delay = 3; state = State.WaitHighfive; float moveTime = 0.4f; if (highfiveIndex == 0) { currentHighfiveMuzzle = HighfiveMuzzle1; //Up: -9.4 //Down: -17.58 iTween.MoveTo(Highfive1, iTween.Hash("islocal", true, "x", -11.7f, "y", -9.4f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } if (highfiveIndex == 1) { currentHighfiveMuzzle = HighfiveMuzzle2; //Up x: -13.6 //Down x: -26.73 iTween.MoveTo(Highfive2, iTween.Hash("islocal", true, "x", -13.6f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } if (highfiveIndex == 2) { currentHighfiveMuzzle = HighfiveMuzzle3; //Up: 9.6 //Down: 17.27 iTween.MoveTo(Highfive3, iTween.Hash("islocal", true, "x", 5.7f, "y", 9.6f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } if (highfiveIndex == 3) { currentHighfiveMuzzle = HighfiveMuzzle4; //Up: -9.4 //Down: -17.07 iTween.MoveTo(Highfive4, iTween.Hash("islocal", true, "x", 5.3f, "y", -9.4f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } break; } case State.WaitHighfive: { if (fa.time > (timeset + delay) || highfived) { state = State.EndHighfive; } break; } case State.EndHighfive: { float moveTime = 0.4f; if (highfiveIndex == 0) { //Up: -9.4 //Down: -17.58 iTween.MoveTo(Highfive1, iTween.Hash("islocal", true, "x", -11.7f, "y", -17.58f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } if (highfiveIndex == 1) { //Up x: -15.8 //Down x: -26.73 iTween.MoveTo(Highfive2, iTween.Hash("islocal", true, "x", -26.73f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } if (highfiveIndex == 2) { //Up: 9.6 //Down: 17.27 iTween.MoveTo(Highfive3, iTween.Hash("islocal", true, "x", 5.7f, "y", 17.27f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } if (highfiveIndex == 3) { //Up: -9.4 //Down: -17.07 iTween.MoveTo(Highfive4, iTween.Hash("islocal", true, "x", 5.3f, "y", -17.07f, "time", moveTime, "easetype", iTween.EaseType.easeInOutSine)); } highfiveIndex++; if (highfiveIndex == 4) { highfiveIndex = 0; } timeset = fa.time; delay = 0.6f; state = State.WaitAfterHighfive; break; } case State.WaitAfterHighfive: { if (fa.time > (timeset + delay)) { if (highfived == false) { GetHurt(); } state = State.StartThrowing; } break; } } /* * if (aniScript.index != oldIndex) * { * oldIndex = aniScript.index; * * //if (oldIndex == 4) * //{ * //throw * // Instantiate(ballBullet, muzzlepoints[oldIndex].transform.position, muzzlepoints[oldIndex].transform.rotation); * //ball.SetActive(false); * //} * //else * //{ * //ball.SetActive(true); * iTween.MoveTo(ball, iTween.Hash("x", muzzlepoints[oldIndex].transform.position.x, "y", muzzlepoints[oldIndex].transform.position.y, "time", 0.09f)); * * //} * * * * }*/ }
void Awake() { self = this; }
void Update() { bool changed = false; if (!oncePerGameStart) { Debug.Log("ONCE"); oncePerGameStart = true; changed = true; for (int i = 0; i < nodes.Length; i++) { if (nodes[i].levelType == FreshLevels.Type.IntroStory) { currentNode = nodes[i]; break; } } currentLevelName.text = currentNode.levelName; LoadLevelStats(); } if (!checkedForSavedMapPos) { checkedForSavedMapPos = true; if (fa.lastLevelPlayed != FreshLevels.Type.None) { for (int i = 0; i < nodes.Length; i++) { if (nodes[i].levelType == fa.lastLevelPlayed) { currentNode = nodes[i]; changed = true; } } } } if (Controls.GetInputDown(Controls.Type.MenuUp, 0)) { if (currentNode.north != null) { currentNode = currentNode.north; // fa.lastLevelPlayed = currentNode.levelType; changed = true; } } if (Controls.GetInputDown(Controls.Type.MenuDown, 0)) { if (currentNode.south != null) { currentNode = currentNode.south; fa.lastLevelPlayed = currentNode.levelType; changed = true; } } if (Controls.GetInputDown(Controls.Type.MenuLeft, 0)) { if (currentNode.west != null) { currentNode = currentNode.west; fa.lastLevelPlayed = currentNode.levelType; changed = true; } } if (Controls.GetInputDown(Controls.Type.MenuRight, 0)) { if (currentNode.east != null) { currentNode = currentNode.east; fa.lastLevelPlayed = currentNode.levelType; changed = true; } } if (Controls.GetInputDown(Controls.Type.MenuSelect, 0)) { if (currentNode.locked) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Fart); iTween.PunchRotation(currentNode.gameObject, iTween.Hash("z", 17.5f, "time", 0.3f)); } else { string lvlName = FreshLevels.GetStrNameForType(currentNode.levelType); //Debug.Log("Tried to go to level: " + lvlName); if (lvlName != "") { xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, lvlName); } } } if (changed) { for (int i = 0; i < allSkies.Length; i++) { allSkies[i].SetActive(false); } iTween.MoveTo(nodeCamera, iTween.Hash("x", currentNode.transform.position.x, "y", currentNode.transform.position.y, "easetype", iTween.EaseType.easeInOutSine, "time", 0.2f)); if (currentNode.setCamPos) { //iTween.MoveTo(camera, iTween.Hash("x", currentNode.camPos.x, "y", currentNode.camPos.y, "easetype", iTween.EaseType.easeInOutSine, "time", 0.5f)); //camera.transform.SetX(currentNode.camPos.x); //camera.transform.SetY(currentNode.camPos.y); } iTween.RotateTo(nodeCamera, iTween.Hash("z", currentNode.cameraAngle2, "easetype", iTween.EaseType.easeInOutSine, "time", 0.2f)); for (int i = 0; i < currentNode.objsOn.Length; i++) { currentNode.objsOn[i].SetActive(true); } currentLevelName.text = currentNode.levelName; LoadLevelStats(); } cursor.transform.SetX(currentNode.gameObject.transform.position.x); cursor.transform.SetY(currentNode.gameObject.transform.position.y); }
void Update() { if (fa.paused) { return; } //changing hurt state if (!hurt1 && healthScript.health <= FPSBalanceScript.MegaSatanHurtHP1) { hurt1 = true; Mesh_IdleHead.material = IdleHeadHurtMat1; Mesh_FPSHead.material = FPSHeadHurtMat1; } if (!hurt2 && healthScript.health <= FPSBalanceScript.MegaSatanHurtHP2) { hurt2 = true; Mesh_IdleHead.material = IdleHeadHurtMat2; Mesh_FPSHead.material = FPSHeadHurtMat2; } //getting hit if (oldHealth != healthScript.health) { oldHealth = healthScript.health; //got hit iTween.PunchRotation(IdleHead, iTween.Hash("z", Random.Range(-45, 45), "time", Random.Range(0.3f, 0.5f), "easetype", iTween.EaseType.linear)); iTween.PunchRotation(IdleBody, iTween.Hash("z", Random.Range(-45, 45), "time", Random.Range(0.3f, 0.5f), "easetype", iTween.EaseType.linear)); iTween.PunchRotation(ChargingHead, iTween.Hash("z", Random.Range(-45, 45), "time", Random.Range(0.3f, 0.5f), "easetype", iTween.EaseType.linear)); iTween.PunchRotation(ChargingBody, iTween.Hash("z", Random.Range(-45, 45), "time", Random.Range(0.3f, 0.5f), "easetype", iTween.EaseType.linear)); } float delay = 1; if (state == State.Charging) { delay = stateChargeTime; } if (state == State.Firing) { delay = stateFiringTime; } if (fa.time >= (delay + stateTimeSet)) { stateTimeSet = fa.time; if (state == State.Charging) { state = State.Firing; ChargingController.SetActive(false); IdleController.SetActive(true); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.FPSMS_Scream1); } else { state = State.Charging; ChargingController.SetActive(true); IdleController.SetActive(false); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.FPSMS_Scream2); } } if (state == State.Firing) { if (fa.time > (firingSpeed_TimeSet + firingSpeed_Delay)) { Vector3 target = Vector3.zero; if (FPSMainScript.FPSPlayer != null) { target = FPSMainScript.FPSPlayer.transform.position; } muzzlePoint.transform.LookAt(target); // + offset); firingSpeed_TimeSet = fa.time; GameObject go = Instantiate(zombiePrefab, muzzlePoint.transform.position, muzzlePoint.transform.rotation); go = Instantiate(bulletPrefab, muzzlePoint.transform.position, muzzlePoint.transform.rotation); } } if (healthScript.health <= 0) { GameObject g1 = Instantiate(HeadGib, HeadGibMuzzle.transform.position, HeadGibMuzzle.transform.rotation); Instantiate(GenericGib1, GenericGibMuzzle1.transform.position, GenericGibMuzzle1.transform.rotation); Instantiate(GenericGib1, GenericGibMuzzle2.transform.position, GenericGibMuzzle2.transform.rotation); Instantiate(GenericGib1, GenericGibMuzzle3.transform.position, GenericGibMuzzle3.transform.rotation); Instantiate(GenericGib2, GenericGibMuzzle4.transform.position, GenericGibMuzzle4.transform.rotation); Instantiate(GenericGib2, GenericGibMuzzle5.transform.position, GenericGibMuzzle5.transform.rotation); Instantiate(GenericGib2, GenericGibMuzzle6.transform.position, GenericGibMuzzle6.transform.rotation); portal.transform.SetX(transform.position.x); portal.transform.SetZ(transform.position.z); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.FPSMS_Death); GameObject go = Instantiate(corpse, transform.position, corpse.transform.rotation); for (int i = 0; i < FPSMainScript.anyMonster.Count; i++) { if (FPSMainScript.anyMonster[i].uid == uid) { FPSMainScript.anyMonster.RemoveAt(i); break; } } Destroy(this.gameObject); } else { if (FPSMainScript.FPSPlayer != null) { goal = FPSMainScript.FPSPlayer.transform.position; } //Close enough to melee attack? if (Vector3.Distance(goal, transform.position) < 2) { if (fa.time > (attackTimeSet + attackDelay)) { attackTimeSet = fa.time; HealthScript h = FPSMainScript.FPSPlayer.GetComponent <HealthScript>(); h.health -= Random.Range(minDam, maxDam + 1); ScreenShakeCamera.Screenshake(0.1f, 0.1f, ScreenShakeCamera.ScreenshakeMethod.Basic); } } else { if (state == State.Charging) //if moving { Vector3 oldAngles = transform.localEulerAngles; //ok, so move. Can I see the player? Ray ray = new Ray(); RaycastHit hit; LayerMask mask = 1 << 19; float dist = 0; transform.LookAt(FPSMainScript.playerPos); ray.origin = transform.position; ray.direction = transform.forward; dist = Vector3.Distance(ray.origin, FPSMainScript.playerPos); if (!Physics.Raycast(ray, out hit, dist, mask)) { //can see the player tempGoal = goal; if (active == false) { Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.FPSMS_Intro); } active = true; } else { if (active) { //can't see the player. Find the node with the lowest steps, that I can see. int bestYet = 999; int bestIndex = -1; for (int i = 0; i < PF.nodes.Count; i++) { if (PF.nodes[i].steps < bestYet) //If it's worth checking if I can see it { transform.LookAt(PF.nodes[i].go.transform); ray.origin = transform.position; ray.direction = transform.forward; dist = Vector3.Distance(ray.origin, PF.nodes[i].go.transform.position); if (!Physics.Raycast(ray, out hit, dist, mask)) { bestYet = PF.nodes[i].steps; bestIndex = i; } } } tempGoal = transform.position; if (bestIndex != -1) { tempGoal = PF.nodes[bestIndex].go.transform.position; } } } if (active) { if (tempGoal.x > 36) { tempGoal.x = 36; } if (tempGoal.x < 12) { tempGoal.x = 12; } if (tempGoal.z > -72) { tempGoal.z = -72; } if (tempGoal.z < -96) { tempGoal.z = -96; } ScreenShakeCamera.Screenshake(0.01f, 0.1f, ScreenShakeCamera.ScreenshakeMethod.Basic); transform.localEulerAngles = oldAngles; transform.LookAt(tempGoal); // + offset); transform.Translate(0, 0, speed * Time.deltaTime); transform.localEulerAngles = oldAngles; } } } } }
void Update() { if (healthScript != null && healthScript.health <= 0) { return; } if (unicorn) { if (CheckRaycast() || charging) { charging = true; moveSpeed = unicornChargeSpd; } else { moveSpeed = unicornWalkSpd; } } //If the player is far enough away from me, destroy me (as I'm probably a spawned monster) if (destroyWhenFarAwayFromPlayer) { if (xa.player != null) { if (Vector2.Distance(xa.player.transform.position, transform.position) > 50) { Destroy(this.gameObject); } } } //Check for ground ray.origin = new Vector3(checkForGroundPoint.transform.position.x, checkForGroundPoint.transform.position.y, xa.GetLayer(xa.layers.RaycastLayer)); ray.direction = new Vector3(0, -1, 0); mask = 1 << 19; //Debug.DrawLine(new Vector3(ray.origin.x, ray.origin.y, 15), ray.GetPoint(checkForGroundDist), Color.yellow); if (Physics.Raycast(ray, out hit, checkForGroundDist, mask)) { transform.SetY(hit.point.y + checkForGroundDist); falling = false; } else { falling = true; } //Check for walls if (checkForWalls) { ray.origin = new Vector3(checkForWallsPoint.transform.position.x, checkForWallsPoint.transform.position.y, xa.GetLayer(xa.layers.RaycastLayer)); ray.direction = new Vector3(-transform.localScale.x, 0, 0); mask = 1 << 19 | 1 << 25; //Debug.DrawLine(new Vector3(ray.origin.x, ray.origin.y, 15), ray.GetPoint(checkForWallsDist), Color.yellow); if (Physics.Raycast(ray, out hit, checkForWallsDist, mask)) { transform.SetScaleX(-transform.localScale.x); if (charging) { charging = false; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact); ScreenShakeCamera.Screenshake(0.2f, 0.15f, ScreenShakeCamera.ScreenshakeMethod.Basic); Vector3 pos = hit.point; pos.y += 0.19f; pos.z = xa.GetLayer(xa.layers.Explo1); Vector3 dir = new Vector3(0, 0, 0); if (transform.localScale.x == 1) { dir = new Vector3(0, -90, 90); } if (transform.localScale.x == -1) { dir = new Vector3(-180, -90, 90); } GameObject tempGo = Instantiate(impactDust, pos, Quaternion.Euler(dir)); tempGo.transform.SetParent(xa.createdObjects.transform); } } } //is the ground under me? if (falling) { vel.y -= gravity * Time.deltaTime * fa.pausedFloat; if (vel.y < -8) { vel.y = -8; } //vel.x += 0.2f * Time.deltaTime; //if(vel.x > 0) {vel.x = 0; } vel.x = 0; } else { vel.x = -moveSpeed * Time.deltaTime * fa.pausedFloat * transform.localScale.x; vel.y = 0; } transform.Translate(vel); }
public void SwordUpdate() { if (Controls.GetInputDown(Controls.Type.Jump, novaPlayerScript.playerNumber) && !xa.playerHasJetpack) { //Debug.Log("PRESSED JUMP WHILE AIRSWORDING"); storedJump = true; } switch (swordState) { case SwordState.Setup: { hitDeadlyBoxCollider = false; swordDir = Vector3.zero; if (xa.playerControlsHeldDir < 0) { swordDir.x = -1; } if (xa.playerControlsHeldDir >= 0) { swordDir.x = 1; } swordState = SwordState.Charge; //play sound effect Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.SwordSlice); ScreenSlash.ScreenSlashOn(transform.position.y); previousTime = Time.timeScale; Time.timeScale = timeSlowEffect; xa.playerAirSwording = true; //gotBoost = false; novaPlayerScript.Unstick(); } break; case SwordState.Charge: { float dist = swordSpeed * fa.deltaTime; //raycast for blocks LayerMask swordMask = 1 << 19 | 1 << 21; //Only hits hitboxes on the NovaBlock layer Ray ray = new Ray(); RaycastHit hit1 = new RaycastHit(); RaycastHit hit2 = new RaycastHit(); RaycastHit hit3 = new RaycastHit(); ray.direction = swordDir; float tempSpeed = swordSpeed; bool hitSomething = false; bool raycastsHitSomething = false; float half = (novaPlayerScript.plHeight * 0.5f); // + 0.1f;//ghx Vector3 v1 = Vector3.zero; Vector3 v2 = Vector3.zero; float raycastLayer = xa.GetLayer(xa.layers.RaycastLayer); ray.origin = new Vector3(transform.position.x, transform.position.y, raycastLayer); v1 = ray.origin; v1.z = 33; if (Physics.Raycast(ray, out hit1, dist, swordMask)) { /* v2 = hit1.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/ raycastsHitSomething = true; } ray.origin = new Vector3(transform.position.x, transform.position.y + half, raycastLayer); v1 = ray.origin; v1.z = 33; if (Physics.Raycast(ray, out hit2, dist, swordMask)) { /* v2 = hit2.point; v2.z = 33; Debug.DrawLine(v1, v2, Color.yellow, 5);*/ raycastsHitSomething = true; } ray.origin = new Vector3(transform.position.x, transform.position.y - half, raycastLayer); v1 = ray.origin; v1.z = 33; if (Physics.Raycast(ray, out hit3, dist, swordMask)) { /* v2 = hit3.point; v2.z = 33;Debug.DrawLine(v1, v2, Color.yellow, 5); */ raycastsHitSomething = true; } if (raycastsHitSomething) { float finalDist = 9999; Vector3 finalPoint = Vector3.zero; Collider finalCollider = null; int hitChoice = 0; float dist1 = 9999; float dist2 = 9999; float dist3 = 9999; if (hit1.collider != null) { dist1 = hit1.distance; } if (hit2.collider != null) { dist2 = hit2.distance; } if (hit3.collider != null) { dist3 = hit3.distance; } hitChoice = 3; if (dist1 <= dist2 && dist1 <= dist3) { hitChoice = 1; } if (dist2 <= dist1 && dist2 <= dist3) { hitChoice = 2; } if (dist3 <= dist1 && dist3 <= dist2) { hitChoice = 3; } //Debug.Log("Hit choice: " + hitChoice + ", D1: " + dist1 + ", D2: " + dist2 + ", D3: " + dist3); if (hitChoice == 1) { finalDist = hit1.distance; finalPoint = hit1.point; finalCollider = hit1.collider; } if (hitChoice == 2) { finalDist = hit2.distance; finalPoint = hit2.point; finalCollider = hit2.collider; } if (hitChoice == 3) { finalDist = hit3.distance; finalPoint = hit3.point; finalCollider = hit3.collider; } // Debug.Log("HIT SOMETHING"); tempSpeed = finalDist; hitSomething = true; transform.SetX(finalPoint.x); /* * //Debug.Log("AirSwordHitSOmething: " + xa.playerBoxWidth + ", " + xa.playerBoxHeight); * Vector3 a1 = transform.position; * a1.z = 33; * Vector2 a2; * * //draw up * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.y += xa.playerBoxHeight * 0.5f; * //Debug.DrawLine(a1, a2, Color.green, 5); * * //draw down * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.y -= xa.playerBoxHeight * 0.5f; * //Debug.DrawLine(a1, a2, Color.green, 5); * * //draw left * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.x -= xa.playerBoxWidth * 0.5f; * //Debug.DrawLine(a1, a2, Color.green, 5); * * //draw right * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.x += xa.playerBoxWidth * 0.5f; * Debug.DrawLine(a1, a2, Color.green, 5); * * * //draw along the top * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.y += xa.playerBoxHeight * 0.5f; * a2.x -= xa.playerBoxWidth * 0.5f; * Debug.DrawLine(a1, a2, Color.green, 5); * * //draw along the bottom * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.y -= xa.playerBoxHeight * 0.5f; * a2.x -= xa.playerBoxWidth * 0.5f; * Debug.DrawLine(a1, a2, Color.green, 5); * * //draw along the left * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.y += xa.playerBoxHeight * 0.5f; * a2.x += xa.playerBoxWidth * 0.5f; * Debug.DrawLine(a1, a2, Color.green, 5); * * //draw along the right * a2 = new Vector3(a1.x, a1.y, a1.z); * a2.y -= xa.playerBoxHeight * 0.5f; * a2.x += xa.playerBoxWidth * 0.5f; * Debug.DrawLine(a1, a2, Color.green, 5); */ Info infoScript = null; if (hitChoice == 1) { infoScript = hit1.collider.GetComponent <Info>(); } if (hitChoice == 2) { infoScript = hit2.collider.GetComponent <Info>(); } if (hitChoice == 3) { infoScript = hit3.collider.GetComponent <Info>(); } if (infoScript != null) { if (infoScript.killPlayer) { hitDeadlyBoxCollider = true; } } HittableByAirsword hittableScript = finalCollider.gameObject.GetComponent <HittableByAirsword>(); if (hittableScript != null) { hittableScript.HitByPlayer(); /*if (hittableScript.giveAirswordBoost) * { * gotBoost = true; * }*/ } } if (hitSomething) { swordState = SwordState.WrapUp; } else { Vector3 swordVel = new Vector3(); swordVel.x = (swordDir.x * tempSpeed) * fa.deltaTime; swordVel.y = (swordDir.y * tempSpeed) * fa.deltaTime; int split = 15; for (int m = split; m > 0; m--) { CheckForItems(dist * 1f, transform.position); CheckHurtZones(); transform.Translate(swordVel / split); } //transform.Translate(swordVel); } if (!NovaPlayerScript.checkPlayerDeathBox(transform.position) && !novaPlayerScript.ThreeDee) { novaPlayerScript.hpScript.health = 0; swordState = SwordState.WrapUp; } if (novaPlayerScript.hpScript.health <= 0) { swordState = SwordState.WrapUp; } } break; case SwordState.WrapUp: { if (novaPlayerScript.altTrailPS_Normal != null) { novaPlayerScript.altTrailPS_Normal.Play(); novaPlayerScript.altTrailPS_Airsword.Stop(); } ScreenSlash.ScreenSlashOff(); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact); ScreenShakeCamera.Screenshake(1, 0.25f, ScreenShakeCamera.ScreenshakeMethod.Basic); xa.playerAirSwording = false; Time.timeScale = previousTime; //1f; //Time.timeScale = 0.7f;//previousTime;//1f; swordState = SwordState.Setup; novaPlayerScript.state = NovaPlayerScript.State.NovaPlayer; novaPlayerScript.DidAirSwordImpact = true; novaPlayerScript.vel.y = 0; if (hitDeadlyBoxCollider) { novaPlayerScript.hpScript.health = 0; } if (novaPlayerScript.hpScript.health <= 0) { if (novaPlayerScript.hpScript.setPosWhenKilled) { transform.SetX(novaPlayerScript.hpScript.posWhenKilled.x); transform.SetY(novaPlayerScript.hpScript.posWhenKilled.y); } } /*if (gotBoost) * { * novaPlayerScript.GotAirswordBoost(); * }*/ if (storedJump) { storedJump = false; novaPlayerScript.ExternalPossibleJump(); } } break; } }
void HandleBoss() { //Debug.Log("State: " + state + ", Intro: " + intro + ", Outro: " + outro + ", choice: " + choice + ", ChoicePhase: " + choiceStage); switch (state) { case State.Intro: switch (intro) { case Intro.StartLanding: landing_legs.transform.SetY(-8.62f); landing_head.transform.SetY(-2f); landing_arms.transform.SetY(-4.44f); landing_body.transform.SetY(-4.47f); landing_legs.transform.AddY(23); landing_head.transform.AddY(23); landing_arms.transform.AddY(23); landing_body.transform.AddY(23); iTween.MoveTo(landing_legs, iTween.Hash("delay", 0.3f, "y", -8.62f, "time", 0.3f, "easetype", iTween.EaseType.easeOutSine, "looptype", iTween.LoopType.none)); iTween.MoveTo(landing_head, iTween.Hash("delay", 0.3f, "y", -2f, "time", 0.27f, "easetype", iTween.EaseType.easeOutSine, "looptype", iTween.LoopType.none)); iTween.MoveTo(landing_arms, iTween.Hash("delay", 0.3f, "y", -4.44f, "time", 0.33f, "easetype", iTween.EaseType.easeOutSine, "looptype", iTween.LoopType.none)); iTween.MoveTo(landing_body, iTween.Hash("delay", 0.3f, "y", -4.47f, "time", 0.3f, "easetype", iTween.EaseType.easeOutSine, "looptype", iTween.LoopType.none)); intro = Intro.Impact; state = State.Waiting; timeSet = fa.time; delay = 0.37f; break; case Intro.Impact: ScreenShakeCamera.Screenshake(2, 0.35f, ScreenShakeCamera.ScreenshakeMethod.Basic); GameObject go = Instantiate(blastEffect, blastPoint.transform.position, blastPoint.transform.rotation); intro = Intro.Yell; state = State.Waiting; timeSet = fa.time; delay = 0.5f; break; case Intro.Yell: //Yell(); intro = Intro.AfterYell; state = State.Waiting; timeSet = fa.time; delay = 0.1f; break; case Intro.AfterYell: intro = Intro.End; state = State.Waiting; timeSet = fa.time; delay = 0.1f; break; } break; case State.Decide: if (healthScript.health > 100 && healthScript.health <= 125 && choiceStage != ChoiceStage.Phase2_Fireballs) { choice = 0; choiceStage = ChoiceStage.Phase2_Fireballs; } if (healthScript.health > 0 && healthScript.health <= 100 && choiceStage != ChoiceStage.Phase5_CuteGhost) { choice = 0; choiceStage = ChoiceStage.Phase4_Vanish; } if (healthScript.health <= 0 && choiceStage != ChoiceStage.Phase99_DerpyGhostDeath) { choice = 0; choiceStage = ChoiceStage.Phase99_DerpyGhostDeath; } if (choiceStage == ChoiceStage.Phase1_ChargeAndScythe) { if (choice == 0) { choice = 1; state = State.Idle; } else if (choice == 1) { state = State.Charging; if (healthScript.health < 180) { choice = 2; } else { choice = 3; } } else if (choice == 2) { state = State.Attacking; choice = 3; } else if (choice == 3) { choice = 4; state = State.Stunned; } else if (choice == 4) { choice = 0; state = State.LongIdle; } } else if (choiceStage == ChoiceStage.Phase2_Fireballs) { if (choice == 0) { choice = 1; state = State.Idle; } else if (choice == 1) { choice = 2; state = State.Attacking2; } else if (choice >= 2) { choice = 0; state = State.Stunned; } } else if (choiceStage == ChoiceStage.Phase4_Vanish) { choice = 0; state = State.DieToGhost; choiceStage = ChoiceStage.Phase5_CuteGhost; } else if (choiceStage == ChoiceStage.Phase5_CuteGhost) { state = State.CuteGhost; } else if (choiceStage == ChoiceStage.Phase99_DerpyGhostDeath) { state = State.Outro; outro = Outro.StartTweening; EnterOutro(); } break; case State.Waiting: if (fa.time > (timeSet + delay)) { timeSet = 0; delay = 0; if (intro != Intro.End) { //If the intro isn't finished, go back to the intro state = State.Intro; } else if (outro != Outro.End && outro != Outro.NotStartedYet) { state = State.Outro; } else if (lastState == State.DieToGhost) { state = State.DieToGhost2; } else { state = State.Decide; } } break; case State.Idle: timeSet = fa.time; delay = 0.8f; EnterIdle(); state = State.Waiting; break; case State.LongIdle: timeSet = fa.time; delay = 1f; EnterIdle(); state = State.Waiting; break; case State.Stunned: timeSet = fa.time; delay = 5; EnterStunned(); GameObject g4 = Instantiate(aboutToFlipPrefab, stunnedMuzzlePoint.transform.position, stunnedMuzzlePoint.transform.rotation); state = State.Waiting; break; case State.Attacking: timeSet = fa.time; delay = 3; EnterAttacking(); state = State.Waiting; GameObject g1 = Instantiate(scythPrefab, muzzlePoint1.transform.position, muzzlePoint1.transform.rotation); //GameObject g2 = Instantiate(scythPrefab,muzzlePoint2.transform.position,muzzlePoint2.transform.rotation); GameObject g3 = Instantiate(scythPrefab, muzzlePoint3.transform.position, muzzlePoint3.transform.rotation); ScytheScript ss = null; ss = g1.GetComponent <ScytheScript>(); ss.vel = new Vector3(-6, -6, 0); //ss = g2.GetComponent<ScytheScript>(); //ss.vel = new Vector3(-14,11,0); ss = g3.GetComponent <ScytheScript>(); ss.vel = new Vector3(-6, 4, 0); break; case State.Attacking2: timeSet = fa.time; delay = 5; EnterAttacking2(); state = State.Waiting; break; case State.Big: timeSet = fa.time; delay = 3; EnterBig(); state = State.Waiting; break; case State.Charging: EnterCharging(); iTween.MoveTo(Controller_Charging, iTween.Hash("x", -21.5f, "time", 1f, "easetype", iTween.EaseType.linear)); iTween.MoveTo(Controller_Charging, iTween.Hash("delay", 1f, "x", 10.27f, "time", 1f, "easetype", iTween.EaseType.linear)); iTween.ScaleTo(Controller_ChargingSubController, iTween.Hash("delay", 1f, "x", -1, "time", 0)); iTween.ScaleTo(Controller_ChargingSubController, iTween.Hash("delay", 2f, "x", 1, "time", 0)); timeSet = fa.time; delay = 2f; state = State.Waiting; break; case State.DieToGhost: EnterDieToGhost(); dieToGhost_AniScript.Play(); dieToGhost_Ghost.transform.SetX(3.5f); dieToGhost_Ghost.transform.SetY(-14.86f); iTween.MoveTo(dieToGhost_Ghost, iTween.Hash("delay", 1f, "y", 0.14, "time", 1f, "easetype", iTween.EaseType.easeInOutSine)); lastState = State.DieToGhost; timeSet = fa.time; delay = 2f; state = State.Waiting; break; case State.DieToGhost2: if (xa.pgMode) { DieToGhostText.text = "Cray cray, bro bro!"; } else { DieToGhostText.text = "F**k it!"; } iTween.MoveTo(dieToGhost_Ghost, iTween.Hash("delay", 1f, "y", 18.11, "time", 1f, "easetype", iTween.EaseType.easeInOutSine)); Instantiate(dieToGhost_Corpse, dieToGhost_CorpseMuzzlePoint.transform.position, dieToGhost_CorpseMuzzlePoint.transform.rotation); lastState = State.None; timeSet = fa.time; delay = 3f; state = State.Waiting; break; case State.CuteGhost: EnterCuteGhost(); if (nonRandomCuteGhostCycle == 0) { nonRandomCuteGhostCycle = 1; ghostSkull.transform.position = new Vector3(19f, 9.5f, 55); iTween.MoveTo(ghostSkull, iTween.Hash("x", -28.9f, "y", -9.1f, "time", 5f, "easetype", iTween.EaseType.linear)); } else if (nonRandomCuteGhostCycle == 1) { nonRandomCuteGhostCycle = 2; ghostSkull.transform.position = new Vector3(4.1f, 16.2f, 55); iTween.MoveTo(ghostSkull, iTween.Hash("x", -3.7f, "y", -13f, "time", 5f, "easetype", iTween.EaseType.linear)); } else if (nonRandomCuteGhostCycle == 2) { nonRandomCuteGhostCycle = 3; ghostSkull.transform.position = new Vector3(21f, 5f, 55); iTween.MoveTo(ghostSkull, iTween.Hash("x", -30f, "y", 5f, "time", 5f, "easetype", iTween.EaseType.linear)); } else if (nonRandomCuteGhostCycle == 3) { nonRandomCuteGhostCycle = 0; ghostSkull.transform.position = new Vector3(21f, -4.4f, 55); iTween.MoveTo(ghostSkull, iTween.Hash("x", -30f, "y", -4.4f, "time", 5f, "easetype", iTween.EaseType.linear)); } timeSet = fa.time; delay = 6f; state = State.Waiting; break; case State.Outro: switch (outro) { case Outro.StartTweening: toSay = "Nooooooooooooo!\nMy beautiful butt!"; OutroText.text = ""; firstYell = false; finalSkull.transform.SetX(31); finalSkull.transform.SetY(-9); iTween.MoveTo(finalSkull, iTween.Hash("x", -4f, "y", -2f, "time", 2f, "easetype", iTween.EaseType.easeOutSine, "looptype", iTween.LoopType.none)); outro = Outro.Yell; state = State.Waiting; timeSet = fa.time; delay = 2.2f; break; case Outro.Yell: if (!firstYell) { firstYell = true; Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.MegaSatan_Scream); } if (toSay.Length > 0) { string chop = "" + toSay[0]; toSay = toSay.Remove(0, 1); OutroText.text += chop; outro = Outro.Yell; delay = 0.05f; } else { outro = Outro.AfterYell; delay = 0.5f; } state = State.Waiting; timeSet = fa.time; break; case Outro.AfterYell: outro = Outro.DropButt; state = State.Waiting; timeSet = fa.time; delay = 0.1f; break; case Outro.DropButt: goldenButt.transform.SetParent(null, true); //goldenButt.transform.SetScaleX(12); //goldenButt.transform.SetScaleY(12); iTween.MoveTo(goldenButt, iTween.Hash("x", -2f, "y", -8.9f, "time", 1f, "easetype", iTween.EaseType.easeOutBounce)); iTween.RotateBy(goldenButt, iTween.Hash("z", 1, "time", 1f, "easetype", iTween.EaseType.easeInOutSine)); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.MegaSatan_Bounce); outro = Outro.Explode; state = State.Waiting; timeSet = fa.time; delay = 2f; break; case Outro.Explode: Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.MegaSatan_Explo); //ScreenShakeCamera.Screenshake(2, 0.45f, ScreenShakeCamera.ScreenshakeMethod.Basic); Instantiate(flameDeathExplo, outroMuzzlePoint.transform.position, outroMuzzlePoint.transform.rotation); Instantiate(sparksDeathExplo, outroMuzzlePoint.transform.position, outroMuzzlePoint.transform.rotation); Instantiate(epicDeathPinwheel, outroMuzzlePoint.transform.position, outroMuzzlePoint.transform.rotation); outro = Outro.Portal; state = State.Waiting; timeSet = fa.time; delay = 3f; break; case Outro.Portal: portal.SetActive(true); outro = Outro.End; state = State.Dead; timeSet = fa.time; delay = 1f; break; } break; } }
void Update() { float fireOut = 0.7f; float fireIn = 0.3f; switch (stage) { case 0: //move to the top NormalHead.SetActive(true); ScreamingHead.SetActive(false); beam.Stop(); iTween.MoveTo(beamHurtZones, iTween.Hash("islocal", true, "x", 42, "time", fireIn, "easetype", iTween.EaseType.linear)); iTween.MoveTo(this.gameObject, iTween.Hash("islocal", true, "y", 1.35f, "x", 16f, "time", 1f, "easetype", iTween.EaseType.easeInOutSine)); stage = 1; timeset = fa.time; delay = 2; break; case 1: //wait if (fa.time > (timeset + delay)) { stage = 2; } break; case 2: //Breath fire NormalHead.SetActive(false); ScreamingHead.SetActive(true); beam.Play(); iTween.MoveTo(beamHurtZones, iTween.Hash("islocal", true, "x", -2, "time", fireOut, "easetype", iTween.EaseType.linear)); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.MegaSatan_Scream); timeset = fa.time; delay = 5; stage = 3; break; case 3: //wait to stop breathing fire if (fa.time > (timeset + delay)) { stage = 4; } break; case 4: //stop breathing fire, move down NormalHead.SetActive(true); ScreamingHead.SetActive(false); beam.Stop(); iTween.MoveTo(beamHurtZones, iTween.Hash("islocal", true, "x", 42, "time", fireIn, "easetype", iTween.EaseType.linear)); iTween.MoveTo(this.gameObject, iTween.Hash("islocal", true, "y", -9.8f, "x", 16f, "time", 1f, "easetype", iTween.EaseType.easeInOutSine)); stage = 5; timeset = fa.time; delay = 2; break; case 5: //wait to stop moving down, if (fa.time > (timeset + delay)) { stage = 6; } break; case 6: //breath fire NormalHead.SetActive(false); ScreamingHead.SetActive(true); beam.Play(); iTween.MoveTo(beamHurtZones, iTween.Hash("islocal", true, "x", -2, "time", fireOut, "easetype", iTween.EaseType.linear)); timeset = fa.time; delay = 5; stage = 7; break; case 7: //wait to stop breathing fire, if (fa.time > (timeset + delay)) { stage = 0; } break; } }
void Start() { ScreenShakeCamera.Screenshake(1, 0.2f, ScreenShakeCamera.ScreenshakeMethod.Basic); Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.RockImpact); }