Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 public virtual bool TryUseWeapon(WeaponUser user)
 {
     return(true);
 }
Exemple #6
0
 public virtual void UnEquipWeapon(WeaponUser user)
 {
     Debug.Log($"UnEqupping {name}");
 }
Exemple #7
0
 public virtual void UseWeapon(WeaponUser user)
 {
     Debug.Log($"Using {name}");
 }
Exemple #8
0
 public override void UnEquipWeapon(WeaponUser user)
 {
     base.UnEquipWeapon(user);
     GetWeaponUsageData(user)?.weaponObject?.gameObject.SetActive(false);
 }