Exemplo n.º 1
0
    protected void HitDetachableHitbox(AttachableHitbox user, DetachableHitbox receiver)
    {
        // Destroy projectile(or deflect projectile + hitstun the projectile too)
        MonoBehaviour.Destroy(receiver.gameObject);

        // Apply hitstun
        user.Character.GetComponent <CharacterCore>().ApplyHitstun(preset.HitstunDuration);
    }
Exemplo n.º 2
0
 protected void HitCharacter(DetachableHitbox user, CharacterCore receiver)
 {
     // Apply damage
     ShowFloatingText(receiver.transform, preset.Damage);
     receiver.TakeDamage(preset.Damage);
     receiver.ApplyHitstun(preset.HitstunDuration);
     receiver.GetComponent <CharacterMover>().SetVelocity(Vector2.up * preset.KnockupVelocity);
     Debug.Log("Hit character!");
 }
Exemplo n.º 3
0
    protected DetachableHitbox InstantiateProjectile(Vector2 direction, float duration)
    {
        Transform        projectileSpawnLocation = user.transform.Find(preset.ProjectileSpawnLocationName);
        DetachableHitbox projectile = MonoBehaviour.Instantiate(preset.ProjectilePrefab, projectileSpawnLocation.position, Quaternion.identity).GetComponent <DetachableHitbox>();

        projectile.Initialise(user);
        projectile.AddEnterListener(HitCharacter);
        projectile.GetComponent <LinearProjectile>().SetParameters(direction, duration);

        return(projectile);
    }
Exemplo n.º 4
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (!Active || !StayActive)
        {
            return;
        }

        if (ReferenceEquals(User, collision.gameObject)) // If I collided with the user, ignore
        {
            return;
        }


        bool successfulHit = false;

        if (attachedHitboxLayer.Contains(collision.gameObject))
        {
            AttachableHitbox other = collision.GetComponent <AttachableHitbox>();
            OnHitAttachableHitboxStay?.Invoke((T)this, other);
            HitAttachableHitboxStay(other);
            successfulHit = true;
        }
        else if (detachedHitboxLayer.Contains(collision.gameObject))
        {
            DetachableHitbox other = collision.GetComponent <DetachableHitbox>();
            if (GetInstanceID() > other.GetInstanceID())
            {
                OnHitDetachableHitboxStay?.Invoke((T)this, other); // Apply Destroy() within the Effect
                HitDetachableHitboxStay(other);
                successfulHit = true;
            }
        }
        else if (characterLayer.Contains(collision.gameObject))
        {
            CharacterCore other = collision.GetComponent <CharacterCore>();
            OnHitCharacterStay?.Invoke((T)this, other);
            HitCharacterStay(other);
            successfulHit = true;
        }
        else if (groundLayer.Contains(collision.gameObject))
        {
            OnHitGroundStay?.Invoke((T)this);
            HitGroundStay();
            successfulHit = true;
        }

        // General behaviour
        if (successfulHit)
        {
            HitAnythingStay();
        }
    }
Exemplo n.º 5
0
 protected virtual void HitDetachableHitboxStay(DetachableHitbox other)
 {
 }
Exemplo n.º 6
0
 protected virtual void HitDetachableHitboxEnter(DetachableHitbox other)
 {
 }
Exemplo n.º 7
0
    protected override void HitDetachableHitboxEnter(DetachableHitbox other)
    {
        GameObject hp = Instantiate(hitParticle);

        hp.transform.position = transform.position;
    }