private void InstantiateVirusSpawner()
    {
        if (_disableVirusSpawnerInstancing)
        {
            return;
        }

        // prevent spawning another virus spawner
        if (_currentVirusSpawner != null)
        {
            return;
        }

        ExtendedAnalytics.SendEvent("Virus Spawner Instanciated", new Dictionary <string, object>()
        {
            { "Kill count", GameManager.Instance.Gamemode.KillCount }
        });

        // prevent spawning if viruses are on the map
        if (FindObjectsOfType <VirusController>().Length != 0)
        {
            return;
        }

        var        position = LevelDataLocator.GetLevelData().GetRandomVirusSpawnerPosition();
        Quaternion rot      = Quaternion.identity;

        _currentVirusSpawner = Instantiate(_prefabVirusSpawner, position, rot);

        OnVirusSpawnerSpawned?.Invoke(_currentVirusSpawner.GetComponent <VirusSpawner>());
    }
Beispiel #2
0
    protected override void Death(Entity killer)
    {
        _currentDeathCount++;
        SetCurrentHealthBar();

        // VirusTriggerer has reach last position
        if (_currentDeathCount >= _deathCountToReleaseVirus || _debugInstantKill)
        {
            killer.OnKillMade?.Invoke(killer, this);
            TriggerVirus(killer);

            CameraShake.Instance.Shake(0.3f, 0.15f);
            CameraEffectController.Instance.EnableGlitch(true);

            CameraEffectController.Instance.ExecuteAfterTime(_glitchEffectDuration, ()
                                                             => CameraEffectController.Instance.EnableGlitch(false));

            float lifetime = Time.time - _instanciatedTime;
            ExtendedAnalytics.SendEvent("Virus Spawner Killed", new Dictionary <string, object>
            {
                { "Lifetime", lifetime }
            });
        }
        else
        {
            var newPosition = LevelDataLocator.GetLevelData().GetRandomVirusSpawnerPosition(transform.position);
            GetComponent <FancyObject>()?.ResetStartingPosition(newPosition);

            _hp = MaxHp;
            UpdateHealthSlider();

            CameraShake.Instance.Shake();
        }
    }
    void GrabStickmanToNextSpawnPoints()
    {
        // foreach stickman
        for (int i = 0; i < GameManager.Instance.Characters.Count; i++)
        {
            var charId    = (CharId)i;
            var character = GameManager.Instance.Characters[charId];
            var cursor    = _owner.GrabStickmanCursors[i];

            if (character == null)
            {
                continue;
            }

            // freeze character input
            character.Freeze  = true;
            character.enabled = false;


            Queue <AbstractCursorCommand> cursorCommands = new Queue <AbstractCursorCommand>();

            // cursor commands
            Vector3 spawnPosition = LevelDataLocator.GetLevelData().GetDefaultSpawnPoint(charId);

            var moveToStickman   = new MoveToCommand(character.transform);
            var drag             = new StartDragCommand(character.transform, character.ForceJumpSprite);
            var moveToSpawnPoint = new MoveToCommand(spawnPosition);

            cursorCommands.Enqueue(moveToStickman);
            cursorCommands.Enqueue(drag);
            cursorCommands.Enqueue(moveToSpawnPoint);

            cursor.StartCommandsSequence(cursorCommands);
        }
    }
    void SpawnProjectilePickup()
    {
        if (_disablePickupSpawning)
        {
            return;
        }

        ResetTimers();

        int projectilePickupInLevel = FindObjectsOfType <ProjectilePickup>().Length;

        // projectiles pickup in the level limit reached
        if (projectilePickupInLevel >= _data.MaxProjectilePickupsSimultaneously)
        {
            return;
        }

        var position = LevelDataLocator.GetLevelData().GetRandomProjectilePickupPosition();
        var rotation = Quaternion.identity;

        var projectilePickup = ObjectPooler.Instance.SpawnFromPool(POOL_ID_PROJECTILEPICKUP, position, rotation).GetComponent <ProjectilePickup>();

        OnProjectilePickupSpawn?.Invoke(projectilePickup);
    }