Пример #1
0
    void DamageAlert(int id, int amount, Vector3 dir, Vector3 point, int newHealth)
    {
        Debug.Log("DamageAlert");

        FPControl target = null;

        foreach (FPControl fp in FindObjectsOfType <FPControl>())
        {
            if (fp.unitId == id)
            {
                target = fp;
                break;
            }
        }
        if (target != null)
        {
            if (target.hasAuthority)
            {
                target.Damage(amount, dir, point);
            }
            else
            {
                target.OnDamage(amount, dir, point);
            }
        }
    }
Пример #2
0
    public void DamageUnit(FPControl fp, int amount, Vector3 point)    //Called to damage this controller, isFromServer defaults to be "sent" from other side
    {
        if (fp.hasAuthority)
        {
            fp.Damage(amount, -direction, point);
        }
        else
        {
            fp.OnDamage(amount, -direction, point);
        }

        if (fp.playerControl != null)                                                                                            //Player may not have joined yet;   IF COMMANDING PLAYER HAS NOT JOINED, THIS WILL NOT DEAL DAMAGE. HOWEVER, THIS SHOULD NEVER OCCUR.
        {
            Manager.bulletHits.Add(new Manager.HitInfo(fp.unitId, amount, -direction, point, fp.health /*, (isServer ?1 :0)*/)); //This necessary to get around Unity's built-in refusal to let Bullet send Cmds
        }
    }