Ejemplo n.º 1
0
        private Player CreatePlayer(int userId, string playerName, Appearance appearance)
        {
            var random = new Random();
            var pos    = new Vector3((float)random.NextDouble() * 2f, 7.5f, (float)random.NextDouble() * 2f);

            if (appearance == null)
            {
                appearance = gameData.GenerateRandomAppearance();
            }
            else
            {
                appearance = gameData.CreateAppearance(appearance);
            }

            var transform = gameData.CreateTransform();

            transform.SetPosition(pos);
            transform.SetDestination(pos);

            var attributes  = gameData.CreateAttributes();
            var professions = gameData.CreateProfessions();

            var player = gameData.CreatePlayer();

            player.UserId        = userId;
            player.Name          = playerName;
            player.AttributesId  = attributes.Id;
            player.ProfessionsId = professions.Id;
            player.TransformId   = transform.Id;
            player.AppearanceId  = appearance.Id;

            inventoryProvider.CreateInventory(player.Id);

            //var addedPlayer = new Player()
            //{
            //    Id = id,
            //    Name = playerName,
            //    UserId = userId,
            //    TransformId = transform.Id,
            //    Created = DateTime.UtcNow,
            //    AppearanceId = appearance.Id
            //};

            //gameData.Add(player);
            return(player);
        }