public override void HandleCollectableInput(vCollectableStandalone collectableStandAlone) { if (isLocalPlayer) { CmdHandleCollectableInput(collectableStandAlone.weapon); } }
public override void HandleCollectableInput(vCollectableStandalone collectableStandAlone) { if (shooterManager && collectableStandAlone != null && collectableStandAlone.weapon != null) { var weapon = collectableStandAlone.weapon.GetComponent <vShooterWeapon>(); if (weapon) { var p = GetEquipPoint(rightHandler, collectableStandAlone.targetEquipPoint); if (p) { collectableStandAlone.weapon.transform.SetParent(p); collectableStandAlone.weapon.transform.localPosition = Vector3.zero; collectableStandAlone.weapon.transform.localEulerAngles = Vector3.zero; if (rightWeapon && rightWeapon != weapon.gameObject) { RemoveRightWeapon(); } shooterManager.SetRightWeapon(weapon.gameObject); collectableStandAlone.OnEquip.Invoke(); rightWeapon = weapon.gameObject; UpdateRightDisplay(collectableStandAlone); if (leftWeapon) { RemoveLeftWeapon(); } } } } base.HandleCollectableInput(collectableStandAlone); }
public override void HandleCollectableInput(vCollectableStandalone collectableStandAlone) { if (shooterManager && collectableStandAlone != null && collectableStandAlone.weapon != null) { EquipShooterWeapon(collectableStandAlone); } base.HandleCollectableInput(collectableStandAlone); }
protected virtual void EquipMeleeWeapon(vCollectableStandalone collectable) { var weapon = collectable.weapon.GetComponent <vMeleeWeapon>(); if (!weapon) { return; } if (weapon.meleeType != vMeleeType.OnlyDefense) { var p = GetEquipPoint(rightHandler, collectable.targetEquipPoint); if (!p) { return; } collectable.weapon.transform.SetParent(p); collectable.weapon.transform.localPosition = Vector3.zero; collectable.weapon.transform.localEulerAngles = Vector3.zero; if (rightWeapon && rightWeapon.gameObject != collectable.gameObject) { RemoveRightWeapon(); } if (collectable.twoHandWeapon || leftWeapon && leftWeapon.twoHandWeapon) { RemoveLeftWeapon(); } meleeManager.SetRightWeapon(weapon.gameObject); collectable.OnEquip.Invoke(); rightWeapon = collectable; UpdateRightDisplay(collectable); } if (weapon.meleeType != vMeleeType.OnlyAttack && weapon.meleeType != vMeleeType.AttackAndDefense) { var p = GetEquipPoint(leftHandler, collectable.targetEquipPoint); if (!p) { return; } collectable.weapon.transform.SetParent(p); collectable.weapon.transform.localPosition = Vector3.zero; collectable.weapon.transform.localEulerAngles = Vector3.zero; if (leftWeapon && leftWeapon.gameObject != collectable.gameObject) { RemoveLeftWeapon(); } if (collectable.twoHandWeapon || rightWeapon && rightWeapon.twoHandWeapon) { RemoveRightWeapon(); } meleeManager.SetLeftWeapon(weapon.gameObject); collectable.OnEquip.Invoke(); leftWeapon = collectable; UpdateLeftDisplay(collectable); } }
public virtual void HandleCollectableInput(vCollectableStandalone collectableStandAlone) { if (!meleeManager) { return; } if (collectableStandAlone != null && collectableStandAlone.weapon != null) { EquipMeleeWeapon(collectableStandAlone); } }
/// <summary> /// Condition to drop the shooter weapon when equipping a shield /// </summary> /// <param name="collectableStandAlone"></param> private void RemoveShooterWeaponWhenEquippingDefense(vCollectableStandalone collectableStandAlone) { var meleeWeapon = collectableStandAlone.weapon.GetComponent <vMeleeWeapon>(); if (!meleeWeapon) { return; } if (meleeWeapon.meleeType == vMeleeType.OnlyDefense) { if (shooterManager.CurrentWeapon) { RemoveRightWeapon(); } } }
protected virtual void UpdateRightDisplay(vCollectableStandalone collectable = null) { if (!currentDisplay) { return; } if (collectable) { currentDisplay.SetRightWeaponIcon(collectable.weaponIcon); currentDisplay.SetRightWeaponText(collectable.weaponText); } else { currentDisplay.RemoveRightWeaponIcon(); currentDisplay.RemoveRightWeaponText(); } }
IEnumerator DelayedEquip(float delay) { yield return(new WaitForSeconds(delay)); if (rootBone.childCount > 0) { GameObject weapon = rootBone.GetChild(0).gameObject; if (weapon != null && weapon.tag == "Weapon") { vCollectableStandalone collectable = weapon.GetComponentInChildren <vCollectableStandalone>(); equippedWeaponType = weapon.GetComponent <WeaponType>().GetWeaponType(); meleeControl.HandleCollectableInput(collectable); } else { // Unarmed Deals Damage equippedWeaponType = FarmWeaponType.Damage; } } }
public GameObject SetItem(int weaponViewId, EquipSide side, GameObject calledFrom) { PhotonView weapon = null; if (weaponViewId != -1) { weapon = PhotonNetwork.GetPhotonView(weaponViewId); if (weapon) { vCollectableStandalone collectableStandalone = weapon.GetComponentInChildren <vCollectableStandalone>(); if (collectableStandalone != null) { if (collectableStandalone.targetEquipPoint != "") { if (!customHandlers.Contains(collectableStandalone.targetEquipPoint)) { customHandlers.Add(collectableStandalone.targetEquipPoint); } } } if (weapon.GetComponent <vShooterWeapon>()) { SetWeapon(weapon.gameObject, calledFrom, side, WeaponType.shooter, collectableStandalone.targetEquipPoint); } else { SetWeapon(weapon.gameObject, calledFrom, side, WeaponType.melee, collectableStandalone.targetEquipPoint); } return(weapon.gameObject); } } return(null); }
protected override void InternalHandleCollectableInput(vCollectableStandalone collectableStandAlone) { if (shooterManager && collectableStandAlone != null && collectableStandAlone.weapon != null) { var weapon = collectableStandAlone.weapon.GetComponent <vShooterWeapon>(); if (weapon) { Transform p = null; if (weapon.isLeftWeapon) { p = GetEquipPoint(leftHandler, collectableStandAlone.targetEquipPoint); if (p) { collectableStandAlone.weapon.transform.SetParent(p); collectableStandAlone.weapon.transform.localPosition = Vector3.zero; collectableStandAlone.weapon.transform.localEulerAngles = Vector3.zero; if (leftWeapon && leftWeapon != weapon.gameObject) { RemoveLeftWeapon(); } shooterManager.SetLeftWeapon(weapon.gameObject); collectableStandAlone.OnEquip.Invoke(); if (isServer) { SetAuthority(collectableStandAlone.weapon.GetComponent <NetworkIdentity>(), gameObject.GetComponent <NetworkIdentity>()); } leftWeapon = weapon.gameObject; UpdateLeftDisplay(collectableStandAlone); if (rightWeapon) { RemoveRightWeapon(); } } else { throw new System.Exception("Invalid equipment point"); } } else { p = GetEquipPoint(rightHandler, collectableStandAlone.targetEquipPoint); if (p) { collectableStandAlone.weapon.transform.SetParent(p); collectableStandAlone.weapon.transform.localPosition = Vector3.zero; collectableStandAlone.weapon.transform.localEulerAngles = Vector3.zero; if (rightWeapon && rightWeapon != weapon.gameObject) { RemoveRightWeapon(); } shooterManager.SetRightWeapon(weapon.gameObject); collectableStandAlone.OnEquip.Invoke(); if (isServer) { SetAuthority(collectableStandAlone.weapon.GetComponent <NetworkIdentity>(), gameObject.GetComponent <NetworkIdentity>()); } rightWeapon = weapon.gameObject; UpdateRightDisplay(collectableStandAlone); if (leftWeapon) { RemoveLeftWeapon(); } } else { throw new System.Exception("Invalid equipment point"); } } } else { throw new System.Exception("Invalid collectable"); } } else { throw new System.Exception("Invalid collectable"); } base.InternalHandleCollectableInput(collectableStandAlone); }
public virtual void HandleCollectableInput(vCollectableStandalone collectableStandAlone) { }
protected virtual void EquipShooterWeapon(vCollectableStandalone collectable) { var weapon = collectable.weapon.GetComponent <vShooterWeapon>(); if (!weapon) { return; } Transform p = null; if (weapon.isLeftWeapon) { p = GetEquipPoint(leftHandler, collectable.targetEquipPoint); if (p) { collectable.weapon.transform.SetParent(p); collectable.weapon.transform.localPosition = Vector3.zero; collectable.weapon.transform.localEulerAngles = Vector3.zero; if (leftWeapon && leftWeapon.gameObject != collectable.gameObject) { RemoveLeftWeapon(); } shooterManager.SetLeftWeapon(weapon.gameObject); collectable.OnEquip.Invoke(); leftWeapon = collectable; UpdateLeftDisplay(collectable); if (rightWeapon) { RemoveRightWeapon(); } } } else { p = GetEquipPoint(rightHandler, collectable.targetEquipPoint); if (p) { collectable.weapon.transform.SetParent(p); collectable.weapon.transform.localPosition = Vector3.zero; collectable.weapon.transform.localEulerAngles = Vector3.zero; if (rightWeapon && rightWeapon.gameObject != collectable.gameObject) { RemoveRightWeapon(); } shooterManager.SetRightWeapon(weapon.gameObject); collectable.OnEquip.Invoke(); rightWeapon = collectable; UpdateRightDisplay(collectable); if (leftWeapon) { RemoveLeftWeapon(); } } } }