Esempio n. 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        targetdir = parentscript.gettargetdir();

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

            hitbody.GetComponent <health>().Hurt(damagecoefficient * (basedamage + (maxdamagecharge)));
            screenctrl.StopScreen(0.01f);
            return;
        }

        if (col.CompareTag("Player"))
        {
            hitbody      = col.transform;
            playerscript = hitbody.GetComponent <movementctrl>();

            hitvel = hitcoefficient * targetdir * (basepower + (maxhitcharge));
            playerscript.hit(hitvel);

            hitbody.GetComponent <health>().Hurt(damagecoefficient * (basedamage + (maxdamagecharge)));
            screenctrl.StopScreen(0.01f);
            return;
        }
    }
Esempio n. 2
0
 void SpawnNormal(int spawnnum)
 {
     for (int i = 0; i < spawnnum; i++)
     {
         normalscript = Instantiate(spawnman, new Vector2(effectorpos.x + 0.1f, effectorpos.y + Random.Range(-0.1f, 0.1f)), Quaternion.identity).GetComponent <normalai>();
         normalscript.Scared(true);
     }
 }
Esempio n. 3
0
 void Start()
 {
     recover();
     healthbarupdate();
     if (CompareTag("normal"))
     {
         normalscript = transform.GetComponent <normalai>();
     }
     else if (CompareTag("normal enemy"))
     {
         enemyscript = transform.GetComponent <enemyai>();
     }
 }
Esempio n. 4
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;
        }
    }