private void PlaceCamera(int id) { this.headCamera.transform.SetParent(PhotonView.Find(id).transform); this.headCamera.transform.localPosition = Vector3.zero; this.headCamera.transform.localRotation = Quaternion.identity; this.headCamera.cam.transform.SetParent(this.headCamera.headCamParent); this.headCamera.cam.transform.localPosition = Vector3.zero; this.headCamera.cam.transform.localRotation = Quaternion.identity; this.headCamera.GetComponent <Collider>().enabled = true; this.headCamera.TurnOff(); this.headCamera.cam.enabled = false; this.headCamera.myLight.enabled = false; for (int i = 0; i < this.headCamera.rends.Length; i++) { this.headCamera.rends[i].enabled = true; } for (int j = 0; j < this.headCameraModels.Length; j++) { this.headCameraModels[j].SetActive(false); } this.headCamera = null; this.isEquipped = false; }
/// <summary> /// /// This is called when Remote player enter in car /// you can write here if you need do something in this event. /// </summary> void OnEnterNetwork(VehicleType vt, int vehicleID, bool playerVisible) { if (!playerVisible) { RemoteObjects.SetActive(false); } chararcterController.enabled = false; isInVehicle = true; StopCoroutine(WaitForCC()); if (vt == VehicleType.Jet) { GetComponent <bl_DrawName>().ShowUI(false); } GameObject vehicle = PhotonView.Find(vehicleID).gameObject; Vehicle = vehicle.GetComponent <bl_VehicleManager>(); transform.parent = Vehicle.PlayerHolder; transform.localPosition = Vehicle.DriverPosition; transform.localEulerAngles = Vehicle.DriverRotation; PlayerAnim.Anim.SetInteger("Vehicle", 2); }
public void KillPlayer(int newPlayerViewId) { //Set attributes for the new playable character PlayableCharacter newCharacter = PhotonView.Find(newPlayerViewId).GetComponent <PlayableCharacter>(); newCharacter.playerTile = playerTile; newCharacter.playersUI = playersUI; newCharacter.startingTeam = startingTeam; newCharacter.taskNotificationUI = taskNotificationUI; newCharacter.playerInfo = playerInfo; //Update UI to show player death playersUI.SetToDead(newCharacter); //Set new body game object to be parented by the new playable character transform GameObject body = Instantiate(playerInfo.ghostPrefab, new Vector3(0, 0, 0), Quaternion.identity); body.transform.parent = newCharacter.transform; // Sets the parent of the body to the player body.transform.position = newCharacter.transform.position; body.transform.Rotate(-90f, 0f, 0f); Destroy(gameObject); }
public void RPC_SetPass(bool Passing, int Target, float Force, Vector3 HandPos, int WhoThrew) { transform.SetParent(null); Thrown = true; CanBeCaughtTimer = 0.15f; passedTarget = PhotonView.Find(Target).gameObject; isInPassing = true; RB.useGravity = false; RB.isKinematic = false; RB.detectCollisions = true; transform.position = HandPos; Held = false; WhoTossedTheBall = PhotonView.Find(WhoThrew).gameObject; Hand = null; BH = null; HardCol.isTrigger = false; RB.velocity = Vector3.zero; RB.angularVelocity = Vector3.zero; transform.LookAt(PhotonView.Find(Target).gameObject.transform); RB.AddForce(Force * transform.forward, ForceMode.Impulse); teamTag = tag; gameObject.layer = 10; }
public void HitSync(int viewID) { GameObject obj = PhotonView.Find(viewID).gameObject; //각각 피격당한 대상의 HitMe 함수를 호출함. if (obj != null) { if (obj.tag.Equals("Minion")) { MinionBehavior minBehav = obj.GetComponent <MinionBehavior>(); if (minBehav != null) { minBehav.HitMe(stat.AttackDamage, "AD", gameObject); } } else if (obj.layer.Equals(LayerMask.NameToLayer("Champion"))) { ChampionSound.instance.IamAttackedSound(audio, obj.name); obj.GetComponent <ChampionBehavior>().HitMe(stat.AttackDamage, "AD", gameObject, gameObject.name); } } }
private void CustomChangeBladeRPC(int parentViewId, string bladeName) { PhotonView parentView = PhotonView.Find(parentViewId); if (parentView == null) { return; } Transform prentTran = parentView.transform; GameObject bladeObj = GameObject.Find(bladeName); if (bladeObj == null) { return; } Transform bladeTran = bladeObj.transform; bladeTran.SetParent(prentTran, false); bladeTran.localPosition = Vector3.zero; blade = bladeTran.gameObject; blade.SetActive(false); effectCtrl = blade.GetComponent <EffectController>(); }
/// <summary> /// Function that destroy a coin on the server and increases the score. /// </summary> /// <param name="coin">The Photon View ID of the coin that we are going to destroy.</param> /// <param name="playerNumber">Player who has collected the coin. 0 if null.</param> [PunRPC] void DestroyCoinServer(int coin, int playerNumber) { if (PhotonView.Find(coin) != null) { PhotonNetwork.Destroy(PhotonView.Find(coin)); switch (playerNumber) { case 1: photonView.RPC("UpdateScore", RpcTarget.All, true); photonView.RPC("PlaySound", RpcTarget.All, "coin"); break; case 2: photonView.RPC("UpdateScore", RpcTarget.All, false); photonView.RPC("PlaySound", RpcTarget.All, "coin"); break; default: break; } } }
void CreateECLRElectricLR(int ElectricLR_ID) { PhotonView.Find(ElectricLR_ID).GetComponent <Electric>().LR = PhotonView.Find(ElectricLR_ID).GetComponent <LineRenderer>(); PhotonView.Find(ElectricLR_ID).GetComponent <Electric>().origin = OldEnemy; PhotonView.Find(ElectricLR_ID).GetComponent <Electric>().destination = TargetEnemy; PhotonView.Find(ElectricLR_ID).GetComponent <Electric>().Target = TargetEnemy; GetComponent <SphereCollider>().enabled = false; JumpCount--; JumpTime = 0.1f; //清空資料 Enemys.Clear(); D.Clear(); //移動位置 gameObject.transform.position = TargetEnemy.transform.position; GetComponent <SphereCollider>().enabled = true; OldEnemy = TargetEnemy; }
void RPC_ChangeCharacterName(string name, int pvID) { // 0 = private; 1 = public inPublicRoom = PlayerPrefs.GetInt("isInPublicWorld"); GameObject nameCanvas; if (inPublicRoom == 0) { nameCanvas = PhotonView.Find(pvID).transform.GetChild(3).gameObject; } else { nameCanvas = PhotonView.Find(pvID).transform.GetChild(4).gameObject; } nameCanvas.SetActive(true); TMPro.TextMeshProUGUI playerName = nameCanvas.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent <TMPro.TextMeshProUGUI>(); if (photonView.IsMine && (inPublicRoom == 0)) { Destroy(nameCanvas); return; } playerName.text = "@" + name; }
private void myMasterIs(int viewId, string launcherRef, PhotonMessageInfo info) { if (Guardian.AntiAbuse.HookPatches.IsHookMasterSetValid(this, viewId, info)) { master = PhotonView.Find(viewId).gameObject; if (launcherRef == "hookRefL1") { myRef = master.GetComponent <HERO>().hookRefL1; } if (launcherRef == "hookRefL2") { myRef = master.GetComponent <HERO>().hookRefL2; } if (launcherRef == "hookRefR1") { myRef = master.GetComponent <HERO>().hookRefR1; } if (launcherRef == "hookRefR2") { myRef = master.GetComponent <HERO>().hookRefR2; } } }
private void Start() { if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer) { if (!baseT.root.gameObject.GetPhotonView().IsMine) { base.enabled = false; return; } if (baseT.root.gameObject.GetComponent <EnemyfxIDcontainer>() != null) { this.viewID = baseT.root.gameObject.GetComponent <EnemyfxIDcontainer>().myOwnerViewID; this.ownerName = baseT.root.gameObject.GetComponent <EnemyfxIDcontainer>().titanName; this.myTeam = PhotonView.Find(this.viewID).gameObject.GetComponent <HERO>().myTeam; } } else { this.myTeam = IN_GAME_MAIN_CAMERA.MainHERO.myTeam; } this.active_me = true; this.count = 0; }
protected void RiseTheObject(int ItemID, int ViewID, float LocalDistanceY) { Item = PhotonView.Find(ItemID).gameObject; PickUpController PickCon = Item.GetComponent <PickUpController>(); Physics.IgnoreCollision(Item.GetComponent <Collider>(), PhotonView.Find(ViewID).gameObject.GetComponent <Collider>(), true); if (carryObject = false && !PickCon.IsAttached) { PickCon.photonView.TransferOwnership(ViewID); } Item.transform.SetParent(transform); Item.gameObject.transform.localPosition = new Vector3(Item.gameObject.transform.localPosition.x, LocalDistanceY, Item.gameObject.transform.localPosition.z); DistanceY = Item.gameObject.transform.localPosition.y; DistanceX = Item.gameObject.transform.localPosition.x; DistanceZ = Item.gameObject.transform.localPosition.z; Rigidbody ItemRB = Item.GetComponent <Rigidbody>(); ItemRB.constraints = RigidbodyConstraints.FreezeRotation; ItemRB.useGravity = false; PickCon.IsAttached = true; carryObject = true; IsThrowable = true; }
public void RpcShoot(float damage, int targetID) { switch (faction) { case 0: GameObject target = PhotonView.Find(targetID).gameObject; GameObject obj = Instantiate(projectile, projectileOrigin.position, Quaternion.LookRotation(target.transform.position - transform.position)); obj.GetComponent <ProjectileScript>().SetTarget(target, damage); break; case 1: GameObject target1 = PhotonView.Find(targetID).gameObject; GameObject obj1 = Instantiate(projectile, projectileOrigin.position, Quaternion.LookRotation(target1.transform.position - transform.position)); obj1.GetComponent <ProjectileScript>().SetTarget(target1, damage); break; case 2: GameObject target2 = PhotonView.Find(targetID).gameObject; GameObject obj2 = Instantiate(projectile, projectileOrigin.position, Quaternion.LookRotation(target2.transform.position - transform.position)); obj2.GetComponent <ProjectileScript>().SetTarget(target2, damage); break; } }
public Transform ChooseMostDangerousPlayer() { float max = -1; int index = -1; for (int i = 0; i < threatList.Count; i++) { if (threatList[i] != null && threatList[i].threat > max) { max = threatList[i].threat; index = i; } } if (index != -1 && PhotonView.Find(threatList[index].viewId) != null) { //if(threatList[index].threat != 50) Debug.Log(gameObject.name + " is targeting : " + threatList[index].playerName + ". Threat : " + threatList[index].threat); return(PhotonView.Find(threatList[index].viewId).gameObject.transform); } else { return(GameObject.FindGameObjectWithTag("Nexus").transform); } }
public void RaceiveDamage(int playerID, int otherPlayerID, int damage, int otherPhotonViewID) { if (player.GetPhotonView().ownerId == otherPlayerID) { LocalVariables localVariables = player.GetComponent <LocalVariables>(); if (localVariables.Hp - damage <= 0) { if (localVariables.Hp > 0) { photonView.RPC("CallIfPlayerKilled", PhotonTargets.All, (int)PhotonView.Find(otherPhotonViewID).gameObject.GetComponent <LocalVariables>().team); photonView.RPC("SendMoney", PhotonTargets.All, playerID, killPlayerMoney); photonView.RPC("AttackEnemy", PhotonTargets.All, PhotonView.Find(otherPhotonViewID).transform.position, killPlayerExp, otherPlayerID); } localVariables.Hp = 0; } else { localVariables.Hp -= damage; } photonView.RPC("RecieveChangedHP", PhotonTargets.MasterClient, player.gameObject.GetPhotonView().ownerId, localVariables.Hp); } }
private void PlayLootAnimation(int looterViewId, string lootItemName, Vector3 lootItemPosition) { var looterPhotonView = PhotonView.Find(looterViewId); if (looterPhotonView == null) { Debug.LogWarning($"해당 id와 일치하는 {nameof(photonView)}를 찾을 수 없습니다, {nameof(looterViewId)}: {looterViewId}"); return; } if (ItemDataCollection.Instance.ItemDataByName.TryGetValue(lootItemName, out var lootItemData) == false) { Debug.LogWarning($"해당 이름의 {nameof(ItemData)}가 {nameof(ItemDataCollection)}에 없습니다, {nameof(lootItemName)}: {lootItemName}"); return; } var lootAnimation = LootAnimation.InstantiateAnimation(looterPhotonView.transform, lootItemData.Model, lootItemPosition, lootAnimationSettings); if (lootAnimation != null) { lootAnimation.transform.parent = transform; } }
private void ReceivePickUpBallEvent(BallType ballType, int ballViewID, int pickerViewID) { PlayerController picker = PhotonView.Find(pickerViewID)?.GetComponent <PlayerController>(); Ball ball = PhotonView.Find(ballViewID)?.GetComponent <Ball>(); if (picker == null) { Debug.LogWarning("Can't find picker with id " + pickerViewID); return; } // Delete ball if you are the owner if (ball.NetworkedObject.IsMine) { Destroy(ball.NetworkedObject); } // Call local pickup if you are not the picker if (!picker.NetworkedObject.IsMine) { picker.PickupBallLocal(ballType); } }
public void DetermineTeamForNewPlayer(int viewID, bool sendRpc = true) { PlayerController player = PhotonView.Find(viewID).GetComponent <PlayerController>(); if (Team1.Count == Team2.Count) { PlayerToTeam(player, true, viewID, sendRpc); return; } else { if (Team1.Count - Team2.Count < 0) { PlayerToTeam(player, true, viewID, sendRpc); return; } else { PlayerToTeam(player, false, viewID, sendRpc); return; } } }
private void myMasterIs(int id, string launcherRef) { master = PhotonView.Find(id).gameObject; if (launcherRef == "hookRefL1") { myRef = master.GetComponent <HERO>().hookRefL1; } if (launcherRef == "hookRefL2") { myRef = master.GetComponent <HERO>().hookRefL2; } if (launcherRef == "hookRefR1") { myRef = master.GetComponent <HERO>().hookRefR1; } if (launcherRef == "hookRefR2") { myRef = master.GetComponent <HERO>().hookRefR2; } }
[PunRPC]//On dead client and everyone else, stream killfeed,wait 5s(while death anim plays),Hide Player,Reset Health,Teleport to spawn point,Show Player! public void BroadcastDeath(int PhotonViewID) { //Set anim to "IsDead" via health == 0 (PlayerMove) PhotonView.Find(PhotonViewID).GetComponent <Health>().hitPoints = 0; string PlayFabID = ""; //Use given ID to extrapolate further info on player locally for (int i = 0; i < GSC.networkObjects.Count; i++) { if (GSC.networkObjects[i].viewID.ViewID == PhotonViewID) { PlayFabID = GSC.networkObjects[i].Player; break; } } //Stream local info Debug.Log("Player: " + PlayFabID + " Has Died."); //Wait 5 seconds StartCoroutine(waiter(PhotonViewID)); }
public void AdjustPP(int adj, string currentOrMax, int attacker) { if (currentOrMax == "max") { curMaxPP += adj; GameObject attackingPokemon = PhotonView.Find(attacker).gameObject; if (attackingPokemon != gameObject && attackingPokemon.GetComponent <Pokemon>().isCaptured&& !PokemonToGiveEXPTo.Contains(attacker)) { PokemonToGiveEXPTo.Add(attacker); } if (curMaxPP < 0) { curMaxPP = 0; } if (curMaxPP > maxPP) { curMaxPP = maxPP; } } if (currentOrMax == "current") { curPP += adj; GameObject attackingPokemon = PhotonView.Find(attacker).gameObject; if (attackingPokemon != gameObject && attackingPokemon.GetComponent <Pokemon>().isCaptured&& !PokemonToGiveEXPTo.Contains(attacker)) { PokemonToGiveEXPTo.Add(attacker); } if (curPP < 0) { curPP = 0; } if (curPP > curMaxPP) { curPP = curMaxPP; } } }
private void Start() { //Se corre localmente este script //Coger el local player int viewId = GameManager.Instance.GetPlayerViewId(PhotonNetwork.LocalPlayer.ActorNumber); localPlayer = PhotonView.Find(viewId).gameObject; int position = localPlayer.GetComponent <PlayerInfo>().RankPosition; PlayerPrefs.SetInt("Cookies", PlayerPrefs.GetInt("Cookies", 0) + AssignRewards(position)); PlayerPrefs.SetInt("Experience", PlayerPrefs.GetInt("Experience", 0) + AssignRewards(position)); if (PlayerPrefs.GetInt("Experience") >= 200) //Every 200xp the player levels up { PlayerPrefs.SetInt("Level", PlayerPrefs.GetInt("Level", 1) + 1); PlayerPrefs.SetInt("Experience", 0); } //Si quieres que solo pase el servidor (cliente que hace de servidor) //if (PhotonNetwork.IsMasterClient) ; //Si quieres que solo pase el que posee el objeto actual (pista, solo erres propietario si lo instancias tu con PhotonNetwork.Instantiate) //if (photonView.IsMine) ; //Pasarselo //Poner a cada uno en su lugar foreach (var player in PhotonNetwork.PlayerList) { int viewIdOther = GameManager.Instance.GetPlayerViewId(player.ActorNumber); GameObject localPlayerOther = PhotonView.Find(viewIdOther).gameObject; int positionOther = localPlayerOther.GetComponent <PlayerInfo>().RankPosition; string nameOther = player.NickName; names[positionOther - 1].text = positionOther + ". " + nameOther + ": +" + AssignRewards(positionOther) + " Galletas / +" + AssignRewards(positionOther) + " Exp"; } }
public void SetTable(int tableId) { if (!photonView.isMine) { return; } PhotonView tableObj = PhotonView.Find(tableId); if (tableObj == null) { Debug.LogError("Failed to find target table: " + tableId); return; } targetTable = tableObj.GetComponent <TableGroup>(); //Occupy Seats Queue <Customer> customers = new Queue <Customer>(group.GetCustomers()); foreach (Chair chair in targetTable.GetChairs()) { if (customers.Count == 0) { break; } if (chair.seatedCustomer == null) { chair.seatedCustomer = customers.Dequeue(); } } //Move Customers to their seats StatusIconLibrary.Get().ShowTaskCompleteTick(currentIcon.transform.position); goToTable.SetDestination(targetTable.transform.position); SwitchState(stateWalkToTable); }
// HERO.netGrabbed public static bool IsGrabValid(int viewId, PhotonMessageInfo info) { if (IN_GAME_MAIN_CAMERA.Gametype != GameType.Multiplayer) { return(true); } PhotonView view = PhotonView.Find(viewId); if (info != null && view != null) { GameObject go = view.gameObject; if (go != null) { TITAN titan = go.GetComponent <TITAN>(); if (titan != null && titan.photonView.ownerId == info.sender.Id) { return(true); } FEMALE_TITAN annie = go.GetComponent <FEMALE_TITAN>(); if (annie != null && annie.photonView.ownerId == info.sender.Id) { return(true); } } } Mod.Logger.Error($"'HERO.netGrabbed' from #{(info == null ? "?" : info.sender.Id.ToString())}"); if (info.sender != null && !FengGameManagerMKII.IgnoreList.Contains(info.sender.Id)) { FengGameManagerMKII.IgnoreList.Add(info.sender.Id); } return(false); }
void BlueLineWorking(int victimId, int senderId, Vector2 missedplace, float spd, float dmg, float maxT) { if (victimId != 0) { receiver = PhotonView.Find(victimId).GetComponent <Rigidbody2D>(); sender = PhotonView.Find(senderId).GetComponent <Rigidbody2D>(); damage = dmg; speed = spd; receiver.GetComponent <MoveScript>().cook += AddConstentCentrallyVelocity; maxtime = maxT; if (receiver.gameObject.GetPhotonView().isMine) { Idrag = true; receiver.GetComponent <DoSkill>().ClearDebuff += gameObject.GetComponent <DestroyScript>().Destroyself; } } else { sender = PhotonView.Find(senderId).GetComponent <Rigidbody2D>(); drawmyline(sender.position, missedplace); StartCoroutine(EraseLine()); } enabled = true; }
private void Start() { if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.MULTIPLAYER) { if (!base.transform.root.gameObject.GetPhotonView().isMine) { base.enabled = false; return; } if (base.transform.root.gameObject.GetComponent<EnemyfxIDcontainer>() != null) { this.viewID = base.transform.root.gameObject.GetComponent<EnemyfxIDcontainer>().myOwnerViewID; this.ownerName = base.transform.root.gameObject.GetComponent<EnemyfxIDcontainer>().titanName; this.myTeam = PhotonView.Find(this.viewID).gameObject.GetComponent<HERO>().myTeam; } } else { this.myTeam = GameObject.Find("MainCamera").GetComponent<IN_GAME_MAIN_CAMERA>().main_object.GetComponent<HERO>().myTeam; } this.active_me = true; this.count = 0; this.currentCamera = GameObject.Find("MainCamera"); }
public void PickupItemInit(double timeBase, float[] inactivePickupsAndTimes) { this.IsWaitingForPickupInit = false; for (int i = 0; i < inactivePickupsAndTimes.Length / 2; i++) { int num = i * 2; int viewID = (int)inactivePickupsAndTimes[num]; float num2 = inactivePickupsAndTimes[num + 1]; PhotonView photonView = PhotonView.Find(viewID); PickupItem component = photonView.GetComponent <PickupItem>(); if (num2 <= 0f) { component.PickedUp(0f); } else { double num3 = (double)num2 + timeBase; Debug.Log(string.Concat(new object[] { photonView.viewID, " respawn: ", num3, " timeUntilRespawnBasedOnTimeBase:", num2, " SecondsBeforeRespawn: ", component.SecondsBeforeRespawn })); double num4 = num3 - PhotonNetwork.time; if (num2 <= 0f) { num4 = 0.0; } component.PickedUp((float)num4); } } }
public void HitSyncEffect(int viewID, string name, string key, int number, float term) { // 추가해야함 GameObject g = PhotonView.Find(viewID).gameObject; key += "Effect"; if (name.Contains("Alistar")) { g.GetComponent <AlistarSkill>().InvokeEffect(key, number, term); } else if (name.Contains("Mundo")) { g.GetComponent <MundoSkill>().InvokeEffect(key, number, term); } else if (name.Contains("Ashe")) { g.GetComponent <AsheSkill>().InvokeEffect(key, number, term); } else if (name.Contains("Ahri")) { } else if (name.Contains("Garen")) { } }
private void tieMeToOBJ(int id, PhotonMessageInfo info) { if (info.sender != basePV.owner) { FengGameManagerMKII.instance.kickPlayerRC(info.sender, true, "invalid tieMeToObj"); return; } //PhotonView photonView = PhotonView.Find(id); //if (photonView != null) //{ // GameObject gameObject = photonView.gameObject; // if (gameObject != null) // { // this.baseT.parent = photonView.transform; // TITAN component = gameObject.GetComponent<TITAN>(); // if (component != null) // { // component.hooks.Add(this); // } // } //} baseT.parent = PhotonView.Find(id).gameObject.transform; }
public void GrabbingObject(int viewID) { grabbedObject = PhotonView.Find(viewID).gameObject; grabbedObject.GetComponent <CapsuleCollider> ().enabled = false; grabbedObject.transform.SetParent(gameObject.transform, false); Vector3 offset = Quaternion.AngleAxis(-45, gameObject.transform.right) * gameObject.transform.forward * 4; grabbedObject.transform.position = gameObject.transform.position + offset; // Adjust the scale of the object to the scale of the new parent so it retains its size. { Vector3 parentScale = gameObject.transform.localScale; originalGrabbedObjectScale = grabbedObject.transform.localScale; Vector3 adjustedScale = originalGrabbedObjectScale; adjustedScale.x /= parentScale.x; adjustedScale.y /= parentScale.y; adjustedScale.z /= parentScale.z; grabbedObject.transform.localScale = adjustedScale; } }