Exemple #1
0
 public void onRegionUpdate()
 {
     if (!Network.isServer && Network.peerType != NetworkPeerType.Disconnected)
     {
         if (NetworkRegions.lastRegion.x != -1)
         {
             for (int i = 0; i < NetworkRegions.REGION_X; i++)
             {
                 for (int j = 0; j < NetworkRegions.REGION_Y; j++)
                 {
                     if (SpawnBarricades.regions[i, j].models.Count > 0 && (!BarricadesRegion.acceptable(i, NetworkRegions.region.x) || !BarricadesRegion.acceptable(j, NetworkRegions.region.y)))
                     {
                         GameObject[] array = SpawnBarricades.regions[i, j].models.ToArray();
                         for (int k = 0; k < (int)array.Length; k++)
                         {
                             UnityEngine.Object.Destroy(array[k]);
                         }
                         SpawnBarricades.regions[i, j].models.Clear();
                     }
                 }
             }
         }
         for (int l = NetworkRegions.region.x - 4; l < NetworkRegions.region.x + 5; l++)
         {
             for (int m = NetworkRegions.region.y - 4; m < NetworkRegions.region.y + 5; m++)
             {
                 if (l >= 0 && m >= 0 && l < NetworkRegions.REGION_X && m < NetworkRegions.REGION_Y && SpawnBarricades.regions[l, m].models.Count == 0 && Time.realtimeSinceStartup - SpawnBarricades.regions[l, m].cooldown > 1f)
                 {
                     SpawnBarricades.regions[l, m].cooldown = Time.realtimeSinceStartup;
                     if (!Network.isServer)
                     {
                         SpawnBarricades.tool.networkView.RPC("askAllBarricades", RPCMode.Server, new object[] { Network.player, l, m });
                     }
                     else
                     {
                         this.askAllBarricades(Network.player, l, m);
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
 public void testBarricade(int id, int x, int y, Vector3 position, Vector3 rotation, NetworkMessageInfo info)
 {
     if ((info.sender.ToString() == "0" || info.sender.ToString() == "-1") && (Network.isServer || BarricadesRegion.acceptable(x, NetworkRegions.region.x) && BarricadesRegion.acceptable(y, NetworkRegions.region.y)))
     {
         GameObject str = (GameObject)UnityEngine.Object.Instantiate(Resources.Load(string.Concat("Prefabs/Barricades/", id)));
         str.name               = id.ToString();
         str.transform.parent   = SpawnBarricades.model.transform;
         str.transform.position = position;
         str.transform.rotation = Quaternion.Euler(rotation.x, rotation.y, rotation.z);
         SpawnBarricades.regions[x, y].models.Add(str);
     }
 }
Exemple #3
0
 public static bool acceptable(Point2 a, Point2 b)
 {
     return(!BarricadesRegion.acceptable(a.x, b.y) ? false : BarricadesRegion.acceptable(a.y, b.y));
 }