public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { stream.SendNext(mVelX); stream.SendNext(mVelY); stream.SendNext(mGrounded); stream.SendNext(mWeaponId); stream.SendNext(mAimingDir); stream.SendNext(mFacingRight); stream.SendNext(transform.position); } else { mVelX = (float)stream.ReceiveNext(); mVelY = (float)stream.ReceiveNext(); mGrounded = (bool)stream.ReceiveNext(); mWeaponId = (WeaponId)stream.ReceiveNext(); mAimingDir = (Aim)stream.ReceiveNext(); mFacingRight = (bool)stream.ReceiveNext(); mPreviousPosition = mAccuratePosition; mAccuratePosition = (Vector3)stream.ReceiveNext(); mPositionLerpTime = 0; ++mNumUpdates; mPositionUpdateRate = mTotalTime / mNumUpdates; } }
void OnWeaponFired(WeaponId weaponId, Vector3 pos, int ownerId) { if (ownerId == mPhotonView.ownerId) { mPhotonView.RPC("OnWeaponFiredRPC", PhotonTargets.All, ownerId); } }
void Update() { if (InputWrapper.Instance.FirePressed) { if (mWeaponInventory.CooledDown()) { // Grab weapon id to trigger fire button effects WeaponId weaponId = mWeaponInventory.mWeaponId; // Has ammo if (mWeaponInventory.GetRound()) { string projectile = GetProjectileName(weaponId); Transform xform = mBarrelTip.GetBarrelTransform(); if (ProjectileSpawnIsntClipping(transform.position, xform.position)) { PhotonNetwork.Instantiate(projectile, xform.position, xform.rotation, 0); } EventSystem.OnWeaponFired(weaponId, transform.position, ownerId); } // Weapon is out of ammo else { EventSystem.OnWeaponMisfired(weaponId); } } } }
void WeaponFireCallback(WeaponId weaponId, Vector3 pos) { AudioClip clip = null; switch (weaponId) { case WeaponId.DARK_HORSE: clip = mUseDarkhorse; break; case WeaponId.VETO: clip = mUseVeto; break; case WeaponId.MAGIC_BULLET: clip = mUseMagicBullet; break; case WeaponId.ANARCHY: clip = mUseAnarchy; break; case WeaponId.LIBEL_AND_SLANDER: clip = mUseLibelAndSlander; break; } AudioSource.PlayClipAtPoint(clip, pos); }
public void ResetWeapon() { mWeaponId = WeaponId.DARK_HORSE; var attributes = GameConstants.WeaponProperties[(int)mWeaponId]; mAmmo = attributes.mMaxAmmo; mCoolDownSeconds = attributes.mCoolDown; }
public void EquipWeapon(WeaponId weaponId) { mWeaponId = weaponId; int actorId = mPhotonView.owner.ID; EventSystem.OnEquipWeapon(actorId, weaponId); WeaponAttributes attributes = GameConstants.WeaponProperties[(int)weaponId]; mAmmo = attributes.mMaxAmmo; mCoolDownSeconds = attributes.mCoolDown; }
string GetProjectileName(WeaponId weaponId) { switch (weaponId) { case WeaponId.DARK_HORSE: return("DarkHorseBullet"); case WeaponId.VETO: return("VetoBullet"); case WeaponId.MAGIC_BULLET: return("MagicBulletBullet"); default: return("DarkHorseBullet"); } }