Пример #1
0
    private void OnTriggerEnter(Collider other)
    {
        int layer = other.gameObject.layer;

        if (layer == LayerManager.TerrainLayer || layer == LayerManager.DeviceLayer)
        {
            if (explosionEffect)
            {
                BurstParticleController   particle = explosionEffect.Get <BurstParticleController>();
                ParticleSystem.MainModule main     = particle.ParticleSystem.main;
                main.startColor             = explosionEffectColor;
                particle.transform.position = transform.position;
                particle.Burst();
            }

            if (hitSound)
            {
                AudioManager.PlayAtPoint(hitSound.Source, transform.position);
            }

            _startTime = Time.time;
            lifespan   = destroyDelay;
        }
        else if (layer == LayerManager.CharacterLayer)
        {
            if (other == ownerCollider)
            {
                return;
            }
            _startTime = Time.time;
            lifespan   = destroyDelay;
        }
    }
    protected override void Fire()
    {
        float face = (float)characterMotor.FaceDirection;

        foreach (var fireStyle in fireStyles)
        {
            ProjectileController projectileController = projectileType.Get <ProjectileController>();
            fireOffset   = fireStyle.offset;
            fireRotation = fireStyle.rotation;
            LoadUpProjectile(projectileController);
            float   rad      = fireStyle.direction * Mathf.Deg2Rad;
            Vector3 velocity = new Vector3(Mathf.Cos(rad) * face, Mathf.Sin(rad), 0).normalized *firePower;
            projectileController.Fire(velocity);
        }

        if (attackSound)
        {
            _audioSource.PlayOneShot(attackSound.Source);
        }
        if (fireShake != Vector3.zero)
        {
            CameraManager.Shake(transform.position, fireShake);
        }
        if (fireEffect)
        {
            BurstParticleController explosion = fireEffect.Get <BurstParticleController>();
            explosion.transform.position = transform.position + new Vector3(transform.lossyScale.x / 2f, 0, 0);
            explosion.Burst();
        }
    }
Пример #3
0
    protected virtual void OnDetectCharacterEnter(IBSpriteTrigger trigger, Collider detectedCollider, Vector3 contactPosition)
    {
        CharacterController character = detectedCollider.GetComponentInParent <CharacterController>();
        float distance;
        float hitDirection = GetHitDirection(contactPosition, characterMotor.transform, out distance);

        if (attackEffectSettings.doesHit)
        {
            character.GetHit(attackEffectSettings.hitVelocityX * hitDirection, attackEffectSettings.hitVelocityY);
        }
        if (attackEffectSettings.doesStun)
        {
            character.GetStunned(hitDirection * attackEffectSettings.stunAngle, attackEffectSettings.stunTime);
        }
        if (attackEffectSettings.doesDamage)
        {
            character.GetDamaged(attackEffectSettings.damage);
        }
        if (hitEffect)
        {
            BurstParticleController   particle = hitEffect.Get <BurstParticleController>();
            ParticleSystem.MainModule main     = particle.ParticleSystem.main;
            main.startColor             = hitEffectColor;
            particle.transform.position = contactPosition;
            particle.Burst();
        }

        DamageSoundEffect(contactPosition);

        if (characterController.CompareTag(TagManager.LOCAL_PLAYER_TAG))
        {
            DisplayPlayerDamageEffect(distance, hitDirection, contactPosition);
        }
        DisplayDamageEffect(distance, hitDirection, contactPosition);
    }
Пример #4
0
    protected void SprayBlood()
    {
        BurstParticleController blood = bloodSprayEffect.Get <BurstParticleController>();

        ParticleSystem.MainModule main = blood.ParticleSystem.main;
        main.startColor          = bloodColor;
        blood.transform.position = transform.position;
        blood.Burst();
        AudioManager.PlayAtPoint(bloodSpraySound, transform.position);
    }
