Exemple #1
0
    /// <summary>
    /// Called when the reloading started.
    /// </summary>
    /// <param name="reloadTime">The time it takes to reload the weapon.</param>
    private void ReloadingBegins(float reloadTime)
    {
        if (reloadCoroutine != null && reloadCoroutine.IsFinshed == false)
        {
            reloadCoroutine.Stop();
        }

        reloadCoroutine = new ExtendedCoroutine(this, ReloadAnimation(reloadTime), startNow: true);
    }
Exemple #2
0
    /// <summary>
    /// Hides the element.
    /// </summary>
    public void Hide()
    {
        if (extendedCoroutine != null && extendedCoroutine.IsFinshed == false)
        {
            return;
        }

        extendedCoroutine = new ExtendedCoroutine(this, OnHide(), OnHideFinished, true);
    }
Exemple #3
0
    /// <summary>
    /// Plays a sound that the weapon can not shoot for whatever reason, if it was not play
    /// too long ago.
    /// </summary>
    /// <param name="eventName">The event to be played</param>
    public void PlayWeaponCanNotShoot(string eventName)
    {
        if (weaponCanNotShootCoroutine != null && weaponCanNotShootCoroutine.IsFinshed == false)
        {
            return;
        }

        weaponCanNotShootCoroutine = new ExtendedCoroutine(this, WeaponCanNotShoot(eventName), startNow: true);
    }
Exemple #4
0
    /// <summary>
    /// Handles the displaying a temp effect.
    /// </summary>
    /// <param name="material">The temp material.</param>
    /// <param name="duration">The duration of the effect.</param>
    private void StartTempEffect(IEnumerator enumerator, Material material)
    {
        if (currentTempEffect != null && currentTempEffect.IsFinshed == false)
        {
            return;
        }

        spriteRenderer.material = currentEffectMaterial = material;
        currentTempEffect       = new ExtendedCoroutine(this, enumerator, ResetMaterial, true);
    }
Exemple #5
0
 /// <summary>
 /// Reloads the gun.
 /// </summary>
 public bool Reload()
 {
     if (weapon && !IsFiring && !IsReloading && weapon.MagazineSize != 0)
     {
         reloadCoroutine = ExtendedCoroutine.ActionAfterSeconds(this, weapon.ReloadTime, OnReloaded, true);
         NetworkWeaponAnimator.OnStartedReload();
         ReloadingBegins?.Invoke(weapon.ReloadTime);
         return(true);
     }
     return(false);
 }
Exemple #6
0
    /// <summary>
    /// Starts the boss animation for the local player.
    /// </summary>
    public void StartBossAnimation(BossSpawnMessage bossSpawnMessage)
    {
        if (!Player.LocalPlayer || Player.LocalPlayer.isServer)
        {
            return;
        }

        BossEnterAnimation bea = BossEnterAnimation.AddAnimationType(gameObject, bossSpawnMessage.animationType);

        enterAnimationCoroutine = new ExtendedCoroutine(this, bea.PlayAnimation(bossSpawnMessage.bossGameObjects[0], this), Player.LocalPlayer.StateCommunicator.CmdBossAnimationFinished, true);
    }
Exemple #7
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);
        }
    }
Exemple #8
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);
    }
Exemple #9
0
    public void ServerReviving(Player player)
    {
        // Maybe add a check if the player is in range.

        if (!player || player.Health.Alive)
        {
            return;
        }

        downedPlayerAbleToRevive = player;
        revivingCoroutine        = ExtendedCoroutine.ActionAfterSeconds(this, timeForPlayerRevive, OnServerPlayerRevived, true);
        RpcOnRevivingOtherPlayerStarted();
    }
Exemple #10
0
    public override void OnStartClient()
    {
        SpriteRenderer renderer = GetComponent <SpriteRenderer>();

        renderer.sprite = pickable.Icon ? pickable.Icon : PickableDict.Instance.MissingTexture;

        if (playSpawnAnimation == true)
        {
            spawnRoutine = new ExtendedCoroutine(this, SpawnEffect(renderer), startNow: true);
        }

        gameObject.layer = LayerDict.Instance.GetPickableLayer();
    }
    public void Spawn()
    {
        if (spawnedPlayer != null)
        {
            return;
        }

        spawnedPlayer = Instantiate(playerPrefab, transform.position, Quaternion.identity);
        spawnedPlayer.PlayerAI.Brain.tree = tree;
        NetworkServer.Spawn(spawnedPlayer.gameObject);

        effectSpawn = new ExtendedCoroutine(this, SpawnWorldEffect(), startNow: true);
    }
Exemple #12
0
    /// <summary>
    /// Starts firing the gun.
    /// </summary>
    public bool StartFire()
    {
        if (!CanFire)
        {
            return(false);
        }

        // Play shoot animation
        fireCoroutine = new ExtendedCoroutine(this, weapon.Shoot(this), OnStopFiring, true);

        NetworkWeaponAnimator.OnStartedFire();

        return(true);
    }
Exemple #13
0
    /// <summary>
    /// Show the element.
    /// </summary>
    public void Show()
    {
        if (extendedCoroutine != null && extendedCoroutine.IsFinshed == false)
        {
            return;
        }

        extendedCoroutine = new ExtendedCoroutine
                            (
            this,
            EnumeratorUtil.GoToInSecondsLocalCurve(transform, endPos, hideShowCurve, showInSeconds),
            OnShownFinished,
            true
                            );
    }
Exemple #14
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;
            }
        }
    }
Exemple #15
0
    public void OnAllPlayersReadyToEnter(BossReadyZone bossReadyZone)
    {
        CurrentState = State.InProgress;

        GameObject[] objs = SpawnBoss();
        CloseDoors();

        PlayersStartPos = (bossReadyZone.OnDoor.transform.position - bossReadyZone.transform.position) * 2 + bossReadyZone.transform.position;

        BossSpawnMessage bossSpawnMessage = new BossSpawnMessage {
            bossGameObjects = objs,
            id            = id,
            animationType = bossObjects[0].AnimationType
        };

        SpawnedEnemies = new Enemy[objs.Length];
        for (int i = 0; i < objs.Length; i++)
        {
            SpawnedEnemies[i] = objs[i].GetComponent <Enemy>();
        }

        NetworkServer.SendToAll(bossSpawnMessage);

        // Make all players not being able to move.
        List <Player> players = PlayersDict.Instance.Players;

        for (int i = 0; i < players.Count; i++)
        {
            players[i].RpcChangeCanMove(false);
        }

        // Start the boss animations.
        enterAnimation          = BossEnterAnimation.AddAnimationType(gameObject, bossObjects[0].AnimationType);
        enterAnimationCoroutine = new ExtendedCoroutine(this, enterAnimation.PlayAnimation(objs[0], this),
                                                        StartCheckingForAllPlayersWatchedEnterAnimation, true);

        GameManager.OnRoomEventStarted();
    }
Exemple #16
0
 public void Show()
 {
     gameObject.SetActive(true);
     checkForConnect = new ExtendedCoroutine(this, CheckForConnected(), startNow: true);
 }
Exemple #17
0
 private void Awake()
 {
     ext = new ExtendedCoroutine(this, Test(), OnFinished);
     ext.Start();
 }
Exemple #18
0
 private void StartCheckingForAllPlayersWatchedEnterAnimation()
 {
     enterAnimationCoroutine = new ExtendedCoroutine(this, CheckForPlayersWatchedEnterAnimation(), StartBossEncounter, true);
 }