/// <summary> /// Respawn Boing at the last checkpoint reached. /// </summary> public void RespawnAtCheckpoint() { DeathCount++; // Determine area of the checkpoint. nextArea = lastCheckpoint.areaGameObject; Transform parentInArea = nextArea.transform.Find("Level/Character"); // Only one boing can exists. if (boing == null) { boing = Instantiate(GameManager.instance.boingPrefab, parentInArea); boingScript = boing.GetComponent <BoingManager>(); } // Set respawn position. Vector3 newPos = lastCheckpoint.gameObject.transform.position; newPos.z = 0.0f; // Move Boing and camera then fade out. nextPosition = newPos; MoveBoingToNewArea(); // Reset AI like mushroom. ResetAI(); GameManager.instance.TriggerFadeOut(); }
private IEnumerator BounceWhileAffected() { isBouncing = true; // Trigger bouncing effect. ToggleAIBehaviours(false); animator.SetBool("Bouncing", isBouncing); noteEmitter.SetActive(isBouncing); BoingManager player = GameObject.FindGameObjectWithTag("Player").GetComponent <BoingManager>(); // Don't do anything while Boing bounce. yield return(new WaitWhile(() => (player != null && player.IsBouncing))); // Cooldown. Reset if Boing bounce one more time. timer = BounceEffectDuration; while (timer >= 0.0f) { yield return(new WaitForSeconds(0.5f)); timer -= 0.5f; } StopBouncing(); }
// Setup all components and variables of the gamemanager. private void SetupLevel() { // Recover Boing and camera. boing = GameObject.FindGameObjectWithTag("Player"); boingScript = boing.GetComponent <BoingManager>(); cameraFollow = Camera.main.GetComponent <CustomCamera2DFollow>(); // Setup Ui. GameObject ui = GameObject.FindGameObjectWithTag("UI"); if (ui) { hudMgr = ui.transform.Find("HUD").GetComponent <LevelHUDManager>(); levelIntroMgr = ui.transform.Find("LevelIntro").GetComponent <LevelIntroManager>(); levelOutroMgr = ui.transform.Find("LevelOutro").GetComponent <LevelOutroManager>(); } // Retrieve informations about the level. featherCount = data.totalFeathers; specialItemPresent = data.itemsPresent; // Update level HUD and level outro. UpdateLifePoints(boingScript.maxLifePoints); hudMgr.SetupFeatherIndicators(featherCount); for (int i = 0; i < specialItemPresent.Length; i++) { hudMgr.SetupSpecificItem(i, specialItemPresent[i]); levelOutroMgr.SetupSpecificItem(i, specialItemPresent[i]); } }
private void Start() { if (GameManager.instance.levelMgr) { m_Character = GetComponent <PlatformerCharacter2D>(); boing = GetComponent <BoingManager>(); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { BoingManager boing = other.gameObject.GetComponent <BoingManager>(); // Kill boing after a delay. boing.Die(deathDelay); } // Destroy anything else which enter in this killzone. Except if it's the killzone of a forced scrolling area. else { if (!isMovingKillzone) { Destroy(other.gameObject, deathDelay); } } }