Пример #1
0
    }    //end of shoot method

    //animation event function to deal damage, in animation event use this format "damage amount,direction value,range of attack,child object name", ex (1,1,2.5,HitUP) NO SPACES
    //for direction, 1 = right/left, 3 = up, 4 = down, left is actually 2 in the script however in the event it could be either direction, so we will set it to 1
    //and then figure out the direction in the script using the facingright bool
    public void Attack(string info)
    {
        string[] nstring    = info.Split(',');
        float    d          = float.Parse(nstring [0]);
        int      dir        = int.Parse(nstring [1]);
        float    range      = float.Parse(nstring [2]);
        string   hitboxname = nstring [3];

        if (facingRight == true && dir == 1)
        {
            dir = 2;
        }
        DealDamage dmgscript = transform.FindChild(hitboxname).GetComponent <DealDamage> ();

        dmgscript.dmg       = d;
        dmgscript.atkRange  = range;
        dmgscript.direction = dir;
        dmgscript.doDamage();
    }    //end of attack method