public void TryFire(WeaponType weaponType) { if (player.IsDead()) return; Vector3 worldMousePosition = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); Vector2 direction = (worldMousePosition - player.transform.position); direction.Normalize(); C2S.Fire fire = new C2S.Fire(player.GetOwner(), -1, weaponType, direction); if (Network.isServer) { Fire(fire.SerializeToBytes(), new NetworkMessageInfo()); } else { GetComponent<NetworkView>().RPC("Fire", RPCMode.Server, fire.SerializeToBytes()); } }
public void Fire(byte[] fireData, NetworkMessageInfo msgInfo) { if (!Network.isServer) return; //if (!PlayerManager.Inst.IsValidPlayer(player.GetOwner(), msgInfo.sender)) return; C2S.Fire fire = new C2S.Fire(); fire.DeserializeFromBytes(fireData); if (!CanFire(fire.weaponType)) return; lock (weaponLock) { ChangeWeapon(fire.weaponType); WeaponInfo weapon = weapons[fire.weaponType]; FireInfo info = new FireInfo(player.GetOwner(), player.transform.position, fire.direction); weapon.Fire(player, info); } }