Exemplo n.º 1
0
 public virtual void OnTriggerEnter2D(Collider2D collision)
 {
     /*if (collisionTag != "" && collisionTag != null)
      * {*/
     foreach (string collisionTag in collisionTags)
     {
         if (collision.gameObject.CompareTag(collisionTag) && collision.isTrigger)
         {
             //     print(collision.name);
             GenericHealth temp = collision.GetComponent <GenericHealth>();
             if (temp)
             {
                 //print(temp.currentHealth);
                 if (statistics == null || !(statistics is Atacking))
                 {
                     temp.Damage(damage);
                     //print(damage);
                 }
                 else
                 {
                     Atacking atacking = (Atacking)statistics;
                     temp.Damage(atacking.GetAttack());
                     //print(atacking.GetAttack());
                 }
                 //print(damage);
                 //print(temp.currentHealth);
             }
         }
     }
 }
Exemplo n.º 2
0
    //public Resorce res;
    public override void OnTriggerEnter2D(Collider2D collision)
    {
        foreach (string collisionTag in collisionTags)
        {
            if (collision.gameObject.CompareTag(collisionTag) && collision.isTrigger)
            {
                GenericHealth temp = collision.GetComponent <GenericHealth>();
                if (temp)
                {
                    //print(temp.currentHealth);

                    switch (collisionTag)
                    {
                    case "Stone":
                        if (statistics == null || !(statistics is PlayerStatistics))
                        {
                            temp.Damage(damage);
                            gui.ModifyStone(1);
                            //print(damage);
                        }
                        else
                        {
                            PlayerStatistics player = (PlayerStatistics)statistics;
                            temp.Damage(player.stoneDamage.Value);
                            gui.ModifyStone((int)player.stoneGetting.Value);
                            //  print(player.stoneDamage.Value);
                        }

                        break;

                    case "Tree":
                        if (statistics == null || !(statistics is PlayerStatistics))
                        {
                            temp.Damage(damage);
                            gui.ModifyWood(1);
                            //print(damage);
                        }
                        else
                        {
                            PlayerStatistics player = (PlayerStatistics)statistics;
                            temp.Damage(player.woodDamage.Value);
                            gui.ModifyWood((int)player.woodGetting.Value);
                            // print(player.woodDamage.Value);
                        }

                        break;

                    default:
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag(otherTag) && other.isTrigger)
     {
         GenericHealth temp = other.GetComponent <GenericHealth>();
         if (temp)
         {
             temp.Damage(damage);
         }
     }
 }
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag(_otherTag) && other.isTrigger)
     {
         GenericHealth component = other.GetComponent <GenericHealth>();
         if (component)
         {
             component.Damage(_damage);
         }
     }
 }
Exemplo n.º 5
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag(otherTag) && collision.isTrigger)
     {
         GenericHealth temp = collision.gameObject.GetComponent <GenericHealth>();
         if (temp)
         {
             temp.Damage(damage);
         }
     }
 }
Exemplo n.º 6
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag(otherString))
     {
         //Check if there is health
         GenericHealth temp = other.gameObject.GetComponent <GenericHealth>();
         if (temp)
         {
             temp.Damage(damage);
         }
         Destroy(this.gameObject);
     }
 }
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag(otherString))
     {
         // First check to see if there is health
         GenericHealth temp = other.gameObject.GetComponent <GenericHealth>();
         if (temp)
         {
             temp.Damage(damage);
         }
         this.transform.gameObject.SetActive(false);
         //this.transform.parent.gameObject.SetActive(false);
         // Destroy(this.gameObject);
     }
 }
Exemplo n.º 8
0
 public override void OnTriggerEnter2D(Collider2D collision)
 {
     base.OnTriggerEnter2D(collision);
     foreach (string collisionTag in collisionTags)
     {
         if (collision.gameObject.CompareTag(collisionTag) && collision.isTrigger)
         {
             DeathEffect();
             ghoustBasic.thisLoot = null;
             // Destroy(this.transform.parent.gameObject);
             this.GetComponent <KnockBack>().OnTriggerEnter2D(collision);
             //this.GetComponentInParent<Light2D>().
             genericHealth.Damage(genericHealth.currentHealth);
             //print()
         }
     }
 }
Exemplo n.º 9
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag != "Untagged")
        {
            if (other.gameObject.CompareTag(otherTag) && other.isTrigger)
            {
                GenericHealth temp = other.GetComponent <GenericHealth>();

                if (temp)
                {
                    bool isCritical = false;

                    if (tech.category == TechCategory.Physical)
                    {
                        float powerTemp = powerValue(tech, tech.power);
                        // Debug.Log(tech.power + " : " + powerTemp);
                        DamageCalc(thisMonster.GetComponent <MonsterStats>().currentLevel.RuntimeValue,
                                   tech.techType, powerTemp, thisMonster.GetComponentInParent <MonsterStats>().AttackStat,
                                   other.GetComponentInParent <MonsterStats>().DefenceStat);

                        float multiplier = moveEffectiveness(tech, other);
                        float final      = multiplier * damage;
                        final = Random.Range(final * 0.9f, final * 1.1f);
                        temp.Damage((int)final);
                        //Debug.Log("Damage: " + (int)final);
                        DamagePopup.Create(other.transform.position, (int)final, isCritical);
                    }
                    else if (tech.category == TechCategory.Magical)
                    {
                        float powerTemp = powerValue(tech, tech.power);
                        // Debug.Log(tech.power + " : " + powerTemp);
                        DamageCalc(thisMonster.GetComponent <MonsterStats>().currentLevel.RuntimeValue,
                                   tech.techType,
                                   powerTemp, thisMonster.GetComponentInParent <MonsterStats>().MagicStat,
                                   other.GetComponentInParent <MonsterStats>().WillpowerStat);

                        float multiplier = moveEffectiveness(tech, other);
                        float final      = multiplier * damage;
                        final = Random.Range(final * 0.9f, final * 1.1f);
                        temp.Damage((int)final);
                        //  Debug.Log("Damage: " + (int)final);
                        DamagePopup.Create(other.transform.position, (int)final, isCritical);
                    }

                    float powerValue(GenericTech tech, float power)
                    {
                        if (tech.techType != MonsterType.Neutral)
                        {
                            if (tech.techType == thisMonster.GetComponent <MonsterStats>().thisMonster.type1 ||
                                tech.techType == thisMonster.GetComponent <MonsterStats>().thisMonster.type2)
                            {
                                power = power * 1.5f;
                            }
                        }
                        return(power);
                    }

                    float moveEffectiveness(GenericTech tech, Collider2D otherMon)
                    {
                        float result = MonsterData.TypeEffectiveness[tech.techType.ToString()]
                                       [other.GetComponentInParent <MonsterStats>().thisMonster.type1.ToString()];

                        if (other.GetComponentInParent <MonsterStats>().thisMonster.type2.ToString() != "Neutral")
                        {
                            result *= MonsterData.TypeEffectiveness[tech.techType.ToString()]
                                      [other.GetComponentInParent <MonsterStats>().thisMonster.type2.ToString()];
                        }
                        return(result);
                    }
                }
            }
        }
    }