Skip to content

Instantly share code, notes, and snippets.

@smkplus
Created April 9, 2020 16:08
Show Gist options
  • Select an option

  • Save smkplus/9c9c61bbfb588e2094f91aaaebc206c2 to your computer and use it in GitHub Desktop.

Select an option

Save smkplus/9c9c61bbfb588e2094f91aaaebc206c2 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class CombatComponent : MonoBehaviour
{
public void PlayerAttacksEnemy(Player player, Enemy enemy)
{
if (player != null)
{
enemy?.ReceiveDamage(player.Attack);
}
}
public void EnemyAttacksPlayer(Enemy enemy, Player player)
{
if (enemy != null)
{
player?.ReceiveDamage(enemy.Attack);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment