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