Esempio n. 1
0
    public static void placeBarricade(int id, Vector3 position, Vector3 rotation, string state)
    {
        Point2 region = NetworkRegions.getRegion(position);

        SpawnBarricades.regions[region.x, region.y].barricades.Add(new ServerBarricade(id, BarricadeStats.getHealth(id), state, position, rotation));
        SpawnBarricades.tool.networkView.RPC("testBarricade", RPCMode.All, new object[] { id, region.x, region.y, position, rotation });
    }
Esempio n. 2
0
 public static void @remove(Vector3 position)
 {
     if (SpawnBarricades.getIndexFromPositionServer(NetworkRegions.getRegion(position), position) != -1)
     {
         SpawnBarricades.tool.networkView.RPC("destroyBarricade", RPCMode.All, new object[] { position });
     }
 }
Esempio n. 3
0
    public void askItem(Vector3 position, NetworkPlayer player)
    {
        Point2 region = NetworkRegions.getRegion(position);
        int    indexFromPositionServer = SpawnItems.getIndexFromPositionServer(region, position);

        if (indexFromPositionServer != -1)
        {
            GameObject modelFromPlayer = NetworkUserList.getModelFromPlayer(player);
            if (modelFromPlayer != null)
            {
                Inventory component = modelFromPlayer.GetComponent <Inventory>();
                if (component.hasSpace(SpawnItems.regions[region.x, region.y].items[indexFromPositionServer]) == 0)
                {
                    component.addItem(SpawnItems.regions[region.x, region.y].items[indexFromPositionServer]);
                    base.networkView.RPC("destroyItem", RPCMode.All, new object[] { position });
                    NetworkSounds.askSound("Sounds/General/take", component.transform.position, 0.1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
                    NetworkManager.error(Texts.ALERT_ITEM_ADDED, string.Empty, player);
                    if (!modelFromPlayer.networkView.isMine)
                    {
                        modelFromPlayer.networkView.RPC("tookItem", player, new object[0]);
                    }
                    else
                    {
                        modelFromPlayer.GetComponent <Player>().tookItem();
                    }
                }
            }
        }
    }
Esempio n. 4
0
    public static void spawn(int id, int amount, string state, Vector3 position)
    {
        Point2 region = NetworkRegions.getRegion(position);

        SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(id, amount, state, position));
        SpawnItems.tool.networkView.RPC("testItem", RPCMode.All, new object[] { id, region.x, region.y, position });
    }
Esempio n. 5
0
    public void createBarricade(int id, Vector3 position, Vector3 rotation)
    {
        Point2     region = NetworkRegions.getRegion(position);
        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[region.x, region.y].models.Add(str);
    }
Esempio n. 6
0
 public void createItemNotRPC(int id, Vector3 position)
 {
     if (ItemWeight.getWeight(id) != -1000)
     {
         GameObject str = (GameObject)UnityEngine.Object.Instantiate(Resources.Load(string.Concat("Prefabs/Items/", id)));
         str.name               = id.ToString();
         str.transform.parent   = SpawnItems.model.transform.FindChild("models");
         str.transform.position = position;
         str.transform.rotation = Quaternion.Euler(-90f, (float)UnityEngine.Random.Range(0, 360), 0f);
         Point2 region = NetworkRegions.getRegion(position);
         SpawnItems.regions[region.x, region.y].models.Add(str);
     }
 }
Esempio n. 7
0
    public static ServerBarricade[] getBarricades(Vector3 point, float range)
    {
        Point2 region = NetworkRegions.getRegion(point);
        List <ServerBarricade> serverBarricades = new List <ServerBarricade>();

        for (int i = 0; i < SpawnBarricades.regions[region.x, region.y].barricades.Count; i++)
        {
            if (Mathf.Abs(point.x - SpawnBarricades.regions[region.x, region.y].barricades[i].position.x) < range && Mathf.Abs(point.y - SpawnBarricades.regions[region.x, region.y].barricades[i].position.y) < range && Mathf.Abs(point.z - SpawnBarricades.regions[region.x, region.y].barricades[i].position.z) < range)
            {
                serverBarricades.Add(SpawnBarricades.regions[region.x, region.y].barricades[i]);
            }
        }
        return(serverBarricades.ToArray());
    }
