static private RPC ( PhotonView view, string methodName, PhotonPlayer targetPlayer ) : void | ||
view | PhotonView | |
methodName | string | |
targetPlayer | PhotonPlayer | |
return | void |
public void UpdateRoom() { //string path = UWB_Texturing.Config.AssetBundle.RoomPackage.CompileAbsoluteAssetPath(UWB_Texturing.Config.AssetBundle.RoomPackage.CompileFilename()); //string path = Config.AssetBundle.Current.CompileAbsoluteBundlePath(UWB_Texturing.Config.AssetBundle.RoomPackage.CompileFilename()); string path = Config.Current.AssetBundle.CompileAbsoluteAssetPath(UWB_Texturing.Config.AssetBundle.RoomPackage.CompileFilename()); Debug.Log("Asset path when updating room = " + path); if (File.Exists(path)) { FileInfo f = new FileInfo(path); if ((int)f.LastWriteTime.CompareTo(lastRoomUpdate) > 0) { // Update to room bundle has occurred lastRoomUpdate = f.LastWriteTime; for (int i = 0; i < PhotonNetwork.otherPlayers.Length; i++) { //SendRoomModel(PhotonNetwork.otherPlayers[i].ID); PhotonNetwork.RPC(photonView, "RequestRoomModel", PhotonTargets.Others, false); } } } else { Debug.Log("Room model not found at path " + path); PhotonNetwork.RPC(photonView, "RequestRoomModel", PhotonTargets.Others, false); } }
public void Update() { if (Input.GetMouseButtonDown(2)) { PhotonNetwork.RPC(this.photonView, "Effect", RpcTarget.AllBuffered, false, this.gameObject.GetPhotonView().ViewID); } }
public void endGame() { if (PhotonNetwork.isMasterClient) { PhotonNetwork.RPC(this.gameObject.GetComponent <PhotonView>(), "Lose", PhotonTargets.All, false); } }
public void Start() { if (photonView.IsMine != true) { return; } Camera.main.transform.SetParent(this.transform); Camera.main.transform.localPosition = new Vector3(0f, 0.25f, 1f); Camera.main.transform.localRotation = Quaternion.Euler(new Vector3(10f, 0f, 0f)); PhotonNetwork.RPC(photonView, "ChangeEnergyColor", RpcTarget.AllBuffered, false, new Vector3(EnergyColor.r, EnergyColor.g, EnergyColor.b), this.gameObject.GetPhotonView().ViewID); LastEnergyColor = EnergyColor; //jobsTransform.Add(this.transform); //Camera.main.transform.GetComponent<AlternateCameraScript>().target = this.transform; this.transform.position = new Vector3(0f, 0.5f, 0f); rigid = this.GetComponent <Rigidbody> (); desObj = this.GetComponent <DestroyableObject> (); if (CubeSettings.weapon != null) { weapon = CubeSettings.weapon; } }
private void ChooseModel() { var index = UnityEngine.Random.Range(0, AvailableModels.Count); var modelName = AvailableModels[index].name; LoadModel(modelName); PhotonNetwork.RPC(photonView, "LoadModel", PhotonTargets.OthersBuffered, false, modelName); }
IEnumerator SendColor() { yield return(new WaitForSeconds(1)); object[] parameters = new object[2]; parameters[1] = PhotonConnection.GetInstance().myColor; parameters[0] = PhotonConnection.GetInstance().ownPlayer.GetComponent <PhotonView>().ownerId; PhotonNetwork.RPC(GetComponent <PhotonView>(), "ChangeColor", PhotonTargets.AllBuffered, false, parameters); }
public void CyanRPC(string methodName, params object[] parameters) { foreach (PhotonPlayer player in PhotonNetwork.playerList) { if (player.CM || PhotonNetwork.offlineMode) { PhotonNetwork.RPC(this, methodName, player, parameters); } } }
void DropBomb(Vector3 position) { GameObject _bomb = Instantiate(bomb) as GameObject; _bomb.transform.position = position; if (photonView.isMine) { PhotonNetwork.RPC(photonView, "DropBomb", PhotonTargets.Others, true, position); } }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "enemy") { if (PhotonNetwork.isMasterClient) { PhotonNetwork.RPC(GameObject.FindGameObjectWithTag("manager").GetComponent <PhotonView>(), "Lose", PhotonTargets.All, false); } print("end game"); } }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// RPC calls can target "All" or the "Others". /// Usually, the target "All" gets executed locally immediately after sending the RPC. /// The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> /// <param name="methodName">The name of a fitting method that was has the RPC attribute.</param> /// <param name="target">The group of targets and the way the RPC gets sent.</param> /// <param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RPC(string methodName, PhotonTargets target, params object[] parameters) { if (PhotonNetwork.networkingPeer.hasSwitchedMC && target == PhotonTargets.MasterClient) { PhotonNetwork.RPC(this, methodName, PhotonNetwork.masterClient, parameters); } else { PhotonNetwork.RPC(this, methodName, target, parameters); } }
public void GetHit(Vector3 point, GameObject killer) { if (photonView != null) { PhotonNetwork.RPC(photonView, "PunBreak", RpcTarget.AllBuffered, false, point, killer.GetPhotonView().ViewID); } else { Break(point); } }
public void Update() { if (photonView.IsMine != true) { return; } if (EnergyColor != LastEnergyColor) { PhotonNetwork.RPC(photonView, "ChangeEnergyColor", RpcTarget.AllBuffered, false, new Vector3(EnergyColor.r, EnergyColor.g, EnergyColor.b), this.gameObject.GetPhotonView().ViewID); LastEnergyColor = EnergyColor; } }
void OnTriggerEnter2D(Collider2D coll) { if (!coll.gameObject.isStatic) { Destroy(coll.gameObject); } if (coll.gameObject.tag == "Player") { PhotonView otherPhotonView = coll.gameObject.GetComponent <PhotonView>(); Debug.Log(photonView.ownerId + " -> " + otherPhotonView.ownerId); PhotonNetwork.RPC(otherPhotonView, "takeDamage", PhotonTargets.All, false, 1, photonView.ownerId); PhotonNetwork.Destroy(gameObject); } }
public void OnCollisionEnter2D(Collision2D other) { if (!photonView.isMine) { return; } if (other.gameObject.tag == "Player") { PhotonView otherPhotonView = other.gameObject.GetComponent <PhotonView>(); Debug.Log(photonView.ownerId + " -> " + otherPhotonView.ownerId); PhotonNetwork.RPC(otherPhotonView, "takeDamage", PhotonTargets.All, false, 5, photonView.ownerId); PhotonNetwork.Destroy(gameObject); } }
public void FixedUpdate() { CurrentTime += Time.deltaTime; TimeText.text = "Current Time: " + Mathf.FloorToInt(CurrentTime).ToString() + " Seconds"; if (CurrentTime >= TimeLimit && gameEnded == false) { gameEnded = true; List <int> ids = new List <int>(); var players = Resources.FindObjectsOfTypeAll <GameObject>().Where(obj => obj.name == "PlayerCube(Clone)"); foreach (GameObject player in players) { ids.Add(player.GetPhotonView().ViewID); } PhotonNetwork.RPC(this.photonView, "EndGame", RpcTarget.All, false, ids.ToArray()); } }
void OnMouseUp() { ballToSoohtHintRenderer.color = Color.clear; if (this.IsDisabled()) { return; } //calculate drag vector Vector3 diff = initialPosition - transform.position; if (debugPrints) { print("initial = " + initialPosition + "\ncurrent position = " + transform.position + "\nvec = " + diff + "\ndist = " + diff.magnitude); } //snap draggable back transform.position = initialPosition; updateRubberBand(); //hide guide trajectoryMngr.hideTrajectory(); //shoot AudioManager.EndSlingshot(); if (diff.y > 0) { Shot.ShotParams nextShot = Manager.instance.GetNextShot(); if (PhotonNetwork.inRoom) { PhotonNetwork.RPC(photonView, "shoot", PhotonTargets.All, false, new object[] { diff *velocityMultiplier, (int)nextShot.type, (int)nextShot.color, nextShot.timeToLive }); } else { shoot(diff * velocityMultiplier, (int)nextShot.type, (int)nextShot.color, nextShot.timeToLive); } } }
//0 - Ready / Not Ready //1 - Player Character Reference #endregion #region DEBUG DELETE ME //Debug void OnGUI( ) { if (DebugMode) { GUILayout.BeginVertical( ); GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString( )); bool isInRoom = PhotonNetwork.inRoom; if (GUILayout.Button(!isInRoom ? "Join Room" : "Leave Room")) { if (isInRoom) { LeaveRoom( ); } else { JoinRoom( ); } } GUILayout.Label("Players in room: " + PhotonNetwork.playerList.Length); GUILayout.Label("SERVER NETWORK STATE: " + ( NETWORK_STATE )NetworkState); GUILayout.BeginHorizontal( ); if (PhotonNetwork.isMasterClient) { if (NetworkState == ( int )NETWORK_STATE.ROOM) { if (GUILayout.Button("LaunchGame")) { PhotonNetwork.RPC(PhotonView.Get(this), "LaunchGame", PhotonTargets.AllBuffered, false); } } } else { } GUILayout.EndHorizontal( ); GUILayout.EndVertical( ); } }
IEnumerator spawn() { spawnReady = false; wave++; PhotonNetwork.RPC(man.GetComponent <PhotonView>(), "setWave", PhotonTargets.AllBuffered, false, wave); if (enemy2count >= 1) { StartCoroutine(spawn2()); } if (enemy3count >= 1) { StartCoroutine(spawn3()); } for (int i = 0; i < enemy1count; i++) { GameObject en1; if (wave < 10) { en1 = PhotonNetwork.Instantiate(enemy1.name, spawnL.transform.position, Quaternion.identity, 0) as GameObject; } else { en1 = PhotonNetwork.Instantiate("enemy12", spawnL.transform.position, Quaternion.identity, 0) as GameObject; } Vector3 tempScale = en1.transform.localScale; tempScale.x *= -1; en1.transform.localScale = tempScale; en1.GetComponent <enemyScript>().enabled = true; en1.GetComponent <enemyScript>().setSpeed(wave); if (wave < 10) { en1 = PhotonNetwork.Instantiate(enemy1.name, spawnR.transform.position, Quaternion.identity, 0) as GameObject; } else { en1 = PhotonNetwork.Instantiate("enemy12", spawnR.transform.position, Quaternion.identity, 0) as GameObject; } en1.GetComponent <enemyScript>().enabled = true; en1.GetComponent <enemyScript>().setSpeed(wave); yield return(new WaitForSeconds(2f)); } StartCoroutine(wait(15)); }
// Update is called once per frame public void ChangeWeapon(WeaponType type, WeaponRarity rarity, int seed) { object[] objects = new object[4]; objects[0] = photonView.viewID; objects[1] = seed; objects[2] = type; objects[3] = rarity; if (type == WeaponType.MELEE) { PhotonNetwork.RPC(photonView, "GetMeleeWeapon", PhotonTargets.All, false, objects); } else { PhotonNetwork.RPC(photonView, "GetRangedWeapon", PhotonTargets.All, false, objects); } }
void SetHP(int hp, int viewID, int bulletId) { if (_photonView.ownerId == viewID) { Hp = hp; } if (Hp <= 0) { if (PhotonNetwork.isMasterClient) { var player = PhotonNetwork.playerList.Single((x) => x.ID == bulletId); player.SetScore(player.GetScore() + 1); PhotonNetwork.RPC(NetworkManager._photonView, "UpdateScore", PhotonTargets.All, false); } } }
void Update() { // Add the time since Update was last called to the timer. timer += Time.deltaTime; #if !MOBILE_INPUT // If the Fire1 button is being press and it's time to fire... if (Input.GetButton("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0) { if (!pv.isMine) { return; } PhotonNetwork.RPC(pv, "Shooting", PhotonTargets.All, false); // ... shoot the gun. // Shoot (); } #else // If there is input on the shoot direction stick and it's time to fire... if ((CrossPlatformInputManager.GetAxisRaw("Mouse X") != 0 || CrossPlatformInputManager.GetAxisRaw("Mouse Y") != 0) && timer >= timeBetweenBullets) { if (!pv.isMine) { return; } PhotonNetwork.RPC(pv, "Shooting", PhotonTargets.All, false); // ... shoot the gun Shoot(); } #endif // If the timer has exceeded the proportion of timeBetweenBullets that the effects should be displayed for... if (timer >= timeBetweenBullets * effectsDisplayTime) { // ... disable the effects. DisableEffects(); } }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// This method allows you to make an RPC calls on a specific player's client. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> /// <param name="methodName">The name of a fitting method that was has the RPC attribute.</param> /// <param name="targetPlayer">The group of targets and the way the RPC gets sent.</param> /// <param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RPC(string methodName, PhotonPlayer targetPlayer, params object[] parameters) { PhotonNetwork.RPC(this, methodName, targetPlayer, parameters); }
/// <summary> /// Processes the outbound packet. /// </summary> /// <returns> /// The outbound packet. /// </returns> /// <param name='packet'> /// Packet. /// </param> public override void SendPacket(DFNetwork.Networking.PacketHandling.Packet packet) { // Send the packet PhotonNetwork.RPC(PhotonView.Get(this), "RecievePacket", PhotonTargets.AllBuffered, false, base.ProcessOutboundPacket(packet)); }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// This method allows you to make an RPC calls on a specific player's client. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> ///<param name="methodName">The name of a fitting method that was has the RPC attribute.</param> ///<param name="targetPlayer">The group of targets and the way the RPC gets sent.</param> ///<param name="encrypt"> </param> ///<param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RpcSecure(string methodName, PhotonPlayer targetPlayer, bool encrypt, params object[] parameters) { PhotonNetwork.RPC(this, methodName, targetPlayer, encrypt, parameters); }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// RPC calls can target "All" or the "Others". /// Usually, the target "All" gets executed locally immediately after sending the RPC. /// The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> /// <param name="methodName">The name of a fitting method that was has the RPC attribute.</param> /// <param name="target">The group of targets and the way the RPC gets sent.</param> /// <param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RPC(string methodName, PhotonTargets target, params object[] parameters) { PhotonNetwork.RPC(this, methodName, target, false, parameters); }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "fireball") { PhotonNetwork.RPC(col.gameObject.GetComponent <PhotonView>(), "killMe", PhotonTargets.AllBuffered, false); realHP--; //print(realHP); } if (col.gameObject.tag == "sword") { realHP--; } if (col.gameObject.tag == "flamePillar") { realHP -= 5f; } if (col.gameObject.tag == "iceball") { realHP -= 4f; } if (col.gameObject.tag == "slowIce") { realHP--; speed = speed * .5f; } if (col.gameObject.tag == "shield") { follow = col.gameObject; } if (realHP <= 0) { if (split) { Vector3 pos = transform.position; Vector3 scal = transform.localScale; GameObject smGO; scal = new Vector3(scal.x * .66f, scal.y * .66f, 1); pos.x = pos.x - .5f; smGO = PhotonNetwork.Instantiate("enemy3Sm", pos, Quaternion.identity, 0); smGO.transform.localScale = scal; smGO.GetComponent <enemyScript>().enabled = true; //smGO.GetComponent<enemyScript>().setSpeed((speed-15)*2); pos.x = pos.x + .25f; smGO = PhotonNetwork.Instantiate("enemy3Sm", pos, Quaternion.identity, 0); smGO.transform.localScale = scal; smGO.GetComponent <enemyScript>().enabled = true; //smGO.GetComponent<enemyScript>().setSpeed((speed-15)*2); pos.x = pos.x + .25f; smGO = PhotonNetwork.Instantiate("enemy3Sm", pos, Quaternion.identity, 0); smGO.transform.localScale = scal; smGO.GetComponent <enemyScript>().enabled = true; //smGO.GetComponent<enemyScript>().setSpeed((speed-15)*2); pos.x = pos.x + .25f; smGO = PhotonNetwork.Instantiate("enemy3Sm", pos, Quaternion.identity, 0); smGO.transform.localScale = scal; smGO.GetComponent <enemyScript>().enabled = true; //smGO.GetComponent<enemyScript>().setSpeed((speed-15)*2); pos.x = pos.x + .25f; smGO = PhotonNetwork.Instantiate("enemy3Sm", pos, Quaternion.identity, 0); smGO.transform.localScale = scal; smGO.GetComponent <enemyScript>().enabled = true; //smGO.GetComponent<enemyScript>().setSpeed((speed-15)*2); } PhotonNetwork.RPC(GetComponent <PhotonView>(), "killMe", PhotonTargets.AllBuffered, false); } }
void Update() { healthText.text = "HP:" + Hp.hp.ToString(); healthBar.fillAmount = Hp.hp / 100f; if (!stunned) { // The player is grounded if a linecast to the groundcheck position hits anything on the ground layer. grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground")); // If the jump button is pressed and the player is grounded then the player should jump. if (Input.GetButtonDown("Jump") && grounded) { anim.SetBool("Jump", true); jump = true; } if (Input.GetButtonDown("Fire1")) { GetComponent <PhotonView> ().RPC("Fire", PhotonTargets.All, true); } if (Input.GetButtonUp("Fire1")) { GetComponent <PhotonView> ().RPC("Fire", PhotonTargets.All, false); } if (Input.GetButtonDown("Fire2")) { GetComponent <PhotonView> ().RPC("Fire2", PhotonTargets.All, true); } if (Input.GetButtonUp("Fire2")) { GetComponent <PhotonView> ().RPC("Fire2", PhotonTargets.All, false); } if (Input.GetButtonDown("Use")) { int bitmask = 1 << LayerMask.NameToLayer("Items"); //Кастуем круг радиусом useRadius itemHit = Physics2D.OverlapCircle(transform.position, useRadius, bitmask); } if (Input.GetButton("Use")) { Ability.Use(gameObject, "Jump"); //Если круг чего-то коснулся if (itemHit != null) { if (!UseBar.enabled) { UseBar.enabled = true; UseBarBg.enabled = true; } if (itemHit.tag == "Player" && itemHit.GetComponent <PlayerControl> ().stunned) { if (Vector2.Distance(transform.position, itemHit.transform.position) > useRadius) { PhotonNetwork.RPC(itemHit.gameObject.GetPhotonView(), "Unstunning", PhotonTargets.AllBuffered, false); } if (Time.time >= nextTime) { PhotonNetwork.RPC(itemHit.gameObject.GetPhotonView(), "Unstunning", PhotonTargets.AllBuffered, true); nextTime = Time.time + unstSpeed; } UseBar.fillAmount = itemHit.GetComponent <PlayerControl> ().unstAm; } else { UseBar.enabled = false; UseBarBg.enabled = false; } } } if (Input.GetButtonUp("Use")) { UseBar.enabled = false; UseBarBg.enabled = false; if (itemHit != null) { if (itemHit.tag == "Player" && itemHit.GetComponent <PlayerControl> ().stunned) { PhotonNetwork.RPC(itemHit.gameObject.GetPhotonView(), "Unstunning", PhotonTargets.AllBuffered, false); } } } } else { UseBar.enabled = false; UseBarBg.enabled = false; if (itemHit != null) { if (itemHit.tag == "Player" && itemHit.GetComponent <PlayerControl> ().stunned) { PhotonNetwork.RPC(itemHit.gameObject.GetPhotonView(), "Unstunning", PhotonTargets.AllBuffered, false); } } if (!unstunning) { if (!MainMessage.enabled) { MainMessage.enabled = true; } if (cdToResp > 0) { if (Time.time >= nextCdTime) { cdToResp -= 0.1f; nextCdTime = Time.time + 0.1f; MainMessage.text = "To respawn:\n" + cdToResp.ToString("#0.00"); } } else { transform.GetComponent <PhotonView> ().RPC("Respawn", PhotonTargets.All, null); } } } }
public void Shoot(FiringPoint Point, int Index) { EmmisionMode Emmision = Point.Emmision; ShotMode Shooting = Point.Shooting; ParticleMode Particles = Point.Particles; SoundMode Sound = Point.Sound; Vector3 ShootPosition = this.transform.position + this.transform.TransformDirection(Vector3.forward); switch (Emmision.Positioning) { case ShotPositioning.Direct: ShootPosition = this.transform.position + this.transform.forward; break; case ShotPositioning.Weapon1: ShootPosition = Weapons.ElementAt(0).position + this.transform.forward; break; case ShotPositioning.Weapon2: ShootPosition = Weapons.ElementAt(1).position + this.transform.forward; break; case ShotPositioning.Split: int CurrentWeapon = SplitFiringSelection.ElementAt(Index); ShootPosition = Weapons.ElementAt(CurrentWeapon).position + this.transform.forward; switch (CurrentWeapon) { case 0: SplitFiringSelection[Index] = 1; break; case 1: SplitFiringSelection[Index] = 0; break; } break; } if (Emmision.EmmisionRandomOffset != Vector3.zero && Emmision.EmmisionRandomOffset != null) { ShootPosition.x += Random.Range(-Emmision.EmmisionRandomOffset.x, Emmision.EmmisionRandomOffset.x); ShootPosition.y += Random.Range(-Emmision.EmmisionRandomOffset.y, Emmision.EmmisionRandomOffset.y); ShootPosition.z += Random.Range(-Emmision.EmmisionRandomOffset.z, Emmision.EmmisionRandomOffset.x); } Vector3 ParticlesPosition = Emmision.EmmisionOffset + Particles.Position; Quaternion ShootRotation = this.transform.rotation * Quaternion.Euler(Emmision.RotationOffset); if (Particles.HasParticles == true) { Vector3 ParticleColor = new Vector3(Particles.Coloring.r, Particles.Coloring.g, Particles.Coloring.b); PhotonNetwork.RPC(this.photonView, "PlayParticles", RpcTarget.AllBuffered, false, ParticleColor, Particles.Prefab, Particles.Type, ParticlesPosition, ShootRotation, Index, Particles.Size); } if (Sound != null && Time.time > NextTimeToPlaySound) { AudioSource Source = this.GetComponent <AudioSource>(); Source.PlayOneShot(Sound.Clip, Sound.Volume); NextTimeToPlaySound = Time.time + Sound.Refresh; } for (int i = 0; i < Shooting.ShotCount; i++) { /* * EmmisionType EmitType = Emmision.Type; * RaycastHit Hit; * var dir = Quaternion.Euler(Emmision.RotationOffset) * this.transform.forward; * Debug.DrawRay(ShootPosition, dir, Color.cyan); * * switch (EmitType) * { * case EmmisionType.Line: * if (Physics.Raycast(ShootPosition, dir, out Hit, Shooting.Range, ~(1 << LayerMask.NameToLayer("Pieces")))) * { * Damage(Hit, Shooting, Index); * } * break; * case EmmisionType.Tube: * if (Physics.SphereCast(ShootPosition, Emmision.EmmisionSize, dir, out Hit, Shooting.Range, ~(1 << LayerMask.NameToLayer("Pieces")))) * { * Damage(Hit, Shooting, Index); * } * * break; * } */ //Quaternion dir = Quaternion.Euler(Quaternion.Euler(Emmision.RotationOffset) * this.transform.forward); Quaternion dir = this.transform.rotation * Quaternion.Euler(Emmision.RotationOffset); GameObject projectile = PhotonNetwork.Instantiate(Emmision.Prefab, ShootPosition, dir); projectile.layer = LayerMask.NameToLayer("Bullets"); projectile.transform.SetParent(GameObject.Find("TempStorage").transform); projectile.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; PhotonNetwork.RPC(photonView, "SetProjectile", RpcTarget.AllBuffered, false, projectile.gameObject.GetPhotonView().ViewID, this.gameObject.GetPhotonView().ViewID, new Vector3(Particles.ProjectileColor.r, Particles.ProjectileColor.g, Particles.ProjectileColor.b)); projectile.GetComponent <Renderer>().sharedMaterial.color = Particles.ProjectileColor; Bullet b = projectile.AddComponent <Bullet>(); b.shooter = this.transform; b.Shooting = Shooting; b.index = Index; b.speed = Shooting.Speed; b.maxRange = Shooting.Range; b.force = Shooting.Force; b.Fire(); } NextTimesToFire[Index] = Time.time + (1 / Shooting.FireRate) + Shooting.Recharge; if (NextTimesToFire[Index] == Mathf.Infinity || NextTimesToFire[Index] == Mathf.NegativeInfinity) { NextTimesToFire[Index] = 0; } }
void Die(int sourcePlayerIndex) { // RPC that we were destroyed PhotonNetwork.RPC(this.photonView, "TankDestroyed", PhotonTargets.All, false, sourcePlayerIndex); }
public void Respawn() { PhotonNetwork.RPC(photonView, "Respawn", RpcTarget.AllBuffered, false, this.gameObject.GetPhotonView()); }