Пример #1
0
        public IActionResult AddpointFieldToExperienceView(string expGrpId)
        {
            var activeUserId = _userManager.GetUserId(User);
            var userInfoId   = _userInfoRepo.Read(activeUserId).UserInformationId;

            if (!ModelState.IsValid)
            {
                return(ViewComponent("ExperienceEditDisplay", new { userInfoId = userInfoId }));
            }

            var exp = _experienceRepo.Read(expGrpId);


            if (exp.UserInformationId != userInfoId)
            {
                Response.StatusCode  = 403;
                ViewBag.ErrorTitle   = "Wrong user";
                ViewBag.ErrorMessage = "Unauthorized edit attempt was made";
                return(View("Error"));
            }

            var expPointCount = exp.ExperiencePoints.Count;
            var maxLimit      = _config.GetValue <int>("ExperienceDBLimits:ExperienceHighLightMaxLimit");

            if (expPointCount >= maxLimit)
            {
                ModelState.AddModelError("", $"You have exceeded the maximum({maxLimit}) amount of experience point sections you can make.");
                return(ViewComponent("ExperienceEditDisplay", new { userInfoId = userInfoId }));
            }

            var newExpPoint = new ExperiencePoint
            {
                Id    = Guid.NewGuid().ToString(),
                Index = expPointCount,
                Title = ""
            };

            newExpPoint.Descriptions = new List <ExperiencePointDescription>();
            newExpPoint.Descriptions.Add(new ExperiencePointDescription
            {
                Id          = Guid.NewGuid().ToString(),
                Index       = 0,
                Discription = ""
            });

            exp.ExperiencePoints.Add(newExpPoint);
            _experienceRepo.Update(exp);

            return(ViewComponent("ExperienceEditDisplay", new { userInfoId = userInfoId }));
        }
Пример #2
0
    public static bool DestroyDeadEnemy(GameObject enemy, Dictionary <GameObject, List <GameObject> > whichPlayerReachEnemy)
    {
        Enemy enemyStatus = enemy.gameObject.GetComponent <Enemy>();

        if (enemyStatus.hp <= 0)
        {
            ExperiencePoint.passExperiencePoint(enemy, whichPlayerReachEnemy);
            GameObject.Destroy(enemy.gameObject);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #3
0
    private bool CheckAndHandleEnd()
    {
        var endResult = gameEndChecker.Check(playerAndItsGoalsList);

        if (endResult != GameEndChecker.Result.NotEnd)
        {
            Debug.Log("Game end cause of " + endResult);
        }



        switch (endResult)
        {
        case GameEndChecker.Result.NotEnd:
            return(false);

        case GameEndChecker.Result.AllEnemyDeath:
            UIManager.Instance.Cleard();
            ExperiencePoint.GetStageExperiencePoint(stageNumber, playerAndItsGoalsList);
            return(true);

        case GameEndChecker.Result.AllPlayerDeath:
            UIManager.Instance.GameOver();
            ExperiencePoint.GetExperiencePoint(playerAndItsGoalsList);
            return(true);

        case GameEndChecker.Result.TurnOver:
            UIManager.Instance.GameOver();
            ExperiencePoint.GetExperiencePoint(playerAndItsGoalsList);
            return(true);

        case GameEndChecker.Result.NothingToDo:
            UIManager.Instance.GameOver();
            ExperiencePoint.GetExperiencePoint(playerAndItsGoalsList);
            return(true);

        default:
            Debug.LogError("Invalid game end " + endResult);
            return(false);
        }
    }
Пример #4
0
        public IActionResult AddEXP()
        {
            var activeUserId = _userManager.GetUserId(User);

            var expCount    = _experienceRepo.GetExperienceCount(_userInfoRepo.Read(activeUserId).UserInformationId);
            var expMaxLimit = _config.GetValue <int>("ExperienceDBLimits:ExperienceSectionsMaxLimit");

            if (expCount >= expMaxLimit)
            {
                ModelState.AddModelError("", $"You have exceeded the maximum({expMaxLimit}) amount of experience sections you can make.");
                return(ViewComponent("ExperienceEditDisplay", new { userInfoId = _userInfoRepo.Read(activeUserId).UserInformationId }));
            }

            var exp = new Experience()
            {
                Id                = Guid.NewGuid().ToString(),
                Index             = expCount,
                Title             = "",
                UserInformationId = _userInfoRepo.Read(activeUserId).UserInformationId,
                ExperiencePoints  = new List <ExperiencePoint>()
            };

            var newExpPoint = new ExperiencePoint
            {
                Id    = Guid.NewGuid().ToString(),
                Index = 0,
                Title = ""
            };

            newExpPoint.Descriptions = new List <ExperiencePointDescription>();
            newExpPoint.Descriptions.Add(new ExperiencePointDescription
            {
                Id          = Guid.NewGuid().ToString(),
                Index       = 0,
                Discription = ""
            });

            exp.ExperiencePoints.Add(newExpPoint);
            _experienceRepo.CreateExp(exp);
            return(ViewComponent("ExperienceEditDisplay", new { userInfoId = _userInfoRepo.Read(activeUserId).UserInformationId }));
        }
Пример #5
0
 public void LevelAndExperiencePointUp()
 {
     if (this.characterName == CharacterName.Roserian)
     {
         Dictionary <string, int> levelAndExperiencePoint;
         levelAndExperiencePoint = ExperiencePoint.CalculateExperiencePoint(levelRoserian, experiencePointRoserian, gainedExperiencePoint);
         gainedExperiencePoint   = 0;
         levelRoserian           = levelAndExperiencePoint["Level"];
         experiencePointRoserian = levelAndExperiencePoint["ExperiencePoint"];
         PlayerPrefs.SetInt("levelRoserian", levelRoserian);
         PlayerPrefs.SetInt("experiencePointRoserian", experiencePointRoserian);
     }
     if (this.characterName == CharacterName.Hesmen)
     {
         Dictionary <string, int> levelAndExperiencePoint;
         levelAndExperiencePoint = ExperiencePoint.CalculateExperiencePoint(levelHesmen, experiencePointHesmen, gainedExperiencePoint);
         gainedExperiencePoint   = 0;
         levelHesmen             = levelAndExperiencePoint["Level"];
         experiencePointHesmen   = levelAndExperiencePoint["ExperiencePoint"];
         PlayerPrefs.SetInt("levelHesmen", levelHesmen);
         PlayerPrefs.SetInt("experiencePointHesmen", experiencePointHesmen);
     }
 }
Пример #6
0
 public ExperiencePoint DeleteExpPoint(ExperiencePoint experiencePointToDelete)
 {
     _appDbContext.Remove(experiencePointToDelete);
     _appDbContext.SaveChanges();
     return(experiencePointToDelete);
 }
Пример #7
0
 public ExperiencePoint CreateExpPoint(ExperiencePoint newExpPoint)
 {
     _appDbContext.Add(newExpPoint);
     _appDbContext.SaveChanges();
     return(newExpPoint);
 }