예제 #1
0
 protected void Play(Payloader <SC_Play> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
     });
 }
예제 #2
0
 private void EnterRoom(Payloader <SC_EnterRoom> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
     });
 }
예제 #3
0
        public async Task <IActionResult> Create([FromBody] ManagerViewModel body)
        {
            try
            {
                var entity = await _unitOfWork.Managers.GetAsync(u => u.Id == body.Id);

                if (entity != null)
                {
                    return(Payloader.Fail(PayloadCode.Duplication));
                }

                var newEntity = new Manager
                {
                    Id       = body.Id,
                    Password = body.Password,
                };

                await _unitOfWork.Managers.AddAsync(newEntity);

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(_mapper.Map <ManagerViewModel>(newEntity)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #4
0
 protected void CompleteLoading(Payloader <SC_CompleteLoading> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
     });
 }
예제 #5
0
        public async Task <IActionResult> Get()
        {
            try
            {
                var authToken   = Request.Headers["Authorization"].ToString();
                var tokenString = authToken.Substring(7);

                var tokenHandler = new JwtSecurityTokenHandler();
                var token        = tokenHandler.ReadToken(tokenString);
                var userId       = ((JwtSecurityToken)token).Payload["nameid"].ToString();

                var entity = await _unitOfWork.Managers.GetAsync(u => u.Id == userId);

                if (entity == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                return(Payloader.Success(_mapper.Map <ManagerViewModel>(entity)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #6
0
        public async Task <IActionResult> Create([FromBody] VideoViewModel body)
        {
            try
            {
                var entity = await _unitOfWork.Videos.GetAsync(u => u.Id == body.Id);

                if (entity != null)
                {
                    return(Payloader.Fail(PayloadCode.Duplication));
                }

                var newEntity = new Video
                {
                    Title = body.Title,
                    Uri   = body.Uri,
                };

                await _unitOfWork.Videos.AddAsync(newEntity);

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(_mapper.Map <VideoViewModel>(newEntity)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #7
0
 protected void MoveCube(Payloader <SC_MoveCube> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         GetTeam(data.Id)?.MoveCube(data.CubeSeq, data.PositionX, data.PositionY);
     });
 }
예제 #8
0
 private void ExitRoom(Payloader <SC_ExitRoom> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         Router.CloseAndOpen("LobbyView/PlayView");
     });
 }
예제 #9
0
 protected void ShotMissile(Payloader <SC_ShotMissile> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         GetTeam(data.Id)?.ShotMissile(data.CubeSeq, data.MonsterSeq);
     });
 }
예제 #10
0
 protected void DeleteCube(Payloader <SC_DeleteCube> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         GetTeam(data.Id)?.DeleteCube(data.DeleteCubes);
     });
 }
예제 #11
0
 protected void CombineCube(Payloader <SC_CombineCube> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         GetTeam(data.Id)?.CombineCube(data.OwnerSeq, data.TargetSeq);
     });
 }
예제 #12
0
 private void ExitMatch(Payloader <SC_ExitMatch> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         Router.Close("MatchView");
     });
 }
예제 #13
0
 private void EnterMatch(Payloader <SC_EnterMatch> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         Router.Open("MatchView");
     });
 }
예제 #14
0
 protected void Wave(Payloader <SC_Wave> payloader)
 {
     payloader.Callback(
         success: (data) =>
     {
         StartCoroutine(WaveMonster(8f));
     });
 }
예제 #15
0
    private void Login(Payloader <SC_Login> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            ServerInfo.isLogin = true;

            Router.CloseAndOpen("LobbyView/PlayView");
        });
    }
예제 #16
0
    protected void UpdateSlot(Payloader <SC_UpdateSlot> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            GetTeam(data.Id)?.UpdateSlot(data.SlotIndex, data.SlotLv);

            Router.Refresh();
        });
    }
예제 #17
0
    protected void DieMonster(Payloader <SC_DieMonster> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            GetTeam(data.Id)?.DieMonster(data.MonsterSeq);

            Router.Refresh();
        });
    }
예제 #18
0
    protected void CreateCube(Payloader <SC_CreateCube> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            GetTeam(data.Id)?.CreateCube(data.NewCube);

            Router.Refresh();
        });
    }
예제 #19
0
    private void Loading(Payloader <SC_Loading> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            ServerInfo.GameUsers = data.Users;

            SceneManager.LoadScene("MultiGame", LoadSceneMode.Single);
        });
    }
