private void Fire_Projectile() { Weapon_Projectile weapon = WeaponSlot.currentWeapon as Weapon_Projectile; ProjectileManager.ProjectileData data = new ProjectileManager.ProjectileData { spawnPosition = projectileSpawn.position, //spawnRotation = fireDirection != Vector3.zero ? Quaternion.LookRotation(fireDirection, Vector3.forward) : projectileSpawn.rotation, spawnRotation = projectileSpawn.rotation, projectilePool = weapon.projectilePoolName, speed = weapon.projectileSpeed, paintType = (int)WeaponSlot.currentPaintType, paintAmount = weapon.paintDamage, projectileOwnerID = PlayerManager.instance.photonView.ViewID, }; ProjectileManager.instance.FireProjectile(data); //photonView.RPC("SpawnEffects", RpcTarget.All, paintImpact, paintDecal, hitPoint, paintDecalRot, paintImpactRot, (int)WeaponSlot.currentPaintType); photonView.RPC("SpawnEffects", RpcTarget.All, false, false, Vector3.zero, Quaternion.identity, Quaternion.identity, (int)WeaponSlot.currentPaintType); }
private void WeaponSlot_OnUseSecondary(Weapon.SecondaryType secondaryType) { if (isDropped || isDecoy) { return; } Weapon weapon = WeaponSlot.currentWeapon; ProjectileManager.ProjectileData data = new ProjectileManager.ProjectileData { spawnPosition = ProjectileManager.instance.GetProjectileSpawn(this, weapon.secondaryProjectile), spawnRotation = (secondaryType == Weapon.SecondaryType.Attack) ? projectileSpawn.rotation : Player.localPlayer.transform.rotation, projectilePool = weapon.secondaryProjectile, speed = ProjectileManager.instance.GetProjectileSpeed(weapon.secondaryForce, weapon.secondaryProjectile), damage = weapon.baseDamage + Player.localPlayer.entity.CalculateDamage(Stats.DamageType.Secondary), amount = weapon.secondaryAmountOfProjectiles, coneOfFireInDegrees = weapon.secondaryConeOfFireInDegrees, mousePos = PlayerController.mouseInWorldPos, projectileOwnerID = Player.localPlayer.photonView.ViewID }; ProjectileManager.instance.FireProjectile(data); }
private void WeaponSlot_OnUsePrimary() { if (isDropped || isDecoy) { return; } // Ranged Attack. if (WeaponSlot.currentWeapon is Weapon_Ranged) { Weapon_Ranged weapon = WeaponSlot.currentWeapon as Weapon_Ranged; ProjectileManager.ProjectileData data = new ProjectileManager.ProjectileData { spawnPosition = ProjectileManager.instance.GetProjectileSpawn(this, weapon.primaryProjectile), spawnRotation = projectileSpawn.rotation, projectilePool = weapon.primaryProjectile, speed = ProjectileManager.instance.GetProjectileSpeed(weapon.force, weapon.primaryProjectile), damage = weapon.baseDamage + Player.localPlayer.entity.CalculateDamage(Stats.DamageType.Ranged), amount = weapon.amountOfProjectiles, coneOfFireInDegrees = weapon.coneOfFireInDegrees, mousePos = PlayerController.mouseInWorldPos, projectileOwnerID = Player.localPlayer.photonView.ViewID }; ProjectileManager.instance.FireProjectile(data); } // Melee Attack. else { Weapon_Melee weapon = WeaponSlot.currentWeapon as Weapon_Melee; int collidersFound = Physics.OverlapSphereNonAlloc(transform.position, weapon.attackRange, meleeHits, hitLayerMask); bool pvp = false; for (int i = 0; i < collidersFound; i++) { if (meleeHits[i].transform.tag == "PvPZone") { pvp = true; } } for (int i = 0; i < collidersFound; i++) { Vector3 toHit = meleeHits[i].transform.position - Player.localPlayer.playerController.body.position; if (Vector3.Dot(Player.localPlayer.playerController.body.forward, toHit) > 0) { Entity entity = meleeHits[i].GetComponent <Entity>(); if (entity) { if (pvp ? meleeHits[i].transform.tag == "Player" : meleeHits[i].transform.tag != "Player") { entity.Hit(-(weapon.baseDamage + Player.localPlayer.entity.CalculateDamage(Stats.DamageType.Melee)), Stats.DamageType.Melee, WeaponSlot.weaponBuffs); // TODO: Change this to an event or a parameter in Entity.Hit() UIManager.instance.playerStatusCanvas.Hit(); if (weapon.knockBack > 0 && !pvp) { entity.KnockBack(toHit, weapon.knockBack); } } } if (!string.IsNullOrEmpty(prefabToSpawnOnHit)) { GameObject newSpawn = ObjectPooler.instance.GrabFromPool(prefabToSpawnOnHit, meleeHits[i].ClosestPoint(transform.position), Quaternion.identity); } } } } }