Guest User

:(

a guest
Oct 15th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.78 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ServerMoveScript : MonoBehaviour {
  5.  
  6.     public Transform _Rotate_X_1;
  7.     public Transform _Rotate_Z_1;
  8.     public Transform _Rotate_X_2;
  9.     public Transform _Rotate_Z_2;
  10.     public Transform _Rotate_X_3;
  11.     public Transform _Rotate_Z_3;
  12.     public Transform _Rotate_X_4;
  13.     public Transform _Rotate_Z_4;
  14.     public int PlayerIs = 0;
  15.     public int PlayerIsRt = 0;
  16.     void Update()
  17.     {
  18.         switch (PlayerIs)
  19.         {
  20.             case 0:
  21.                 networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_1.rotation, _Rotate_Z_1.rotation, PlayerIs, PlayerIsRt, false);
  22.                 break;
  23.             case 1:
  24.                 networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_2.rotation, _Rotate_Z_2.rotation, PlayerIs, PlayerIsRt, false);
  25.                 break;
  26.             case 2:
  27.                 networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_3.rotation, _Rotate_Z_3.rotation, PlayerIs, PlayerIsRt, false);
  28.                 break;
  29.             case 3:
  30.                 networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_4.rotation, _Rotate_Z_4.rotation, PlayerIs, PlayerIsRt, false);
  31.                 break;
  32.         }
  33.     }
  34.     [RPC]
  35.     private void _Rotate(Quaternion x, Quaternion z, int RotateInt, int RotateIntRt, bool RotateOn = false)
  36.     {
  37.         if(!RotateOn){
  38.             if (Network.peerType == NetworkPeerType.Server)
  39.             {
  40.                 switch (RotateInt){
  41.                 case 0:
  42.                         _Rotate_X_1.rotation = x;
  43.                         _Rotate_Z_1.rotation = z;
  44.                 break;
  45.                 case 1:
  46.                         _Rotate_X_2.rotation = x;
  47.                         _Rotate_Z_2.rotation = z;
  48.                 break;
  49.                 case 2:
  50.                         _Rotate_X_3.rotation = x;
  51.                         _Rotate_Z_3.rotation = z;
  52.                 break;
  53.                 case 3:
  54.                         _Rotate_X_4.rotation = x;
  55.                         _Rotate_Z_4.rotation = z;
  56.                 break;
  57.                 }
  58.                 switch (RotateInt)
  59.                 {
  60.                     case 0:
  61.                         networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_1.rotation, _Rotate_Z_1.rotation, RotateInt, RotateIntRt, true);
  62.                         break;
  63.                     case 1:
  64.                         networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_2.rotation, _Rotate_Z_2.rotation, RotateInt, RotateIntRt, true);
  65.                         break;
  66.                     case 2:
  67.                         networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_3.rotation, _Rotate_Z_3.rotation, RotateInt, RotateIntRt, true);
  68.                         break;
  69.                     case 3:
  70.                         networkView.RPC("_Rotate", RPCMode.Server, _Rotate_X_4.rotation, _Rotate_Z_4.rotation, RotateInt, RotateIntRt, true);
  71.                         break;
  72.                 }
  73.             }
  74.             if (Network.peerType == NetworkPeerType.Client)
  75.             {
  76.                 switch (RotateInt)
  77.                 {
  78.                     case 0:
  79.                         _Rotate_X_1.rotation = x;
  80.                         _Rotate_Z_1.rotation = z;
  81.                         break;
  82.                     case 1:
  83.                         _Rotate_X_2.rotation = x;
  84.                         _Rotate_Z_2.rotation = z;
  85.                         break;
  86.                     case 2:
  87.                         _Rotate_X_3.rotation = x;
  88.                         _Rotate_Z_3.rotation = z;
  89.                         break;
  90.                     case 3:
  91.                         _Rotate_X_4.rotation = x;
  92.                         _Rotate_Z_4.rotation = z;
  93.                         break;
  94.                 }
  95.             }
  96.         }
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment