Exemplo n.º 1
0
    public override void OnStateEnter()
    {
        base.OnStateEnter();
        mosquitoBlackboard.agent.Stop();
        mosquitoBlackboard.agent.enabled = false;

        color = mosquitoBlackboard.mosquito.color;

        blackboard.entity.DisableShields();

        if (mosquitoBlackboard.lastShotPlayer != null)
        {
            rsc.rumbleMng.Rumble(mosquitoBlackboard.lastShotPlayer.Id, 0.25f, 0f, 0.5f);
        }

        EnemyDiedEventInfo.eventInfo.color           = color;
        EnemyDiedEventInfo.eventInfo.infectionValue  = MosquitoAIBehaviour.infectionValue;
        EnemyDiedEventInfo.eventInfo.killerPlayer    = mosquitoBlackboard.lastShotPlayer;
        EnemyDiedEventInfo.eventInfo.killedSameColor = mosquitoBlackboard.lastShotSameColor;
        EnemyDiedEventInfo.eventInfo.specialKill     = mosquitoBlackboard.specialKill;
        rsc.eventMng.TriggerEvent(EventManager.EventType.ENEMY_DIED, EnemyDiedEventInfo.eventInfo);

        if (mosquitoBlackboard.lastShotSameColor)
        {
            mosquitoBlackboard.entity.mainCollider.enabled = false;
            mosquitoBlackboard.entity.dyingCollider.SetActive(true);
            mosquitoBlackboard.canReceiveDamage  = false;
            mosquitoBlackboard.dieAnimationEnded = false;
            mosquitoBlackboard.animator.SetTrigger("die");

            movement = mosquitoBlackboard.lastShotDirection * mosquitoBlackboard.entity.shotForceModifier;

            EnemyExplosionController explosion = rsc.poolMng.enemyExplosionPool.GetObject();

            if (explosion != null)
            {
                explosion.transform.position = blackboard.entityGO.transform.position;
                explosion.Play(color, mosquitoBlackboard.mosquito.explosion1SoundFx);
            }
        }
        else
        {
            mosquitoBlackboard.mosquito.SpawnVoxelsAndReturnToPool(false);
        }
    }
Exemplo n.º 2
0
    public void SpawnVoxelsAndReturnToPool(bool spawnEnergyVoxels = true)
    {
        EnemyExplosionController explosion = rsc.poolMng.enemyExplosionPool.GetObject();
        Vector3 pos = transform.position;

        if (spawnEnergyVoxels)
        {
            if (explosion != null)
            {
                explosion.transform.position = pos;
                explosion.Play(color, explosion2SoundFx);
            }

            EnergyVoxelPool pool = rsc.poolMng.energyVoxelPool;
            for (int i = 0; i < energyVoxelsSpawnedOnDie; ++i)
            {
                EnergyVoxelController voxel = pool.GetObject();
                if (voxel != null)
                {
                    voxel.transform.position = pos;
                    voxel.transform.rotation = Random.rotation;
                }
            }

            rsc.eventMng.TriggerEvent(EventManager.EventType.ENERGY_VOXEL_SPAWNED, EventInfo.emptyInfo);
        }
        else
        {
            if (explosion != null)
            {
                explosion.transform.position = pos;
                explosion.PlayAudioOnly(explosionWrongColorSoundFx);
            }
        }

        SpawnVoxels();
        rsc.poolMng.spiderPool.AddObject(this);
    }
    public void SpawnVoxelsAndReturnToPool(bool spawnEnergyVoxels = true)
    {
        EnemyExplosionController explosion = rsc.poolMng.enemyExplosionPool.GetObject();
        Vector3 pos = transform.position;

        if (spawnEnergyVoxels)
        {
            if (explosion != null)
            {
                explosion.transform.position = pos;
                explosion.Play(color, explosion2SoundFx);
            }

            EnergyVoxelPool pool = rsc.poolMng.energyVoxelPool;
            for (int i = 0; i < energyVoxelsSpawnedOnDie; ++i)
            {
                EnergyVoxelController voxel = pool.GetObject();
                if (voxel != null)
                {
                    voxel.transform.position = pos;
                    voxel.transform.rotation = Random.rotation;
                }
            }
        }
        else
        {
            if (explosion != null)
            {
                explosion.transform.position = pos;
                explosion.PlayAudioOnly(explosionWrongColorSoundFx);
            }
        }

        SpawnVoxels();
        rsc.poolMng.mosquitoPool.AddObject(this);
    }