Esempio n. 8
0
 public void Update()
 {
     if (Player.model == null)
     {
         NetworkRegions.loaded = Time.realtimeSinceStartup;
     }
     else if (Time.realtimeSinceStartup - NetworkRegions.loaded > 1f)
     {
         NetworkRegions.region = NetworkRegions.getRegion(Player.model.transform.position);
         if (NetworkRegions.region.x != NetworkRegions.lastRegion.x || NetworkRegions.region.y != NetworkRegions.lastRegion.y)
         {
             NetworkEvents.triggerOnRegionUpdate();
             NetworkRegions.lastRegion = NetworkRegions.region;
         }
     }
 }
Esempio n. 9
0
    public static void damage(Vector3 position, int amount)
    {
        Point2 region = NetworkRegions.getRegion(position);
        int    indexFromPositionServer = SpawnBarricades.getIndexFromPositionServer(region, position);

        if (indexFromPositionServer != -1)
        {
            ServerBarricade item = SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer];
            item.health = item.health - amount;
            if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].health <= 0)
            {
                NetworkEffects.askEffect(BarricadeStats.getEffect(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id), position, Quaternion.Euler(-90f, 0f, 0f), -1f);
                NetworkSounds.askSound(BarricadeStats.getSound(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id), position, 1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
                SpawnBarricades.tool.networkView.RPC("destroyBarricade", RPCMode.All, new object[] { position });
            }
        }
    }
Esempio n. 10
0
    public void destroyItem(Vector3 position)
    {
        int    indexFromPositionServer;
        Point2 region = NetworkRegions.getRegion(position);

        if (Network.isServer)
        {
            indexFromPositionServer = SpawnItems.getIndexFromPositionServer(region, position);
            if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnItems.regions[region.x, region.y].items.Count)
            {
                SpawnItems.regions[region.x, region.y].items.RemoveAt(indexFromPositionServer);
            }
        }
        indexFromPositionServer = SpawnItems.getIndexFromPositionClient(region, position);
        if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnItems.regions[region.x, region.y].models.Count)
        {
            UnityEngine.Object.Destroy(SpawnItems.regions[region.x, region.y].models[indexFromPositionServer]);
            SpawnItems.regions[region.x, region.y].models.RemoveAt(indexFromPositionServer);
        }
    }
Esempio n. 11
0
    public void destroyBarricade(Vector3 position)
    {
        int indexFromPositionServer;

        ClientItem[,] crateItems;
        Point2  region  = NetworkRegions.getRegion(position);
        bool    flag    = false;
        int     item    = -1;
        Vector3 vector3 = Vector3.zero;

        if (Network.isServer)
        {
            indexFromPositionServer = SpawnBarricades.getIndexFromPositionServer(region, position);
            if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16019 || SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16025 || SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16023)
            {
                if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id != 16019)
                {
                    string[] strArrays = Packer.unpack(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].state, '\u005F');
                    crateItems = InteractionInterface.getCrateItems(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id, Sneaky.expose(strArrays[2]));
                }
                else
                {
                    crateItems = InteractionInterface.getCrateItems(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id, Sneaky.expose(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].state));
                }
                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < BarricadeStats.getCapacity(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id); j++)
                    {
                        if (!ItemStackable.getStackable(crateItems[i, j].id))
                        {
                            SpawnItems.drop(crateItems[i, j].id, crateItems[i, j].amount, crateItems[i, j].state, position);
                        }
                        else
                        {
                            for (int k = 0; k < crateItems[i, j].amount; k++)
                            {
                                SpawnItems.drop(crateItems[i, j].id, 1, crateItems[i, j].state, position);
                            }
                        }
                    }
                }
            }
            else if (ExplosiveStats.getDamage(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id) != 0)
            {
                flag = true;
                item = SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id;
                if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id != 16015)
                {
                    vector3 = position + Vector3.up;
                    NetworkEffects.askEffect("Effects/grenade", position, Quaternion.Euler(-90f, 0f, 0f), -1f);
                    NetworkSounds.askSoundMax("Sounds/Projectiles/grenade", position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 4f, 64f);
                }
                else
                {
                    vector3 = position + SpawnBarricades.regions[region.x, region.y].models[indexFromPositionServer].transform.up;
                    NetworkEffects.askEffect("Effects/bomb", position, Quaternion.Euler(-90f, 0f, 0f), -1f);
                    NetworkSounds.askSoundMax("Sounds/Projectiles/bomb", position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 4f, 64f);
                }
            }
            if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnBarricades.regions[region.x, region.y].barricades.Count)
            {
                SpawnBarricades.regions[region.x, region.y].barricades.RemoveAt(indexFromPositionServer);
            }
        }
        indexFromPositionServer = SpawnBarricades.getIndexFromPositionClient(region, position);
        if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnBarricades.regions[region.x, region.y].models.Count)
        {
            UnityEngine.Object.Destroy(SpawnBarricades.regions[region.x, region.y].models[indexFromPositionServer]);
            SpawnBarricades.regions[region.x, region.y].models.RemoveAt(indexFromPositionServer);
        }
        if (flag)
        {
            ExplosionTool.explode(vector3, (float)ExplosiveStats.getRange(item), ExplosiveStats.getDamage(item));
        }
    }
