private void Start() { Player = GameObject.FindGameObjectWithTag("Player"); playerTransform = Player.transform; if (!playerTransform) { Debug.LogWarning("Player not found by Game Manager."); } playerRigidbody = Player.GetComponent <Rigidbody2D>(); if (!playerRigidbody) { Debug.LogWarning("Rigidbody2D not found on player."); } playerRewindTime = Player.GetComponent <RewindTime>(); if (!playerRigidbody) { Debug.LogWarning("RewindTime not found on player."); } playerAnimator = Player.GetComponent <Animator>(); if (!playerRigidbody) { Debug.LogWarning("Animator not found on player."); } if (!swordEffect) { Debug.LogWarning("Sword Effect not attached to Game Manager!"); } swordEffectAnimator = swordEffect.GetComponent <Animator>(); waitUntilPlayerPositionTooLow = new WaitUntil(PlayerPositionTooLow); waitForFlashTime = new WaitForSeconds(flashTime); waitForSwordDuration1SecondLess = new WaitForSeconds(swordDuration - 1f); waitWhilePlayerAtMaxHealth = new WaitWhile(PlayerAtMaxHealth); Setup(); }
// Update is called once per frame void Update() { Collider2D[] cols = Physics2D.OverlapCircleAll(transform.position, enterRadius); foreach (Collider2D col in cols) { GameObject obje = col.gameObject; if (obje.layer == 11 || obje.layer == 14) { if (obje.GetComponent <RewindTime>()) { RewindTime rewinder = obje.GetComponent <RewindTime>(); if (!rewinder.isRewinding && !rewinder.cantRewind) { if (obje.GetComponent <Rigidbody2D>().bodyType != RigidbodyType2D.Static) { GameObject summon = Instantiate(blueEffect); summon.transform.position = obje.transform.position; rewinder.StartRewind(); } } else { rewinder.ResetTimer(); } } } } }
// Use this for initialization void Start() { blend = FindObjectOfType <BlendCharacters>(); rewind = FindObjectOfType <RewindTime>(); newParent = parent; }