void FixedUpdate() { //Debug.Log(transform.rotation); float inputX = Input.GetAxisRaw("Horizontal") > 0 ? 1 : (Input.GetAxisRaw("Horizontal") < 0 ? -1 : 0); float inputZ = Input.GetAxisRaw("Vertical") > 0 ? 1 : (Input.GetAxisRaw("Vertical") < 0 ? -1 : 0); if (inputX != 0 || inputZ != 0) { var cam = Camera.main; var forward = cam.transform.forward; var right = cam.transform.right; forward.y = 0f; right.y = 0f; forward.Normalize(); right.Normalize(); Vector3 desiredMoveDirection = forward * inputZ + right * inputX; transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(desiredMoveDirection), 0.1f); rigidBody.velocity = desiredMoveDirection * Time.fixedDeltaTime * 500; animator.SetFloat("Blend", 1, 0.3f, Time.fixedDeltaTime); if (!soundsPlayer.IsPlaying(0)) { soundsPlayer.Play(0); } } else { rigidBody.velocity = Vector3.zero; animator.SetFloat("Blend", 0, 0.15f, Time.fixedDeltaTime); soundsPlayer.Stop(0); } }
public void OnPointerEnter() { if (!_button.interactable) { return; } _soundsPlayer.Play("Hover"); ShowArrows(); }
protected virtual void Die() { stateMachine.ExitState(); if (Anim != false) { Anim.enabled = false; } spriteAnim !.SetTrigger(Dying); var damageableAreas = GetComponentsInChildren <EnemyDamageableArea>(); foreach (var damageableArea in damageableAreas) { damageableArea.DisableCollider(); } damagingArea.DisableCollider(); HideShadows(); _enemyDeathParticles.PlayParticles(); _essenceOfPunishmentSpawner.SpawnEssences(BaseParameters.Stats.essenceOfPunishmentAmount); SoundsPlayer.Play("Dying"); onDie?.Invoke(); if (!BaseParameters.hasBeenSpawned) { SaveSystem.AddEnemyDead(BaseParameters.id); } }
public void SetLights(bool value) { soundsPlayer.Play(value ? 1 : 0); for (int i = 0; i < lights.Count; i++) { lights[i].intensity = value ? 2 : 0; } }
protected void Shoot() { fireAudio.Play(SoundsPlayer.Selection.Randomly, audioSource, 1f); if (muzzleFlash) { muzzleFlash.Play(true); } float spread = spreadAim; RaycastHit hitInfo; var firePos = new Vector3(user.transform.position.x, user.transform.position.y + user.GetComponent <CapsuleCollider>().height / 2, user.transform.position.z); Ray ray = new Ray(firePos, transform.forward); Vector3 spreadVector = user.transform.TransformVector(new Vector3(Random.Range(-spread, spread), Random.Range(-spread, spread), 0f)); ray.direction = Quaternion.Euler(spreadVector) * ray.direction; if (debugVisual) { Debug.DrawLine(firePos, firePos + user.transform.forward * distanceMax, Color.red, 1100); } if (Physics.Raycast(ray, out hitInfo, distanceMax, damageMask, QueryTriggerInteraction.Ignore)) { if (hitInfo.collider.gameObject == user) { return; } float impulse = hitImpact.GetImpulseAtDistance(hitInfo.distance, distanceMax); float damage = hitImpact.GetDamageAtDistance(hitInfo.distance, distanceMax); SpawnHitEffect(hitInfo); SpawnHitSound(hitInfo); var damageable = hitInfo.collider.GetComponent <IDamageable>(); if (damageable != null) { var damageData = new DamageEventData(-damage, user, hitInfo.point, ray.direction, impulse); damageable.TakeDamage(damageData); } else if (hitInfo.rigidbody) { hitInfo.rigidbody.AddForceAtPosition(ray.direction * impulse, hitInfo.point, ForceMode.Impulse); } } if (tracer) { var temp = Instantiate(tracer, transform.position, Quaternion.LookRotation(ray.direction)); Destroy(temp, 1); } }
private void DirectionalAttack(Vector2 direction) { SetState(DirectionalAttackState); var force = directionalAttackInitialForce; force *= SaveSystem.currentMaskType == PlayerMaskController.MaskType.ScarletMask ? 1.9f : 1; force *= SaveSystem.currentMaskType == PlayerMaskController.MaskType.VigorousMask ? 1.25f : 1; Rigidbody.velocity = force * direction; SoundsPlayer.Play("Throwing"); }
void FixedUpdate() { if (posTarget != null && Vector3.Distance(transform.position, posTarget) > 0.1f) { transform.rotation = rotTarget; Vector3 dir = (posTarget - transform.position).normalized; rigidBody.velocity = dir * Time.fixedDeltaTime * 500; animator.SetFloat("Blend", 1, 0.3f, Time.fixedDeltaTime); if (!soundsPlayer.IsPlaying(0)) { soundsPlayer.Play(0); } } else { rigidBody.velocity = Vector3.zero; animator.SetFloat("Blend", 0, 0.15f, Time.fixedDeltaTime); soundsPlayer.Stop(0); } }
public void SetState(bool open) { Debug.Log("DOOR " + open); if (tween != null) { LeanTween.cancel(tween.id); } opened = open; tween = LeanTween.moveLocal(door, new Vector3(open ? 2.8f : 0f, door.transform.localPosition.y, door.transform.localPosition.z), 0.5f); tween.setOnComplete(() => tween = null); soundsPlayer.Play(open ? 1 : 0); }
private void PlayStepSound() { SoundsPlayer.Play("Step"); }
public void PlaySpawnSound() { soundsPlayer.Play(0); }
public void BallDestroyed() { soundsPlayer.Play(0); light.SetActive(true); }