private void OnTriggerEnter2D(Collider2D collision) { LilypadController lily = collision.GetComponent <LilypadController>(); if (lily != null) { lily.Kill(); } }
private void Outside() { pad = null; GetComponent <Collider2D>().isTrigger = false; GetComponent <Rigidbody2D>().useFullKinematicContacts = true; StopAllCoroutines(); transform.SetParent(null); SetSpeed(velocity); }
private void Inside(LilypadController ctrl) { pad = ctrl; GetComponent <Collider2D>().isTrigger = true; GetComponent <Rigidbody2D>().velocity = Vector2.zero; GetComponent <Rigidbody2D>().isKinematic = true; Vector2 direction = (transform.position - pad.transform.position).normalized; StartCoroutine(StartBiting(direction)); transform.SetParent(ctrl.transform); }
private void OnTriggerStay2D(Collider2D other) { if (position_reached) { return; } LilypadController lily = other.GetComponent <LilypadController>(); if (lily != null) { parentLily = lily; } }
public void StartGame() { if (LilySpawner == null) { LilySpawner = FindObjectOfType <LilypadSpawner>(); } LilySpawner.gameObject.SetActive(true); if (originalLilyDelay == -1) { originalLilyDelay = LilySpawner.SpawnInfo.DelayBetweenSpawns; } LilySpawner.SpawnInfo.DelayBetweenSpawns /= PointsMultiplier; if (BugsSpawner == null) { BugsSpawner = FindObjectOfType <BugsSpawner>(); } BugsSpawner.gameObject.SetActive(true); if (originalBugsDelay == -1) { originalBugsDelay = BugsSpawner.SpawnInfo.DelayBetweenSpawns; } BugsSpawner.SpawnInfo.DelayBetweenSpawns /= PointsMultiplier; LilySpawner.SpawnLilypad(); if (Frog == null) { Frog = FindObjectOfType <FrogController>(); } Frog.gameObject.SetActive(true); LilypadController spawnedLily = GetCloseLilyPad(Frog.transform.position, 100); Frog.transform.position = spawnedLily.transform.position; Frog.SetParentLily(spawnedLily); if (UICtrl == null) { UICtrl = FindObjectOfType <UIController>(); } UICtrl.ToggleMainMenu(false); if (inputCtrl == null) { inputCtrl = GetComponent <InputController>(); } inputCtrl.enabled = true; }
private void Update() { if (!pad && bugRenderer.isVisible) { LilypadController _pad = GameManager.I.GetCloseLilyPad(transform.position, EatingRadius); if (_pad) { Inside(_pad); } } else if (pad && Vector2.Distance(transform.position, pad.transform.position) > EatingRadius + 0.2f) { Outside(); } }
public void ReturnLilyToPull(LilypadController _lily) { lilypadsPull.Add(_lily); lilypadsActive.Remove(_lily); _lily.gameObject.SetActive(false); }
public void SetParentLily(LilypadController _parentLily) { parentLily = _parentLily; transform.parent = parentLily.transform; }