示例#1
0
 public void swingStructure(Vector3 position, NetworkMessageInfo info)
 {
     if (!base.GetComponent <Life>().dead&& (position - base.transform.position).magnitude < 5f)
     {
         SpawnStructures.damage(position, (int)((float)MeleeStats.getDamage(base.GetComponent <Clothes>().item) * (1f + base.GetComponent <Skills>().warrior() * 0.4f) * 0.25f), info.sender);
     }
 }
示例#2
0
    public static void save()
    {
        for (int i = 0; i < NetworkUserList.users.Count; i++)
        {
            try
            {
                if (NetworkUserList.users[i].model != null)
                {
                    NetworkUserList.users[i].model.GetComponent <Player>().save();
                }
            }
            catch (Exception e)
            {
                //Logger.LogSecurity("Player not found for given user. Continuing...");
                Console.WriteLine("Player not found for given user. Continuing..." + e.Message);
            }
        }

        for (int j = 0; j < NetworkRegions.REGION_X; j++)
        {
            for (int k = 0; k < NetworkRegions.REGION_Y; k++)
            {
                try {
                    SpawnBarricades.save(j, k);
                }
                catch
                {
                    //Logger.LogSecurity("Player not found for given user. Continuing...");
                    Console.WriteLine("Barricades save error... Continuing...");
                }
            }
        }

        SpawnStructures.save();

        try {
            SpawnVehicles.save();
        }
        catch
        {
            Console.WriteLine("SpawnVehicles error. Continuing...");
        }

        PlayerPrefs.Save();
    }
示例#3
0
    public void askBuild(int slot_x, int slot_y, Vector3 position, int rotation, string state, NetworkMessageInfo info)
    {
        BetterNetworkUser user = UserList.getUserFromPlayer(info.sender);
        int permission         = UserList.getPermission(user.steamid);

        if (!user.player.canBuild)   //TODO: disallowing build
        {
            Reference.Tell(user.networkPlayer, "You are not allowed to build. Request permission from admins!");
            return;
        }

        if (!base.GetComponent <Life>().dead)          // Dead hack
        {
            Inventory inventory = base.GetComponent <Inventory>();

            if (ItemType.getType(inventory.items[slot_x, slot_y].id) == 17)
            {
                SpawnStructures.placeStructure(inventory.items[slot_x, slot_y].id, position, rotation, state);
            }
        }
    }
示例#4
0
    public void onReady()
    {
        SpawnStructures.tool       = this;
        SpawnStructures.model      = GameObject.Find(Application.loadedLevelName).transform.FindChild("structures").gameObject;
        SpawnStructures.structures = new List <ServerStructure>();
        SpawnStructures.models     = new List <GameObject>();
        if (!Network.isServer)
        {
            base.networkView.RPC("askAllStructures", RPCMode.Server, new object[] { Network.player });
        }
        else
        {
            string str = Savedata.loadStructures();
            if (str != string.Empty)
            {
                string[] strArrays = Packer.unpack(str, ';');
                for (int i = 0; i < (int)strArrays.Length; i++)
                {
                    string[] strArrays1 = Packer.unpack(strArrays[i], ':');
                    SpawnStructures.structures.Add(
                        new ServerStructure(
                            int.Parse(strArrays1[0]),
                            int.Parse(strArrays1[1]),
                            strArrays1[2],
                            new Vector3(
                                float.Parse(strArrays1[3]),
                                float.Parse(strArrays1[4]),
                                float.Parse(strArrays1[5])),
                            int.Parse(strArrays1[6]))
                        );

                    this.createStructure(
                        SpawnStructures.structures[SpawnStructures.structures.Count - 1].id,
                        SpawnStructures.structures[SpawnStructures.structures.Count - 1].position,
                        SpawnStructures.structures[SpawnStructures.structures.Count - 1].rotation
                        );
                }
            }
        }
    }