Example #1
0
    public void DeSpawn()
    {
        NetworkServer.Destroy(spawnedPlayer.gameObject);

        if (effectSpawn != null && effectSpawn.IsFinshed == false)
        {
            effectSpawn.Stop(false);
        }
    }
Example #2
0
    /// <summary>
    /// Called when the weapon changed.
    /// </summary>
    /// <param name="newWeapon">The new weapon.</param>
    private void WeaponChanged(Weapon newWeapon)
    {
        if (reloadCoroutine != null && reloadCoroutine.IsFinshed == false)
        {
            reloadCoroutine.Stop();
        }

        if (!newWeapon)
        {
            SetNullWeapon();
            return;
        }

        bulletsLeftDisplay.gameObject.SetActive(true);
        gunIcon.sprite = newWeapon.Icon;
        bulletsLeftDisplay.UpdateValue(maxBullets = newWeapon.MagazineSize);
        bulletsLeftPercentage.UpdateValue(1.0f);
    }
Example #3
0
    public void OnFailed()
    {
        if (checkForConnect != null && checkForConnect.IsFinshed == false)
        {
            checkForConnect.Stop(false);
        }

        if (waitAndConnect == null || waitAndConnect.IsFinshed == true)
        {
            waitAndConnect = new ExtendedCoroutine(this, WaitAndConnect(), startNow: true);
        }
    }
Example #4
0
    /// <summary>
    /// Plays a despawn effect. Should be called before the entity is destroyed.
    /// </summary>
    /// <param name="duration">The duration of the effect.</param>
    /// <param name="onFinished">Callback when the effect has finished playing.</param>
    public void PlayDeSpawnEffect(float duration = 0.6f, Action onFinished = null)
    {
        Material spawnMaterial = new Material(MaterialDict.Instance.SpawnMaterial);

        if (currentTempEffect != null && currentTempEffect.IsFinshed == false)
        {
            currentTempEffect.Stop(true);
        }

        spriteRenderer.material = currentEffectMaterial = spawnMaterial;
        currentTempEffect       = new ExtendedCoroutine(this, DeSpawnEffect(spawnMaterial, duration), onFinished, true);
    }
Example #5
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.TryGetComponent(out Player player) == false)
        {
            return;
        }

        if (isServer)
        {
            playersReady.Remove(player);
            if (changeLevelCoroutine != null)
            {
                changeLevelCoroutine.Stop(false);
                Debug.Log("Advancing abort!");
                changeLevelCoroutine = null;
            }
        }
    }
Example #6
0
    public IEnumerator InnerDespawnPickable()
    {
        if (spawnRoutine != null && spawnRoutine.IsFinshed == false)
        {
            spawnRoutine.Stop(false);
        }

        SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();
        Material       despawnMat     = new Material(MaterialDict.Instance.SpawnMaterial);

        spriteRenderer.material = despawnMat;

        yield return(EntityMaterialManager.DeSpawnEffect(despawnMat, 0.75f));

        if (gameObject && isServer)
        {
            NetworkServer.Destroy(gameObject);
        }
    }