public virtual void Grow() { if (!isPlanted) { return; } if (map.CheckPlant(transform.position, true)) { currentValue = currentValue.AddClamped(model.AsBodyPart().Growth, 0f, model.AsBodyPart().Max); } else { } for (int i = 0; i < GrowingLimbs.Length; i++) { if (i >= (int)currentValue - 1) { break; } GrowingLimbs[i].SetActive(true); } daysPlanted++; if (daysPlanted >= model.AsBodyPart().Days) { CheckGrowth(); } }
public override void Use(GrabbableObject o) { if (!o.GetType().IsSubclassOf(typeof(BodyPart)) || ((BodyPart)o).IsPlanted || currentValue == maxValue) { return; } sfx.PlayAudio(sfx.Blend); currentValue = currentValue.AddClamped(o.AsBodyPart().Value, 0f, maxValue); RefreshBlenderFill(); Destroy(o.gameObject); }
IEnumerator SpawnForce(GameObject g) { Vector2 r = new Vector2(Random.Range(-.1f, .1f), Random.Range(-.1f, .1f)); float d = 0.2f; float t = 0f; while (t < 1f) { t = t.AddClamped(Time.deltaTime / d, 0f, 1f); g.transform.position += r.xyz() * (1f - t); yield return(0); } yield return(0f); }
IEnumerator Falling(Vector2 movement) { float duration = 0.5f; float t = 0f; Vector2 velocity = (movement + (transform.position.xy() - playerRB.position)).normalized / 20f; float rotMod = Random.Range(-1f, 1f); while (t < 1f) { t = t.AddClamped(Time.deltaTime / duration, 0f, 1f); transform.eulerAngles += new Vector3(0f, 0f, rotMod * velocity.x * 100f * (1f - t)); transform.position += velocity.xyz() * (1f - t); yield return(0f); } yield return(0f); }