Esempio n. 12
0
 public void onReady()
 {
     SpawnItems.tool    = this;
     SpawnItems.model   = GameObject.Find(Application.loadedLevelName).transform.FindChild("items").gameObject;
     SpawnItems.regions = new ItemsRegion[NetworkRegions.REGION_X, NetworkRegions.REGION_Y];
     for (int i = 0; i < NetworkRegions.REGION_X; i++)
     {
         for (int j = 0; j < NetworkRegions.REGION_Y; j++)
         {
             SpawnItems.regions[i, j] = new ItemsRegion();
         }
     }
     if (Network.isServer)
     {
         int num = 0;
         for (int k = 0; k < SpawnItems.model.transform.FindChild("spawns").childCount; k++)
         {
             if (ServerSettings.mode == 0 && UnityEngine.Random.@value > Loot.NORMAL_ITEM_CHANCE || ServerSettings.mode == 1 && UnityEngine.Random.@value > Loot.BAMBI_ITEM_CHANCE || ServerSettings.mode == 2 && UnityEngine.Random.@value > Loot.HARDCORE_ITEM_CHANCE || ServerSettings.mode == 3 && UnityEngine.Random.@value > Loot.GOLD_ITEM_CHANCE)
             {
                 Transform child  = SpawnItems.model.transform.FindChild("spawns").GetChild(k);
                 Point2    region = NetworkRegions.getRegion(child.position);
                 int       loot   = Loot.getLoot(child.name);
                 int       type   = ItemType.getType(loot);
                 if (ItemWeight.getWeight(loot) != -1000 || type == 30)
                 {
                     if (type == 10)
                     {
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(loot, UnityEngine.Random.Range(1, ItemAmount.getAmount(loot) + 1), ItemState.getState(loot), child.position));
                         num++;
                     }
                     else if (type == 25)
                     {
                         for (int l = 0; l < UnityEngine.Random.Range(3, 6); l++)
                         {
                             SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(loot, ItemAmount.getAmount(loot), ItemState.getState(loot), child.position + new Vector3(UnityEngine.Random.Range(-0.5f, 0.5f), 0f, UnityEngine.Random.Range(-0.5f, 0.5f))));
                             num++;
                         }
                     }
                     else if (loot == 30000)
                     {
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(11, 1, ItemState.getState(11), child.position));
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(4017, 1, ItemState.getState(4017), child.position));
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(5017, 1, ItemState.getState(5017), child.position));
                         num = num + 3;
                     }
                     else if (loot != 30001)
                     {
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(loot, ItemAmount.getAmount(loot), ItemState.getState(loot), child.position));
                         num++;
                     }
                     else
                     {
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(12, 1, ItemState.getState(12), child.position));
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(4018, 1, ItemState.getState(4018), child.position));
                         SpawnItems.regions[region.x, region.y].items.Add(new ServerItem(5018, 1, ItemState.getState(5018), child.position));
                         num = num + 3;
                     }
                 }
             }
         }
         if (ServerSettings.map != 0)
         {
             base.InvokeRepeating("respawn", 5f, Loot.getRespawnRate() * (ServerSettings.mode != 3 ? 1f : 0.5f));
         }
     }
 }