public override void UseWeapon(WeaponUser user) { // Create a new bullet at the the instantiate point var data = GetWeaponUsageData(user); if (user.photonView.IsMine) { var obj = PhotonNetwork.Instantiate(bullet.name, data.weaponObject.BulletSpawnPoint.position, data.raycaster.GetRotationWithoutRaycast(data.weaponObject.BulletSpawnPoint)); obj.GetComponent <Bullet>().SetBulletData(damage, range); } }
public override void EquipWeapon(WeaponUser user) { base.EquipWeapon(user); var usageData = GetWeaponUsageData(user); if (usageData.weaponObject == null) { if (user.photonView.IsMine) { usageData.equipPoint = user.localEquipPoint; } else { usageData.equipPoint = user.remoteEquipPoint; } usageData.weaponObject = Instantiate(weaponEquipPrefab, usageData.equipPoint.position, usageData.equipPoint.rotation, usageData.equipPoint); } usageData.weaponObject.gameObject.SetActive(true); }
public override void UseWeapon(WeaponUser user) { var usageData = GetWeaponUsageData(user); usageData.raycaster = user.raycastOrigin.transform; if (user.photonView.IsMine) { // Get all enemies in range of the sword Collider[] hitEnemies = Physics.OverlapBox(usageData.raycaster.position, new Vector3(spread, spread, range), usageData.raycaster.rotation, hitLayerMask); // Damage each enemy foreach (Collider enemy in hitEnemies) { var target = enemy.GetComponent <Damageable>(); if (target != null) { attackHitEvent?.Invoke(); target.TakeDamage(damage); } } } usageData.weaponObject.UseWeapon(); }
public override void EquipWeapon(WeaponUser user) { base.EquipWeapon(user); if (bullet == null) { Debug.LogError("BULLET UNASSIGNED FOR WEAPON!!"); } var usageData = GetWeaponUsageData(user); if (usageData.weaponObject == null) { if (user.photonView.IsMine) { usageData.equipPoint = user.localEquipPoint; } else { usageData.equipPoint = user.remoteEquipPoint; } usageData.raycaster = user.raycastOrigin; usageData.weaponObject = Instantiate(weaponEquipPrefab, usageData.equipPoint.position, usageData.equipPoint.rotation, usageData.equipPoint); } usageData.weaponObject.gameObject.SetActive(true); }
public virtual bool TryUseWeapon(WeaponUser user) { return(true); }
public virtual void UnEquipWeapon(WeaponUser user) { Debug.Log($"UnEqupping {name}"); }
public virtual void UseWeapon(WeaponUser user) { Debug.Log($"Using {name}"); }
public override void UnEquipWeapon(WeaponUser user) { base.UnEquipWeapon(user); GetWeaponUsageData(user)?.weaponObject?.gameObject.SetActive(false); }