public void CmdStopPulling(GameObject obj) { if (!isPulling) { return; } isPulling = false; PushPull pulled = obj.GetComponent <PushPull>(); pulled.RpcToggleCnt(true); //Cache value for new players pulled.custNetActiveState = true; if (pulled != null) { // //this triggers currentPos syncvar hook to make sure registertile is been completed on all clients // pulled.currentPos = pulled.transform.position; IPlayerSync pS = gameObject.GetComponent <IPlayerSync>(); pS.PullObjectID = NetworkInstanceId.Invalid; pulled.pulledBy = null; } var netTransform = obj.GetComponent <CustomNetTransform>(); if (netTransform != null) { netTransform.SetPosition(obj.transform.localPosition); } }
private void Start() { playerSprites = gameObject.GetComponent <PlayerSprites>(); playerSync = GetComponent <IPlayerSync>(); pushPull = GetComponent <PushPull>(); registerTile = GetComponent <RegisterTile>(); pna = gameObject.GetComponent <PlayerNetworkActions>(); }
public void CmdSetPositionFromReset(GameObject fromObj, GameObject otherPlayer, Vector3 setPos) { if (fromObj.GetComponent <IPlayerSync>() == null) //Validation { return; } IPlayerSync otherPlayerSync = otherPlayer.GetComponent <IPlayerSync>(); otherPlayerSync.SetPosition(setPos); }
public void CmdPullObject(GameObject obj) { if (isPulling) { GameObject cObj = gameObject.GetComponent <IPlayerSync>().PullingObject; cObj.GetComponent <PushPull>().pulledBy = null; gameObject.GetComponent <IPlayerSync>().PullObjectID = NetworkInstanceId.Invalid; } PushPull pulled = obj.GetComponent <PushPull>(); //Stop CNT as the transform of the pulled obj is now handled by PlayerSync pulled.RpcToggleCnt(false); //Cache value for new players pulled.custNetActiveState = false; //check if the object you want to pull is another player if (pulled.isPlayer) { IPlayerSync playerS = obj.GetComponent <IPlayerSync>(); //Anything that the other player is pulling should be stopped if (playerS.PullingObject != null) { PlayerNetworkActions otherPNA = obj.GetComponent <PlayerNetworkActions>(); otherPNA.CmdStopOtherPulling(playerS.PullingObject); } } //Other player is pulling object, send stop on that player if (pulled.pulledBy != null) { if (pulled.pulledBy != gameObject) { pulled.GetComponent <PlayerNetworkActions>().CmdStopPulling(obj); } } if (pulled != null) { IPlayerSync pS = GetComponent <IPlayerSync>(); pS.PullObjectID = pulled.netId; isPulling = true; } }
/// <summary> /// Sets the player sync interface /// </summary> /// <param name="playerSync"></param> public void SetPlayerSync(IPlayerSync playerSync) { this.playerSyncMono = playerSync; }