public GameObject SpawnBomb(BombController.BombInfo aBombInfo) { GameObject player = null; GameObject[] planes = GameObject.FindGameObjectsWithTag("Plane"); for (int i = 0; i < planes.Length; i++) { if (planes[i].GetComponent <PhotonView>().owner == aBombInfo.m_shooter) { player = planes[i]; break; } } if (player != null) { GameObject flare = (GameObject)Instantiate(m_bombDropPrefab, player.transform.position, player.GetComponent <PlaneController>().m_bulletSpawnPoint.rotation); flare.transform.parent = player.transform; if (aBombInfo.m_shooter == PhotonNetwork.player) { flare.GetComponent <AudioSource>().spatialBlend = 0; } flare.GetComponent <AudioSource>().Play(); } GameObject bomb = (GameObject)Instantiate(m_bombPrefab, aBombInfo.m_startPosition, Quaternion.LookRotation(aBombInfo.m_startDirection, -Vector3.forward)); bomb.GetComponent <Rigidbody>().velocity = aBombInfo.m_startVelocity; bomb.GetComponent <BombController>().SetBombInfo(aBombInfo); return(bomb); }
void RpcSpawnBomb(Vector3 aStartPos, Vector3 aDirection, Vector3 aSpeed, byte aShooter, byte aID) { BombController.BombInfo aBombInfo = new BombController.BombInfo(aStartPos, aDirection, (int)aShooter, aSpeed, (int)aID);//BulletController.BulletInfo.GetBulletInfo(aBulletInfoString); //BombController.BombInfo aBombInfo = BombController.BombInfo.GetBombInfo(aBombInfoString); if (isServer) { aBombInfo.m_isMaster = true; } GameObject bomb = BombersNetworkManager.m_localPlayer.GetComponent<WeaponController>().SpawnBomb(aBombInfo); m_gMan.m_spawnedBombs.Add(bomb.GetComponent<BombController>().GetBombInfo()); int playerTeam = BombersPlayerController.GetPlayer(aBombInfo.m_shooter).m_team; switch (playerTeam) { case 1: bomb.layer = 14; break; case 2: bomb.layer = 15; break; } }
public void CmdSpawnBomb(Vector3 aStartPos, Vector3 aDirection, Vector3 aSpeed, byte aShooter) { int id = m_gMan.GetNextBombID(); //BombController.BombInfo bombInfo = BombController.BombInfo.GetBombInfo(aBombInfo); //bombInfo.m_bombID = id; //RpcSpawnBomb(aStartPos, aDirection, aSpeed, aShooter, (byte)id); //RpcSpawnBomb(bombInfo.GetJson()); BombController.BombInfo aBombInfo = new BombController.BombInfo(aStartPos, aDirection, (int)aShooter, aSpeed, id);//BulletController.BulletInfo.GetBulletInfo(aBulletInfoString); //BombController.BombInfo aBombInfo = BombController.BombInfo.GetBombInfo(aBombInfoString); if (isServer) { aBombInfo.m_isMaster = true; } GameObject bomb = BombersNetworkManager.m_localPlayer.GetComponent<WeaponController>().SpawnBomb(aBombInfo); m_gMan.m_spawnedBombs.Add(bomb.GetComponent<BombController>().GetBombInfo()); int playerTeam = BombersPlayerController.GetPlayer(aBombInfo.m_shooter).m_team; switch (playerTeam) { case 1: bomb.layer = 14; break; case 2: bomb.layer = 15; break; } NetworkServer.Spawn(bomb); }