private void OnDisable()
 {
     if (_SOEffectHandler != null)
     {
         _SOEffectHandler.StopEffect(_effect);
     }
 }
    private void Update()
    {
        // if the player has hit the battery with the shotgun blast. Once they have, this waits for the delay
        // before starting the explosion effect animation, stoping the battery damage effect animation, and hides
        // sprite representing the pod. Lastly, it calls the fucntion to spawn all the swarmers.
        if (_batteryDamaged)
        {
            if (Time.time - _timer > _destructionDelay)
            {
                _SOEffectHandler.PlayEffect(EffectEnums.PodExplosion, _effectPositions[5].position);

                _SOEffectHandler.StopEffect(_podBatteryDamageGO);
                _SOEffectHandler.StopEffect(_oilSpill1);
                _SOEffectHandler.StopEffect(_oilSpill2);

                GetComponent <SpriteRenderer>().enabled = false;
                SpawnSwarm();

                if (_additionalGOs.Length > 0)
                {
                    for (int i = 0; i < _additionalGOs.Length; ++i)
                    {
                        _additionalGOs[i].SetActive(true);
                    }
                }
            }
            else
            {
                // Have the pod shake violently before it explodes
                if (_move)
                {
                    transform.position = new Vector2(transform.position.x + 2.5f, transform.position.y);
                    _move = false;
                }
                else if (!_move)
                {
                    transform.position = new Vector2(transform.position.x - 2.5f, transform.position.y);
                    _move = true;
                }
            }
        }
    }
 private void OnDisable()
 {
     _SOEffectHandler.StopEffect(_laserEffect);
 }
 private void OnDisable()
 {
     _SOEffectHandler.StopEffect(_tellEffect);
 }
예제 #5
0
    private void Update()
    {
        if (_entity == null)
        {
            _entity = GetComponent <SpriterDotNetUnity.SpriterDotNetBehaviour>().ChildData;
        }

        // if the player dies, stop any velocity the player had, place them at the last checkpoint, and reset their health to 100%.
        if (_health <= 0)
        {
            if (!_deathAnimationPlayed)
            {
                if (_inputManager == null)
                {
                    _inputManager = InputManager.Instance.GetComponent <InputManager>();
                }
                _inputManager.StopInput();

                GetComponent <BoxCollider2D>().enabled     = false;
                GetComponent <PolygonCollider2D>().enabled = false;

                _playerBody.SetActive(false);

                if (!_collisionState.OnSolidGround)
                {
                    _SOEffectHandler.PlayEffect(EffectEnums.Player_Death00, transform.position);
                }
                else
                {
                    _SOEffectHandler.PlayEffect(EffectEnums.Player_Death01, transform.position);
                }
                _deathAnimationPlayed = true;
                DeployBodyParts();
                _timer = Time.time;
                if (OnPlayerDeath != null)
                {
                    OnPlayerDeath();
                }                                                   // This tells the save file to add to the number of deaths.
            }

            GetComponent <Rigidbody2D>().velocity     = new Vector3(0.0f, 0.0f, 0.0f);
            GetComponent <Rigidbody2D>().gravityScale = 0.0f;
            GetComponent <PlayerMovementManager>().ClearQueue();

            StartCoroutine(ReloadLevelDelay());

            //if (Time.time - _timer > 1.0f) {

            //    transform.position = _GM.SOSaveHandler.CheckpointPosition;
            //    GetComponent<PlayerMovementManager>().ClearQueue();

            //    if (Camera.main.WorldToViewportPoint(_GM.SOSaveHandler.CheckpointPosition).x > 0.1f &&
            //        Camera.main.WorldToViewportPoint(_GM.SOSaveHandler.CheckpointPosition).x < 0.9f) {

            //        // Delay the player from any input for 1.5 seconds to ensure they do not immediate fly to their death
            //        // Call the respawn effect and restore all the default values for the player.
            //        _inputManager.PauseInput(1.25f);
            //        GetComponent<Rigidbody2D>().gravityScale = 40.0f;
            //        _SOEffectHandler.PlayEffect(EffectEnums.PlayerRespawn, _GM.SOSaveHandler.CheckpointPosition);
            //        _SOWeaponManager.Reload();
            //        _health = _maxHealth;
            //        _playerBody.SetActive(true);
            //        UpdateHealth(_health);
            //        _deathAnimationPlayed = false;
            //    }
            //}
        }

        if (_killPlayerCalled)
        {
            KillPlayer();
        }

        if (_effect != null)
        {
            // If an effect is playing and then the player dies, stop the effect at once.
            if (_health < 0)
            {
                _duration = 0.0f;
                _SOEffectHandler.StopEffect(_effect);

                foreach (GameObject sprite in _entity.Sprites)
                {
                    //Color spriteColor = sprite.GetComponent<SpriteRenderer>().color;
                    sprite.GetComponent <SpriteRenderer>().color = Color.white;
                }
            }
            // if there is any type of effect associated with the player, ensure it is following them with a slight offset.
            _effect.transform.position = transform.position + new Vector3(0.0f, 25.0f, 0.0f);
        }

        // If an enemy has damaged the player and their is an effect to be played,
        // keep calling the damage and effect to do damage over time.
        if (_duration != 0.0f)
        {
            if (Time.time - _timer < _duration)
            {
                if (_damageType == DamageEnum.Acid && _canTakeDamage)
                {
                    _scrnShkRequest.ShakeRequest();
                    StartCoroutine(RecoveryDelay());
                }

                ReturnToNormalColor();
            }
            else
            {
                _duration = 0.0f;
                _SOEffectHandler.StopEffect(_effect);
            }
        }
    }