예제 #20
0
    protected void EscapeMonster(Payloader <SC_EscapeMonster> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            GetTeam(data.Id)?.EscapeMonster(data.MonsterSeq);

            Router.Refresh();

            CheckResult();
        });
    }
예제 #21
0
        public async Task <IActionResult> Parsing()
        {
            try
            {
                await ParsingCubeData();

                return(Payloader.Success("Parse Success"));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #22
0
    protected virtual void Result(Payloader <SC_Result> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            GetTeams().ForEach(x => x.UnRegister());

            ServerInfo.GameUsers = data.Users;

            Router.Open("ResultView");

            var my = ServerInfo.MyGameUser();
            LobbyServer.sInstance.UpdateMoney(my.Id, my.Money);
        });
    }
예제 #23
0
    protected override void Result(Payloader <SC_Result> payloader)
    {
        payloader.Callback(
            success: (data) =>
        {
            GetTeams().ForEach(x => x.UnRegister());

            ServerInfo.GameUsers = data.Users;
            ServerInfo.GameUsers.FirstOrDefault().Id   = tempUserId;
            ServerInfo.GameUsers.FirstOrDefault().Name = tempUserName;
            ServerInfo.User.Id   = tempUserId;
            ServerInfo.User.Name = tempUserName;

            Router.Open("ResultView");
        });
    }
예제 #24
0
        public async Task <IActionResult> Get(string id)
        {
            try
            {
                var entity = await _unitOfWork.Managers.GetAsync(u => u.Id == id);

                if (entity == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                return(Payloader.Success(_mapper.Map <ManagerViewModel>(entity)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #25
0
        public async Task <IActionResult> Get()
        {
            try
            {
                var entries = await _unitOfWork.Managers.GetManyAsync();

                if (entries == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                return(Payloader.Success(_mapper.Map <IEnumerable <ManagerViewModel> >(entries)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #26
0
        public async Task <IActionResult> UpdateLv(string userId, int cubeId)
        {
            try
            {
                var user = await _unitOfWork.Users.GetAsync(x => x.Id == userId, isTracking : true);

                if (user == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                var lv   = 0;
                var cube = await _unitOfWork.Cubes.GetAsync(x => x.UserId == userId && x.CubeId == cubeId);

                if (cube != null)
                {
                    lv = cube.Lv;
                }

                var price = ServerDefine.CubeLv2Price((byte)lv);

                if (user.Money < price)
                {
                    return(Payloader.Fail(PayloadCode.Not));
                }

                user.Money -= price;

                var newCube = await _unitOfWork.Cubes.UpdateLv(userId, cubeId, 1);

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(new UpdateCubeLvBody()
                {
                    Cube = _mapper.Map <CubeViewModel>(newCube),
                    Money = user.Money,
                }));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #27
0
        public async Task <IActionResult> ParsingSkillData(IFormFile xml = null)
        {
            try
            {
                var datas = XmlKey.CubeData.FindAll <SkillDataXml.Data>(xml, new SkillDataXml());

                await _unitOfWork.SkillDatas.DeleteManyAsync();

                await _unitOfWork.SkillDatas.AddAsync(_mapper.Map <IEnumerable <SkillData> >(datas));

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(datas.Count));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #28
0
        public async Task <IActionResult> Get(string id)
        {
            try
            {
                var entity = await _unitOfWork.Users.GetAsync(x => x.Id == id,
                                                              eagerLoad : q => q.Include(x => x.Entry),
                                                              explicitLoad : q => q.Include(x => x.Cubes).ThenInclude(x => x.CubeData).Load(),
                                                              isTracking : true);

                if (entity == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                return(Payloader.Success(_mapper.Map <UserViewModel>(entity)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #29
0
        public async Task <IActionResult> Put(string id, [FromBody] ManagerViewModel body)
        {
            try
            {
                var entity = await _unitOfWork.Managers.GetAsync(u => u.Id == id, isTracking : true);

                if (entity == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                entity.Password = body.Password;

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(_mapper.Map <ManagerViewModel>(entity)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
예제 #30
0
        public async Task <IActionResult> Delete(string id)
        {
            try
            {
                var entity = await _unitOfWork.Managers.GetAsync(u => u.Id == id);

                if (entity == null)
                {
                    return(Payloader.Fail(PayloadCode.DbNull));
                }

                await _unitOfWork.Managers.DeleteAsync(entity);

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(id));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }