protected override void Awake() { base.Awake(); timer = 0f; numOfSpawned = 0; curState = MovStates.Walking; }
protected void Walking() { if (isFacingRight) { vel.x = Xvel; } else { vel.x = -Xvel; } vel.y -= fallingAccel * Time.fixedDeltaTime; if (ec.IsGrounded) { vel.y = 0f; } else if (vel.y < -fallingSpeed) { vel.y = -fallingSpeed; } if (timer >= groundTime) { curState = MovStates.Flying; timer = 0f; } }
protected void Flying() { if (isFacingRight) { vel.x = flyingXvel; } else { vel.x = -flyingXvel; } vel.y = riseSpeed; if (distToMario.y < -blocksAboveMario || (ec.IsCeiling && ec.IsColliding)) { curState = MovStates.Hovering; timer = 0f; vel.y = 0f; } }
protected void Hovering() { if (isFacingRight) { vel.x = flyingXvel; } else { vel.x = -flyingXvel; } if (timer > (airTime / numbertoSpawn) * (numOfSpawned + 1)) { int numOfFallingMG = 0; foreach (var item in allMG) { if (!item.isAttached) { numOfFallingMG++; } if (numOfFallingMG >= numbertoSpawn) { break; } } if (numOfFallingMG < numOfSpawned + 1) { Instantiate(Microgoomba, transform.position, transform.rotation); } numOfSpawned++; } if (timer >= airTime) { curState = MovStates.Walking; timer = 0f; vel.y = 0f; numOfSpawned = 0; } }