private void CheckGround() { RaycastHit2D hit = Physics2D.BoxCast(coll.bounds.center, coll.bounds.size, 0f, Vector2.down, boxReach, groundLayerMask); if (hit.collider != null) { if (currentFallTime >= maxFallTime) { this.enabled = false; slime.Die(); } else if (slime.GetSlimeStatus() == Slime.SlimeStatus.InAir) { currentFallTime = 0f; slime.KeepWalking(); } } else if (slime.GetSlimeStatus() == Slime.SlimeStatus.InAir) { if (currentFallTime > 0.1f) { slime.Fall(); } } else { slime.Fall(false); } }
IEnumerator OnHorn(Slime slime, List <Slime> ableSlimes) { yield return(new WaitForSeconds(pauseSeconds)); slime.KeepWalking(); ableSlimes.ForEach(slime => { if (slime.GetSlimeStatus() == Slime.SlimeStatus.InAir) { slime.Fall(); } else { slime.KeepWalking(); } }); }
public void Spawn() { if (stopSpawning == true) { CancelInvoke(spawnMethod); return; } GameObject instantiatedSpawn = Instantiate(spwanee, spawnPosition, Quaternion.identity); instantiatedSpawn.transform.SetParent(transform); Slime slime = instantiatedSpawn.GetComponent <Slime>(); switch (spawnType) { case SpawnType.Down: slime.Fall(); break; case SpawnType.Right: slime.KeepWalking(); break; default: slime.KeepWalking(); break; } slimes.Add(slime); if (slimes.Count >= spawnNumber) { stopSpawning = true; } }