public void Punch() { if (!punchPos || !settings) { return; } Collider2D[] cols = Physics2D.OverlapCircleAll(punchPos.position, settings.PunchRadiusDetection, settings.BreakableTileMask); if (cols.Length > 0) { sfx.PlayBreak(); CircleCollider2D caps = GetComponent <CircleCollider2D>(); Vector2 pos = transform.position; pos.x -= player.FacingDirection * caps.radius; Collider2D[] colliderBehind = Physics2D.OverlapBoxAll(pos, Vector2.up + (Vector2.right * .5f), 0); if (colliderBehind.Length <= 0 && punchPos.position.y < transform.position.y + (settings.PunchRadiusDetection)) { transform.DOMoveX((transform.position.x) - player.FacingDirection * settings.KnockbackForce, settings.KnockbackDur); } impulseSource.GenerateImpulse(); } foreach (var col in cols) { if (col.TryGetComponent <IDamageable>(out var tile)) { tile.Damage(); } } }
// Update is called once per frame void Update() { mouse_pos = Input.mousePosition; object_pos = Camera.main.WorldToScreenPoint(transform.position); mouse_pos.x -= object_pos.x; mouse_pos.y -= object_pos.y; angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg - 90; transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle)); if (Input.GetButton("Fire1")) { fireBehavior.Fire(gun); } time = Time.time; if (Input.GetKeyDown(KeyCode.LeftShift) && time > dashCoolDownEndTime) { impulse.GenerateImpulse(); dashEndTime = time + dashTime; dashCoolDownEndTime = time + dashCoolDownTime; } }
IEnumerator Explode() { yield return(new WaitForSeconds(_fuseTime)); Vector3 explosionPos = transform.position; Collider[] colliders = Physics.OverlapSphere(explosionPos, _radius); foreach (Collider hit in colliders) { Enemy enemy = hit.gameObject.GetComponent <Enemy>(); if (enemy != null) { Health enemyHealth = enemy.GetComponent <Health>(); enemyHealth.TakeDamage(_damage); } Rigidbody rb = hit.GetComponent <Rigidbody>(); if (rb != null) { rb.AddExplosionForce(_power, explosionPos, _radius + 2, 3.0f); } } _impulse.GenerateImpulse(); Instantiate(_audioSource, transform.position, Quaternion.identity); Instantiate(_explosion, transform.position, Quaternion.identity); Destroy(gameObject); }
public void TakeDamage(float damage) { heart.Damage(damage); Vector3 velocity = Random.insideUnitSphere * impulseMagnitude; // kill the z-channel to avoid going below the 2d plane // where characters are spawned velocity.z = 0; // higher intensity if the player dies if (heart.IsDead) { // strong vibrate when player dies Vibration.VibratePop(); velocity *= 3; } else { // vibrate when player recieves damage Vibration.VibratePeek(); } // create camera shake effect impulseSource.GenerateImpulse(velocity); }
void Update() { if (Input.GetKeyDown(KeyCode.V)) { impulseSource.GenerateImpulse(); } }
private void Update() { if (Mathf.Abs(closedYRotation - transform.rotation.eulerAngles.y) <= closedDelta) { if (!isClosed) { OnDoorClose?.Invoke(); isClosed = true; if (shakeCameraOnClose && impulseSource) { impulseSource.GenerateImpulse(); FMODUnity.RuntimeManager.PlayOneShot(DoorSlam, transform.position); } } } else { if (isClosed) { OnDoorOpen?.Invoke(); FMODUnity.RuntimeManager.PlayOneShot(DoorSqueak, transform.position); isClosed = false; } } }
protected override IEnumerator Cutscene() { cutsceneManager.cutsceneOngoing = true; gameManager.GameState = Enums.GameState.cutscene; impulse.GenerateImpulse(); yield return(null); while (Vector2.Distance(iceRock.transform.position, rockEndWP.position) > 0.001f) { iceRock.transform.position = Vector2.MoveTowards(iceRock.transform.position, rockEndWP.position, dropSpeed * Time.deltaTime); yield return(null); } partnerAnim.SetBool("isDead", true); cutsceneManager.cutsceneOngoing = false; gameManager.GameState = Enums.GameState.playing; gameObject.SetActive(false); }
private IEnumerator ImpulseRoutine() { WaitForSeconds wait = new WaitForSeconds(GameManager.Instance.GameGameData.RepairableRobotData.ImpulseRate); while (true) { yield return(wait); if (PartyParrotManager.Instance.IsPaused) { continue; } if (!_enterRepairBayEffectTrigger.IsRunning && !_exitRepairBayEffectTrigger.IsRunning) { continue; } if (EffectsManager.Instance.EnableViewerShake) { _impulseSource.GenerateImpulse(); } GameManager.Instance.RobotImpulse(); } }
void FinishWarp() { ShowBody(true); sword.parent = swordHand; sword.localPosition = swordOrigPos; sword.localEulerAngles = swordOrigRot; SkinnedMeshRenderer[] skinMeshList = GetComponentsInChildren <SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer smr in skinMeshList) { GlowAmount(30); DOVirtual.Float(30, 0, .5f, GlowAmount); } Instantiate(hitParticle, sword.position, Quaternion.identity); target.GetComponentInParent <Animator>().SetTrigger("hit"); target.parent.DOMove(target.position + transform.forward, 0.5f); StartCoroutine(HideSword()); StartCoroutine(PlayAnimation()); StartCoroutine(StopParticles()); isLocked = false; LockInterface(false); aim.color = Color.clear; // Camera Shake impulse.GenerateImpulse(Vector3.right); // Lens Distortion DOVirtual.Float(-80, 0, 0.2f, DistortionAmount); DOVirtual.Float(2f, 1, 0.1f, ScaleAmount); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Enemy") { //instanciate Hinsound Instantiate(hitsound, transform.position, Quaternion.identity); if (EnableScreenshake == true) { //do some Screenshake ImpulseCOM.GenerateImpulse(new Vector3(2, 2, 0)); } //Instanciate Impactparticle Instantiate(ImpactParticle, transform.position, transform.rotation); if (ShowHitLight == true) { //Instanciate red Hitlight Instantiate(RedLight, transform.position, transform.rotation); } //send damage to collided Object collision.gameObject.SendMessage("EnemyDamage", BulletDamage, SendMessageOptions.DontRequireReceiver); //Update PlayerStats PlayerStats.DamageDealed = PlayerStats.DamageDealed + BulletDamage; Destroy(this.gameObject); } else { Instantiate(ImpactParticle, transform.position, transform.rotation); Destroy(this.gameObject); } }
IEnumerator Attack() { anim.SetTrigger("Attack"); yield return(new WaitForSeconds(0.3f)); LayerMask layer = LayerMask.GetMask("Environment"); Collider[] colliders = Physics.OverlapSphere(attackPoint.position, radius, layer); if (colliders.Length > 0) { screenshake.GenerateImpulse(); } foreach (Collider col in colliders) { switch (col.tag) { case "Box": col.GetComponent <BoxBehavior>().BeenHit(10f, transform.position, hitForce); break; case "Tree": col.GetComponent <TreeBehavior>().BeenHit(col.transform.position); break; case "Rock": col.GetComponent <RockBehavior>().BeenHit(col.transform.position); break; } } }
public void Impulse() { foreach (GameObject item in gameObjInArea) { item.SendMessage("HurtByExplode", (Vector2)this.transform.position); } impulseSource.GenerateImpulse(Vector2.down * hurtImpulsePower); }
public void ShakeCamera(float amplitude, float frequency, float sustainTime) { impulseSource.m_ImpulseDefinition.m_AmplitudeGain = amplitude; impulseSource.m_ImpulseDefinition.m_FrequencyGain = frequency; impulseSource.m_ImpulseDefinition.m_TimeEnvelope.m_SustainTime = sustainTime; impulseSource.GenerateImpulse(); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log("GenerateImpulse"); m_impulseSource.GenerateImpulse(); } }
public IEnumerator ShakeCameraImpulse() { Vector3 shakeAmount = new Vector3(1, 1, 1); m_impulse_source.GenerateImpulse(); yield break; }
public void ShakeCameraCinemachine(float duration, float amplitude, float frequency) { impulseSource.m_ImpulseDefinition.m_AmplitudeGain = amplitude; impulseSource.m_ImpulseDefinition.m_FrequencyGain = frequency; impulseSource.m_ImpulseDefinition.m_TimeEnvelope.m_SustainTime = duration; impulseSource.GenerateImpulse(); }
/// <summary> /// For when the note is successfully hit by the player. /// </summary> public void HitNote() { noteHitEvent.Raise(); GameObject.Instantiate(explosionEffect, this.transform.position, Quaternion.identity); m_CinemachineImpulseSource.GenerateImpulse(); //Debug.Log("DISTANCE: " + (this.gameObject.transform.position.y - buttonY)); Destroy(this.transform.parent.gameObject); }
protected override void Destroy() { ResourceManager.Instance.AddGold(goldValue); GameManager.Instance.IncreaseScore(); base.Destroy(); Instantiate(enemyDeathPS, transform.position, Quaternion.identity); impulseSource.GenerateImpulse(); }
protected override void OnTriggerEnter2D(Collider2D collision) { if (longDamage) { return; } if (collision.CompareTag(m_sTagName)) { ReceiveDamage receiveDamage = collision.gameObject.GetComponent <ReceiveDamage>(); if (!receiveDamage.bScriptEnable) { return; } if (attackForce != Vector2.zero) { receiveDamage.AddDamageForce(attackForce); m_cinemachineImpulse.GenerateImpulse(); } if (m_playerInfo.IsCritical()) { m_damage = (int)((m_damage * 1.5f) + 0.5f); receiveDamage.Receive(m_damage, true); } else { receiveDamage.Receive(m_damage, false); } if (!m_playerState.IsPlayerGround()) { m_playerInfo.PlusAirAttackCount(); } m_playerCombo.plusCombo(); if (autoDistroy) { ObjectPool.Inst.PushToPool(this.gameObject); } } }
public void TakeDamage(int damage) { _impulse.GenerateImpulse(); _hurtSource.Play(); ChangeHealth(-damage); healthBar.SetHealth(currentHealth); SubtractSize(); CheckHealth(); }
private void OnShoot() { impulse.GenerateImpulse(); //先放到父物体预设的位置 var arrow = Instantiate(arrowPrefab, transform.GetChild(0)); //然后脱离父物体 arrow.transform.SetParent(null); }
private void FirePolish() { impulse.GenerateImpulse(); foreach (ParticleSystem p in gun.GetComponentsInChildren <ParticleSystem>()) { p.Play(); } }
public void Shake(ShakeData shake) { Vector2 v = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)).normalized; _impulseSource.m_ImpulseDefinition.m_AmplitudeGain = shake.AmplitudeGain; _impulseSource.m_ImpulseDefinition.m_FrequencyGain = shake.FrequenceGain; _impulseSource.GenerateImpulse(v); }
public void Dash() { gravityActive = false; if (dashExpireTime == dashTime) { StartCoroutine(GameController.Instance.FreezeTime(dashFreezeTime)); dashDirection = isFacingLeft ? -1 : 1; impulse.GenerateImpulse(); velocity.y = 0; batterySpent += dashCost; } if (dashExpireTime > 0 && batterySpent <= batteryCapacity) { if (jumpRequest && batterySpent + jumpCost <= batteryCapacity) { GameController.Instance.ResetFreezeTime(); _currentState = PlayerState.SuperJump; } dashParticles.Play(); dustParticles.Play(); velocity.x = dashDirection * dashSpeed; dashExpireTime -= Time.deltaTime; if (dashExpireTime <= Time.deltaTime * 4) { dashParticles.Stop(); } } else if (dashExpireTime <= 0) { dashDirection = 0; gravityActive = true; if (GroundCheck()) { _currentState = PlayerState.Grounded; } else if (wallHit) { _currentState = PlayerState.WallSlide; } else { _currentState = PlayerState.Fall; } currentGravity = gravity; dashExpireTime = 0f; isDashing = false; } else { isDashing = false; } }
public void ShakeCamera() { //cam.GetComponent<CinemachineImpulseSource>().GenerateImpulse(); impulseSource.GenerateImpulse(); foreach (ParticleSystem p in particles) { p.Play(); } }
private void OnTriggerEnter2D(Collider2D collision) { Debug.Log(collision); if (collision.transform == player.Value) { hasObjectiv.Value = true; impulseSource.GenerateImpulse(Vector3.one * impulseStrength); objectiveSound.Play(); } }
public void PlayPunchLandedEffects() { RaycastHit hit = rayCaster.PunchCast(punchRange); if (hit.transform != null) { Instantiate(hitParticlesPrefab, hit.point - transform.forward * 0.1f, Quaternion.identity); } impulseSource.GenerateImpulse(); }
private void Update() { if (activated) { impulse.GenerateImpulse(); anim.Play("Spring"); activated = false; } }
public void Explode() { StopMoving(); impulseSource.m_ImpulseDefinition.m_AmplitudeGain += bombSystem.GetBombRange(); impulseSource.GenerateImpulse(); Explosion explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity).GetComponent <Explosion>(); explosion.Setup(true, Explosion.ExplosionDirection.ALL, bombSystem.GetBombRange(), groundTile); Destroy(gameObject); }
public void Start() { impulseSource = GetComponent <CinemachineImpulseSource>(); ps = GetComponentInChildren <ParticleSystem>(); if (GetComponent <CinemachineImpulseSource>() != null) { impulseSource.GenerateImpulse(); } }