Ejemplo n.º 1
0
        public void Show()
        {
            if (charCreationMenu != null)
            {
                charCreationMenu.GetMenu().Ended += (sender, e) =>
                {
                    if (!(e.Data.ContainsKey("name") && e.Data.ContainsKey("age") && e.Data.ContainsKey("sex")))
                    {
                        charCreationMenu.Show(player);
                        return;
                    }

                    ServerDbContext dbContext = ((GameMode)GameMode.Instance).DbContext;

                    dbContext.Accounts.Attach(player.AccountData);

                    SpawnLocation chrSpawn = new SpawnLocation();
                    chrSpawn.Interior     = 0;
                    chrSpawn.VirtualWorld = 0;
                    chrSpawn.X            = 1762.1357f;
                    chrSpawn.Y            = -1862.8958f;
                    chrSpawn.Z            = 13.5757f;
                    chrSpawn.RotX         = 0f;
                    chrSpawn.RotY         = 0f;
                    chrSpawn.RotZ         = 269.4686f;

                    Inventory inv = new Inventory();
                    inv.MaxSpace = Constants.CHARACTER_INVENTORY_SIZE;

                    Character chr = new Character();
                    chr.Account       = player.AccountData;
                    chr.Name          = (string)e.Data["name"];
                    chr.Age           = (uint)e.Data["age"];
                    chr.Sex           = (Character.CharSex)e.Data["sex"];
                    chr.Skin          = 26;
                    chr.SpawnLocation = chrSpawn;
                    chr.Inventory     = inv;
                    chr.PermsSet      = new PermissionSet();
                    chr.GroupOwner    = new List <Group>();
                    chr.GroupRanks    = new List <GroupRank>();
                    chr.BuildingOwner = new List <Building>();

                    player.ActiveCharacter = chr;

                    dbContext.Add(chr);
                    dbContext.SaveChanges();

                    player.SpawnCharacter();
                };
                charCreationMenu.Show(player);
                return;
            }

            charList.Show(player);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Host,Username,Password")] ServerModel Server)
        {
            if (ModelState.IsValid)
            {
                _context.Add(Server);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(Server));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,ChannelName,ServerModelId")] ChannelModel channel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(channel);
                var server = _context.Servers.Find(channel.ServerModelId);
                server.Channels.Add(channel);
                _context.Update(server);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Edit", "Servers", new { Id = channel.ServerModelId }));
            }
            return(View(channel));
        }
Ejemplo n.º 4
0
        public static Vehicle CreateVehicle(Character owner, VehicleModel model, Vector3 position, float rotation, VehicleColor color1 = VehicleColor.White, VehicleColor color2 = VehicleColor.White, bool temp = false)
        {
            try
            {
                ServerDbContext dbContext = ((GameMode)GameMode.Instance).DbContext;

                var dataVeh = new VehicleData();

                dataVeh.Type          = model;
                dataVeh.Color1        = color1;
                dataVeh.Color2        = color2;
                dataVeh.SpawnLocation = new SpawnLocation(position, rotation);

                dataVeh.MaxFuel         = model.MaxFuel;
                dataVeh.FuelConsumption = model.FuelConsumption;
                dataVeh.Fuel            = model.MaxFuel;
                dataVeh.Dammages        = 1000f;

                dataVeh.Owner     = owner;
                dataVeh.Container = new Container(10);

                dataVeh.Temporary = temp;

                if (!temp)
                {
                    dbContext.Add(dataVeh);
                    dbContext.SaveChanges();
                }
                Vehicle veh = (Vehicle)Vehicle.Create(model.Model, position, rotation, (int)color1, (int)color2);
                veh.Data = dataVeh;

                return(veh);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 public async Task <int> Add <T>(T entity) where T : BaseEntity
 {
     _dbContext.Add(entity);
     return(dbContextTransaction == null ? await CommitTrans() : 0);
 }