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