Пример #5
0
 private void Bleed()
 {
     if (bleedSound)
     {
         AudioManager.PlayAtPoint(bleedSound, transform.position);
     }
     if (!string.IsNullOrEmpty(bleedEffect))
     {
         BurstParticleController blood = ParticleManager.Get <BurstParticleController>(bleedEffect);
         blood.transform.position = transform.position;
         blood.Burst();
     }
 }
    private void OnIncorrect()
    {
        if (incorrectSound)
        {
            _audioSource.PlayOneShot(incorrectSound.Source);
        }
        Vector3 position;

        switch (SelectedOption)
        {
        case Option.A:
            optionABackgroud.color = incorrectColor;
            position = optionABackgroud.transform.position;
            break;

        case Option.B:
            optionBBackgroud.color = incorrectColor;
            position = optionBBackgroud.transform.position;
            break;

        case Option.C:
            optionCBackgroud.color = incorrectColor;
            position = optionCBackgroud.transform.position;
            break;

        case Option.D:
            optionDBackgroud.color = incorrectColor;
            position = optionDBackgroud.transform.position;
            break;

        default:
            position = Vector3.zero;
            break;
        }

        if (incorrectEffect)
        {
            BurstParticleController effect = incorrectEffect.Get <BurstParticleController>();
            effect.transform.position = position;
            effect.Burst();
        }

        incorrectAction?.Invoke();
    }
Пример #7
0
    protected virtual void Fire()
    {
        ProjectileController projectileController = projectileType.Get <ProjectileController>();

        LoadUpProjectile(projectileController);
        projectileController.Fire(new Vector3(firePower * (float)characterMotor.FaceDirection, 0, 0));
        if (attackSound)
        {
            _audioSource.PlayOneShot(attackSound.Source);
        }
        if (fireShake != Vector3.zero)
        {
            CameraManager.Shake(transform.position, fireShake);
        }
        if (fireEffect)
        {
            BurstParticleController explosion = fireEffect.Get <BurstParticleController>();
            explosion.transform.position = transform.position + new Vector3(transform.lossyScale.x / 2f, 0, 0);
            explosion.Burst();
        }
    }
Пример #8
0
    protected override void Fire()
    {
        if (_regenerateCoroutine == null)
        {
            _regenerateCoroutine = TimeManager.Instance.StartCoroutine(ExeRegenerateCoroutine());
        }
        float   face        = (float)characterMotor.FaceDirection;
        Vector3 targetPos   = Vector3.zero;
        Vector3 halfExtents = lockBoxSize / 2f;
        Vector3 offset      = lockBoxOffset + new Vector3(halfExtents.x, halfExtents.y, 0f);

        halfExtents.x = Mathf.Abs(halfExtents.x);
        halfExtents.y = Mathf.Abs(halfExtents.y);
        offset.x     *= face;
        int      num    = Physics.OverlapBoxNonAlloc(transform.position + offset, halfExtents, _lockResults, Quaternion.identity, 1 << LayerManager.CharacterLayer, QueryTriggerInteraction.Ignore);
        bool     locked = false;
        Vector3  pos    = transform.position;
        float    minSqr = 1000f;
        Collider target = null;

        for (int i = 0; i < num; i++)
        {
            Collider collider = _lockResults[i];
            if (DetectionSettings.detectsEnemy && collider.CompareTag(TagManager.ENEMY_TAG) || DetectionSettings.detectsLocalPlayer && collider.CompareTag(TagManager.LOCAL_PLAYER_TAG))
            {
                float deltaSqr = (collider.transform.position - pos).sqrMagnitude;
                if (deltaSqr < minSqr)
                {
                    minSqr = deltaSqr;
                    target = collider;
                    locked = true;
                }
            }
        }

        if (!locked)
        {
            targetPos    = transform.position;
            targetPos.x += face * 1000f;
        }
        else
        {
            targetPos = target.transform.position;
        }

        int shots = launchPerFire;

        for (int i = 0, l = _rocketControllers.Length; i < l; i++)
        {
            RocketProjectileController rocket = _rocketControllers[i];
            if (!rocket)
            {
                continue;
            }
            rocket.power = firePower;
            if (isTracer && locked)
            {
                rocket.target = target.transform;
            }
            rocket.targetPos = targetPos;
            float rad = rocket.transform.eulerAngles.z * Mathf.Deg2Rad;
            rocket.Fire(new Vector3(Mathf.Cos(rad) * face, Mathf.Sin(rad), 0).normalized *firePower);
            _rocketControllers[i] = null;
            _emptySlots.Enqueue(i);
            if (attackSound)
            {
                _audioSource.PlayOneShot(attackSound.Source);
            }
            if (fireShake != Vector3.zero)
            {
                CameraManager.Shake(rocket.transform.position, fireShake);
            }
            if (fireEffect)
            {
                BurstParticleController explosion = fireEffect.Get <BurstParticleController>();
                explosion.transform.position = rocket.transform.position;
                explosion.Burst();
            }

            shots--;
            if (shots == 0)
            {
                break;
            }
        }
    }