public void ReceiveHit(bool throughFeet) { if (invuln != null && !invuln.IsInvulnerable()) { AudioManager.GetInstance().PlayEffect(Sfx.ENEMY_HIT); if (deathType == DeathType.SLIME || deathType == DeathType.DIVIDE) { if (hits > 0) { var enemyComponent = GetComponent <Enemy>(); SpawnChildren(enemyComponent); } else { KillEnemy(throughFeet); } } else { hits--; if (hits <= 0) { KillEnemy(throughFeet); } else { invuln.SetInvulnerable(GameplayValues.GetEnemyInvulnerableTime()); } } } }
// These are the default new game values. public void SetGameReadyValues() { holyWaters = GameplayValues.GetHolyWaters(); score = 0; lives = 3; lastCheckpoint = null; SetLevelReadyValues(); }
private void FixedUpdate() { if (step == 1) { var bonusLimit = GameplayValues.GetBonusTimeForStage(gs.GetCurrentScene()); if (gs.currentSceneTime < bonusLimit) { timePoints = (bonusLimit - gs.currentSceneTime) * 10; } enemyPoints = gs.enemiesKilled.Count * 10; waferPoints = gs.obleas * 10; step = 2; } if (step == 2) { if (timePoints > 0) { timePoints -= 10; timePointsShown += 10; GameState.score += 10; } else { step = 3; } } if (step == 3) { if (enemyPoints > 0) { enemyPoints -= 10; enemyPointsShown += 10; GameState.score += 10; } else { step = 4; } } if (step == 4) { if (waferPoints > 0) { waferPoints -= 10; waferPointsShown += 10; GameState.score += 10; } else { step = 5; endPointCalc = Time.time; } } }
public void SetHalo() { var time = GameplayValues.GetInvulnerableBoostTime(); invuln.SetInvulnerableNoBlink(time); invulnerableAura.SetActive(true); AudioManager.GetInstance().PlaySecondaryMusic(Music.INVULNERABLE, time); haloActive = true; }
// Use this for initialization void Start() { combo = new List <fish.FishType>(); iconBackgroundsList = new List <Image>(); iconFishList = new List <Image>(); iconSlideDistancesList = new List <float>(); iconSlideCounterList = new List <float>(); gameplayValues = GameObject.Find("Manager").GetComponent <GameplayValues>(); animatingComboBreak = false; iconsFinishedSliding = 0; comboCanBeGenerated = true; }
public void ReceiveHit() { if (invuln.IsInvulnerable() || !movement.CanMove()) { return; } AudioManager.GetInstance().PlayEffect(Sfx.NUN_DAMAGED, 1f); GameState.holyWaters -= GameplayValues.watersPerHit; if (GameState.holyWaters > -1) { invuln.SetInvulnerable(GameplayValues.GetInvulnerableTime()); } }
void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <PlatformerMovement2D>() != null) { AudioManager.GetInstance().PlayEffect(Sfx.PICK_WAFER); Destroy(gameObject); var gs = GameState.GetInstance(); gs.obleas++; GameState.score += 5 * (int)GameState.difficulty; if (gs.obleas % GameplayValues.GetObleasForHolyWater() == 0) { GameState.holyWaters += 1; } GameState.GetInstance().objectsUsed.Add(uid); } }
public void DeathFinished() { AudioManager.GetInstance().StopAllMusic(); if (lives > 0) { if (GameplayValues.ReloadWatersOnDeath()) { holyWaters = GameplayValues.GetHolyWaters(); } lives -= 1; ReloadScene(); } else { GameOver(); } }
protected new void ReceiveHit(int number) { hits -= number; if (hits > 0) { AudioManager.GetInstance().PlayEffect(Sfx.BOSS_HIT); StartCoroutine("SetInvulnerable", invulnerableTime); } else { phasesDone++; if (phases == phasesDone) { Die(); } else { hits = GameplayValues.GetBossHits(); phase++; } } SetCounter(); }
// Specific death that creates smaller children with 1 hit point less. private void SpawnChildren(Enemy enemyComponent) { MarkAsDead(); var pos = enemyComponent != null? enemyComponent.initialPosition : gameObject.transform.position; var firstChild = Instantiate(gameObject, new Vector2(pos.x - 0.23f, pos.y - 0.07f), gameObject.transform.rotation); var secondChild = Instantiate(gameObject, new Vector2(pos.x + 0.23f, pos.y - 0.07f), gameObject.transform.rotation); // Make them smaller. var theScale = firstChild.transform.localScale; firstChild.transform.localScale = new Vector3(theScale.x * 0.75f, theScale.y * 0.75f, theScale.z); theScale = secondChild.transform.localScale; secondChild.transform.localScale = new Vector3(theScale.x * 0.75f, theScale.y * 0.75f, theScale.z); gameObject.SetActive(false); // Make the children invulnerable. firstChild.GetComponent <EnemyInvulnerability>().SetInvulnerable(GameplayValues.GetEnemyInvulnerableTime()); secondChild.GetComponent <EnemyInvulnerability>().SetInvulnerable(GameplayValues.GetEnemyInvulnerableTime()); // Give them the hitpoints. firstChild.GetComponent <PlayerHitReceiver>().hits = hits - 1; secondChild.GetComponent <PlayerHitReceiver>().hits = hits - 1; }
protected void ReceiveHit(int number) { hits -= number; if (hits > 0) { AudioManager.GetInstance().PlayEffect(Sfx.BOSS_HIT); StartCoroutine("SetInvulnerable", invulnerableTime); } else { phasesDone++; if (phases == phasesDone) { Die(); } else { // Me cago en Dios, Juanma. Ni Senior ni pollas, eres un MIERDAS. // Extremely hacky... hits = GameplayValues.GetBossHits(); phase++; } } }
private void Update() { DebugModeHotkeys(); if (!GameState.isGameLocked) { // Time the character has been idle. lastAction += Time.deltaTime; var downPressed = inputManager.IsActionPressed(GameCommand.DOWN); var upPressed = inputManager.IsActionPressed(GameCommand.UP); var leftPressed = inputManager.IsActionPressed(GameCommand.LEFT); var rightPressed = inputManager.IsActionPressed(GameCommand.RIGHT); // Hit management on overlapping objects if (overlapping != null) { if (overlapping && overlapping.activeSelf && overlapping.CompareTag(Tags.ENEMY_HIT) && !invuln.IsInvulnerable()) { EnemyHit(); } } // Halo management, if active. if (haloActive && !invuln.IsInvulnerable()) { haloActive = false; invulnerableAura.SetActive(false); } // Crouch management. if (crouching && !inputManager.IsActionPressed(GameCommand.DOWN)) { Uncrouch(); } // Looking up management. if (!inputManager.IsActionPressed(GameCommand.UP)) { lookingUp = false; } // Control grounded state and the related animations. if (controller.isGrounded) { AchievementManager.jumpKills = 0; velocity.y = 0; if (crouching) { SetAnimation(Animations.NUN_CROUCHING); } if (lookingUp && !leftPressed && !rightPressed) { SetAnimation(Animations.NUN_LOOKING_UP); } } else { // Clean parent from moving platforms if falling or jumping. if (transform.parent != null) { transform.parent = null; } } // Restore one way platform being detected if not pressing crouch+jump if (controller.ignoringOneWayPlatforms && (!downPressed || !inputManager.IsActionPressed(GameCommand.JUMP))) { controller.ignoringOneWayPlatforms = false; } // Horizontal movement. if (canMove && rightPressed) { shootingDirection = Direction.RIGHT; lastAction = 0; normalizedHorizontalSpeed = 1; if (controller.isGrounded && !crouching) { SetAnimation(Animations.NUN_WALKING); } if (!flipper.lookingRight) { flipper.Flip(); shootingDirection = Direction.RIGHT; } } else if (canMove && leftPressed) { shootingDirection = Direction.LEFT; lastAction = 0; normalizedHorizontalSpeed = -1; if (controller.isGrounded && !crouching) { SetAnimation(Animations.NUN_WALKING); } if (flipper.lookingRight) { flipper.Flip(); shootingDirection = Direction.LEFT; } } else { normalizedHorizontalSpeed = 0; velocity.x = 0; // Set the standing up idle animation if there's no movement. if (canMove && !crouching && !lookingUp && controller.isGrounded && lastAction < 4.99f) { SetAnimation(Animations.NUN_IDLE); } } // Shooting if (canMove && inputManager.IsActionPressed(GameCommand.SHOOT) && Time.time - lastProjectile >= projectileRatio) { AudioManager.GetInstance().PlayEffect(Sfx.SHOOT); lastAction = 0; ShootProjectile(); } // Jump only while grounded. // If you're holding down, jump down a platform. if (canMove && controller.isGrounded && inputManager.IsActionPressedOnce(GameCommand.JUMP)) { if (downPressed) { transform.parent = null; controller.ignoringOneWayPlatforms = true; } else { Jump(false); } } // This controls the variable jump. If the key stops being pressed, the velocity is set to 0. if (!ignoreJumpVariable && velocity.y > 0 && velocity.y < 6f && !inputManager.IsActionPressed(GameCommand.JUMP)) { velocity.y = 0; } // Crouch action. if (canMove && controller.isGrounded && downPressed) { lastAction = 0; Crouch(); } // Look up, only possible while in an idle animation (not moving). if (canMove && controller.isGrounded && upPressed && idleAnims.Contains(currentAnimation)) { lastAction = 0; lookingUp = true; } // Apply horizontal speed. var smoothedMovementFactor = controller.isGrounded ? groundDamping : inAirDamping; var actualRunSpeed = speedBuffed ? runSpeed * 2 : runSpeed; if (crouching) { actualRunSpeed /= 2; } velocity.x = Mathf.Lerp(velocity.x, normalizedHorizontalSpeed * actualRunSpeed, Time.deltaTime * smoothedMovementFactor); // Apply gravity before moving. velocity.y += gravity * Time.deltaTime; velocity.y = Mathf.Clamp(velocity.y, -18f, 18f); // Jumping sprite if (velocity.y > 0.8f || velocity.y < -0.8f) { SetAnimation(Animations.NUN_JUMPING); } controller.move(velocity * Time.deltaTime); // Grab our current velocity to use as a base for all calculations. velocity = controller.velocity; // Speed booooooooost if (speedBuffed && Time.time - speedBuffApplied >= GameplayValues.GetSpeedBuffDuration()) { speedBuffed = false; audioManager.UndoFasterSong(); } // Idle animation when no movement after 5 seconds. if (lastAction > 5f && lastAction <= 7.5f) { SetAnimation(Animations.NUN_WAITING); } if (lastAction > 7.5f && lastAction <= 16f) { SetAnimation(Animations.NUN_BORED); } if (lastAction > 16f) { SetAnimation(Animations.NUN_PRAYING); } } }
void Start() { LowPolyFish = _lowPolyFish; HookHit = _hookHit; gameEnded = false; SpawnBoat(_boatSpawn.position, _boatSetUp.position); SpawnHook(); SpawnRadar(); SpawnTrailer(); Boat.AssignRadar(Radar); Hook.AssignBoat(Boat); //Debug.Log(_generals.Count + " generals"); //InputTimer and basic should be on the same object, but I'm explictly calling in case they ever aren't //and therefore I can still get the script _inputTimer = GetComponent <InputTimer>(); if (!_inputTimer) { Debug.Log("ERROR: Cannot get a reference to InputTimer from the Manager object."); } GlobalUI = GetComponent <GlobalUI>(); if (!GlobalUI) { Debug.Log("ERROR: Cannot get a reference to GlobalUI from the Manager object."); } Scorehandler = GetComponent <ScoreHandler>(); if (!Scorehandler) { Debug.Log("ERROR: Cannot get reference to ScoreHandler from Manager object"); } Shoppinglist = GetComponent <ShoppingList>(); if (!Shoppinglist) { Debug.Log("ERROR: Cannot get reference to ShoppingList from Manager object"); } combo = GetComponent <Combo>(); if (!combo) { Debug.Log("ERROR: Cannot get reference to Combo from Manager object"); } Gameplayvalues = GetComponent <GameplayValues>(); if (!Gameplayvalues) { Debug.Log("ERROR: Cannot get reference to GameplayValues from Manager object"); } Tempfishspawn = GetComponent <FishSpawn>(); if (!Tempfishspawn) { Debug.Log("ERROR: Cannot get reference to TempFishSpawn from Manager object"); } Camerahandler = GetComponent <CameraHandler>(); if (!Camerahandler) { Debug.Log("ERROR: Cannot get reference to CameraHandler from Manager object"); } Seafloorspawning = GetComponent <SeafloorSpawning>(); if (!Seafloorspawning) { Debug.Log("ERROR: Cannot get reference to SeafloorSpawning from Manager object"); } Camerahandler.InitializeCameraHandler(); //Find out seaDepth floor = GameObject.FindGameObjectWithTag("Floor"); Vector3 difference = floor.transform.position - Boat.transform.position; seaDepth = Mathf.Abs(difference.y) - floor.transform.lossyScale.y / 2; //Getting the position and size of the zone where the jellyfish can move _jellyfishZoneSizeX = _jellyfishZone.transform.localScale.x / 2; _jellyfishZonePosX = _jellyfishZone.transform.position.x; _jellyfishZoneSizeY = _jellyfishZone.transform.localScale.y / 2; _jellyfishZonePosY = _jellyfishZone.transform.position.y; //Find out seaWidth //_docks = GameObject.FindGameObjectWithTag("Docks"); if (!_docks) Debug.Log("WARNING (Jellyfish uses this): You need to create the Docks and tag it with Docks"); //_endOfLevel = GameObject.FindGameObjectWithTag("EndOfLevel"); if (!_endOfLevel) Debug.Log("WARNING (Jellyfish uses this): You need to create an empy object, place it at the end of the level (x) and tag it with EndOfLevel"); //_seaWidth = Vector3.Distance(_docks.transform.position, _endOfLevel.transform.position); // }
public void Update() { // Pressing up, down, left, right, and jump + enter leads you to the select level screen. CheckLevelSelect(); CheckDebug(); // Choosing a difficulty level for a new game. if (choosingDifficulty && choosingForNewGame && inputManager.IsMenuStart() && !switchingScene && (!activedLevelSelect || inputManager.IsActionPressed(GameCommand.JUMP))) { switchingScene = true; GameState.difficulty = (Difficulty)difficultyIndex; audioManager.PlayEffect(Sfx.MENU_ACCEPT); gs.LoadScene(Scenes.MONASTERY_ACT_1, 0.5f); } // Choosing difficulty setting to continue the game. // Changing it overwrites the waters you get. if (choosingDifficulty && inputManager.IsMenuStart() && !switchingScene && (!activedLevelSelect || inputManager.IsActionPressed(GameCommand.JUMP))) { switchingScene = true; // Adapt holy waters to new difficulty. if (difficultyIndex != (int)savedState.difficulty) { var level = savedState.level == (Scenes.CREDITS) ? Scenes.FINAL_ZONE : savedState.level; savedState.level = level; savedState.holyWaters = GameplayValues.GetHolyWatersByLevel(level); savedState.difficulty = (Difficulty)difficultyIndex; } audioManager.PlayEffect(Sfx.MENU_ACCEPT); gs.LoadGame(savedState); } // Choosing a main option. if (!choosingDifficulty && inputManager.IsMenuStart() && !switchingScene && (!activedLevelSelect || inputManager.IsActionPressed(GameCommand.JUMP))) { audioManager.PlayEffect(Sfx.MENU_ACCEPT); if (optionIndex == 1) { difficultyIndex = (int)savedState.difficulty; chooseDifficultyMenu.SetActive(true); UpdateNunDifficultyIcon(); choosingDifficulty = true; choosingForNewGame = false; } else if (optionIndex == 2) { switchingScene = true; gs.LoadScene(Scenes.OPTIONS, 0.5f); } else if (optionIndex == 3) { Application.Quit(); } else if (optionIndex == -1) { switchingScene = true; gs.LoadScene(Scenes.TUTORIAL); } else { difficultyIndex = 2; chooseDifficultyMenu.SetActive(true); UpdateNunDifficultyIcon(); choosingDifficulty = true; choosingForNewGame = true; } } if (choosingDifficulty && (Input.GetKeyDown(KeyCode.Escape) || inputManager.IsActionPressed(GameCommand.SHOOT))) { chooseDifficultyMenu.SetActive(false); choosingDifficulty = false; } if (!choosingDifficulty) { CheckMenuNavigation(); } else { CheckDifficultyNavegation(); } // Fade out. if (switchingScene) { var color = spriteRenderer.color; color.a += 0.03f; spriteRenderer.color = color; } // Nun Icon position. nunIcon.anchoredPosition = iconPositions[optionIndex]; }