void UpdateHumans() { foreach (GameObject h in m_Humans) { Dude dude = h.GetComponent <Dude>(); if (!dude.isAlive) { m_Trash.Add(h); continue; } if (dude.isFlying) { if ((dude.target.transform.position - dude.transform.position).magnitude <= 2.5f) { Game.instance.monster.OpenMouth(); } if ((dude.target.transform.position - dude.transform.position).magnitude <= 0.5f) { dude.isAlive = false; Game.instance.monster.Eat(); } Vector3 targetScale = Vector3.one; float completion = (dude.distance / dude.distanceToGo); if (completion <= 0.5f) { targetScale *= 3f; } dude.transform.localScale = Vector3.Slerp(dude.transform.localScale, targetScale, Time.deltaTime * 4f); } else { if (dude.hasWall && null != dude.wall) { if (!dude.target.GetComponent <Slot>().isFree) { dude.Drop(); dude.GoBack(); } else { if (dude.target.GetComponent <PolygonCollider2D>().OverlapPoint(dude.wall.transform.position)) { dude.Build(); dude.GoBack(); } } } else { if (!h.GetComponent <SpriteRenderer>().isVisible&& !dude.hasWall) { m_Trash.Add(h); } } } Vector3 direction = dude.direction; if (dude.lurching) { float sin = Mathf.Sin(Time.time * 5f); direction.x += sin * 0.1f; direction.y += sin * 0.1f; direction.Normalize(); } float speed = dude.speed; if (dude.speedVariant) { float sin = Mathf.Sin(Time.time * 4) * 0.5f + 0.5f; speed += 2f * (sin * 0.7f + 0.3f); } if (!dude.isFlying && Game.instance.monster.PointInSlime(h.transform.position)) { speed = 0.1f; dude.sweatFX.SetActive(true); } else { dude.sweatFX.SetActive(false); } Vector3 move = direction * speed * Time.deltaTime; dude.distance += move.magnitude; h.transform.position += move; float angle = Vector3.Angle(Vector3.left, direction); Vector3 cross = Vector3.Cross(Vector3.left, direction); if (cross.z < 0) { angle = -angle; } h.transform.localRotation = Quaternion.Euler(0, 0, angle); } foreach (GameObject h in m_Trash) { m_Humans.Remove(h); Destroy(h); } m_Trash.Clear(); }