Пример #1
0
// Used when you want to add avaliable hero to the team in DispalyAndAddToTheTeam
    private void AddToTeam(int index, Team team)
    {
        team.AddCharacter(hero, index);
        SelectHeroes selectHeroPanel = FindObjectOfType <SelectHeroes>();

        selectHeroPanel.PopulatePanel();
        selectHeroPanel.gameObject.GetComponent <Animator>().SetTrigger("FadeIn");
        GetComponentInParent <Animator>().SetTrigger("FadeOut");
    }
Пример #2
0
        public async Task <ActionResult> AddCharacter(string teamId, string characterId, string weaponId, int charLvl, int weaponLvl)
        {
            Team team = await _unitOfWork.TeamRepository.GetById(teamId);

            Character character = await _unitOfWork.CharacterRepository.GetById(characterId);

            Weapon weapon = await _unitOfWork.WeaponRepository.GetById(weaponId);

            CharacterWeapon characterWeapon = new CharacterWeapon(charLvl)
            {
                Character = character,
                Weapon    = weapon
            };

            characterWeapon.setWeaponPower(weaponLvl);
            if (team.AddCharacter(characterWeapon))
            {
                await _unitOfWork.SaveChangesAsync();

                return(Ok(team));
            }
            return(BadRequest("The maximum Characters per Team is 5."));
        }
Пример #3
0
        public async Task <ActionResult> AddTeam(string userId, ICollection <CharacterDto> characters)
        {
            if (characters.Count == 0)
            {
                return(BadRequest("The team must contain at least one character."));
            }
            Team team = new Team();

            foreach (CharacterDto characterDto in characters)
            {
                Character       character       = _mapper.Map <Character>(characterDto);
                CharacterWeapon characterWeapon = new CharacterWeapon(0)
                {
                    Character = character
                };
                team.AddCharacter(characterWeapon);
            }
            User user = await _unitOfWork.UserRepository.GetById(userId);

            user.Teams.Add(team);
            await _unitOfWork.SaveChangesAsync();

            return(Ok(characters));
        }