Example #1
0
        public static RequestData AddOfficer(string handle, string callsign)
        {
            Player p = Common.GetPlayerByHandle(handle);

            var ofc = Common.GetOfficer(handle);

            EventArgument[] old = null;

            // check for officer existing
            if (ofc == null)
            {
                ofc = new Officer(p.Identifiers["ip"], callsign);
                Officers.Add(ofc); // adding new officer
#if DEBUG
                Common.SendMessage(p, "", new[] { 0, 0, 0 }, "Creating new Officer profile...");
#endif
            }
            else
            {
                int index = Officers.IndexOf(ofc); // finding the index
                old             = ofc.ToArray();
                ofc             = new Officer(p.Identifiers["ip"], callsign);
                Officers[index] = ofc; // setting the index to the specified officer
            }

            return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p), ofc.ToArray(), old }));
        }
Example #2
0
 void LaunchSupplyVan()
 {
     if (StorageManager.Add(StoragableType.Material, 1))
     {
         Debug.Log("Success");
     }
 }
Example #3
0
        public static RequestData SetName(string handle, string first, string last)
        {
            Player p = Common.GetPlayerByHandle(handle);

            var civ    = Common.GetCivilian(handle);
            var oldVeh = Common.GetCivilianVeh(handle);

            if (Common.GetCivilianByName(first, last) != null && Common.GetPlayerByIp(civ?.SourceIP) != p) // checking if the name already exists in the system
            {
                return(new RequestData("civ_name_exist", new EventArgument[] { Common.GetPlayerId(p) }));
            }
            if (oldVeh != null)
            {
                // deletes vehicle from list of vehicles
                CivilianVehs.Remove(oldVeh);
            }

            // old civilian information, for the event
            EventArgument[] oldCivInfo = null;
            // checking if the civilian already has a civ in the system
            if (Common.GetCivilian(handle) != null)
            {
                int index = Civilians.IndexOf(Common.GetCivilian(handle)); // finding the index of the existing civ

                civ = new Civilian(p.Identifiers["ip"])
                {
                    First = first, Last = last
                };                                                                      // setting the index to an instance of a new civilian
                oldCivInfo       = Civilians[index].ToArray();
                Civilians[index] = civ;
            }
            else // if the civ doesn't exist
            {
                civ = new Civilian(p.Identifiers["ip"])
                {
                    First = first, Last = last
                };
                Civilians.Add(civ); // add a new civilian to the system

#if DEBUG
                Common.SendMessage(p, "", new[] { 0, 0, 0 }, "Creating new civilian profile...");
#endif
            }

            return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p), civ.ToArray(), oldCivInfo }));
        }
Example #4
0
 void Produce()
 {
     if (currentProductionProgress < 1)
     {
         currentProductionProgress = currentProductionProgress + productionRate * 0.01667f * Time.deltaTime;
     }
     else
     {
         StorageManager.Add(storagableDrugType, 1);
         currentProductionProgress = 0;
     }
 }
Example #5
0
        public static RequestData AddBolo(string handle, string reason)
        {
            Player p   = Common.GetPlayerByHandle(handle); // getting the invoker
            var    ofc = Common.GetOfficer(handle);

            // checking for leo
            if (ofc == null)
            {
                return(new RequestData("leo_not_exist", new EventArgument[] { Common.GetPlayerId(p) }));
            }

            var bolo = new Bolo(p.Name, p.Identifiers["ip"], reason); // creating new bolo

            Bolos.Add(bolo);                                          // adding teh bolos
            return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p), bolo.ToArray() }));
        }
