public void Handle(TeamCommand command)
        {
            var ball   = command.Ball;
            var player = command.Player;
            var team   = command.Team;

            if (!ball.LandingSpot.HasValue)
            {
                return;
            }
            var landingSpot = ball.LandingSpot.Value;

            if (!player.IsDefenseNecessary(landingSpot))
            {
                player.RemoveAction(PlayerAction.Block);
                return;
            }

            if (player.InBlockRange(ball.Position))
            {
                player.IsBlocking = true;
                Jump(command);
                player.RemoveAction(PlayerAction.Block);
                return;
            }
            if (!player.CanBlock(ball.Position))
            {
                player.RemoveAction(PlayerAction.Block);
                return;
            }
        }
Esempio n. 2
0
 public Team MapToEntity(TeamCommand teamCommand)
 {
     return(new Team()
     {
         Id = teamCommand.Id,
         Name = teamCommand.Name,
         Wins = teamCommand.Wins,
         Loses = teamCommand.Loses
     });
 }
Esempio n. 3
0
        public void Handle(TeamCommand command)
        {
            var ball   = command.Ball;
            var player = command.Player;
            var team   = command.Team;

            if (!ball.LandingSpot.HasValue)
            {
                return;
            }
            var landingSpot = ball.LandingSpot.Value;

            if (!player.IsDefenseNecessary(landingSpot))
            {
                player.RemoveAction(PlayerAction.Defend);
                return;
            }

            var playerID = team.GetNearestPlayerIdFrom(landingSpot);

            if (player.Id != playerID)
            {
                player.RemoveAction(PlayerAction.Defend);
                return;
            }
            var inDefenseRange = player.InDefenseRange(ball.transform.position);

            if (player.Position.Distance(ball.Position) < 2.5f &&
                !inDefenseRange)
            {
                player.IsDefending = true;
            }
            if (inDefenseRange)
            {
                var foward = player.TeamFoward.z * 0.15f;
                ball.Stop();
                ball.MoveInDirection(new Vector3(0, 1, foward), 6, player.TeamId);
                player.RemoveAction(PlayerAction.Defend);
                team.Pass();
                team.Spike();
                return;
            }
            var margin            = 0.5f * team.Foward.z;
            var target            = new Vector3(landingSpot.x, 0, landingSpot.z + margin);
            var arrivedInPosition = player.ArrivedInTarget(target);

            if (!arrivedInPosition)
            {
                MoveToTarget(target, command, 0, lookAtBall: true);
                return;
            }
        }
Esempio n. 4
0
        public ActionResult Post([FromBody] TeamCommand teamCommand)
        {
            try
            {
                if (teamCommand == null)
                {
                    return(NotFound());
                }

                _applicationTeamService.Add(teamCommand);
                return(Ok("Time criado com sucesso!"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        protected override void OnViewLoaded(object view)
        {
            if (!context.Database.Exists())
            {
                IWindowManager            manager            = new WindowManager();
                DBInitializationViewModel dbInitializingView = new DBInitializationViewModel(context);
                manager.ShowDialog(dbInitializingView, null, null);
            }

            CreateButton          = CreateButton.Initialize();
            barrackCommand        = new BarrackCommand(CreateButton);
            teamCommand           = new TeamCommand(CreateButton);
            specializationCommand = new SpecializationCommand(CreateButton);
            rankCommand           = new RankCommand(CreateButton);
            permissionCommand     = new PermissionCommand(CreateButton);
            missionCommand        = new MissionCommand(CreateButton);
            equipmentCommand      = new EquipmentCommand(CreateButton);
            employeeCommand       = new EmployeeCommand(CreateButton);
            LoadBarrackPage();
        }
Esempio n. 6
0
        public ActionResult Delete(
            Guid id,
            [FromBody] TeamCommand teamCommand
            )
        {
            try
            {
                if (teamCommand == null || id != teamCommand.Id)
                {
                    return(NotFound());
                }

                _applicationTeamService.Remove(teamCommand);
                return(Ok("Time deletado com sucesso!"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
0
 public void Update(TeamCommand obj)
 {
     _teamService.Update(_teamMap.MapToEntity(obj));
 }
Esempio n. 8
0
 public void Add(TeamCommand obj)
 {
     _teamService.Add(_teamMap.MapToEntity(obj));
 }
Esempio n. 9
0
 public void Remove(TeamCommand obj)
 {
     _teamService.Remove(_teamMap.MapToEntity(obj));
 }