Example #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        PlayerControl player     = col.gameObject.GetComponent <PlayerControl>();
        ThrowEnemy    throwEnemy = col.gameObject.GetComponent <ThrowEnemy>();
        PlayerBat     bat        = col.gameObject.GetComponent <PlayerBat>();

        if (bat)
        {
            this.collider2D.enabled = false;
            DispatchMessage("OnHitByBat", this);
            this.directionX = 1;
            this.directionY = Random.Range(minimumYOffset, maximumYOffset);
            this.speed     *= hitByPlayerMultiplier;
            isHitBybat      = true;
            onHitSound.GetSound().Play();
            Invoke("OnDestroy", destroyTimeout);
            return;
        }

        if (throwEnemy && isHitBybat)
        {
            DispatchMessage("OnHitByThrowable", this);
            Destroy(this.gameObject);
        }

        if (player)
        {
            this.collider2D.enabled = false;
            player.OnDie();
        }
    }
Example #2
0
 protected override void DoExtraOnEntered()
 {
     throwEnemy = this.GetComponentInChildren <ThrowEnemy>();
     throwEnemy.AddEventListener(this.gameObject);
     throwEnemy.SetAmountOfObjectsToThrow(amountOfObjectsThrown);
 }