/// <summary> /// Aggiornamento del sistema di fuoco /// </summary> void UpdateWeapons() { // Primo sistema di armi // Controllo sia la situazione di fuoco manuale, che quella di auto-fire if ((!data.weapon1Autofire && Input.GetKeyDown(data.weapon1Key) && _weapon1Countdown <= 0) || (data.weapon1Autofire && _weapon1Countdown <= 0)) { ShootWeapon(weapon1GunList, data.bullet1ObjectPooler, data.weapon1Sfx); // Se ho sparato, reinizializzo il countdown _weapon1Countdown = data.weapon1FireInterval; weapon1Feedback.PlayFeedbacks(); } // Secondo sistema di armi // Controllo sia la situazione di fuoco manuale, che quella di auto-fire if ((!data.weapon2Autofire && Input.GetKeyDown(data.weapon2Key) && _weapon2Countdown <= 0) || (data.weapon2Autofire && _weapon2Countdown <= 0)) { ShootWeapon(weapon2GunList, data.bullet2ObjectPooler, data.weapon2Sfx); // Se ho sparato, reinizializzo il countdown _weapon2Countdown = data.weapon2FireInterval; weapon1Feedback.PlayFeedbacks(); } }
public void activate() { model.gameObject.SetActive(false); GetComponent <BoxCollider2D>().enabled = true; HitDamageableFeedback.PlayFeedbacks(this.transform.position); StartCoroutine("projectileFadeIn"); }
private void OnNoteSuccess(KeyCode _keyCode) { if (keyCode == _keyCode && successFeedback != null) { successFeedback.PlayFeedbacks(); } }
private void Activate() { pressed = true; spriteRenderer.sprite = activeSprite; if (pressFeedback != null) { pressFeedback.PlayFeedbacks(); } }
/// <summary> /// Applies a bounce in 2D /// </summary> /// <param name="hit"></param> protected virtual void Bounce2D(RaycastHit2D hit) { BounceFeedback?.PlayFeedbacks(); _reflectedDirection = Vector3.Reflect(_raycastDirection, hit.normal); float angle = Vector3.Angle(_raycastDirection, _reflectedDirection); Direction = _reflectedDirection.normalized; this.transform.right = _spawnerIsFacingRight ? _reflectedDirection.normalized : -_reflectedDirection.normalized; Speed *= _randomSpeedModifier; _bouncesLeft--; }
/// <summary> /// Turns the switch off /// </summary> public virtual void TurnSwitchOff() { CurrentSwitchState = SwitchStates.Off; if (SwitchOff != null) { SwitchOff.Invoke(); } if (SwitchToggle != null) { SwitchToggle.Invoke(); } SwitchOffFeedback?.PlayFeedbacks(this.transform.position); }
public void Damage(int damage, Vector3 knockbackDir, float knockbackSpeed) { damageFeedback.PlayFeedbacks(); this.AddImpulse(knockbackDir * knockbackSpeed); invincibilityTimer = Time.time; if (HungerOut.Value <= 0) { OnDeath(); } else { IncrementHunger(-damage); } }
protected virtual void CountPoints() { int points = 10; foreach (Collider col in _pinColliders) { if (col.bounds.Intersects(PointsCollider.bounds)) { points--; } } LastScore = points; ConsecutiveStrikes = (points == 10) ? ConsecutiveStrikes + 1 : 0; if (points == 10) { StrikeFeedback?.PlayFeedbacks(); SetStrikeElements(true); } else { NoStrikeFeedback?.PlayFeedbacks(); SetStrikeElements(false); } TotalPoints += points; ConsecutiveStrikesText.text = ConsecutiveStrikes.ToString(); LastScoreText.text = LastScore.ToString(); TotalScoreText.text = TotalPoints.ToString(); }
/// <summary> /// Resets the whole scene /// </summary> /// <returns></returns> protected virtual IEnumerator ResetSceneCo() { yield return(MMCoroutine.WaitFor(DelayBeforeReset)); CountPoints(); yield return(MMCoroutine.WaitFor(DelayForPoints)); ResetFeedback?.PlayFeedbacks(); yield return(MMCoroutine.WaitFor(0.1f)); // we reset the ball's position and forces BowlingBallRb.MovePosition(_initialBallPosition); BowlingBallRb.transform.localRotation = _initialBallRotation; BowlingBallRb.velocity = Vector3.zero; BowlingBallRb.angularVelocity = Vector3.zero; yield return(MMCoroutine.WaitForFrames(1)); BowlingBallRb.transform.position = _initialBallPosition; // we make our launcher rotate again BowlingBallLauncherWiggler.RotationActive = true; foreach (StrikePin pin in _strikePins) { pin.ResetPin(); } _ballThrown = false; }
/// <summary> /// Detonates the bomb and instantiates damage areas /// </summary> /// <returns></returns> protected virtual IEnumerator DetonateCoroutine() { _exploded = true; _boxCollider.enabled = false; StopCoroutine(_delayBeforeExplosionCoroutine); // we cast rays in all directions CastRays(); // we add our damage areas DirectedExplosion(_raycastEast, _damageAreaEast, DirectedExplosionE, 90f); DirectedExplosion(_raycastWest, _damageAreaWest, DirectedExplosionW, 90f); DirectedExplosion(_raycastNorth, _damageAreaNorth, DirectedExplosionN, 0f); DirectedExplosion(_raycastSouth, _damageAreaSouth, DirectedExplosionS, 0f); _damageAreaCenter.gameObject.SetActive(true); ExplosionFeedbacks?.PlayFeedbacks(); BombModel.gameObject.SetActive(false); yield return(_explosionDuration); _damageAreaEast.gameObject.SetActive(false); _damageAreaWest.gameObject.SetActive(false); _damageAreaNorth.gameObject.SetActive(false); _damageAreaSouth.gameObject.SetActive(false); _damageAreaCenter.gameObject.SetActive(false); yield return(_additionalDelayBeforeDestruction); this.gameObject.SetActive(false); }
/// <summary> /// Stops the car /// </summary> protected virtual void TurnStop() { DriveFeedback?.StopFeedbacks(); StopFeedback?.PlayFeedbacks(); SetCar(false); _turning = false; }
/// <summary> /// Makes the player respawn at the location passed in parameters /// </summary> /// <param name="spawnPoint">The location of the respawn.</param> public override void RespawnAt(Transform spawnPoint, FacingDirections facingDirection) { // if (!gameObject.activeInHierarchy) // { // //Debug.LogError("Spawn : your Character's gameobject is inactive"); // return; // } UnFreeze(); // we make sure the character is facing right Face(facingDirection); // we raise it from the dead (if it was dead) ConditionState.ChangeState(CharacterStates.CharacterConditions.Normal); // we re-enable its 2D collider this.gameObject.MMGetComponentNoAlloc <Collider2D>().enabled = true; // we make it handle collisions again _controller.CollisionsOn(); transform.position = new Vector3(spawnPoint.position.x, spawnPoint.position.y, transform.position.z); if (_health != null) { _health.ResetHealthToMaxHealth(); _health.Revive(); } respawnFeedback?.PlayFeedbacks(); }
/// <summary> /// Changes the state for the next in line /// </summary> public virtual void ChangeState() { if (((_nextState == AppearDisappearStates.HiddenToVisible) || (_nextState == AppearDisappearStates.Visible)) && _characterInTriggerArea && PreventAppearWhenCharacterInArea) { return; } if (((_nextState == AppearDisappearStates.VisibleToHidden) || (_nextState == AppearDisappearStates.Hidden)) && _characterInTriggerArea && PreventDisappearWhenCharacterInArea) { return; } _lastStateChangedAt = Time.time; _currentState = _nextState; _nextFeedback?.PlayFeedbacks(); RandomizeDurations(); if (_currentState == AppearDisappearStates.Hidden) { UpdateBoundComponents(false); } if (_currentState == AppearDisappearStates.Visible) { UpdateBoundComponents(true); } DetermineNextState(); }
/// <summary> /// Describes what happens when colliding with a damageable object /// </summary> /// <param name="health">Health.</param> protected virtual void OnCollideWithDamageable(Health health) { // if what we're colliding with is a CorgiController, we apply a knockback force _colliderCorgiController = health.gameObject.MMGetComponentNoAlloc <CorgiController>(); ApplyDamageCausedKnockback(); OnHitDamageable?.Invoke(); HitDamageableFeedback?.PlayFeedbacks(this.transform.position); if ((FreezeFramesOnHitDuration > 0) && (Time.timeScale > 0)) { MMFreezeFrameEvent.Trigger(Mathf.Abs(FreezeFramesOnHitDuration)); } // we apply the damage to the thing we've collided with _colliderHealth.Damage(DamageCaused, gameObject, InvincibilityDuration, InvincibilityDuration); if (_colliderHealth.CurrentHealth <= 0) { OnKill?.Invoke(); } SelfDamage(DamageTakenEveryTime + DamageTakenDamageable); }
/// <summary> /// Every frame, checks if we just hit the ground, and if yes, changes the state and triggers a particle effect /// </summary> protected virtual void CheckJustGotGrounded() { // if the character just got grounded if (_movement.CurrentState == CharacterStates.MovementStates.Dashing) { return; } if (_controller.State.JustGotGrounded) { if (_controller.State.ColliderResized) { _movement.ChangeState(CharacterStates.MovementStates.Crouching); } else { _movement.ChangeState(CharacterStates.MovementStates.Idle); } _controller.SlowFall(0f); if (Time.time - _lastTimeGrounded > MinimumAirTimeBeforeFeedback) { TouchTheGroundFeedback?.PlayFeedbacks(); } } if (_controller.State.IsGrounded) { _lastTimeGrounded = Time.time; } }
/// <summary> /// On Update we handle our cooldowns and activate the bomb if needed /// </summary> protected virtual void Update() { _timeSinceStart += Time.deltaTime; // flickering if (_timeSinceStart >= TimeBeforeFlicker) { if (!_flickering && FlickerSprite) { // We make the bomb's sprite flicker if (_renderer != null) { StartCoroutine(MMImage.Flicker(_renderer, _initialColor, _flickerColor, 0.05f, (TimeBeforeExplosion - TimeBeforeFlicker))); } } } // activate damage area if (_timeSinceStart >= TimeBeforeExplosion && !_damageAreaActive) { EnableDamageArea(); _renderer.enabled = false; ExplosionFeedback?.PlayFeedbacks(); _damageAreaActive = true; } if (_timeSinceStart >= TimeBeforeExplosion + DamageAreaActiveDuration) { Destroy(); } }
/// <summary> /// Describes the events happening once the initial fade in is complete /// </summary> protected virtual void AfterFadeOut(Collider2D collider) { if (AddToDestinationIgnoreList) { Destination.AddToIgnoreList(collider.transform); } if (CameraMode == CameraModes.CinemachinePriority) { MMCameraEvent.Trigger(MMCameraEventTypes.ResetPriorities); MMCinemachineBrainEvent.Trigger(MMCinemachineBrainEventTypes.ChangeBlendDuration, DelayBetweenFades); } if (CurrentRoom != null) { CurrentRoom.PlayerExitsRoom(); } if (TargetRoom != null) { TargetRoom.PlayerEntersRoom(); TargetRoom.VirtualCamera.Priority = 10; MMSpriteMaskEvent.Trigger(MoveMaskMethod, (Vector2)TargetRoom.RoomCollider.bounds.center + TargetRoom.RoomCollider.offset, TargetRoom.RoomCollider.bounds.size, MoveMaskDuration, MoveMaskCurve); } AfterFadeOutFeedback?.PlayFeedbacks(); }
/// <summary> /// Use this method to go from one state to the other /// </summary> public virtual void ToggleSwitch() { if (CurrentSwitchState == SwitchStates.Off) { CurrentSwitchState = SwitchStates.On; if (SwitchOn != null) { SwitchOn.Invoke(); } if (SwitchToggle != null) { SwitchToggle.Invoke(); } SwitchOnFeedback?.PlayFeedbacks(this.transform.position); } else { CurrentSwitchState = SwitchStates.Off; if (SwitchOff != null) { SwitchOff.Invoke(); } if (SwitchToggle != null) { SwitchToggle.Invoke(); } SwitchOffFeedback?.PlayFeedbacks(this.transform.position); } ToggleFeedback?.PlayFeedbacks(this.transform.position); }
protected override void OnLevelUp(int level, int maxLevel) { var oldMovementSpeed = _movement.MovementSpeed; _movement.MovementSpeed = MinMovementSpeed + (MaxMovementSpeed - MinMovementSpeed) * LevelMovementSpeedCurve.Evaluate((float)level / maxLevel); SetMovementSpeedFeedbacks?.PlayFeedbacks(transform.position, _movement.MovementSpeed - oldMovementSpeed); }
/// <summary> /// Performs a move if possible, otherwise plays a denied feedback /// </summary> protected virtual void SpecialDanceMove() { if (Time.time - _lastMoveStartedAt >= CooldownDuration) { SpecialDanceMoveFeedbacks?.PlayFeedbacks(); _lastMoveStartedAt = Time.time; } }
/// <summary> /// Describes what happens when colliding with a non damageable object /// </summary> protected virtual void OnCollideWithNonDamageable() { if (DamageTakenEveryTime + DamageTakenNonDamageable > 0) { HitNonDamageableFeedback?.PlayFeedbacks(this.transform.position); SelfDamage(DamageTakenEveryTime + DamageTakenNonDamageable); } }
public void IdleTalk() //Idle talk sound event { if (!Idletalk.IsPlaying) { Cemewholo.StopFeedbacks(); Idletalk.PlayFeedbacks(); } }
public void OnStop(StatusEffect statusEffect) { if (statusEffect != StatusEffect) { return; } StatusEffectStopFeedbacks?.PlayFeedbacks(); }
/// <summary> /// Plays the ability start sound effect /// </summary> protected virtual void PlayAbilityFeedbacks() { if (AbilityFeedbacks == null) { return; } AbilityFeedbacks.PlayFeedbacks(this.transform.position); }
/// <summary> /// Makes the wheel turn, plays a feedback if it's just starting to turn this frame /// </summary> protected virtual void Turn() { if (!_turning) { TurnFeedback?.PlayFeedbacks(); } _turning = true; }
/// <summary> /// Describes the events happening after the initial delay has passed /// </summary> /// <param name="collider"></param> protected virtual void AfterInitialDelay(Collider2D collider) { if (TriggerFade) { MMFadeInEvent.Trigger(FadeOutDuration, FadeTween, FaderID, false, LevelManager.Instance.Players[0].transform.position); } AfterInitialDelayFeedback?.PlayFeedbacks(); }
public void OnCorrect() { correctFeedback.PlayFeedbacks(); var temp = Instantiate(fireTrail, transform); temp.GetComponent <ParticleSystem>().Play(); Destroy(gameObject, 2); }
/// <summary> /// Triggers an error /// </summary> public virtual void PromptError() { if (_buttonPromptAnimator != null) { _buttonPromptAnimator.SetTrigger("Error"); } DeniedFeedback?.PlayFeedbacks(this.transform.position); }
public void CemeWholo() //CemewholoCemewholoCemewholoCemewholoCemewholo { if (!Cemewholo.IsPlaying) { Idletalk.StopFeedbacks(); Cemewholo.PlayFeedbacks(); } }
/// <summary> /// Called when the object takes damage /// </summary> /// <param name="damage">The amount of health points that will get lost.</param> /// <param name="instigator">The object that caused the damage.</param> /// <param name="flickerDuration">The time (in seconds) the object should flicker after taking the damage.</param> /// <param name="invincibilityDuration">The duration of the short invincibility following the hit.</param> public virtual void Damage(int damage, GameObject instigator, float flickerDuration, float invincibilityDuration) { // if the object is invulnerable, we do nothing and exit if (Invulnerable) { return; } // if we're already below zero, we do nothing and exit if ((CurrentHealth <= 0) && (InitialHealth != 0)) { return; } // we decrease the character's health by the damage float previousHealth = CurrentHealth; CurrentHealth -= damage; if (OnHit != null) { OnHit(); } if (CurrentHealth < 0) { CurrentHealth = 0; } // we prevent the character from colliding with Projectiles, Player and Enemies if (invincibilityDuration > 0) { DamageDisabled(); StartCoroutine(DamageEnabled(invincibilityDuration)); } // we trigger a damage taken event MMDamageTakenEvent.Trigger(_character, instigator, CurrentHealth, damage, previousHealth); if (_animator != null) { _animator.SetTrigger("Damage"); } DamageMMFeedbacks?.PlayFeedbacks(this.transform.position); // we update the health bar UpdateHealthBar(true); // if health has reached zero if (CurrentHealth <= 0) { // we set its health to zero (useful for the healthbar) CurrentHealth = 0; Kill(); } }