Example #6
0
        public static RequestData SetVehicle(string handle, string plate)
        {
            Player p = Common.GetPlayerByHandle(handle);

            var civ = Common.GetCivilian(handle);
            var veh = Common.GetCivilianVeh(handle);

            // if no civilian exists
            if (civ == null)
            {
                return(new RequestData("civ_not_exist", new EventArgument[] { Common.GetPlayerId(p) }));
            }
            // checking if the plate already exists in the system
            if (Common.GetCivilianVehByPlate(plate) != null && Common.GetPlayerByIp(veh.SourceIP) != p)
            {
                return(new RequestData("veh_plate_exist", new EventArgument[] { Common.GetPlayerId(p), plate }));
            }

            EventArgument[] old = null;
            // checking if player already owns a vehicle
            if (veh != null)
            {
                int index = CivilianVehs.IndexOf(Common.GetCivilianVeh(handle)); // finding the existing index
                old = CivilianVehs[index].ToArray();
                // setting the index to a new vehicle item
                veh = new CivilianVeh(p.Identifiers["ip"])
                {
                    Plate = plate, Owner = Common.GetCivilian(handle)
                };
                CivilianVehs[index] = veh;
            }
            else
            {
                veh = new CivilianVeh(p.Identifiers["ip"])
                {
                    Plate = plate, Owner = Common.GetCivilian(handle)
                };                     // creating the new vehicle
                CivilianVehs.Add(veh); // adding the new vehicle to the list of vehicles
            }

            return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p), veh.ToArray(), old }));
        }
Example #7
0
        public static async Task <RequestData> InitializeEmergency(string handle)
        {
            Player p = Common.GetPlayerByHandle(handle);
            // ReSharper disable once IdentifierTypo
            var emerCall = Common.GetEmergencyCall(handle);

            // checking for an existing emergency
            if (emerCall != null)
            {
                return(new RequestData("civ_911_exist", new EventArgument[] { Common.GetPlayerId(p) }));
            }

            Civilian civ = Common.GetCivilian(handle); // finding the civ

            if (civ == null)
            {
                return(new RequestData("civ_not_exist", new EventArgument[] { Common.GetPlayerId(p) }));
            }

            // checking how many active dispatchers there are
            if (Server.ConnectedDispatchers.Length == 0)
            {
                return(new RequestData("civ_911_no_dispatchers", new EventArgument[] { Common.GetPlayerId(p) }));
            }

            emerCall = new EmergencyCall(p.Identifiers["ip"],
                                         $"{civ.First} {civ.Last}");
            CurrentCalls.Add(emerCall); // adding and creating the instance of the emergency
            foreach (var peer in Server.ConnectedDispatchers)
            {
                await peer.RemoteCallbacks.Events["911alert"]
                .Invoke(civ, emerCall);     // notifying the dispatchers of the 911 call
            }

            return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p) }));
        }
Example #8
0
        //保存
        private void buttonX2_Click(object sender, EventArgs e)
        {
            if (!_update)
            {
                if (string.IsNullOrWhiteSpace(textBoxXName.Text))
                {
                    MessageBox.Show("仓库名称不可为空,请检查.");
                    return;
                }

                StorageManager sm = new StorageManager();

                try
                {
                    //获取实体,增加该实体数据
                    int result = sm.Add(fillStorage());
                    if (result > 0)
                    {
                        MessageBox.Show("新增仓库信息成功!");
                        StorageForm sf = (StorageForm)Owner;
                        //绑定
                        sf.DataGridViewRowsAdd(0, "", textBoxXName.Text,
                                               textBoxXMan.Text,
                                               textBoxXPhone.Text,
                                               textBoxXAddress.Text,
                                               checkBoxXEnable.Checked ? 0 : 1,
                                               1,
                                               textBoxXRemark.Text,
                                               "",
                                               "");
                    }
                    else
                    {
                        MessageBox.Show("新增仓库信息失败,请尝试重新增加");
                        Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("查询异常,请检查服务器连接.错误:" + ex.Message);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(textBoxXName.Text))
                {
                    StorageManager sm = new StorageManager();

                    try
                    {
                        //获取实体,增加该实体数据
                        bool result = sm.UpdateByCode(fillStorage());
                        if (result)
                        {
                            MessageBox.Show("更改仓库信息成功!");
                        }
                        else
                        {
                            MessageBox.Show("更改仓库信息失败,请尝试重新增加");
                            Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("查询异常,请检查服务器连接.错误:" + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("仓库名称不可为空,请检查.");
                }
            }
        }