Exemple #1
0
    /// <summary>
    /// Applies damage to this monster.
    /// </summary>
    /// <param name="attack">Contains damage info.</param>
    public void TakeDamage(MonsterAttackInfo attackInfo)
    {
        health -= attackInfo.baseDamage;
        //healthText.text = health.ToString();
        if (health <= 0)
        {
            // Should this be here???
            //OnDeath += group.MonsterDeath;
            //OnDeath(this,enemyTarget.GetComponent<Monster>());  // send event to this monster group
            //OnDeath.
            if (attackInfo.attacker != null)
            {
                Debug.Log("Alas poor " + name + " was killed by " + attackInfo.attacker.name);
            }
            else
            {
                Debug.Log("Alas poor " + name + " was killed by natural causes (probably a status effect)");
            }
            Die(attackInfo);
        }

        if (state != MonsterState.ATTACK && attackInfo.attacker != null && !attackInfo.attacker.IsDead)
        {
            AttackMonster(attackInfo.attacker);
            if (OnAttacked != null)
            {
                OnAttacked(this, attackInfo.attacker);
            }
        }

        //Debug.Log(this.name + " Attacked! Health: " + this.health.ToString());
    }
Exemple #2
0
        private MonsterAttackInfo GetAttackInfo(bool usingSkill)
        {
            MonsterAttackInfo i = new MonsterAttackInfo
            {
                Target   = Monster.Target,
                UseSkill = usingSkill
            };

            return(i);
        }
Exemple #3
0
    protected override void EffectBehaviour()
    {
        MonsterAttackInfo info = new MonsterAttackInfo(null, -1);

        targetMonster.TakeDamage(info);
        if (targetMonster.GetHealth() == 100)
        {
            EndEffect();
        }
    }
Exemple #4
0
    /*
     * private void UpdateText() {
     *  if(healthText != null){
     *          string text = gameObject.name + "\n";
     *          if(health < 100){
     *              text += "HP: "; //text += "HP: " + health.ToString() + "\n";
     *              for(int i = 0; i < health/10;i++){
     *                  text += "X";
     *              }
     *              text += "\n";
     *          }
     *          text += "ST: ";
     *          if(state == MonsterState.ATTACK)
     *              text += combatState.ToString();
     *          else
     *              text += state.ToString();
     *          text += "\n";
     *          if(followTarget != null)
     *              text += "FT: " +followTarget.name + " ";
     *          if(enemyTarget != null)
     *              text +="ET: "+ enemyTarget.name;
     *
     *          healthText.text = text;
     *      }
     *  //healthText.text = health.ToString() + "\n" + state.ToString() + ((state == MonsterState.ATTACK) ? " " + combatState.ToString() : "") + "\nFT: " + (followTarget != null) + " AT: " + (enemyTarget != false) + " ANGLE: " + (angle*Mathf.Rad2Deg).ToString();
     * }
     */

    private void Die(MonsterAttackInfo finalBlow)
    {
        isDead = true;
        Debug.Log(name + " Died");

        /*
         * if(enemyTarget != null){
         *  OnDeath(this,enemyTarget.GetComponent<Monster>());  // send event to this monster group
         * }else{
         *  OnDeath(this,null);
         * }*/
        OnDeath(this, finalBlow.attacker);
        Debug.Log(name + " Getting Destroyed!");
        //DropLoot();
        Destroy(this.gameObject);
        Debug.Log(name + " Destroyed?!?");
    }
Exemple #5
0
        private void AttackEntity(BaseEntity ent)
        {
            UpdateTarget();

            if (Monster.Target != null)
            {
                if (!TargetOnAttackRange())
                {
                    state = MonsterAIState.Chase;
                }
                else
                {
                    Monster.Target    = ent;
                    Monster.Attacking = true;

                    MonsterAttackInfo info = GetAttackInfo(false);
                    if (MonsterAttack != null)
                    {
                        MonsterAttack(this, new MonsterAttackInfoEventArgs(info));
                    }
                }
            }
        }
Exemple #6
0
 public MonsterAttackInfoEventArgs(MonsterAttackInfo i)
 {
     this.info = i;
 }
Exemple #7
0
    public override void AddOrb()
    {
        MonsterAttackInfo info = new MonsterAttackInfo(null, -HEAL_AMOUNT);

        monster.TakeDamage(info);
    }
Exemple #8
0
 public void SetInfo(MonsterAttackInfo i)
 {
     this.GetComponent <Collider>().enabled = true;
     info    = i;
     hasInfo = true;
 }
Exemple #9
0
    protected override void EffectBehaviour()
    {
        MonsterAttackInfo info = new MonsterAttackInfo(null, damage);

        targetMonster.TakeDamage(info);
    }