예제 #1
0
    private void Stun(Player otherPlayer)
    {
        PlayerStun         otherStun         = otherPlayer.GetComponent <PlayerStun>();
        PlayerStateManager otherStateManager = otherPlayer.GetComponent <PlayerStateManager>();

        if (otherStun != null && otherStateManager != null)
        {
            cameraShake.shakeAmount   = stealShakeAmount;
            cameraShake.shakeDuration = stealShakeDuration;
            otherStateManager.AttemptStun(
                () => otherStun.StartStun(rb.velocity.normalized * stealKnockbackAmount, stealKnockbackLength),
                otherStun.StopStunned);
        }
    }
예제 #2
0
    private void BlowBackEnemyPlayers()
    {
        if (player.team == null)
        {
            return;
        }
        TeamManager enemyTeam = GameManager.instance.teams.Find((teamManager) => teamManager != player.team);

        Debug.Assert(enemyTeam != null);

        {
            // Because C# doesn't have lvalue references. FML.
            GameObject     effect = Instantiate(blowbackEffectPrefab, transform.position, transform.rotation);
            ParticleSystem ps     = effect.GetComponent <ParticleSystem>();
            ParticleSystem.ColorOverLifetimeModule col = ps.colorOverLifetime;

            col.enabled = true;

            Gradient grad = new Gradient();
            grad.SetKeys(
                new GradientColorKey[] {
                new GradientColorKey(player.team.teamColor, 0.0f)
            },
                new GradientAlphaKey[] {
                new GradientAlphaKey(1.0f, 0.0f),
                new GradientAlphaKey(0.25f, 0.75f),
                new GradientAlphaKey(0.0f, 1.0f)
            }
                );
            col.color = grad;

            Destroy(effect, 1.0f);
        }

        foreach (Player enemyPlayer in enemyTeam.teamMembers)
        {
            Vector3 blowBackVector = enemyPlayer.transform.position - transform.position;
            if (blowBackVector.magnitude < blowbackRadius)
            {
                PlayerStun         otherStun         = enemyPlayer.GetComponent <PlayerStun>();
                PlayerStateManager otherStateManager = enemyPlayer.GetComponent <PlayerStateManager>();
                if (otherStun != null && otherStateManager != null)
                {
                    otherStateManager.AttemptStun(() => otherStun.StartStun(blowBackVector.normalized * blowbackForce, blowbackStunTime), otherStun.StopStunned);
                }
            }
        }
    }
예제 #3
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject         other        = collision.gameObject;
        Player             player       = other.GetComponent <Player>();
        PlayerStateManager stateManager = other.GetComponent <PlayerStateManager>();

        if (stretchWallCoroutine != null)
        {
            // Check if it was your teammate
            Player otherPlayer = other.GetComponent <Player>();
            if (otherPlayer != null &&
                otherPlayer.team.teamColor == team.teamColor)
            {
                return;
            }

            creator.HandleWallCollision();
            GameManager.instance.notificationManager.NotifyMessage(Message.TronWallDestroyedWhileLaying, creator.gameObject);
            PlayDestroyedParticleEffect();
            Destroy(gameObject);
            return;
        }

        Ball ball = other.GetComponent <Ball>();

        if (ball != null)
        {
            KillSelf();
        }
        else if ((player != null) && (stateManager != null) &&
                 (stateManager.currentState == State.Dash))
        {
            KillSelf();
            PlayerStun playerStun = other.EnsureComponent <PlayerStun>();
            stateManager.AttemptStun(() =>
            {
                Vector3 otherDirection = player.transform.right;
                other.EnsureComponent <Rigidbody2D>().velocity = Vector2.zero;
                playerStun.StartStun(-otherDirection * knockbackOnBreak, creator.wallBreakerStunTime);
                GameManager.instance.notificationManager.NotifyMessage(Message.TronWallDestroyed, other);
            },
                                     playerStun.StopStunned);
        }
    }
예제 #4
0
    public static void BlowbackPlayers(Vector2 center, float radius,
                                       float blowback_strength,
                                       bool blowback_is_velocity     = false,
                                       HashSet <GameObject> excludes = null,
                                       float?stunTime = null)
    {
        GameObjectCallback stunPlayer = (GameObject thing) =>
        {
            PlayerStateManager player = thing.GetComponent <PlayerStateManager>();
            PlayerStun         stun   = thing.GetComponent <PlayerStun>();
            if (player != null && stun != null)
            {
                player.AttemptStun(
                    () => stun.StartStun(null, stunTime), stun.StopStunned);
            }
        };

        Blowback(center, radius, blowback_strength, blowback_is_velocity,
                 LayerMask.GetMask("Player"), stunPlayer, excludes);
    }
예제 #5
0
 public void HandleWallCollision()
 {
     AudioManager.instance.StunPlayerWallBreak.Play(.35f);
     stateManager.AttemptStun(() => playerStun.StartStun(Vector2.zero, lengthStunWhileLaying),
                              () => playerStun.StopStunned());
 }