private void CharacterDeath_Died(CharacterDeath source, CharacterDeadBody deadBody) { OneShotAudioEffect effect = OneShotAudioEffectPooler.Get(); effect.Set(source.Transform.position); effect.gameObject.SetActive(true); }
private void FixedUpdate() { if (!Check.Evaluate()) { return; } gameObject.SetActive(false); PlayerStatistics.AddCoin(); OneShotAudioEffect effect = OneShotAudioEffectPooler.Get(); effect.Set(transform.position); effect.gameObject.SetActive(true); }
public void Ray(Vector2 target) { if (!newAimTimer.Execute(Time.fixedDeltaTime)) { newAimTimer.SetTime(NewAimTime); aimTime = Random.Range(MinAimTime, MaxAimTime); } Vector2 dir = target - (Vector2)Origin.position; Rest((Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg) + 90f); const float maxDistance = 1000f; LaserTransform.position = Origin.position; LaserTransform.rotation = Quaternion.Euler(0f, 0f, Angle); Vector2 raySize = new Vector2(0.375f, 0.5f); RaycastHit2D hit = Physics2D.BoxCast(Origin.position, raySize, Angle, Direction, maxDistance, Action.ObstacleLayerMask); float dis; if (hit.collider) { dis = hit.distance; LaserSpriteRenderer.size = new Vector2(1f, (dis * (1f / 0.625f)) + 0.5f); } else { dis = maxDistance; LaserSpriteRenderer.size = new Vector2(1f, dis); } LaserGameObject.SetActive(true); foreach (RaycastHit2D h in Physics2D.BoxCastAll(Origin.position, raySize, Angle, Direction, dis, Action.KillLayerMask)) { OneShotAudioEffect effect = Action.LaserHitOneShotAudioEffectPooler.Get(); effect.Set(h.transform.position); effect.gameObject.SetActive(true); CharacterDeath.Kill(h.collider); } }