public RPC ( string methodName, PhotonPlayer, targetPlayer ) : void | ||
methodName | string | The name of a fitting method that was has the RPC attribute. |
targetPlayer | PhotonPlayer, | The group of targets and the way the RPC gets sent. |
return | void |
public void Damage(float damage) { if (Currenthealth - damage <= 0) { DieEvent?.Invoke(); } else { PhotonView?.RPC("DamageRPC", RpcTarget.All, damage); } }
void GetCharacter(string _username, PhotonPlayer _player) { GameObject controller = GameObject.FindGameObjectWithTag("GameController"); int[] _stats = controller.GetComponent<Database>().GeneratePlayerCore(_username, _player); myPhotonView = this.gameObject.GetComponent<PhotonView>(); if (_stats != null) { myPhotonView.RPC("ReturnCore", _player, _stats); } else { myPhotonView.RPC("NoCharacter", _player); } }
public override void OnEnter () { photonView = PhotonView.Get (gameObject.Value); photonView.RPC (methodName.Value, targets, parameter1.GetValue (),parameter2.GetValue()); Finish (); }
public void ResultOn() { ResultActvie = true; Ending.SetActive (false); Canvas.GetComponent<Animator>().SetTrigger("OnResultStart"); AudioManager.Instance.PlayBGM(win ? "resultclearbgm" : "resultfailbgm", 0.5f); GameObject.Find ("MyResultText").GetComponent<Text> ().text = (GameManager.instance.CorrectAnswerNum + GameManager.instance.IncorrectAnswerNum).ToString () + "もん中、\n" + GameManager.instance.CorrectAnswerNum.ToString() + "もんせいかい!"; myPv = this.GetComponent<PhotonView>(); memberCorrectAnswerNum = new Dictionary<string, int>(); memberInCorrectAnswerNum = new Dictionary<string, int>(); myPv.RPC ("SetMemberAnswerNum", PhotonTargets.All, GameManager.instance.name, GameManager.instance.CorrectAnswerNum, GameManager.instance.IncorrectAnswerNum); GameObject.Find("HpGuage").transform.localScale = new Vector3(1, (GameManager.instance.BossHp > GameManager.instance.Score)? (float)(GameManager.instance.BossHp - GameManager.instance.Score) / GameManager.instance.BossHp : 0, 1); if (win) { GameObject.Find ("BackGround").GetComponent<Image> ().sprite = backgroundWin; GameObject.Find ("Title").GetComponent<Image> ().sprite = titleWin; GameObject.Find ("Enemy").GetComponent<Image> ().sprite = enemyWin[GameManager.instance.SelectLevel]; } else { GameObject.Find ("BackGround").GetComponent<Image> ().sprite = backgroundLose; GameObject.Find ("Title").GetComponent<Image> ().sprite = titleLose; GameObject.Find ("Enemy").GetComponent<Image> ().sprite = enemyLose[GameManager.instance.SelectLevel]; } }
void Start() { photonView = GetComponent<PhotonView> (); NAMEPLATE = gameObject.GetComponent<TextMesh>(); playerName = GetComponentInParent<PlayerStatus> ().playerName; photonView.RPC ("setName", PhotonTargets.All, playerName); }
public override void OnEnter () { photonView = PhotonView.Get (gameObject.Value); photonView.RPC ("SetFsmBool", targets, variable.Name,value.Value); Finish (); }
public override void OnEnter () { photonView = PhotonView.Get (gameObject.Value); photonView.RPC ("SetTrigger", targets, trigger.Value); Finish (); }
public override void OnEnter () { photonView = PhotonView.Get (gameObject.Value); photonView.RPC ("LoadLevel", targets, level.Value); Finish (); }
void Start() { myPhotonView = gameObject.GetComponent<PhotonView>(); if (myPhotonView.isMine){ myPhotonView.RPC("setLife", PhotonTargets.All ); } }
// Use this for initialization void Start() { alphaWall = GameObject.Find ("AlphaWall") as GameObject; pv = GetComponent<PhotonView> (); curRoom = PhotonNetwork.room; bool isCustomBack = System.Convert.ToBoolean (curRoom.customProperties ["ISCUSTOMBACK"].ToString()); string backgroundOfNewUser = curRoom.customProperties ["BACKGROUND"].ToString(); pv.RPC ("SetBackground", PhotonTargets.All, backgroundOfNewUser, isCustomBack); }
void DbUsernameCheck(string _username, PhotonPlayer _player) { GameObject controller = GameObject.FindGameObjectWithTag("GameController"); bool _go = controller.GetComponent<Database>().CheckUsername(_username); Debug.Log("_go: " + _go); Debug.Log("_player: " + _player); myPhotonView = this.gameObject.GetComponent<PhotonView>(); myPhotonView.RPC("DbUsercheckReturn", _player, _go); }
// Use this for initialization void Start() { myView = this.GetComponent<PhotonView>(); if(PhotonNetwork.isMasterClient){ RandomPos(); myView.RPC ("SetPosition",PhotonTargets.AllBuffered,position); } }
void Start() { controller = GetComponent<NavMeshAgent>(); GameManager.players.Add(gameObject); position = transform.position; playerAnimation = GetComponent<Animator>(); photonView = GetComponent<PhotonView>(); photonView.RPC("AddPlayer", PhotonTargets.AllBufferedViaServer, photonView.viewID); playerSpeed = controller.speed; }
void DbLogin(string[] _creds, PhotonPlayer _player) { string _username = _creds[0]; string _password = _creds[1]; GameObject controller = GameObject.FindGameObjectWithTag("GameController"); bool _go = controller.GetComponent<Database>().Login(_username, _password); myPhotonView = this.gameObject.GetComponent<PhotonView>(); myPhotonView.RPC("LoginResult", _player, _go); }
void Start() { health = 100; photonView = GetComponent<PhotonView> (); zombScript = GetComponent<ZombieScript> (); bool startAsZombie = true; foreach (ZombieScript zombz in FindObjectsOfType<ZombieScript>()) if (zombz.isActiveAndEnabled) startAsZombie = false; if (startAsZombie) photonView.RPC ("TurnZomb", PhotonTargets.AllBufferedViaServer); }
private void Start(){ if (transform.root != transform) { EquipmentHandler handler = transform.root.gameObject.AddComponent<EquipmentHandler> (); handler.equipment = equipment; handler.defaultAttack=defaultAttack; Destroy(this); return; } photonView = PhotonView.Get (gameObject); if (photonView != null) { if ( !photonView.isMine) { photonView.RPC ("NetworkEquipRequest", photonView.owner, null); }else{ if (defaultAttack != null) { gameObject.AddBehaviour(defaultAttack,attackGroup,true); } } } }
void SpawnMyPlayer() { myCharacter = PhotonNetwork.Instantiate("knight", Vector3.zero, Quaternion.identity, 0); myCharacterPhotonView = myCharacter.GetComponent<PhotonView>(); myCharacter.name = PlayerPrefs.GetString("playerName"); // set character name for all players myCharacterPhotonView.RPC("SetName", PhotonTargets.AllBuffered, myCharacter.name); // enable character script and set team KnightMovement m = myCharacter.GetComponent<KnightMovement>(); m.enabled = true; PhotonView pv = myCharacter.GetComponent<PhotonView>(); myCharacter.GetComponent<BoxCollider2D>().enabled = true; myCharacter.transform.FindChild("Main Camera").gameObject.SetActive(true); }
void Start() { myPhotonView = GetComponent<PhotonView>(); for (int i = 0; i < Arenas.arenaInstances.Count; i++) { ArenaManagers.Add(Arenas.arenaInstances[i]); } for (int i = 0; i < ArenaManagers.Count; i++) { ArenaManagers[i].arenaID = ArenaManagers.IndexOf(ArenaManagers[i]); } if(!PhotonNetwork.isMasterClient) { myPhotonView.RPC("RequestArenaStateDataFromMaster", PhotonTargets.MasterClient); } //request arena data //ArenaManagers.Clear(); }
public void VoteForMap(int Vote) { myPhotonView.RPC("AddToCount", RpcTarget.MasterClient, Vote); }
public void Login(string[] loginInfo) { myPhotonView = this.gameObject.GetComponent<PhotonView>(); myPhotonView.RPC("DbLogin", PhotonTargets.MasterClient, loginInfo, myPhotonView.owner); }
/// <summary> /// Calls the event to update players' properties locally. /// </summary> public void OnPropertiesChanged() { view.RPC("OnNetworkPropertiesChanged", PhotonTargets.All); }
public void TakeDamage(float damage) { PV.RPC("RPC_TakeDamage", RpcTarget.All, damage); }
void SpawnMyPlayer() { myCharacter = PhotonNetwork.Instantiate(selectedClass, Vector3.zero, Quaternion.identity, 0); myCharacterPhotonView = myCharacter.GetComponent<PhotonView>(); myCharacter.name = PlayerPrefs.GetString("playerName"); // set character name for all players myCharacterPhotonView.RPC("SetName", PhotonTargets.AllBuffered, myCharacter.name); // activate character script and camera standbyCamera.SetActive(false); // enable character script and set team Character c = myCharacter.GetComponent<Character>(); c.enabled = true; PhotonView pv = myCharacter.GetComponent<PhotonView>(); if(selectedTeam == team1) { pv.RPC("SetTeamID", PhotonTargets.AllBuffered, team1); // add this character to the team list if it hasn't already been added if (!teamSetup) { c.playerID = team1Players.Count; netManPhotonView.RPC("AddPlayerToTeam", PhotonTargets.AllBuffered, myCharacter.name, 0); teamSetup = true; } } else { pv.RPC("SetTeamID", PhotonTargets.AllBuffered, team2); // add this character to the team list if it hasn't already been added if (!teamSetup) { c.playerID = team2Players.Count; netManPhotonView.RPC("AddPlayerToTeam", PhotonTargets.AllBuffered, myCharacter.name, 1); teamSetup = true; } } // set layer mask for character controller so you collide with the enemy team CharacterController2D cc = myCharacter.GetComponent<CharacterController2D>(); if(selectedTeam == team1) { cc.platformMask = cc.platformMask | (1 << team2); } else { cc.platformMask = cc.platformMask | (1 << team1); } myCharacter.GetComponent<BoxCollider2D>().enabled = true; myCharacter.transform.FindChild("Main Camera").gameObject.SetActive(true); // create an item handler and attach it to this character GameObject items = (GameObject)Instantiate(itemHandlerPrefab); c.itemHandler = items.GetComponent<Items>(); c.itemHandler.LookForCharacter(myCharacter.name); c.ReadyItems(); }
/*---------------------------- UPDATE ----------------------------*/ // Update is called once per frame void Update() { PhotonView photonView = PhotonView.Get(this); //When our playerCreator is created we add ourself on the scoreboards playerSpawn playSpawn = GetComponent <playerSpawn>(); //While we're not on the scoreboard we try to be added if (addedOnBoard == false) { //We make a string out of our gamertag and playerID string myTag = PlayerPrefs.GetString("Gamertag"); int myID = photonView.owner.ID; //If we have all the components we send the RPC if (myTeam == "Blue" || myTeam == "Red") { string tagTeamID = myID.ToString() + ";" + myTag + ";" + myTeam; if (PhotonNetwork.isMasterClient) { photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID); } else { photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID); photonView.RPC("updateMe", PhotonTargets.Others, myID); } /*if(photonView.isMine) * { * addOnBoard(tagTeamID); * }*/ addedOnBoard = true; } } //Managing the kills //We update the last shot each frame foreach (Transform child in transform) { if (child.name != "scoreHUD" && child.name != "scoreBoardUI") { playerNetwork playSet = child.GetComponent <playerNetwork>(); myLastShot = playSet.lastShot; } } //If we're killed we add the kill and update the score if (wasKilled) { int myID = photonView.owner.ID; if (myTeam == "Blue") { photonView.RPC("addRedKill", PhotonTargets.All, myLastShot); photonView.RPC("addBlueDeath", PhotonTargets.All, myID); } else { photonView.RPC("addBlueKill", PhotonTargets.All, myLastShot); photonView.RPC("addRedDeath", PhotonTargets.All, myID); } wasKilled = false; } /*--------------------------- SCOREBOARD ----------------------*/ //We get the scoreboard object Transform scoreB = transform.Find("scoreBoardUI"); //Drawing the score if (Input.GetKeyDown(KeyCode.Tab)) { drawTheScore = true; } if (Input.GetKeyUp(KeyCode.Tab)) { drawTheScore = false; } if (photonView.isMine) { if (drawTheScore) //If the player press tab we activate the board { scoreB.gameObject.active = true; } else { scoreB.gameObject.active = false; } } else { scoreB.gameObject.active = false; } }
public void ShuffleAndDeal() { Deck.Shuffle(); PV.RPC("RPC_Deal", RpcTarget.AllViaServer); }
void Update() { //When the master client place the popcorn machine in their local copy, isPlaced=true if (m_AppMode == AppMode.ReadyToHostCloudReferencePoint && isPlaced) { placePos = new Pose(popcornMachine.transform.position, Quaternion.identity); OutputText.text = m_AppMode.ToString(); ARReferencePoint referencePoint = ReferencePointManager.AddReferencePoint( placePos); // Create Cloud Reference Point. m_CloudReferencePoint = ReferencePointManager.AddCloudReferencePoint( referencePoint); if (m_CloudReferencePoint == null) { OutputText.text = "Create Failed!"; return; } // Wait for the reference point to be ready. m_AppMode = AppMode.WaitingForHostedReferencePoint; } else if (m_AppMode == AppMode.WaitingForHostedReferencePoint) { CloudReferenceState cloudReferenceState = m_CloudReferencePoint.cloudReferenceState; if (cloudReferenceState == CloudReferenceState.Success) { //Instantiate an empty game object to indicate the cloud anchor is placed at the position, can be replaced with other game object for debugging OutputText.text = "Success! Click Ready when you are ready"; GameObject cloudAnchor = Instantiate( HostedPointPrefab, Vector3.zero, Quaternion.identity); cloudAnchor.transform.SetParent( m_CloudReferencePoint.transform, false); //Popcorn machine will follow the transform of cloud anchor popcornMachine.transform.position = cloudAnchor.transform.position; popcornMachine.transform.SetParent(m_CloudReferencePoint.transform); //Get the cloud anchor reference Id and send this ID to other clients m_CloudReferenceId = m_CloudReferencePoint.cloudReferenceId; m_CloudReferencePoint = null; _photonView.RPC("setCloudReferenceId", RpcTarget.Others, m_CloudReferenceId); } else { OutputText.text = /*m_AppMode.ToString() +*/ " Please wait for a few seconds..." + " - " + cloudReferenceState.ToString(); } } else if (m_AppMode == AppMode.ReadyToResolveCloudReferencePoint) { OutputText.text = m_CloudReferenceId; { m_CloudReferencePoint = ReferencePointManager.ResolveCloudReferenceId( m_CloudReferenceId); if (m_CloudReferencePoint == null) { OutputText.text = "Resolve Failed!"; m_CloudReferenceId = string.Empty; return; } m_CloudReferenceId = string.Empty; // Wait for the reference point to be ready. m_AppMode = AppMode.WaitingForResolvedReferencePoint; } } else if (m_AppMode == AppMode.WaitingForResolvedReferencePoint) { CloudReferenceState cloudReferenceState = m_CloudReferencePoint.cloudReferenceState; if (cloudReferenceState == CloudReferenceState.Success) { OutputText.text = "Success! Click Ready when you are ready"; GameObject cloudAnchor = Instantiate( ResolvedPointPrefab, Vector3.zero, Quaternion.identity); cloudAnchor.transform.SetParent( m_CloudReferencePoint.transform, false); popcornMachine.transform.position = cloudAnchor.transform.position; popcornMachine.transform.SetParent(m_CloudReferencePoint.transform); m_CloudReferencePoint = null; } else { OutputText.text = /*m_AppMode.ToString()+*/ " Please wait for a few seconds..." + " - " + cloudReferenceState.ToString(); } } }
int currentPhase = 0; // 0 - Not Start, 1 - Prepearing, 2 - Playing, 3 - Ending. // This function is used to call for the phase timing by the host. public void nextPhase(bool timeWin) { if (PhotonNetwork.isMasterClient && timeLeft <= 0) { if (currentPhase == 0 && PhotonNetwork.room.PlayerCount >= minimumPlayers) { PhotonView photonView = PhotonView.Get(this); photonView.RPC("SpawnUser", PhotonTargets.All); ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable() { { "S", 1 } }; PhotonNetwork.room.SetCustomProperties(hash); currentPhase += 1; PhotonView.Get(this).RPC("updatePhase", PhotonTargets.All, "PREPEARING"); // Setup UI timeLeft = preparingTime; StartCoroutine("timePhase"); } else if (currentPhase == 1 && PhotonNetwork.room.PlayerCount >= minimumPlayers) { currentPhase += 1; ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable() { { "S", 2 } }; PhotonNetwork.room.SetCustomProperties(hash); // Code for selecting traitors etc. selectTraitors(); PhotonView.Get(this).RPC("updatePhase", PhotonTargets.All, "PLAYING"); // Setup UI timeLeft = gamingTime; StartCoroutine("timePhase"); } else if (currentPhase == 2) { currentPhase += 1; ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable() { { "S", 3 } }; PhotonNetwork.room.SetCustomProperties(hash); if (timeWin) { // If it makes it to this point, they innocents win by time! PhotonView.Get(this).RPC("roundWin", PhotonTargets.All, "innocent", "Time Up"); } PhotonView.Get(this).RPC("updatePhase", PhotonTargets.All, "ROUND END"); // Setup UI Debug.Log("Yay"); timeLeft = endingTime; Debug.Log(timeLeft); StartCoroutine("timePhase"); } else { // Next round? PhotonView.Get(this).RPC("nextRound", PhotonTargets.All); } } }
void dijonSharing() { pv.RPC("dijonSharevalue", RpcTarget.AllBuffered, buyitem1, buyitem2, buyitem3, buyitem4, buyitem5, buyitem6, buyitem7, buyitem8, buyitem9, buyitem10, buyitem11, buyitem12); }
public void Send_ToOthers() {//送信メソッド _PhotonViewControl.RPC("SendFunc", PhotonTargets.Others, GameJudgeScript.MyHitCount); //RPC([使うメソッドの名前],[メソッドを発動させる対象],[メソッドの引数に突っ込む値]) }
public static void Deal(PhotonView photonView) { Debug.Log("IN DEAL METHOD"); //Make sure we only call the Deal method once if (dealtOnce) { return; } dealtOnce = true; int numGood = 0; int numBad; //TODO: Change this to be configurable based on amt of special cards int numSpecialGood = 1; int numSpecialBad = 1; List <int> playerOrder = RandomizePlayerOrder(); allPlayers = PhotonNetwork.playerList; numGood = playerConfig[num_players]; numBad = num_players - numGood; int curPlayerNum; int orderIdx = 0; //GET BAD GUY ARRAY OF EVERY BAD GUY PPL WILL SEE string [] badGuys = new string[numBad]; for (int b = 0; b < numBad; b++) { badGuys [b] = allPlayers[playerOrder [b]].name; } //Deal generic bad (4) for (int bg = 0; bg < numBad - numSpecialBad; bg++) { Debug.Log("deal generic bad"); curPlayerNum = playerOrder [orderIdx]; orderIdx++; photonView.RPC("SetDealSettings", allPlayers[curPlayerNum], 4, badGuys); } //Deal Assassin (2) curPlayerNum = playerOrder [orderIdx]; orderIdx++; Debug.Log("deal assassin to player " + curPlayerNum + " with ID " + allPlayers[curPlayerNum].ID + " and name " + allPlayers[curPlayerNum].name); photonView.RPC("SetDealSettings", allPlayers[curPlayerNum], 2, badGuys); //TODO: Deal special bad guys //Deal generic good (3) for (int g = 0; g < numGood - numSpecialGood; g++) { Debug.Log("deal generic good"); curPlayerNum = playerOrder [orderIdx]; orderIdx++; Debug.Log("dealing to player " + curPlayerNum + " with ID " + allPlayers[curPlayerNum].ID + " and name " + allPlayers[curPlayerNum].name); photonView.RPC("SetDealSettings", allPlayers[curPlayerNum], 3, null); } //Deal Merlin (1) curPlayerNum = playerOrder [orderIdx]; orderIdx++; Debug.Log("deal merlin to player " + curPlayerNum + " with ID " + allPlayers[curPlayerNum].ID + " and name " + allPlayers[curPlayerNum].name); photonView.RPC("SetDealSettings", allPlayers[curPlayerNum], 1, badGuys); //TODO: Deal special good guys }
private void Update() { if (SceneManager.GetActiveScene().name.Contains("Level")) { //if photonview is you if (photonView.IsMine) { if (!LevelsManager.Instance.isPause) { CheckInteraction(); if (detect.IsGround()) { if (isFalling) { isFalling = false; isAnima = false; photonView.RPC("RPC_SyncBool", RpcTarget.All, "isFall", false, thisCharacter); } } else if (GetComponent <Rigidbody2D>().velocity.y < 0) { isAnima = true; isFalling = true; isGround = false; photonView.RPC("RPC_SyncBool", RpcTarget.All, "isFall", true, thisCharacter); } } } } else if (SceneManager.GetActiveScene().name == "CharacterCreator") { if (detect.IsGround()) { if (isFalling) { isFalling = false; animator.SetBool("isFall", false); } } else if (GetComponent <Rigidbody2D>().velocity.y < 0) { isFalling = true; isGround = false; animator.SetBool("isFall", true); } } }
private double vida; //Vida total del personaje #endregion Fields #region Methods public void danio(PhotonView pv, double danio) { pv.RPC("hayDanio", PhotonTargets.Others, danio); }
public override void OnPlayerEnteredRoom(Player newPlayer) { RoomRenewal(); PV.RPC("ChatRPC", RpcTarget.All, "<color=yellow>" + newPlayer.NickName + "님이 참가하셨습니다</color>"); }
private void SendGangTurn(int gangTurn) { _photonView.RPC("GetGangTurn", RpcTarget.All, gangTurn); }
public void OffensiveOccuppied(EPlayerController controller) { int tID = controller.GetComponent <PhotonView>().ViewID; pView.RPC("RPC_OffensiveOccupied", RpcTarget.All, tID); }
//Call AddMessage to report to the chat, pass through death or frag message void AddMessage(string message) { // what we call who sent to parameter (what passes) photonView.RPC("AddMessage_RPC", PhotonTargets.All, message); }
/// <summary> /// Sets the voice channel for all clients. /// </summary> /// <param name="input"></param> public void setchannelforall(VoiceChannel input) { locview.RPC("SetCurrentChannel", PhotonTargets.All, (int)input); }
void updateMe(int senderID) { //********** ADDING US ON THE BOARD //We get the ID of the new player who needs to be updated PhotonPlayer sender = PhotonPlayer.Find(senderID); //We get our own ID PhotonView myView = PhotonView.Get(this); int myID = myView.owner.ID; //We get our basic stats string myTag = PhotonNetwork.playerName; /*int iA=0; * bool doneA=false; * * //Retrieving our gamertag * while(iA<4 && doneA==false) * { * if(myTeam=="Blue") * { * myTag = playerTagsBlue[iA]; * } * else * { * myTag = playerTagsRed[iA]; * } * iA++; * }*/ //We pack all of this string myTagTeam = myID.ToString() + ";" + myTag + ";" + myTeam; //We add ourself on his board myView.RPC("addOnBoard", sender, myTagTeam); //********* UPDATING OUR STATS ON THE BOARD //We get our stats int myKill = 0; int myAssist = 0; int myDeath = 0; int iU = 0; bool doneU = false; //Retrieving our score while (iU < 4 && doneU == false) { if (myTeam == "Blue") { if (playerScoreBlue[iU, 0] == myID) { myKill = playerScoreBlue[iU, 1]; myAssist = playerScoreBlue[iU, 2]; myDeath = playerScoreBlue[iU, 3]; doneU = true; } } else { if (playerScoreRed[iU, 0] == myID) { myKill = playerScoreRed[iU, 1]; myAssist = playerScoreRed[iU, 2]; myDeath = playerScoreRed[iU, 3]; doneU = true; } } iU++; } //We pack this into a string string myTagScore = myID.ToString() + ";" + myKill.ToString() + ";" + myAssist.ToString() + ";" + myDeath.ToString(); myView.RPC("updateScore", sender, myTagScore); }
public void VoteForPlayer(string name) { mevoted = true; PhotonView.RPC("VoteForPlayer_RPC", PhotonTargets.AllBuffered, PhotonNetwork.player, name); }
// Update is called once per frame void Update() { //Anti suicide code if (outOfBounds) { return; } if (transform.position.y < -4) { outOfBounds = true; LeanTween.moveLocalY(gameObject, 5, 2).setEase(LeanTweenType.easeInOutElastic).setOnComplete(() => { LeanTween.moveLocal(gameObject, new Vector3(7, 5, -7), 2).setEase(LeanTweenType.easeInOutExpo).setOnComplete(() => outOfBounds = false); }); } if (Input.GetKeyDown(KeyCode.Tab)) { if (!_photonView.IsMine) { return; } ChangeColor(_photonView.ViewID); _photonView.RPC("ChangeColor", RpcTarget.Others, _photonView.ViewID); } if (!_photonView.IsMine) { return; } //Ground Movement Control if (Input.GetKey(KeyCode.UpArrow)) { if (velZ < 0) { velZ = 0; } if (controller.isGrounded) { velZ += speed; } else { velZ += airSpeed; } if (velZ > maxSpeed) { velZ = maxSpeed; } } else if (Input.GetKey(KeyCode.DownArrow)) { //Breaking if we're going the other way if (velZ > 0) { velZ = 0; } //if we're on the ground if (controller.isGrounded) { velZ -= speed; } else { velZ -= airSpeed; } if (velZ < -maxSpeed) { velZ = -maxSpeed; } } else { //Deaccelarate if (Math.Abs(velZ - 0) < 1) { velZ = 0; } if (velZ > 0) { velZ -= deAccValue; } if (velZ < 0) { velZ += deAccValue; } } if (Input.GetKey(KeyCode.LeftArrow)) { if (velX > 0) { velX = 0; } if (controller.isGrounded) { velX -= speed; } else { velX -= airSpeed; } if (velX < -maxSpeed) { velX = -maxSpeed; } } else if (Input.GetKey(KeyCode.RightArrow)) { if (velX < 0) { velX = 0; } if (controller.isGrounded) { velX += speed; } else { velX += airSpeed; } if (velX > maxSpeed) { velX = maxSpeed; } } else { if (Math.Abs(velX - 0) < 1) { velX = 0; } if (velX > 0) { velX -= deAccValue; } if (velX < 0) { velX += deAccValue; } } if (controller.isGrounded) { velY = 0; if (Input.GetKeyDown(KeyCode.Space)) { velY = jumpSpeed; } } velY -= gravity * Time.deltaTime; Vector3 newPosition = new Vector3(velX, 0.0f, velZ); transform.LookAt(newPosition + transform.position); moveVector = new Vector3(velX * Time.deltaTime, velY * Time.deltaTime, velZ * Time.deltaTime) + (externalVelocity * Time.deltaTime); controller.Move(moveVector); }
public void BaseSpeedUI(string num) { BaseSpeed = float.Parse(num); BaseSpeedtxt.text = BaseSpeed.ToString(); pv.RPC("BaseSpeedFunc", RpcTarget.AllBuffered, null); }
public void TeamChange() { houseTeam = team.isOn; pview.RPC("StatusChanged", RpcTarget.OthersBuffered, bready, houseTeam); }
// Use this for initialization public void Start() { if (MainMenu.IsMulti) { ScenePhotonView = this.GetComponent<PhotonView> (); ScenePhotonView.RPC ("SendEnemyName", PhotonTargets.Others, PhotonNetwork.playerName); ScenePhotonView.RPC ("FirstPlayerCanPlay", PhotonTargets.Others); Debug.Log ("sending name to 1st player"); } }
// Update is called once per frame void Update() { if (PV.IsMine) { timer += Time.deltaTime; if (timer > waitingTime) { gameObject.GetComponent <Status>().AD += 5; //gameObject.GetComponent<Status>().currHp += 10; Debug.Log("AD상승@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); timer = 0; } //d_distance = Vector3.Distance(transform.position, GameObject.FindWithTag("Player").transform.position); //Debug.Log(GameObject.Find("player").transform.position); if (m_tfTarget == null) //검출된 타겟이 없을시 { //Debug.Log("적 없음"); Tower_Top.Rotate(new Vector3(0, 45, 0) * Time.deltaTime); //포신이 계속 돌게 만듬 } //else if (m_tfTarget.tag == ("EnemyMinion") && //챔피언 타워안에서 공격시 우선검출 코드 // GameObject.FindWithTag("EnemyHero").GetComponent<CharacterControl>().AggroTarget == GameObject.FindWithTag("TeamHero")|| // GameObject.FindWithTag("EnemyHero").GetComponent<CharacterControl>().AggroTarget == GameObject.FindWithTag("Player")) //{ // Quaternion t_lookRotation = Quaternion.LookRotation(GameObject.FindWithTag("EnemyHero").transform.position - transform.position);//특정 좌표값(타겟 좌표값)을 바라보게 만드는 회전값 리턴 // //Debug.Log(t_lookRotation); // Vector3 t_euler = Quaternion.RotateTowards(Tower_Top.rotation,//a지점에서, // t_lookRotation, //b지점까지, // m_spinSpeed * Time.deltaTime).eulerAngles;//c의 속도로 회전. // Tower_Top.rotation = Quaternion.Euler(0, t_euler.y, 0);//오일러 값에서 y축만 반영되도록 설정. // Quaternion t_fireRotation = Quaternion.Euler(0, t_lookRotation.eulerAngles.y, 0);//터렛이 최종적으로 조준해야하는 방향 // //Debug.Log(GameObject.Find("Tower_Top2").transform.rotation); // if (Quaternion.Angle(Tower_Top.rotation, t_fireRotation) < 5f)//현재 포진의 방향과 조준해야할 방향의 각도차를 계산 약간의 여유위에 < 5도 설정. // { // m_currentFireRate -= Time.deltaTime;//해당 조건을 만족하면 연산 변수가 1씩 감소하다가 // if (m_currentFireRate <= 0) //연산 변수가 0보다 작아지면 // { // m_currentFireRate = m_fireRate;//다시 연산 변수를 본래 값으로 되돌리고 공격. // Shoot(); // Debug.Log("Attack"); // } // } //} else { //Debug.Log("적 발견"); Quaternion t_lookRotation = Quaternion.LookRotation(m_tfTarget.position - transform.position); //특정 좌표값(타겟 좌표값)을 바라보게 만드는 회전값 리턴 //Debug.Log(t_lookRotation); Vector3 t_euler = Quaternion.RotateTowards(Tower_Top.rotation, //a지점에서, t_lookRotation, //b지점까지, m_spinSpeed * Time.deltaTime).eulerAngles; //c의 속도로 회전. Tower_Top.rotation = Quaternion.Euler(0, t_euler.y, 0); //오일러 값에서 y축만 반영되도록 설정. Quaternion t_fireRotation = Quaternion.Euler(0, t_lookRotation.eulerAngles.y, 0); //터렛이 최종적으로 조준해야하는 방향 //Debug.Log(GameObject.Find("Tower_Top2").transform.rotation); if (Quaternion.Angle(Tower_Top.rotation, t_fireRotation) < 5f) //현재 포진의 방향과 조준해야할 방향의 각도차를 계산 약간의 여유위에 < 5도 설정. { m_currentFireRate -= Time.deltaTime; //해당 조건을 만족하면 연산 변수가 1씩 감소하다가 if (m_currentFireRate <= 0) //연산 변수가 0보다 작아지면 { if (m_tfTarget.tag == ("EnemyHero")) { m_currentFireRate = m_fireRate;//다시 연산 변수를 본래 값으로 되돌리고 공격. Shoot(); } if (m_tfTarget.tag == ("TeamHero")) { m_currentFireRate = m_fireRate;//다시 연산 변수를 본래 값으로 되돌리고 공격. Shoot(); } if (m_tfTarget.tag == ("EnemyMinion")) { m_currentFireRate = m_fireRate;//다시 연산 변수를 본래 값으로 되돌리고 공격. Shoot(); } if (m_tfTarget.tag == ("TeamMinion")) { m_currentFireRate = m_fireRate;//다시 연산 변수를 본래 값으로 되돌리고 공격. Shoot(); } if (m_tfTarget.tag == ("Player")) { m_currentFireRate = m_fireRate;//다시 연산 변수를 본래 값으로 되돌리고 공격. Shoot(); } } } } if (status.CurrHp <= 0) //터렛 파괴 { PV.RPC("DestroyTurret", RpcTarget.AllBuffered); DestroyTurret(); } if (t_tfTarget != null && Laser != null) { if (t_tfTarget != null) { Laser.transform.LookAt(t_tfTarget.transform.position); Laser.transform.Translate(Vector3.forward * Time.deltaTime * 30.0f); if (Vector3.Distance(t_tfTarget.transform.position, Laser.transform.position) < 0.2f && PhotonNetwork.IsMasterClient && t_tfTarget.tag != "Player" && t_tfTarget.tag != "EnemyHero" && t_tfTarget.tag != "TeamHero") { t_tfTarget.GetComponent <Status>().CurrHp -= status.AD; PhotonNetwork.Destroy(Laser); t_tfTarget = null; } else if (Vector3.Distance(t_tfTarget.transform.position, Laser.transform.position) < 0.2f && !PhotonNetwork.IsMasterClient && t_tfTarget.tag != "Player" && t_tfTarget.tag != "EnemyHero" && t_tfTarget.tag != "TeamHero") { int a = t_tfTarget.GetComponent <PhotonView>().ViewID; PV.RPC("RemoteHitMinion", RpcTarget.MasterClient, a, status.AD); PhotonNetwork.Destroy(Laser); } } } } //isMine이 아닌 것들은 동기화 else { //끊어진 시간이 너무 길 경우(텔레포트) if ((transform.position - curPos).sqrMagnitude >= 10.0f * 10.0f) { transform.position = curPos; transform.rotation = curRot; } //끊어진 시간이 짧을 경우(자연스럽게 연결 - 데드레커닝) else { transform.position = Vector3.Lerp(transform.position, curPos, Time.deltaTime * 10.0f); transform.rotation = Quaternion.Slerp(transform.rotation, curRot, Time.deltaTime * 10.0f); } status.MaxHp = remoteMaxHp; status.CurrHp = remoteCurrHp; } /////////////////////////////////////////////////// HP 감소 부분 ////////////////////////////////////////////////////// HpBar.GetComponent <Image>().fillAmount = (status.CurrHp / status.MaxHp); /////////////////////////////////////////////////// HP 감소 부분 ////////////////////////////////////////////////////// }
/// <summary> /// Calls an RPC to add the pawn to the team on all clients /// </summary> public void SendPawnTeam(int teamId) { m_scenePhotonView = GetComponent<PhotonView>(); m_scenePhotonView.RPC("RPCAddPawnToTeam", PhotonTargets.Others, teamId); }
public void RemoteSetColor(EnemyState eState) { photonView.RPC("EnemySetColor", PhotonTargets.All, eState); }
void Start() { photonView = GetComponent<PhotonView> (); if (photonView.isMine) { myCamera = Camera.main; ((PlayerMainGui)myCamera.GetComponent (typeof(PlayerMainGui))).SetLocalPlayer(this); //TODO: UNCOMMENT robotTimer = robotTime; //this.name = "Player"; PlayerName = "Player" + PhotonNetwork.playerList.Length; // photonView.RPC ("ASKTeam", PhotonTargets.MasterClient); globalPlayer = FindObjectOfType<GlobalPlayer>(); UID = globalPlayer.GetUID(); PlayerName = globalPlayer.GetPlayerName(); friendsInfo = globalPlayer.friendsInfo; photonView.RPC("RPCSetNameUID",PhotonTargets.AllBuffered,UID,PlayerName); EventHolder.instance.FireEvent(typeof(LocalPlayerListener),"EventAppear",this); //StatisticHandler.StartStats(UID,PlayerName); } else { Destroy(GetComponent<MusicHolder>()); Destroy(GetComponent<AudioSource>()); } }
void Start() { myPhotonView = gameObject.GetComponent<PhotonView> (); GameObject[] players = GameObject.FindGameObjectsWithTag ("Other"); animation [punch1Animation.name].AddMixingTransform (torso); animation [punch2Animation.name].AddMixingTransform (torso); animation [punch3Animation.name].AddMixingTransform (torso); animation [hit1Animation.name].AddMixingTransform (torso); animation [hit1Animation.name].layer = 90; animation [punch1Animation.name].layer = 55; animation [punch2Animation.name].layer = 55; animation [punch3Animation.name].layer = 55; animation [jumpAnimation.name].layer = 40; animation [runAnimation.name].wrapMode = WrapMode.Loop;// set the animation to loop .. animation [deathAnimation.name].wrapMode = WrapMode.ClampForever;// set the animation to loop .. //|inov| get chat script and store it for future use CHATScript = GameObject.Find ("GameManager").GetComponent<ChatVik> (); if (myPhotonView.isMine) { //|inov| sets local variable myName to this users name for future use myName = PhotonNetwork.playerName; //|inov| sends my local name to all other players myPhotonView.RPC ("setNameGlobal", PhotonTargets.All, myName); } }
void Start () { pv = GetComponent<PhotonView>(); string msg = "\n<color=#FF0084>[" + PhotonNetwork.player.name + "] 대기실에 참가하셨습니다</color>"; pv.RPC("SendMsg", PhotonTargets.All, msg); myEventSystem = GameObject.Find("EventSystem"); }
public void CreateNewLootAnimation(Player looter, ItemObject lootItemObject) { photonView.RPC(nameof(PlayLootAnimation), PhotonTargets.All, looter.PhotonViewId, lootItemObject.Item.Data.ItemName, lootItemObject.transform.position); }
public void golpe(PhotonView b, Vector3 t) { b.RPC("AplicarFuerza", PhotonTargets.Others, t.x, t.z); }
public void RPCForPlayer(string rpcFunction, PhotonView netView, int playerIndex, object[] rpcParams) { // Send RPC to a particular (other) player netView.RPC (rpcFunction, PhotonNetwork.otherPlayers [playerIndex], rpcParams); }
void Update() { //Reset the recoil animation if (recoilAnim.GetCurrentAnimatorStateInfo(0).IsName("Recoil")) { recoilAnim.SetBool("Shoot", false); } //Hide the hit indicators from last frame HideHitIndicator(); /* * //TEST CODE FOR GETTING SHOT * if(Input.GetButtonDown("Fire2")) * { * CmdHitPlayer(this.gameObject); * } */ //Determine if we fired (left mouse) if (Input.GetButtonDown("Fire1") && cooldownTimer <= 0) { //Reset the shot timer cooldownTimer = 20.0f; //Play the recoil animation recoilAnim.SetBool("Shoot", true); //Shoot a Ray and find the closest thing we hit that isn't ourselves Ray ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward); Vector3 hitPoint = Vector3.zero; Transform hitTransform = FindClosestHitInfo(ray, out hitPoint); //Flag to show if we hit an enemy or not bool hitEnemy = false; //Make sure we actually hit something if (hitTransform != null) { //Determine if the object we hit has hit points Health h = hitTransform.GetComponent <Health>(); //If we did not find an object with health if (h == null) { //Loop through it's parents and try to find one that has health while (hitTransform.parent && h == null) { hitTransform = hitTransform.parent; h = hitTransform.GetComponent <Health>(); } } //Check if we eventually found an object with health if (h != null) { //Show the hit indicator hitEnemy = true; ShowHitIndicator(); //Use an RPC to send damage over the network PhotonView pv = h.GetComponent <PhotonView>(); if (pv != null) { pv.RPC("TakeDamage", PhotonTargets.AllBuffered, weaponDamage); } } //Show some bullet FX if (fxManager != null) { GunFX(hitPoint, hitEnemy); } //Instantiate(debris, hitPoint, Quaternion.identity); } //Hit nothing, show bull FX anyway else if (fxManager != null) { //Make the FX reach a certain distance from the camera hitPoint = playerCamera.transform.position + (playerCamera.transform.forward * 100f); GunFX(hitPoint, hitEnemy); } /* * //Shoot a ray from the center of the camera * RaycastHit hit; * Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit); * //If our ray hit something * if(hit.collider != null) * { * if(hit.transform.tag == "Player") * { * } * else * { * Instantiate(debris, hit.point, Quaternion.identity); * } * } */ } /* * //Aiming - move the gun into the center of the screen * if(Input.GetButtonDown("Fire2") && cooldownTimer <= 0){ * gun.transform.position = new Vector3(0f, -0.031f, 0.65f); * } */ //Decrement the cooldown timer cooldownTimer--; }
void Start() { //PhotonNetwork sends 30 times in a second. PhotonNetwork.sendRate = 30; PhotonNetwork.sendRateOnSerialize = 30; pv = GetComponent<PhotonView> (); //All player must renew all object's texture. pv.RPC ("SetTextureOfPlayer", PhotonTargets.All, null); androidPluginManager = GetComponent<AndroidPluginManager> (); _rigidbody = GetComponent<Rigidbody> (); _transform = GetComponent<Transform> (); if (pv.isMine == true) { } else { _rigidbody.isKinematic=true; } isServer = (bool)PhotonNetwork.player.customProperties ["ISSERVER"]; GetComponent<Rigidbody> ().constraints = RigidbodyConstraints.FreezePositionZ; gameMgr = GameObject.Find ("GameManager").GetComponent<GameMgr> (); ownerID = gameObject.GetComponent<PhotonView> ().owner.ID; }
/// <summary> /// 모든 인스턴스의 스코어 텍스트를 업데이트함 /// </summary> /// <param name="ATeamScore"></param> /// <param name="BTeamScore"></param> public void UpdateScoreRPC(int ATeamScore, int BTeamScore) { view.RPC("UpdateScore", RpcTarget.AllBuffered, ATeamScore, BTeamScore); }
public void RestartSession() { if (PhotonNetwork.isMasterClient) { Debug.Log("Restarting"); foreach (KeyValuePair <int, PlayerInfo> entry in localFrags) { entry.Value.Set(maxHealth, 0, 0); ScenePhotonView.RPC("NewPlayerInfo", PhotonTargets.All, entry.Key, maxHealth, 0, 0); } ScenePhotonView.RPC("Restart", PhotonTargets.All); } }
public void Damage(float value, Photon.Realtime.Player attacker) { PhotonView.RPC("SetKillerRpc", RpcTarget.MasterClient, attacker); Health.Damage(value); }
// --------------------------------------- // Initializing the player in the network // --------------------------------------- public void addPlayerList(PhotonView v, Vector2 startPos) { v.RPC ("addPlayer", PhotonTargets.OthersBuffered, v.viewID, startPos); }
private void MasterLoadedGame() { PhotonView.RPC("RPC_LoadedGameScene", PhotonTargets.MasterClient, PhotonNetwork.player); PhotonView.RPC("RPC_LoadgameOthers", PhotonTargets.Others); }