/// <summary> /// 弾丸発射時 /// </summary> public override void OnShoot(Bullet bullet) { bullet.SetTimeStamp(BattleGlobal.GetTimeStamp()); bullet.SetOnDestroyCallback(this.OnDestroyBullet); //発射した弾丸の速度や角度の情報 var data = new BulletDto(); data.bulletBase = bullet.bulletBase; data.isNormalBullet = bullet is NormalBullet; data.id = this.shootCount; data.timeStamp = bullet.bulletBase.movement.timeStamp; data.speed = bullet.bulletBase.movement.speed; data.bulletLocalPosition = bullet.transform.localPosition; data.bulletLocalEulerAngles = bullet.transform.localEulerAngles; data.barrelLocalEulerAngles = this.turretBase.rotationParts.localEulerAngles; this.bulletList.Add(data); //プロパティ更新 PhotonNetwork.LocalPlayer.SetCustomProperties(new PhotonHashtable { { PlayerPropertyKey.BulletList, this.bulletList.ToBinary() } }); this.shootCount++; }
/// <summary> /// 弾丸生成 /// </summary> private void CreateBullet(BulletDto data) { var prefab = data.isNormalBullet ? this.turretBase.bulletPrefab : AssetManager.FindHandle <BulletBase>(SharkDefine.GetFvAttackBulletPrefabPath(this.fvAttackData.key)).asset as BulletBase; data.bulletBase = this.turretBase.CreateBullet(prefab, BattleGlobal.instance.bulletArea); data.bulletBase.gameObject.AddComponent <BulletBouncing>(); data.bulletBase.movement.timeStamp = data.timeStamp; data.bulletBase.movement.speed = data.speed; data.bulletBase.transform.localPosition = this.cachedTransform.localRotation * data.bulletLocalPosition; data.bulletBase.transform.rotation = this.cachedTransform.localRotation * Quaternion.Euler(data.bulletLocalEulerAngles); data.bulletBase.SetParticleLayer(BattleGlobal.instance.bulletCanvas); this.bulletList.Add(data); }
/// <summary> /// 设置远程子弹 /// </summary> /// <param name="value"></param> void SetRemoteBulletPosAndRot(object value) { bulletDto_SREC = value as BulletDto; int bulletColor = bulletDto_SREC.color; bulletSyncPos = new Vector3(bulletDto_SREC.posX, bulletDto_SREC.posY, bulletDto_SREC.posZ); bulletSyncRot = new Vector3(bulletDto_SREC.rotX, bulletDto_SREC.rotY, bulletDto_SREC.rotZ); GameObject tempPlayer = GameObject.Find(playerNames[bulletColor - 1]); bullet_SREC = Resources.Load <GameObject>(bulletNames[bulletColor - 1]); GameObject bulletObj = Instantiate <GameObject>(bullet_SREC, bulletPos.transform.position, tempPlayer.transform.rotation); //需要优化 bulletObj.transform.position = bulletSyncPos; bulletObj.transform.eulerAngles = bulletSyncRot; bulletObj.GetComponent <Rigidbody>().AddForce(tempPlayer.transform.forward * power); }
/// <summary> /// 波動砲発射イベント受信時 /// </summary> public void OnShootLaserBeam(object value) { var dto = new BulletDto(); dto.SetBinary((byte[])value); //弾丸生成 var bulletPrefab = this.fvaBulletAsset.handle.asset as BulletBase; var bulletBase = this.turretBase.CreateBullet(bulletPrefab, BattleGlobal.instance.bulletArea); bulletBase.transform.localPosition = this.cachedTransform.localRotation * dto.bulletLocalPosition; bulletBase.transform.rotation = this.cachedTransform.localRotation * Quaternion.Euler(dto.bulletLocalEulerAngles); bulletBase.SetParticleLayer(BattleGlobal.instance.bulletCanvas); //砲身回転 this.StartBarrelRotation(dto.barrelLocalEulerAngles); //制御開始 var controller = new FvAttackLaserBeam.Controller(); this.fvaControllers.Add(controller); controller.Start(true, this, bulletBase, null); }
/// <summary> /// 波動砲発射時 /// </summary> public override void OnShoot(LaserBeamBullet bullet) { //自分しかいないのでイベント送信の必要なし if (PhotonNetwork.CurrentRoom.PlayerCount == 1) { return; } var dto = new BulletDto(); dto.timeStamp = BattleGlobal.GetTimeStamp(); dto.bulletLocalPosition = bullet.transform.localPosition; dto.bulletLocalEulerAngles = bullet.transform.localEulerAngles; dto.barrelLocalEulerAngles = this.turretBase.rotationParts.localEulerAngles; //イベント送信 PhotonNetwork.RaiseEvent( (byte)MultiEventCode.ShootLaserBeam, dto.GetBinary(), RaiseEventOptions.Default, SendOptions.SendReliable ); }