public void GetGun(GameObject gun) { if (Input.GetKeyDown(KeyCode.E)) { foreach (var item in Guns) { if (item.GetComponent <WeaponBase>().Name == gun.GetComponent <WeaponBase>().Name) { Copia(gun.GetComponent <WeaponBase>(), item.GetComponent <WeaponBase>()); GameObject obj = Instantiate(item, this.transform.Find("FireWeapon").transform); //Destuir en networking sin mas if (buscarArmaFuego(gun.GetComponent <WeaponBase>().Name)) { WeaponBase droped = buscarArmaFuego(gun.GetComponent <WeaponBase>().Name); //buscar esto en la lista ChangeGunPerIndex(WeaponsInInventory.IndexOf(droped)); //pasarle el indice de la de arriba dropWeapon(WeaponbaseCurrent); } Destroy(gun); Hands = ObjectInHands.fire; OnSwichHandWeapon(Hands); ActualizarInventario(); ChangeGunPerIndex(WeaponsInInventory.Count - 1); GetGunOBJ.Remove(gun); WeaponbaseCurrent.gameObject.SetActive(true); } } } }
public void OnSwichHandWeapon(ObjectInHands type) { GameObject fire = transform.Find("FireWeapon").gameObject, grenade = transform.Find("GrenadeWeapon").gameObject, mele = transform.Find("MeleWeapon").gameObject; WeaponbaseCurrent.OnSwich(); fire.SetActive(false); grenade.SetActive(false); mele.SetActive(false); switch (type) { case ObjectInHands.fire: fire.SetActive(true); StartCoroutine(actuTemp()); break; case ObjectInHands.grenade: grenade.SetActive(true); break; case ObjectInHands.mele: mele.SetActive(true); break; default: break; } }
public bool GrabingSomething(ObjectInHands holding) { bool canHold = false; if (!holdingSomething) { this.holding = holding; canHold = true; } return(canHold); }
void SwitchModeWeapon() { if (Input.GetMouseButtonDown(2)) { Debug.Log("Cambio"); Hands = (Hands == ObjectInHands.grenade) ? ObjectInHands.fire : ObjectInHands.grenade; OnSwichHandWeapon(Hands); //TODOOOOOOOOOOOOOOOOOOO //2WeaponbaseCurrent.OnSwich(); } if (Input.GetKey(KeyCode.V)) { Hands = ObjectInHands.mele; OnSwichHandWeapon(Hands); } }
void SwitchToCurrentWeapon() // Conectar con el controller //Conectado por otro lado { Hands = ObjectInHands.fire; OnSwichHandWeapon(Hands); for (int i = 0; i < WeaponsInInventory.Count; i++) { WeaponsInInventory[i].gameObject.SetActive(false); WeaponsInInventory[i].isReloading = false; WeaponsInInventory[i].fireLock = false; } //transform.Find(weapons[CurrenWeaponIndex].ToString()).gameObject.SetActive(true); WeaponbaseCurrent.OnSwich(); try { WeaponsInInventory[CurrenWeaponIndex].gameObject.SetActive(true); WeaponbaseCurrent = WeaponsInInventory[CurrenWeaponIndex].gameObject.GetComponent <WeaponBase>(); } catch { Debug.LogWarning("Un indice ha salido del rango, pero no afecta al sistema"); } WeaponbaseCurrent.AsingConfigurations(); Switch = false; }
void Update() { if (Input.GetKey(KeyCode.Alpha1)) { ActualizarInventario(); } SwitchModeWeapon(); CheckWeaponSwitch(); if (Input.GetButtonDown("DropWeapon")) { CheckDrop(); } CheckGetGun(); if (transform.Find("FireWeapon").childCount == 0 && Hands != ObjectInHands.grenade) { Hands = ObjectInHands.mele; OnSwichHandWeapon(Hands); } }
public void EmptyHands() { switch (holding) { case ObjectInHands.Seed: SeedBagManager.ResetSelectedSeed(); break; case ObjectInHands.WaterCan: break; case ObjectInHands.Hoe: break; case ObjectInHands.Empty: break; default: break; } holding = ObjectInHands.Empty; }
IEnumerator OnSwichHandsCorr(ObjectInHands obj) { yield return(new WaitForEndOfFrame()); OnSwichHandWeapon(obj); }