public void DrawGizmos() { var tSceneBounds = sceneBounds(); // Draw direction foreach (var data in Enteties) { var boundRadius = data.scaleFactor * data.radius; // Draw a circle around the entity. if (Physics2DUtils.CircleWithin(tSceneBounds, data.position, boundRadius)) { Gizmos.color = Color.blue.WithAlpha(0.5f * data.alpha); } else { Gizmos.color = Color.yellow.WithAlpha(0.5f * data.alpha); } Gizmos.DrawWireSphere(data.position, boundRadius); // Draw the direction. Gizmos.color = Color.green; Gizmos.DrawLine(data.Position, (Vector3)data.position + data.Rotation * Vector3.up * boundRadius); } }
public void Update(BaseLivingEntityConfig entityConfig) { var tSceneBounds = sceneBounds(); var deltaTime = Time.deltaTime; var refenceScale = entetiesReferenceScale(); var referenceAlpha = entetiesReferenceAlpha(); var referenceSpeed = entetiesReferenceSpeed(); bool updateEntity(LivingEntityData data) { var deltaPosition = (Vector2)(data.Rotation * Vector3.up * data.speed * referenceSpeed * deltaTime); data.position += deltaPosition; data.scaleFactor = refenceScale; data.alphaFactor = referenceAlpha; if (data.alpha < 1) { data.alpha = Mathf.Clamp(data.alpha + deltaTime * AlphaFadeOutSpeed, 0, 1); } var boundRadius = data.scaleFactor * data.radius; return(Physics2DUtils.CircleWithin(tSceneBounds, data.position, boundRadius)); } for (int i = 0; i < _enteties.Count; i++) { var entityData = _enteties[i]; if (!updateEntity(entityData)) { CreateOrReinitLivingEntityData(entityConfig, ref entityData); } } if (useSort()) { _enteties.Sort(_sEntetiesComparer); } }