// the enemy is null if not exists one virtual public void OnAttack(Creature enemy = null) { if (currentHP == 0) { return; } int targetId = 0; if (enemy != null) { if (enemy.currentHP == 0) { return; } if (enemy.IsInvulnerable()) { return; } targetId = enemy.entityId; } SAttack attack = new SAttack(); attack.ID = this.entityId; attack.targetID = targetId; Broadcast(attack); }
private void OnRecvAttack(IChannel channel, Message message) { SAttack msg = message as SAttack; NetworkEntity source = networkEntities[msg.ID]; if (msg.targetID != 0 && msg.targetID != World.Instance.teammate_dbid) { NetworkEntity target = networkEntities[msg.targetID]; source.behavior.Attack(target.behavior); } else { source.behavior.Attack(null); } }