public void OnCheatMoney() { SCR_Profile.CheatMoney(); SCR_Audio.PlayClickSound(); UpdateMoneyNumber(); UpdateBoss(); }
private void Crash() { for (int i = 0; i < sprFragment.Length; i++) { GameObject frag = SCR_Pool.GetFreeObject(PFB_Fragment); frag.GetComponent <SCR_Fragment>().Spawn(x, y, sprFragment[i], 100, UFO_SCALE); } gameObject.SetActive(false); SCR_Gameplay.instance.flyingObject = null; smokeParticle.SetActive(false); crashParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, crashParticle.transform.position.z); foreach (Transform child in crashParticle.transform) { child.gameObject.SetActive(true); } broken = false; brokenCountdown = 0; angle = 0; transform.localEulerAngles = new Vector3(0, 0, angle); SCR_Gameplay.instance.ShakeCamera(0.3f); SCR_Gameplay.instance.FlashWhite(); SCR_Audio.PlayUFOExplosionSound(); }
private void Punch() { //SCR_Audio.PlayPunchNormalSound(); SCR_Audio.PlayPunchDirectSound(); float punchAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, bossScript.x, bossScript.y); float punchX = SECURITY_FORCE * SCR_Helper.Sin(punchAngle); float punchY = SECURITY_FORCE * (1 + SCR_Helper.Cos(punchAngle) * 0.33f); float particleX = (x + bossScript.x) * 0.5f; float particleY = (y + bossScript.y) * 0.5f; punchParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + particleX, particleY, punchParticle.transform.position.z); foreach (Transform child in punchParticle.transform) { child.gameObject.SetActive(true); } bossScript.Punch(punchX, Mathf.Abs(punchY), true); SCR_Gameplay.instance.SecurityPunchSuccess(bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight); //SCR_Gameplay.instance.AddMoneyAtPosition(SECURITY_MONEY, x + SCR_Gameplay.SCREEN_W * 0.5f, y - SCR_Gameplay.instance.cameraHeight); SCR_Gameplay.instance.AddMoneyAtPosition( SCR_Player.PUNCH_MONEY_START + SCR_Player.PUNCH_MONEY_STEP * (SCR_Gameplay.instance.comboCount - 1), x + SCR_Gameplay.SCREEN_W * 0.5f, y - SCR_Gameplay.instance.cameraHeight); }
public void OnPlay() { // Load latest level SCR_Profile.SelectBoss(bossSelecting); SCR_Audio.PlayClickSound(); SceneManager.LoadScene("GSGameplay/SCN_Gameplay"); }
public void OnSound() { SCR_Profile.ToggleSound(); RefreshSoundButtonStatus(); RefreshSoundStatus(); SCR_Audio.PlayClickSound(); }
public void OnReset() { SCR_Profile.ResetProfile(); SCR_Audio.PlayClickSound(); UpdateMoneyNumber(); UpdateBoss(); }
public void Thrown() { if (state == BossState.GRAB) { y = BOSS_START_Y; if (SCR_Profile.showTutorial == 1) { speedX = BOSS_TUTORIAL_SPEED_X * -direction; speedY = BOSS_TUTORIAL_SPEED_Y; } else { speedX = BOSS_THROWN_SPEED_X * -direction; speedY = BOSS_THROWN_SPEED_Y; } RandomRotate(); RandomFlyPose(); for (int i = 0; i < 3; i++) { moneyParticle[i].SetActive(true); } SCR_GrabbedSound.Stop(); SCR_Audio.PlayScreamSound(); } }
public override void Break() { base.Break(); angle = Random.Range(30, 60); if (Random.Range(0, 10) > 5) { angle = -angle; } speedX = SCR_Helper.Sin(angle) * BROKEN_SPEED; speedY = SCR_Helper.Cos(angle) * BROKEN_SPEED; smokeParticle.SetActive(true); transform.localEulerAngles = new Vector3(0, 0, angle); breakParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, breakParticle.transform.position.z); foreach (Transform child in breakParticle.transform) { child.gameObject.SetActive(true); } if (SCR_Profile.soundOn == 1) { GetComponent <AudioSource>().Stop(); } SCR_Audio.PlayObjectHitSound(); SCR_Audio.PlayUFOCollisionSound(); }
public void ThrowTheBoss() { if (state == PlayerState.GRAB) { SCR_Audio.PlayFirstPunchSound(); SwitchState(PlayerState.CHARGE); } }
public void Grabbed() { if (state == BossState.TALK) { SwitchState(BossState.GRAB); talkBubble.SetActive(false); SCR_GrabbedSound.Play(); SCR_Audio.StopTalkSound(); } }
public void OnBuy() { if (bossSelecting <= 2) { SCR_Profile.BuyBoss(bossSelecting); UpdateBoss(); UpdateMoneyNumber(); } SCR_Audio.PlayBuySound(); }
public void OnMainMenu() { if (imgNotice.activeSelf) { SCR_Profile.SelectBoss(shouldSelect); SCR_Profile.bosses[shouldSelect].recommended = 1; SCR_Profile.SaveProfile(); } SCR_Audio.PlayClickSound(); SceneManager.LoadScene("GSMenu/SCN_Menu"); }
public void OnPrev() { if (!scrScroll.tweening) { bossSelecting--; if (bossSelecting < 0) { bossSelecting = SCR_Profile.bosses.Length - 1; } UpdateBoss(); SCR_Audio.PlayClickSound(); scrScroll.ForceSnapProfileIndex(bossSelecting); } }
public void OnNext() { if (!scrScroll.tweening) { bossSelecting++; if (bossSelecting >= SCR_Profile.bosses.Length) { bossSelecting = 0; } UpdateBoss(); SCR_Audio.PlayClickSound(); scrScroll.ForceSnapProfileIndex(bossSelecting); } }
// ================================================== // ================================================== // Public functions // ================================================== public void GoGrabTheBoss() { if (state == PlayerState.TALK) { SCR_Audio.PlayTransformSound(); SwitchState(PlayerState.TRANSFORM); if (SCR_Profile.showTutorial == 1) { bossScript.HideTutorial(); } securityScript.StartCheer(); } }
public static void BreakFurniture(float x, float y, float force) { for (int i = 0; i < instance.furniture.Length; i++) { instance.furniture[i].GetComponent <SCR_Furniture>().Break(x, y, force); } if (SCR_Profile.bossSelecting == (int)BossType.THE_BOSS || SCR_Profile.bossSelecting == (int)BossType.THE_DICTATOR) { SCR_Audio.PlayBreakSound(0); // Furniture breaking } else if (SCR_Profile.bossSelecting == (int)BossType.MR_PRESIDENT || SCR_Profile.bossSelecting == (int)BossType.THE_GENERAL || SCR_Profile.bossSelecting == (int)BossType.ERIX_LUKE) { SCR_Audio.PlayBreakSound(1); // Leaf break } }
public void PerformPunch() { if (state == SecurityState.STAND || state == SecurityState.CHEER) { y = SCR_Gameplay.instance.cameraHeight - SECURITY_SIZE; if (y < SECURITY_START_Y) { y = SECURITY_START_Y; } trail.GetComponent <SCR_Trail>().JumpTo(x, y); trail.GetComponent <SCR_Trail>().TurnParticleOn(); SwitchState(SecurityState.FLY_UP); SCR_Audio.PlaySecurityFlyUpSound(); laughDelay = SECURITY_LAUGH_DELAY; } }
// ================================================== private void Ricochet() { if (state == PlayerState.FLY_UP) { if (ricocheted == false) { ricocheted = true; } else { speedY *= 0.8f; speedX *= 0.8f; } } else if (state == PlayerState.FLY_DOWN) { speedX *= 0.1f; } SCR_Audio.PlayBounceSound(); }
public override void Break() { base.Break(); for (int i = 0; i < sprFragment.Length; i++) { GameObject frag = SCR_Pool.GetFreeObject(PFB_Fragment); frag.GetComponent <SCR_Fragment>().Spawn(x, y, sprFragment[i], 200, BALLOON_SCALE); } destroyParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, destroyParticle.transform.position.z); foreach (Transform child in destroyParticle.transform) { child.gameObject.SetActive(true); } gameObject.SetActive(false); SCR_Gameplay.instance.flyingObject = null; SCR_Gameplay.instance.ShakeCamera(0.3f); SCR_Gameplay.instance.FlashWhite(); SCR_Audio.PlayBalloonExplosionSound(); }
// ================================================== private void Update() { float dt = Time.deltaTime; if (state == SecurityState.STAND) { } else if (state == SecurityState.CHEER) { } else if (state == SecurityState.FLY_UP) { float flyAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, bossScript.x, bossScript.y); speedX = SECURITY_SPEED * SCR_Helper.Sin(flyAngle); speedY = SECURITY_SPEED * SCR_Helper.Cos(flyAngle); var distance = SCR_Helper.DistanceBetweenTwoPoint(x, y, bossScript.x, bossScript.y); if (distance <= SECURITY_RANGE * bossScript.currentScale.x / bossScript.originalScale.x) { speedY = 0; trail.GetComponent <SCR_Trail>().TurnParticleOff(); Punch(); SwitchState(SecurityState.FLY_DOWN); } if (laughDelay > 0) { laughDelay -= dt; if (laughDelay <= 0) { SCR_Audio.PlaySecurityLaughSound(); } } } else if (state == SecurityState.FLY_DOWN) { SwitchState(SecurityState.FLY_DOWN); speedY -= SCR_Gameplay.GRAVITY * dt; } x += speedX * dt; y += speedY * dt; if (state == SecurityState.FLY_UP) { trail.GetComponent <SCR_Trail>().MoveTo(x, y); } else if (state == SecurityState.FLY_DOWN) { if (speedX < 0 && x <= -(SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f)) { x = -(SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f); speedX = -speedX; } else if (speedX > 0 && x >= (SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f)) { x = (SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f); speedX = -speedX; } if (y <= SCR_Gameplay.instance.cameraHeight - SECURITY_SIZE || y <= SECURITY_START_Y) { y = SECURITY_START_Y; speedX = 0; speedY = 0; SwitchState(SecurityState.STAND); landParticle.SetActive(true); landParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y + SECURITY_SMOKE_OFFSET_Y, landParticle.transform.position.z); } } transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, transform.position.z); transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE * direction, SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE, SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE); float shadowScale = 1 - (y - SECURITY_START_Y) / SECURITY_SHADOW_DISTANCE; if (shadowScale < 0) { shadowScale = 0; } shadow.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, shadow.transform.position.y, shadow.transform.position.z); shadow.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE * shadowScale * (-direction), SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE * shadowScale, SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE); }
public void Punch(float px, float py, bool isSecurityGuy) { if (state >= BossState.FLY_1 && state <= BossState.FLY_6) { float handicap = BOSS_MIN_HANDICAP + (y / BOSS_HANDICAP_HEIGHT) * (1 - BOSS_MIN_HANDICAP); if (handicap > 1) { handicap = 1; } speedX += px; if (speedX > handicap * BOSS_MAX_SPEED_X) { speedX = handicap * BOSS_MAX_SPEED_X; } else if (speedX < -handicap * BOSS_MAX_SPEED_X) { speedX = -handicap * BOSS_MAX_SPEED_X; } if (isSecurityGuy) { maxSpeedY = BOSS_MAX_SPEED_Y_BONUS; speedY += py; } else { if (speedY <= BOSS_MAX_SPEED_Y) { maxSpeedY = BOSS_MAX_SPEED_Y; speedY += py; if (speedY > BOSS_MAX_SPEED_Y) { speedY = BOSS_MAX_SPEED_Y; } } } RandomRotate(); SCR_Gameplay.instance.TriggerTutorial(TutorialStep.CONTINUE); RandomFlyPose(); if (particleID == 0) { for (int i = 0; i < 3; i++) { ParticleSystem.EmissionModule emission = moneyParticle[i].GetComponent <ParticleSystem>().emission; if (size == BossSize.BIG) { emission.rateOverTimeMultiplier = 120; } else { emission.rateOverTimeMultiplier = 40; } moneyParticle[i].GetComponent <ParticleSystem>().startSpeed = Random.Range(py * 0.012f, py * 0.014f); moneyParticle[i].SetActive(true); } particleID = 1; } else { for (int i = 3; i < 6; i++) { ParticleSystem.EmissionModule emission = moneyParticle[i].GetComponent <ParticleSystem>().emission; if (size == BossSize.BIG) { emission.rateOverTimeMultiplier = 120; } else { emission.rateOverTimeMultiplier = 40; } moneyParticle[i].GetComponent <ParticleSystem>().startSpeed = Random.Range(py * 0.012f, py * 0.014f); moneyParticle[i].SetActive(true); } particleID = 0; } SCR_Audio.PlayScreamSound(); bubble.GetComponent <SCR_Bubble>().Hit(); } }
private void Awake() { if (instance == null) { instance = this; source = GetComponent <AudioSource>(); DontDestroyOnLoad(gameObject); DontDestroyOnLoad(talkSource); if (LOAD_FROM_FILE == true) { scream = new AudioClip[8]; for (int i = 0; i < 8; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/VO/pdb_vo_hurt_v1_0" + (i + 1).ToString() + ".wav", scream, i)); } talk = new AudioClip[6]; for (int i = 0; i < 6; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/VO/pdb_vo_talk_v1_0" + (i + 1).ToString() + ".wav", talk, i)); } punchNormal = new AudioClip[5]; for (int i = 0; i < 5; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_punch_norm_0" + (i + 1).ToString() + ".wav", punchNormal, i)); } punchDirect = new AudioClip[5]; for (int i = 0; i < 5; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_punch_direct_hit_0" + (i + 1).ToString() + ".wav", punchDirect, i)); } punchRicochet = new AudioClip[5]; for (int i = 0; i < 5; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_punch_ricochet_0" + (i + 1).ToString() + ".wav", punchRicochet, i)); } flyUp = new AudioClip[5]; for (int i = 0; i < 5; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_flyup_0" + (i + 1).ToString() + ".wav", flyUp, i)); } bounce = new AudioClip[5]; for (int i = 0; i < 5; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_wall_bounce_0" + (i + 1).ToString() + ".wav", bounce, i)); } securityLaugh = new AudioClip[19]; for (int i = 0; i < 8; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/VO/pdb_security_guy_vo_0" + (i + 1).ToString() + ".wav", securityLaugh, i)); } for (int i = 9; i < 19; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/VO/pdb_security_guy_vo_" + (i + 1).ToString() + ".wav", securityLaugh, i)); } securityFlyUp = new AudioClip[5]; for (int i = 0; i < 5; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_security_flyup_0" + (i + 1).ToString() + ".wav", securityFlyUp, i)); } objectHit = new AudioClip[3]; for (int i = 0; i < 3; i++) { instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_obj_hit_0" + (i + 1).ToString() + ".wav", objectHit, i)); } breakSound = new AudioClip[2]; instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_start_break.wav", breakSound, 0)); instance.StartCoroutine(LoadFromFileAndPutToArray("Sound/Gameplay/pdb_start_tree.wav", breakSound, 1)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_start_transformation.wav", (x) => transform = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_start_first_punch.wav", (x) => firstPunch = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_lose.wav", (x) => fall = x)); instance.StartCoroutine(LoadFromFile("Sound/UI/pdb_ui_select.wav", (x) => click = x)); instance.StartCoroutine(LoadFromFile("Sound/UI/pdb_ui_back.wav", (x) => back = x)); instance.StartCoroutine(LoadFromFile("Sound/UI/pdb_ui_purchase.wav", (x) => buy = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_obj_drone_collision.wav", (x) => droneCollision = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_obj_drone_loop.wav", (x) => droneLoop = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_obj_drone_xplo.wav", (x) => droneExplosion = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_obj_balloon_xplo.wav", (x) => balloonExplosion = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_obj_ufo_collision.wav", (x) => ufoCollision = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_obj_ufo_loop.wav", (x) => ufoLoop = x)); instance.StartCoroutine(LoadFromFile("Sound/Gameplay/pdb_obj_ufo_xplo.wav", (x) => ufoExplosion = x)); } } else { Destroy(gameObject); } }
// ================================================== private void Punch(float distance) { float punchAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, bossScript.x, bossScript.y); float punchX = PLAYER_PUNCH_FORCE * SCR_Helper.Sin(punchAngle); float punchY = PLAYER_PUNCH_FORCE * (1 + SCR_Helper.Cos(punchAngle) * 0.33f); float particleX = (x + bossScript.x) * 0.5f; float particleY = (y + bossScript.y) * 0.5f; punchParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + particleX, particleY, punchParticle.transform.position.z); foreach (Transform child in punchParticle.transform) { child.gameObject.SetActive(true); } Material shockMaterial = punchParticle.transform.Find("Shock").GetComponent <Renderer>().sharedMaterial; int index = SCR_Gameplay.instance.comboCount; if (index < 0) { index = 0; } if (index > PUNCH_PARTICLE_COLORS.Length - 1) { index = PUNCH_PARTICLE_COLORS.Length - 1; } shockMaterial.SetColor("_TintColor", PUNCH_PARTICLE_COLORS[index]); bossScript.Punch(punchX, Mathf.Abs(punchY), false); if (ricocheted == true) { bossScript.ShowMoneyBag(); SCR_Gameplay.instance.ShowRicochet(bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight); SCR_Audio.PlayPunchRicochetSound(); int money = RICOCHET_MONEY; if (bossScript.size == BossSize.BIG) { money *= PUNCH_MONEY_BIG_MULTIPLIER; } SCR_Gameplay.instance.AddMoneyAtPosition(money, bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight); } else { SCR_Audio.PlayPunchNormalSound(); int money = PUNCH_MONEY_START + PUNCH_MONEY_STEP * SCR_Gameplay.instance.comboCount; if (bossScript.size == BossSize.BIG) { money *= PUNCH_MONEY_BIG_MULTIPLIER; } SCR_Gameplay.instance.AddMoneyAtPosition( money, bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight); } SCR_Gameplay.instance.PunchSuccess(bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight); punchCount = PLAYER_PUNCH_TIME; }
// ================================================== private void Update() { float dt = Time.deltaTime; if (SCR_Gameplay.instance.gameState == GameState.BOSS_FALLING) { dt = 0; } if (state >= BossState.FLY_1 && state <= BossState.FLY_6) { if (SCR_Profile.showTutorial == 1) { if (SCR_Gameplay.instance.tutorialStep == TutorialStep.AIM) { predictY = y - (SCR_Gameplay.GRAVITY * BOSS_TUTORIAL_DELTA * BOSS_TUTORIAL_DELTA) * 0.5f; tutorialCounter += dt * 100; tutorialFinger.transform.localPosition = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + SCR_Helper.Sin(tutorialCounter) * SCR_Gameplay.SCREEN_W * 0.3f, predictY, tutorialTarget.transform.localPosition.z); tutorialFinger.SetActive(true); tutorialFinger.GetComponent <SCR_TutorialFinger>().Stop(); } else if (SCR_Gameplay.instance.tutorialStep == TutorialStep.PUNCH) { predictX = x + speedX * BOSS_TUTORIAL_DELTA; predictY = y - (SCR_Gameplay.GRAVITY * BOSS_TUTORIAL_DELTA * BOSS_TUTORIAL_DELTA) * 0.5f; tutorialTarget.transform.localPosition = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + predictX, predictY, tutorialTarget.transform.localPosition.z); tutorialTarget.SetActive(true); //tutorialFinger.transform.localPosition = new Vector3 (SCR_Gameplay.SCREEN_W * 0.5f + predictX, predictY, tutorialTarget.transform.localPosition.z); tutorialFinger.SetActive(false); //tutorialFinger.GetComponent<SCR_TutorialFinger>().Animate(); if (!tutorialRange) { tutorialRange = Instantiate(PFB_TutorialRange); tutorialRange.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * 3, SCR_Gameplay.SCREEN_SCALE * 3, 1); tutorialRange.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + SCR_Gameplay.instance.player.GetComponent <SCR_Player>().x, SCR_Gameplay.instance.cameraHeight - SCR_Player.PLAYER_SIZE, tutorialRange.transform.position.z); float angle = SCR_Helper.AngleBetweenTwoPoint(SCR_Gameplay.instance.player.GetComponent <SCR_Player>().x, SCR_Gameplay.instance.cameraHeight - SCR_Player.PLAYER_SIZE, predictX, predictY); tutorialRange.transform.localEulerAngles = new Vector3(0, 0, -angle); } } } if (SCR_Gameplay.instance.tutorialStep != TutorialStep.AIM && SCR_Gameplay.instance.tutorialStep != TutorialStep.PUNCH) { float oldSpeedY = speedY; if (bubbleTime > 0) { speedY -= SCR_Gameplay.GRAVITY * dt * (speedY / 10000); } else { speedY -= SCR_Gameplay.GRAVITY * dt; } if (speedY < 0 && oldSpeedY >= 0 && SCR_Gameplay.instance.tutorialStep == TutorialStep.THROW) { SCR_Gameplay.instance.TriggerTutorial(TutorialStep.AIM); } if (speedY > maxSpeedY) { speedY = maxSpeedY; } y += speedY * dt; //if (speedY > maxSpeedY) y += maxSpeedY * dt; //else y += speedY * dt; if (magnetTime > 0) { if (SCR_Gameplay.instance.player.GetComponent <SCR_Player>().IsFlyingUp()) { float flyAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, SCR_Gameplay.instance.player.GetComponent <SCR_Player>().x, SCR_Gameplay.instance.player.GetComponent <SCR_Player>().y); float attractX = BOSS_MAGNET_FORCE * SCR_Helper.Sin(flyAngle); float attractY = BOSS_MAGNET_FORCE * SCR_Helper.Cos(flyAngle); // we don't need this actually x += attractX * dt; } } x += speedX * dt; if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { x = -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X); if (bubbleTime > 0) { speedX = -speedX * 0.7f; } else { speedX = -speedX; } RandomRotate(); SCR_Audio.PlayBounceSound(); } else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { x = (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X); if (bubbleTime > 0) { speedX = -speedX * 0.7f; } else { speedX = -speedX; } RandomRotate(); SCR_Audio.PlayBounceSound(); } if (y <= SCR_Gameplay.instance.cameraHeight - BOSS_SIZE) { SwitchState(BossState.FALL); SCR_Gameplay.instance.gameState = GameState.BOSS_FALLING; SCR_Gameplay.instance.Lose(); if (size == BossSize.BIG) { Shrink(); } SCR_Audio.PlayFallSound(); } rotation += rotateSpeed * dt; float r = currentScale.x / originalScale.x; atmosBurn.SetActive(true); atmosBurn.transform.localPosition = new Vector3( SCR_Gameplay.SCREEN_W * 0.5f + x + BOSS_BURN_OFFSET_X * r, y + BOSS_BURN_OFFSET_Y * r, atmosBurn.transform.localPosition.z); float alpha = (speedY - BOSS_BURN_SPEED_MIN) / (BOSS_BURN_SPEED_MAX - BOSS_BURN_SPEED_MIN); if (alpha > BOSS_BURN_ALPHA) { alpha = BOSS_BURN_ALPHA; } Color color = atmosBurn.GetComponent <SpriteRenderer>().color; color.a = alpha; atmosBurn.GetComponent <SpriteRenderer>().color = color; if (alpha > 0) { SCR_Gameplay.instance.ShakeCamera(0.016f); } } } else if (state == BossState.FALL) { speedY -= SCR_Gameplay.GRAVITY * dt; x += speedX * dt; y += speedY * dt; if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { x = -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X); speedX = -speedX; } else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { x = (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X); speedX = -speedX; } if (y <= BOSS_START_Y) { y = BOSS_START_Y; SwitchState(BossState.SLIDE); SCR_Audio.PlayPunchNormalSound(); smokeParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x + BOSS_SMOKE_OFFSET_X * direction, y + BOSS_SMOKE_OFFSET_Y, smokeParticle.transform.position.z); landParticle.SetActive(true); landParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y + BOSS_SMOKE_OFFSET_Y, landParticle.transform.position.z); } rotation = 0; } else if (state == BossState.SLIDE) { if (speedX > 0) { speedX -= BOSS_SLIDE_FRICTION * dt; direction = 1; if (speedX < 0) { speedX = 0; SwitchState(BossState.RUN); SCR_RunSound.Play(); } } else { speedX += BOSS_SLIDE_FRICTION * dt; direction = -1; if (speedX > 0) { speedX = 0; SwitchState(BossState.RUN); SCR_RunSound.Play(); } } smokeParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x + BOSS_SMOKE_OFFSET_X * direction, y + BOSS_SMOKE_OFFSET_Y, smokeParticle.transform.position.z); ParticleSystem.EmissionModule emission = smokeParticle.GetComponent <ParticleSystem>().emission; emission.rateOverTime = Mathf.Abs(speedX) * BOSS_SMOKE_RATE; x += speedX * dt; if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { x = -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X); direction = 1; speedX = -speedX; } else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { x = (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X); direction = -1; speedX = -speedX; } rotation = 0; } else if (state == BossState.RUN) { x += direction * BOSS_RUN_SPEED * dt; rotation = 0; if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { SCR_RunSound.Fade(); } else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X)) { SCR_RunSound.Fade(); } } transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, transform.position.z); transform.localScale = new Vector3(currentScale.x * (-direction), currentScale.y, currentScale.z); transform.localEulerAngles = new Vector3(0, 0, rotation); bossName.transform.localPosition = new Vector3( SCR_Gameplay.SCREEN_W * 0.5f + x, y + BOSS_NAME_OFFSET_Y * currentScale.x / originalScale.x, bossName.transform.localPosition.z); float shadowScale = 1 - (y - BOSS_START_Y) / BOSS_SHADOW_DISTANCE; if (shadowScale < 0) { shadowScale = 0; } shadow.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, shadow.transform.position.y, shadow.transform.position.z); shadow.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * BOSS_SCALE * shadowScale, SCR_Gameplay.SCREEN_SCALE * BOSS_SCALE * shadowScale, SCR_Gameplay.SCREEN_SCALE * BOSS_SCALE); for (int i = 0; i < 6; i++) { moneyParticle[i].transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, moneyParticle[i].transform.position.z); } moneyBagParticle.transform.position = moneyParticle[0].transform.position; if (enlargeTime > 0) { enlargeTime -= dt; if (enlargeTime <= 0) { Shrink(); enlargeTime = 0; } else if (enlargeTime < BOSS_FLASH_DURATION * 0.8f) { Flash(); } } if (bubbleTime > 0) { bubbleTime -= dt; if (bubbleTime < BOSS_FLASH_DURATION * 0.8f) { Flash(); } } else { bubble.GetComponent <SCR_Bubble>().FadeOut(); } if (magnetTime > 0) { magnetTime -= dt; if (magnetTime < BOSS_FLASH_DURATION * 0.8f) { Flash(); } } else { attract.GetComponent <SCR_Attract>().FadeOut(); } if (state == BossState.TALK) { if (talkCounter < BOSS_TALK_START) { talkCounter += dt; if (talkCounter >= BOSS_TALK_START) { SCR_Audio.PlayTalkSound(); dialogueID++; if (dialogueID >= dialogue.Length) { dialogueID = 0; } talkBubble.transform.GetChild(0).GetChild(0).gameObject.GetComponent <Text>().text = dialogue[dialogueID]; talkBubble.SetActive(true); } } else { talkCounter += dt; if (talkCounter >= BOSS_TALK_END) { talkBubble.SetActive(false); talkCounter = 0; } } } }
public void PerformPunch() { if (target.activeSelf) { targetX = currentAimX - SCR_Gameplay.SCREEN_W * 0.5f; targetY = currentAimY; if (SCR_Profile.showTutorial == 1) { SCR_Gameplay.instance.ShowSecurityProgress(); if (SCR_Gameplay.instance.tutorialStep == TutorialStep.AIM) { target.SetActive(false); return; } if (SCR_Gameplay.instance.tutorialStep == TutorialStep.PUNCH) { if (SCR_Helper.DistanceBetweenTwoPoint(targetX, targetY, bossScript.predictX, bossScript.predictY) > PLAYER_TUTORIAL_RANGE) { target.SetActive(false); //return; } } } y = SCR_Gameplay.instance.cameraHeight - PLAYER_SIZE; if (y < PLAYER_START_Y) { y = PLAYER_START_Y; } if (targetX >= x) { direction = 1; } else { direction = -1; } flyAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, targetX, targetY); speedX = PLAYER_FLY_SPEED * SCR_Helper.Sin(flyAngle); speedY = PLAYER_FLY_SPEED * SCR_Helper.Cos(flyAngle); trail.GetComponent <SCR_Trail>().JumpTo(x, y); trail.GetComponent <SCR_Trail>().TurnParticleOn(); target.SetActive(false); SwitchState(PlayerState.FLY_UP); SCR_Audio.PlayFlyUpSound(); ricocheted = false; if (SCR_Profile.showTutorial == 1) { SCR_Gameplay.instance.TriggerTutorial(TutorialStep.FLY_UP); bossScript.HideTutorial(); } } else { target.SetActive(false); } }
public void OnReplay() { SCR_RunSound.Stop(); SCR_Audio.PlayClickSound(); SceneManager.LoadScene("GSGameplay/SCN_Gameplay"); }