Beispiel #1
0
    public override void Die()
    {
        if (!alreadyDead)
        {
            base.Die();

            ArenaManager arenaManager = ArenaManager.arenaManager;

            EnemyLootCrate lootCrate = lootManager.GenerateEnemyLootCrate();
            if (lootCrate != null)
            {
                lootCrate.transform.position = transform.position;
                lootCrate.SetUpFloatingMove();

                if (arenaManager != null)
                {
                    arenaManager.DropManager.AddDropCrate(lootCrate);
                }
            }

            if (arenaManager != null)
            {
                arenaManager.IncreaseNumberOfKilledEnemies();
            }

            shipBody.velocity    = Vector3.zero;
            shipBody.constraints = RigidbodyConstraints.FreezeAll;

            if (shipBoxCollider != null)
            {
                shipBoxCollider.enabled = false;
            }

            if (shipFeedbacks != null)
            {
                shipFeedbacks.DesactivateSlowParticles();
            }

            if (attackPreparationWarningAnim != null)
            {
                attackPreparationWarningAnim.gameObject.SetActive(false);
            }
        }

        #region Variables reset
        externalySetedUp = false;

        remainingStunDuration       = 0;
        skeweringProjectile         = null;
        currentProtectionParameters = default;
        remainingBlindingDuration   = 0;

        currentReactionTime   = 0;
        lastPredictedPosition = Vector3.zero;

        remainingTimeBeforeExitRoutine   = 0;
        remainingTimeBeforeBackToRoutine = 0;
        outOfRoutineModificationCoeff    = 0;

        watchingRoundParameters = default;

        targetShip = null;

        nextPhaseIndex = 0;

        relatedDetectionZone.ResetDetectionZone();
        #endregion
    }
Beispiel #2
0
    public void Die()
    {
        OnDeath?.Invoke(this);

        ArenaManager arenaManager = ArenaManager.arenaManager;

        EnemyLootCrate lootCrate = lootManager.GenerateEnemyLootCrate();

        if (lootCrate != null)
        {
            lootCrate.transform.position = transform.position;
            lootCrate.SetUpFloatingMove();

            if (arenaManager != null)
            {
                arenaManager.DropManager.AddDropCrate(lootCrate);
            }
        }


        if (objectCollider != null)
        {
            objectCollider.enabled = false;
        }
        else if (GetComponent <Collider>() != null)
        {
            GetComponent <Collider>().enabled = false;
        }


        if (particlesToPlay != null)
        {
            particlesToPlay.Play();
        }

        foreach (Transform tr in woodProjectionPositions)
        {
            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = tr.position;
                woodProjection.StartFeedback(2, 0.2f);
            }
        }

        if (particlesToPlay == null && woodProjectionPositions.Length == 0)
        {
            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = transform.position;
                woodProjection.StartFeedback(2, 0.2f);
            }
        }


        if (targetAudioSource != null)
        {
            targetAudioSource.PlaySound(soundToPlayOnDestroy);
        }


        if (objectRenderer != null)
        {
            objectRenderer.enabled = false;
        }

        foreach (GameObject obj in objectRenderers)
        {
            obj.SetActive(false);
        }

        if (objectRenderer == null && objectRenderers.Length == 0)
        {
            Destroy(gameObject);
        }
    }