Exemplo n.º 1
0
        private void UponStopped(RaycastHit2D hit, ICollisionSurface surfaceData, Vector2 dir)
        {
            // Called whenever the projectile is stopped in it's tracks by an object that it can't penetrate.
            SpawnHitEffect(surfaceData.GetHitEffect() ?? HitEffectPrefab, hit.point, hit.normal);

            DealDamage(hit, surfaceData, false, false, dir);
        }
Exemplo n.º 2
0
        private void UponReflected(RaycastHit2D hit, ICollisionSurface surfaceData, float chance, Vector2 dir)
        {
            // Called whenever the projectile is deflected off a surface that it could not penetrate.
            SpawnHitEffect(ReflectEffectPrefab, hit.point, hit.normal);

            DealDamage(hit, surfaceData, false, true, dir);
        }
Exemplo n.º 3
0
        private void UponPenetrate(RaycastHit2D hit, ICollisionSurface surfaceData, Vector2 dir)
        {
            // Called whenever the projectile penetrates a surface.
            SpawnHitEffect(surfaceData.GetHitEffect() ?? HitEffectPrefab, hit.point, hit.normal);

            DealDamage(hit, surfaceData, true, false, dir);
        }
Exemplo n.º 4
0
        private void DealDamage(RaycastHit2D hit, ICollisionSurface surface, bool penetrated, bool reflected, Vector2 dir)
        {
            // Of course no damage is dealt on the client.
            if (!JNet.IsServer)
            {
                return;
            }

            // Currently reflections deal no damage...
            if (reflected)
            {
                return;
            }

            // TODO UNDONE - Reduce damage based on current number of penetrations, damage falloff etc.
            Health h = surface.GetHealth();

            if (h != null)
            {
                h.ChangeHealth(hit.collider, -Damage);
            }
        }