コード例 #1
0
    // 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);
    }
コード例 #2
0
    // 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";
    }
コード例 #3
0
 // Update is called once per frame
 void Update()
 {
     if (HasAnyTargets())
     {
         DetermineLoseTargets();
     }
     if (HasAnyTargets())
     {
         NPCMessageBus.TriggerMessage(
             MessageBuilder.BuildVector2Message(MessageType.MovementAdjustment, GetMovementDirection()));
     }
 }
コード例 #4
0
    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));
        }
    }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
    public void Hurt(float dmgTaken)
    {
        health -= dmgTaken;
        if (isAlive && health <= 0)
        {
            NPCMessageBus.TriggerMessage(MessageBuilder.BuildMessage(MessageType.Died));

            isAlive = false;
        }
        else
        {
            SendHealthUpdateMessage();
        }
    }
コード例 #7
0
 private void TargetLost()
 {
     NPCMessageBus.TriggerMessage(
         MessageBuilder.BuildMessage(MessageType.TargetLost));
 }
コード例 #8
0
 private void TargetAcquired()
 {
     NPCMessageBus.TriggerMessage(
         MessageBuilder.BuildMessage(MessageType.TargetAcquired));
 }
コード例 #9
0
 private void StopAttackAnimation()
 {
     isAttacking = false;
     NPCMessageBus.TriggerMessage(CreateAttackingMessage(false));
 }
コード例 #10
0
 private void SendHealthUpdateMessage()
 {
     NPCMessageBus.TriggerMessage(MessageBuilder
                                  .BuildFloatMessage(MessageType.HealthUpdate, GetPercentageOfMaxHealth()));
 }
コード例 #11
0
 private void ResolveFight()
 {
     attackTarget = null;
     NPCMessageBus.TriggerMessage(
         MessageBuilder.BuildMessage(MessageType.FightResolved));
 }
コード例 #12
0
 private void TriggerVisionEnterMessage(Collider2D other)
 {
     NPCMessageBus.TriggerMessage(
         MessageBuilder.BuildGameObjectMessage(
             MessageType.VisionEnter, other.gameObject));
 }