Esempio n. 1
0
    public void Use(Vector3 pos, Vector3 dir, Vector3 targetPos)
    {
#if !DEADZONE_CLIENT
        if (Settings.ItemUse == E_ItemUse.Passive)
        {
            return;
        }

        if (uLink.Network.isServer == false)
        {
            return;
        }

        bool allowed = false;

        switch (Server.Instance.GameInfo.GameType)
        {
        case E_MPGameType.DeathMatch:
            allowed = Settings.AllowedInDeathmatch;
            break;

        case E_MPGameType.ZoneControl:
            allowed = Settings.AllowedInZoneControl;
            break;
        }

        if (allowed)
        {
            Owner.StatisticAddItemUse(Settings.ID);

            switch (Settings.ItemBehaviour)
            {
            case E_ItemBehaviour.Throw:
                allowed = ThrowObject(pos, (targetPos - pos).normalized);
                break;

            case E_ItemBehaviour.Place:
                allowed = PlaceObject(pos, dir);
                break;

            default:
                throw new System.Exception("Item: Unknown behaviour");
            }
        }         // no else here

        if (!allowed && null != Owner)
        {
            if (Server.Instance != null)
            {
                Server.Instance.PlaySoundDisabledOnClient(Player.GetNetworkPlayer(Owner));
            }
        }
#endif
    }