// Update is called once per frame void Update() { // Check is game is not currently paused if (canMutate && !gameController.IsGamePaused() && !selfOrganism.IsFading() && Random.Range(0f, 1f) < mutationProba) { // Attempt to mutate organism every frame DuplicateShield(); } }
protected void Update() { // Check is game is not currently paused if (canDuplicate && !gameController.IsGamePaused() && !selfOrganism.IsFading()) { // Attempt to duplicate organism every frame TryToDuplicateOrganism(); } }
// Fire projectile over time public IEnumerator StartRepeatFire() { do { // Keep the player rotated toward the target RotatePlayer(fireTarget.transform.position - transform.position); Fire(); // yield return null; yield return(new WaitForSeconds(heavyWeaponSelected ? fireRateP2 : fireRateP1)); // Keep firing until cell die or get out of range } while (fireTarget && !fireTarget.IsFading() && Vector3.Distance(transform.position, fireTarget.transform.position) < maxRange && !heavyWeaponSelected && gameController.CanPlayerShoot()); fireTarget = null; }
protected virtual void FixedUpdate() { if (!hidden) { // Only change moveDirection if a cell is targeted if (target && !target.IsFading()) { moveDirection = target.transform.position - transform.position; moveDirection.Normalize(); } //Add force to the projectile rb.AddForce(moveDirection * speed, ForceMode2D.Impulse); //Clamp max velocity rb.velocity = Vector2.ClampMagnitude(rb.velocity, maxVelocity); } }