From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/ChildRPC.cs | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 GameCode/ChildRPC.cs (limited to 'GameCode/ChildRPC.cs') diff --git a/GameCode/ChildRPC.cs b/GameCode/ChildRPC.cs new file mode 100644 index 0000000..1305ce1 --- /dev/null +++ b/GameCode/ChildRPC.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using Photon.Pun; +using UnityEngine; + +public class ChildRPC : MonoBehaviour +{ + public Dictionary> childRPCsVector2Vector2Int = new Dictionary>(); + + public Dictionary> childRPCsVector2Vector2IntInt = new Dictionary>(); + + public Dictionary> childRPCsVector2 = new Dictionary>(); + + public Dictionary> childRPCsVector3Quaternion = new Dictionary>(); + + public Dictionary> childRPCsInt = new Dictionary>(); + + public Dictionary childRPCs = new Dictionary(); + + private PhotonView view; + + private void Start() + { + view = GetComponent(); + } + + public void CallFunction(string key) + { + view.RPC("RPCA_RecieveFunction", RpcTarget.All, key); + } + + [PunRPC] + public void RPCA_RecieveFunction(string key) + { + if (childRPCs.ContainsKey(key)) + { + childRPCs[key](); + } + } + + public void CallFunction(string key, int intData) + { + view.RPC("RPCA_RecieveFunction", RpcTarget.All, key, intData); + } + + [PunRPC] + public void RPCA_RecieveFunction(string key, int intData) + { + if (childRPCsInt.ContainsKey(key)) + { + childRPCsInt[key](intData); + } + } + + public void CallFunction(string key, Vector2 vectorData) + { + view.RPC("RPCA_RecieveFunction", RpcTarget.All, key, vectorData); + } + + [PunRPC] + public void RPCA_RecieveFunction(string key, Vector2 vectorData) + { + if (childRPCsVector2.ContainsKey(key)) + { + childRPCsVector2[key](vectorData); + } + } + + public void CallFunction(string key, Vector2 vectorData, Vector2 vectorData2, int intData) + { + view.RPC("RPCA_RecieveFunction", RpcTarget.All, key, vectorData, vectorData2, intData); + } + + [PunRPC] + public void RPCA_RecieveFunction(string key, Vector2 vectorData, Vector2 vectorData2, int intData) + { + if (childRPCsVector2Vector2Int.ContainsKey(key)) + { + childRPCsVector2Vector2Int[key](vectorData, vectorData2, intData); + } + } + + public void CallFunction(string key, Vector2 vectorData, Vector2 vectorData2, int intData, int intData2) + { + view.RPC("RPCA_RecieveFunction", RpcTarget.All, key, vectorData, vectorData2, intData, intData2); + } + + [PunRPC] + public void RPCA_RecieveFunction(string key, Vector2 vectorData, Vector2 vectorData2, int intData, int intData2) + { + if (childRPCsVector2Vector2IntInt.ContainsKey(key)) + { + childRPCsVector2Vector2IntInt[key](vectorData, vectorData2, intData, intData2); + } + } + + public void CallFunction(string key, Vector3 vectorData, Quaternion quaterion) + { + view.RPC("RPCA_RecieveFunction", RpcTarget.All, key, vectorData, quaterion); + } + + [PunRPC] + public void RPCA_RecieveFunction(string key, Vector3 vectorData, Quaternion quaterion) + { + if (childRPCsVector3Quaternion.ContainsKey(key)) + { + childRPCsVector3Quaternion[key](vectorData, quaterion); + } + } +} -- cgit v1.1-26-g67d0