Beispiel #1
0
 public override bool TryPickup(Gun_Base gun)
 {
     if (primaryGun == null)
     {
         primaryGun  = gun;
         equippedGun = primaryGun;
         secondaryGun.gameObject.SetActive(false);
         CB_AmmoChanged();
         return(true);
     }
     return(false);
 }
Beispiel #2
0
    private NetworkIdentity SpawnGun(Gun_Base gun)
    {
        GameObject gunGO = Instantiate(gun.gameObject);

        NetworkServer.Spawn(gunGO);

        NetworkIdentity gunIdentity = gunGO.GetComponent <NetworkIdentity>();

        gunIdentity.AssignClientAuthority(conn);

        return(gunIdentity);
    }
Beispiel #3
0
    public override void Drop()
    {
        if (primaryGun != null && equippedGun != secondaryGun)
        {
            equippedGun = secondaryGun;
            secondaryGun.gameObject.SetActive(true);
//            UpdateAmmoHUD();

            primaryGun.transform.parent = null;
            primaryGun.Drop();
            primaryGun = null;
        }

        CB_AmmoChanged();
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        if (primaryGun != null)
        {
            Debug.Log("Primary weapon is null");
            equippedGun = primaryGun;
            secondaryGun.gameObject.SetActive(false);
        }
        else
        {
            equippedGun = secondaryGun;
        }
        equippedGun.gameObject.SetActive(true);
        equippedGun.AlignGun();

        CB_AmmoChanged();
    }
Beispiel #5
0
    public NetPlayer(NetworkConnection playerConn, Player player, Gun_Base primaryWeapon, Gun_Base secondaryWeapon)
    {
        conn        = playerConn;
        this.player = player;


        this.primaryWeapon   = null;
        this.secondaryWeapon = null;


        if (primaryWeapon != null)
        {
            this.primaryWeapon = SpawnGun(primaryWeapon);
        }

        if (secondaryWeapon != null)
        {
            this.secondaryWeapon = SpawnGun(secondaryWeapon);
        }
    }
Beispiel #6
0
    private void ToggleEquip()
    {
        if (primaryGun == null)
        {
            return;
        }

        equippedGun.gameObject.SetActive(false);
        if (equippedGun == primaryGun)
        {
            equippedGun = secondaryGun;
        }
        else
        {
            equippedGun = primaryGun;
        }
        equippedGun.gameObject.SetActive(true);
        CB_AmmoChanged();
        equippedGun.AlignGun();
    }
Beispiel #7
0
    public override void OnInspectorGUI()
    {
        Gun_Base gun = (Gun_Base)target;

        EditorGUILayout.LabelField("Gun Parts", EditorStyles.boldLabel);
        gun.slide           = EditorGUILayout.ObjectField("Slide", gun.slide, typeof(Slide_Interactable), true) as Slide_Interactable;
        gun.magWell         = EditorGUILayout.ObjectField("Magazine Well", gun.magWell, typeof(VRTK_SnapDropZone), true) as VRTK_SnapDropZone;
        gun.trigger         = EditorGUILayout.ObjectField("Trigger", gun.trigger, typeof(Transform), true) as Transform;
        gun.muzzle          = EditorGUILayout.ObjectField("Muzzle", gun.muzzle, typeof(GameObject), true) as GameObject;
        gun.ejectionPort    = EditorGUILayout.ObjectField("Ejection Port", gun.ejectionPort, typeof(GameObject), true) as GameObject;
        gun.chamberedBullet = EditorGUILayout.ObjectField("Chambered Round", gun.chamberedBullet, typeof(GameObject), true) as GameObject;
        gun.bulletPrefab    = EditorGUILayout.ObjectField("Bullet Prefab", gun.bulletPrefab, typeof(GameObject), true) as GameObject;
        gun.shellPrefab     = EditorGUILayout.ObjectField("Shell Prefab", gun.shellPrefab, typeof(GameObject), true) as GameObject;

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Gun Properties", EditorStyles.boldLabel);
        gun.fullAuto     = EditorGUILayout.Toggle("Full auto", gun.fullAuto);
        gun.magRelease   = EditorGUILayout.Toggle("Magazine Release", gun.magRelease);
        gun.slideRelease = EditorGUILayout.Toggle("Slide Release", gun.slideRelease);
        gun.bulletSpeed  = EditorGUILayout.FloatField("Bullet velocity", gun.bulletSpeed);
    }
Beispiel #8
0
 public abstract bool TryPickupGun(Gun_Base gun);
Beispiel #9
0
 public override bool TryPickupGun(Gun_Base gun)
 {
     //TODO: make the pickup gun script target the weapon slot directly
     return(gunSlot.TryPickup(gun));
 }