Пример #1
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (!bouncing)
     {
         if (col.CompareTag("normal") || col.CompareTag("normal enemy"))
         {
             incarscript = col.GetComponent <ableincar>();
             if (incarscript != null)
             {
                 incarscript.getincar(transform.gameObject, slowpercent);
             }
         }
     }
 }
Пример #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        mousedir = parentscript.getmousedir();
        charge   = parentscript.getcharging();

        if (col.CompareTag("normal"))
        {
            hitbody      = col.transform;
            normalscript = hitbody.GetComponent <normalai>();
            if (normalscript.checkincar())
            {
                normalscript.hitincar(hitcoefficient * 1.5f * charge * (1 - normalscript.checkslowpercent()));
            }
            else
            {
                hitvel = hitcoefficient * mousedir * (basepower + (maxhitcharge * (charge / 100)));
                normalscript.hit(hitvel);
            }

            hitbody.GetComponent <health>().Hurt(damagecoefficient * (basedamage + (maxdamagecharge * (charge / 100))));
            if (charge == 100)
            {
                screenctrl.StopScreen(0.05f);
            }
            return;
        }

        if (col.CompareTag("normal enemy"))
        {
            hitbody = col.transform;

            damage = damagecoefficient * (basedamage + (maxdamagecharge * (charge / 100)));
            hitbody.GetComponent <health>().Hurt(damage);

            incarscript = hitbody.GetComponent <ableincar>();
            if (incarscript == null)
            {
                enemyscript = hitbody.GetComponent <enemyai>();
                hitvel      = hitcoefficient * mousedir * (basepower + (maxhitcharge * (charge / 100)));
                enemyscript.hit(hitvel, parent);
                enemyscript.CheckWillScared(damage, hitvel);
            }
            else
            {
                if (incarscript.checkincar())
                {
                    incarscript.hitincar(hitcoefficient * 1.5f * charge * (1 - incarscript.checkslowpercent()));
                }
                else
                {
                    enemyscript = hitbody.GetComponent <enemyai>();
                    hitvel      = hitcoefficient * mousedir * (basepower + (maxhitcharge * (charge / 100)));
                    enemyscript.hit(hitvel, parent);
                    enemyscript.CheckWillScared(damage, hitvel);
                }
            }



            if (charge == 100)
            {
                screenctrl.StopScreen(0.05f);
            }
            return;
        }

        if (col.CompareTag("bodyfragment"))
        {
            hitvel = hitcoefficient * 1.5f * mousedir * (basepower + (maxhitcharge * (charge / 100)));
            col.GetComponent <Rigidbody2D>().velocity = hitvel;
            return;
        }

        if (col.CompareTag("chest") || col.CompareTag("dropweapon"))
        {
            targetweight = col.GetComponent <dropweapon>().getweight();
            hitvel       = hitcoefficient * 1.5f * mousedir * (basepower + (maxhitcharge * (charge / 100))) * (10 / targetweight);
            col.GetComponent <Rigidbody2D>().velocity = hitvel;
            return;
        }
    }