// Use this for initialization protected override void Start() { base.Start(); OpponentTag = NPCKind.SUMMONED.Tag; NPCMessageBus.TriggerMessage( MessageBuilder.BuildNPCKindValueMessage( MessageType.OpponentsChange, NPCKind.SUMMONED)); AttachHealthBar(24f, 1f, 1.1f); }
// Use this for initialization protected override void Start() { base.Start(); OpponentTag = NPCKind.ENEMY.Tag; NPCMessageBus.TriggerMessage( MessageBuilder.BuildNPCKindValueMessage( MessageType.OpponentsChange, NPCKind.ENEMY)); AttachHealthBar(24f, 1f, 0.5f); combatModule.attackAnim = "Summoned_ClawDemon_Attack"; }
// Update is called once per frame void Update() { if (HasAnyTargets()) { DetermineLoseTargets(); } if (HasAnyTargets()) { NPCMessageBus.TriggerMessage( MessageBuilder.BuildVector2Message(MessageType.MovementAdjustment, GetMovementDirection())); } }
private void HandleCollided(Message message) { GameObject other = message.GameObjectValue; IDamageable opponentCombatModule = other.GetComponentInParent <NPC>(); if (other.CompareTag(OpponentTag)) { // TODO: implement a non-entity, combathandler messageBus // so we're not directly referencing another gameobject. SetAttackTarget(opponentCombatModule); NPCMessageBus.TriggerMessage( MessageBuilder.BuildGameObjectMessage(MessageType.FightEngaged, other)); } }
public void Attack() { if (attackTarget != null) { isAttacking = true; NPCMessageBus.TriggerMessage(CreateAttackingMessage(true)); Invoke("DoDamage", 0.3f); } else { Debug.Log("attack target was nullified!"); SetAttackTarget(null); } }
public void Hurt(float dmgTaken) { health -= dmgTaken; if (isAlive && health <= 0) { NPCMessageBus.TriggerMessage(MessageBuilder.BuildMessage(MessageType.Died)); isAlive = false; } else { SendHealthUpdateMessage(); } }
private void TargetLost() { NPCMessageBus.TriggerMessage( MessageBuilder.BuildMessage(MessageType.TargetLost)); }
private void TargetAcquired() { NPCMessageBus.TriggerMessage( MessageBuilder.BuildMessage(MessageType.TargetAcquired)); }
private void StopAttackAnimation() { isAttacking = false; NPCMessageBus.TriggerMessage(CreateAttackingMessage(false)); }
private void SendHealthUpdateMessage() { NPCMessageBus.TriggerMessage(MessageBuilder .BuildFloatMessage(MessageType.HealthUpdate, GetPercentageOfMaxHealth())); }
private void ResolveFight() { attackTarget = null; NPCMessageBus.TriggerMessage( MessageBuilder.BuildMessage(MessageType.FightResolved)); }
private void TriggerVisionEnterMessage(Collider2D other) { NPCMessageBus.TriggerMessage( MessageBuilder.BuildGameObjectMessage( MessageType.VisionEnter, other.gameObject)); }