Inheritance: SportsObject
Esempio n. 1
0
 public void AddPlayerToTeam(TeamPlayer player)
 {
     if (player != null)
     {
         players.Add(player);
     }
 }
Esempio n. 2
0
 //try to grab the ball. Returns true if you got it.
 public bool grabBall(TeamPlayer player)
 {
     if (holdable && takeTimer == 0)
     {
         bool wasHeld = isHeld;
         //give control of the ball to the player who
         if (currentPlayer != null)
         {
             currentPlayer.removeBall(this);
         }
         takeTimer = noTakebacksCooldown;
         previousPlayer = currentPlayer;
         currentPlayer = player;
         isHeld = true;
         //send event
         if (wasHeld)
             gameRules.SendEvent(new GameRuleEvent(GameRuleEventType.PlayerStealBall, tp: currentPlayer, vct: previousPlayer, bl: this));
         else
             gameRules.SendEvent(new GameRuleEvent(GameRuleEventType.PlayerGrabBall, tp: currentPlayer, bl: this));
         //play sound
         soundSource.clip = catchSounds[Random.Range(0, catchSounds.Count)];
         soundSource.Play();
         return true;
     }
     return false;
 }
Esempio n. 3
0
        public async Task <string> SwitchCaptain(int newCaptainId)
        {
            try
            {
                TeamPlayer tmPlayer = App.Current.Properties["loggedUserTeamPlayer"] as TeamPlayer;
                Team       team     = tmPlayer.Team;
                string     responseMessage;
                //List<TeamPlayer> playerList = new List<TeamPlayer>();
                //TeamPlayer currentPlayer = App.Current.Properties["loggedUserTeamPlayer"] as TeamPlayer;
                var input  = $"https://www.harbisaha.com/api/OpponentAdvert/SwitchCaptain?teamId=" + team.Id + "&newCaptainId=" + newCaptainId;
                var client = await GetClient();

                var result = await client.GetStringAsync(input);

                responseMessage = JsonConvert.DeserializeObject <string>((result));
                if (responseMessage == "Başarılı")
                {
                    return("Kaptan Değişti!");
                }
                else
                {
                    return("Hata oluştu");
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 4
0
        protected override void Seed(SoccerApp.Models.SocerContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.


            var teamOne = new Team {
                Name = "Team One"
            };

            context.Teams.Add(teamOne);

            var playerOne = new Player {
                Name = "Player One"
            };

            context.Players.Add(playerOne);

            var teamPlayerOne = new TeamPlayer {
                Team = teamOne, Player = playerOne, StartsAt = new DateTime(2007, 1, 1), EndsAt = new DateTime(2018, 1, 1)
            };

            context.TeamPlayers.Add(teamPlayerOne);

            context.SaveChanges();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CoachTeamId,PlayerId,PositionId,Goals,KitNumber,Approved")] TeamPlayer teamPlayer)
        {
            if (id != teamPlayer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teamPlayer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamPlayerExists(teamPlayer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CoachTeamId"] = new SelectList(_context.CoachTeams, "Id", "Id", teamPlayer.CoachTeamId);
            ViewData["PlayerId"]    = new SelectList(_context.Players, "Id", "FirstName", teamPlayer.PlayerId);
            ViewData["PositionId"]  = new SelectList(_context.Positions, "Id", "Id", teamPlayer.PositionId);
            return(View(teamPlayer));
        }
Esempio n. 6
0
        public bool IsBlocked(int attackTeamId, int defTeamId, out TeamPlayer striker)
        {
            striker = SelectStriker(attackTeamId);
            if (striker == null)
            {
                return(true);
            }
            int    strikerAttack  = striker.Atack;
            double averageDefence = CountAverageDefence(defTeamId);
            double blockProbability;

            if (strikerAttack >= averageDefence)
            {
                blockProbability = 0.75;
            }
            else
            {
                blockProbability = 0.75 + (averageDefence - strikerAttack) / 100;
            }
            if (blockProbability >= 1)
            {
                blockProbability = 0.99;
            }
            double index = GetRandomValue();

            if (index < blockProbability)
            {
                return(true);
            }
            return(false);
        }
        public void UpdatePlayer(int playerId, TeamPlayer teamPlayer)
        {
            TeamPlayer currentTeamPlayer = GetPlayerById(playerId);

            currentTeamPlayer = teamPlayer;
            currentContext.SaveChanges();
        }
Esempio n. 8
0
        public async Task <string> LeaveFromTeam()
        {
            User       currentUser       = App.Current.Properties["loggedUser"] as User;
            TeamPlayer currentTeamPlayer = App.Current.Properties["loggedUserTeamPlayer"] as TeamPlayer;

            if (currentTeamPlayer != null)
            {
                try
                {
                    string responseMessage;
                    //List<TeamPlayer> playerList = new List<TeamPlayer>();
                    //TeamPlayer currentPlayer = App.Current.Properties["loggedUserTeamPlayer"] as TeamPlayer;
                    var input  = $"https://www.harbisaha.com/api/OpponentAdvert/LeaveFromTeam?teamPlayerId=" + currentTeamPlayer.Id;
                    var client = await GetClient();

                    var result = await client.GetStringAsync(input);

                    responseMessage = JsonConvert.DeserializeObject <string>((result));
                    if (responseMessage == "Başarılı")
                    {
                        return("Takımdan Ayrıldınız.");
                    }
                    else
                    {
                        return("Hata oluştu");
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return("Hata oluştu");
        }
        private PlayerPosition GridLengthToPosition(TeamPlayer tp)
        {
            switch (tp.PlayerGridY)
            {
            case 0:
                return(PlayerPosition.Goalkeeper);

            case 1:
            case 2:
                return(PlayerPosition.Defender);

            case 3:
            case 4:
                return(PlayerPosition.Midfielder);

            case 5:
                return(PlayerPosition.Attacker);

            case 6:
            case 7:
                return(PlayerPosition.Striker);
            }

            throw new ArgumentOutOfRangeException();
        }
Esempio n. 10
0
        public async Task <TeamDTO> CreateTeamAsync(CreateTeamDTO createTeamDTO)
        {
            var teamId = Guid.NewGuid();

            var(key, salt) = CreateKeyAndSalt(createTeamDTO.Passphrase);
            var team = new Team()
            {
                TeamUserId = createTeamDTO.TeamId,
                TeamName   = createTeamDTO.Name,
                TeamId     = teamId,
                Passphrase = key,
                Salt       = salt
            };

            dbContext.Team.Add(team);

            foreach (var member in createTeamDTO.Members)
            {
                var teamPlayer = new TeamPlayer()
                {
                    PlayerId = Guid.NewGuid(),
                    TeamId   = teamId,
                    Name     = member.Name
                };
                dbContext.TeamPlayer.Add(teamPlayer);

                team.Members.Add(teamPlayer);
            }

            await dbContext.SaveChangesAsync();

            return(team.ToDto());
        }
Esempio n. 11
0
 void SaveIfLocalPlayer(TeamPlayer player)
 {
     if (player.isLocalPlayer)
     {
         localPlayer = player;
     }
 }
Esempio n. 12
0
    public void UpdateTextureToTeamColor()
    {
        // For the team player thing
        TeamPlayer teamSelf = GetComponent <TeamPlayer>();  // TIDYME: 2018-07-07: should be done in Start()

        Component[] meshRenderers =
            gameObject.GetComponentsInChildren(typeof(MeshRenderer));

        if (meshRenderers == null)
        {
            Debug.Log("TowerLive: MeshRenderers is NULL!!!");
        }

        // Team 0, blue.
        // Team 1, red.
        int          i   = 0;
        Material     mat = Resources.Load((teamSelf.team == 0) ? "MatBlue" : "MatRed") as Material; // TIDYME: 2018-07-07: Can we avoid Resources.Load here, by using Material Property?
        MeshRenderer mrenderer;

        for (i = 0; i < meshRenderers.Length; i += 1)
        {
            mrenderer          = meshRenderers[i] as MeshRenderer;
            mrenderer.material = mat as Material;
        }

        // Add a minimap icon for ourselves.
        // NOTE: This means we don't want to be able to convert a live tower, okay?
        AddMinimapIcon();
    }
        protected bool CheckPlayers(TeamPlayer teamOrPlayerA, TeamPlayer teamOrPlayerB,
                                    string teamOrPlayerALookup, string teamOrPlayerBLookup)
        {
            bool @continue = false;

            if (teamOrPlayerA == null)
            {
                this.missingAlias.Add(new MissingTeamPlayerAliasObject
                {
                    TeamOrPlayerName = teamOrPlayerALookup,
                    ExternalSource   = this.valueOptions.OddsSource.Source,
                    ExternalSourceID = this.valueOptions.OddsSource.Id,
                    Tournament       = this.valueOptions.Tournament.TournamentName,
                    TournamentID     = this.valueOptions.Tournament.Id
                });
                @continue = true;
            }
            if (teamOrPlayerB == null)
            {
                this.missingAlias.Add(new MissingTeamPlayerAliasObject
                {
                    TeamOrPlayerName = teamOrPlayerBLookup,
                    ExternalSource   = this.valueOptions.OddsSource.Source,
                    ExternalSourceID = this.valueOptions.OddsSource.Id,
                    Tournament       = this.valueOptions.Tournament.TournamentName,
                    TournamentID     = this.valueOptions.Tournament.Id
                });
                @continue = true;
            }
            return(@continue);
        }
Esempio n. 14
0
    GameObject FindClosestTarget()
    {
        TeamPlayer[] potentialTargets = UnityEngine.Object.FindObjectsOfType <TeamPlayer>() as TeamPlayer[];

        GameObject bestTarget = null;
        float      bestDist   = 99999; // TIDYME: 2018-07-07: better to use Infinity?

        // TIDYME: 2018-07-07: Use foreach loop
        for (int i = 0; i < potentialTargets.Length; i += 1)
        {
            TeamPlayer t = potentialTargets[i];
            var        d = Vector3.Distance(turret.transform.position, t.gameObject.transform.position);

            if (t.gameObject.Equals(this))
            {
                continue;
            }

            if (d < bestDist && !t.SameTeam(this.GetComponent <TeamPlayer>()))
            {
                bestDist   = d;
                bestTarget = t.gameObject;
            }
        }

        return(bestTarget);
    }
        public void TeamPlayerService_AddTeamPlayer_Success()
        {
            TeamPlayer tp = new TeamPlayer {
            };

            // Create user
            User u = new User {
                ForeName = "Test", SurName = "Test", Password = "******", Role = Role.User, UserName = "******"
            };

            u.Id = userSvc.RegisterUser(u);
            // Create team matching user Id
            Team t = new Team {
                Forename = "Test", Surname = "Test", TeamName = "TestTeamName", UserId = u.Id
            };

            t = teamSvc.AddTeam(t);
            // Add TP to team matching team id
            tp = svc.AddTeamPlayer(t.Id, 1);

            IList <Player> actualTeamPlayers = svc.GetPlayersByTeamId(t.Id);

            Player expectedP = playerSvc.GetPlayerById(1);

            Assert.Equal(expectedP.Id, actualTeamPlayers[0].Id);
        }
Esempio n. 16
0
    public void InitGame()
    {
        Log("GameInit");
        vCam.Follow = null;

        Global.teamA.teamPlayers.Clear();
        Global.teamB.teamPlayers.Clear();

        foreach (var teamA_Player in teamA_Players)
        {
            TeamPlayer teamPlayer = teamA_Player.GetComponent <TeamPlayer>();
            teamPlayer.InitUI();
            Global.teamA.AddTeamPlayer(teamPlayer);
            teamPlayer.PlayerController.enabled = false;
        }

        Global.teamA.InitHP();

        foreach (var teamB_Player in teamB_Players)
        {
            TeamPlayer teamPlayer = teamB_Player.GetComponent <TeamPlayer>();
            teamPlayer.InitUI();
            Global.teamB.AddTeamPlayer(teamPlayer);
            teamPlayer.PlayerController.enabled = false;
        }

        Global.teamB.InitHP();

        TurnBaseController.AddTeam(Global.teamA);
        TurnBaseController.AddTeam(Global.teamB);

        TurnBaseController.StartTurn();
    }
Esempio n. 17
0
        public static async Task Run(
            [CosmosDBTrigger(
                 databaseName: "Players",
                 collectionName: "players",
                 ConnectionStringSetting = "CosmosDBConnection",
                 LeaseCollectionName = "leases",
                 CreateLeaseCollectionIfNotExists = true)] IReadOnlyList <Document> input,
            [CosmosDB(
                 databaseName: "Players",
                 collectionName: "teamplayers",
                 ConnectionStringSetting = "CosmosDBConnection")] IAsyncCollector <TeamPlayer> teamPlayerItemsOut,
            ILogger log)
        {
            if (input != null && input.Count > 0)
            {
                log.LogInformation("Documents modified " + input.Count);
                log.LogInformation("First document Id " + input[0].Id);

                foreach (var item in input)
                {
                    Player player = JsonConvert.DeserializeObject <Player>(item.ToString());
                    // Any changes to the new items are here
                    TeamPlayer teamPlayer = new TeamPlayer()
                    {
                        Id         = player.Id,
                        PlayerName = player.NickName,
                        Region     = player.Region,
                        TeamId     = 1
                    };
                    await teamPlayerItemsOut.AddAsync(teamPlayer);
                }
            }
        }
Esempio n. 18
0
        public void BuyPlayer(int playerId, int teamId)
        {
            Player        player        = playerStorage.GetPlayerById(playerId);
            TeamDataLogic teamDataLogic = new TeamDataLogic();
            TeamData      teamData      = teamDataLogic.GetTeamData(teamId);
            int           playersNumber = teamData.PlayersNumber;

            if (playersNumber == 11)
            {
                throw new Exception("Команда полностью укомплектована");
            }
            TeamPlayerLogic teamPlayerLogic = new TeamPlayerLogic();
            int             budget          = teamData.Budget;

            if (budget < player.Price)
            {
                throw new Exception("Недостаточно денежных средств");
            }
            TeamPlayer teamPlayer = new TeamPlayer
            {
                Age      = player.Age,
                Name     = player.Name,
                Position = player.Position,
                Atack    = player.Atack,
                Defence  = player.Defence,
                Price    = player.Price,
                TeamId   = teamId,
                Number   = playersNumber + 1
            };

            teamPlayerLogic.AddTeamPlayer(teamId, teamPlayer);
            teamDataLogic.UpdateBudget(budget - player.Price, teamId);
            teamDataLogic.UpdatePlayerNumber(teamId);
        }
Esempio n. 19
0
        public async Task <IActionResult> DeleteTeamPlayer([FromRoute] int teamId, [FromRoute] int playerId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (teamId <= 0 || playerId <= 0)
            {
                return(NotFound("Combination of team Id and player Id does not exist"));
            }


            TeamPlayer tp = new TeamPlayer();

            tp.PlayerId = playerId;
            tp.TeamId   = teamId;

            var teamPlayer = await _context.TeamPlayer.Where(T => T.PlayerId == tp.PlayerId && T.TeamId == tp.TeamId).FirstOrDefaultAsync();

            if (teamPlayer == null)
            {
                return(NotFound("Combination of team Id and player Id does not exist"));
            }

            _context.TeamPlayer.Remove(teamPlayer);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Esempio n. 20
0
        private async void ThrowFromTeam(User selectedUser)
        {
            string name = selectedUser.Name;
            bool   isSure;

            isSure = await DisplayAlert("Uyarı", name + " kullanıcısını takımdan çıkarmak istediğinize emin misiniz?", "Evet", "Vazgeç");

            if (isSure == true)
            {
                await Navigation.PushPopupAsync(new AnimationPages.AnimationPopUpPage1_Waiting("İşleniyor"));

                string response = await service.ThrowFromTeam(selectedUser.Id);

                if (response != "Hata oluştu")
                {
                    //App.Current.MainPage = new NavigationPage(new IndexPageMain());
                    TeamPlayer          player = playerList.Where(x => x.UserId == selectedUser.Id).FirstOrDefault();
                    MyTeamPageViewModel model  = viewModels.Where(x => x.User.Id == selectedUser.Id).FirstOrDefault();
                    viewModels.Remove(model);
                    playerList.Remove(player);
                    colTeamPlayers.ItemsSource = null;
                    colTeamPlayers.ItemsSource = viewModels;
                    await Navigation.PopPopupAsync();
                }
            }
        }
Esempio n. 21
0
        public async Task <List <TeamPlayer> > GetTeamplayers()
        {
            User currentUser = new User();

            if (App.Current.Properties["loggedUserTeamPlayer"] == null)
            {
                return(null);
            }
            else
            {
                try
                {
                    List <TeamPlayer> playerList    = new List <TeamPlayer>();
                    TeamPlayer        currentPlayer = App.Current.Properties["loggedUserTeamPlayer"] as TeamPlayer;
                    var input  = $"https://www.harbisaha.com/api/OpponentAdvert/GetTeamPlayers?teamId=" + currentPlayer.TeamId;
                    var client = await GetClient();

                    var result = await client.GetStringAsync(input);

                    playerList = JsonConvert.DeserializeObject <List <TeamPlayer> >((result));
                    return(playerList);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Esempio n. 22
0
    void OnCollisionEnter(Collision collision)
    {
        Debug.Log("Bullet Collided with:" + collision.collider.name + ", gObj:" + collision.gameObject.name);

        // Generally, ignore triggers.
        if (collision.collider.isTrigger)
        {
            return;
        }

        // Damage any "Team Player" thing which we hit. (e.g. mech, tower, tank...).
        if (collision.gameObject.GetComponent <TeamPlayer>() != null)
        {
            TeamPlayer objectHit = collision.gameObject.GetComponent <TeamPlayer>();

            // Apply the damage.
            objectHit.health -= damageAmount;
        }
        else
        {
            Debug.Log("Hit non TP object, " + collision.gameObject);
        }

        // Since we hit something, destroy the bullet.
        Destroy(gameObject);
    }
        /**
         * Create a league with the teamplayers
         */
        private async Task <League> createLeagueWithTeams(string leagueName, IEnumerable <Player> players, List <Team> teams, Random rand)
        {
            League leagueInCreation = new League();

            leagueInCreation.Name = leagueName;

            List <TeamPlayer> teamPlayers = new List <TeamPlayer>();

            // for each players, we choose randomly a team
            foreach (Player player in players)
            {
                // picking a team randomly from the list of teams and add to the player
                int  teamPosition = rand.Next(0, teams.Count() - 1);
                Team team         = teams.ElementAt(teamPosition);
                // remove from the teamlist the selected team
                teams.RemoveAt(teamPosition);

                //we add the team player if not exists
                TeamPlayer tp = new TeamPlayer();
                tp.PlayerId = player.Id;
                tp.TeamId   = team.Id;

                // Add the team players to the season
                teamPlayers.Add(tp);
            }
            leagueInCreation.TeamPlayers = teamPlayers;

            return(leagueInCreation);
        }
Esempio n. 24
0
        public void UpdateNumber(int playerId, int number)
        {
            TeamPlayer teamPlayer = teamPlayerStorage.GetPlayerById(playerId);

            if (teamPlayer == null)
            {
                throw new Exception("Такого футболиста нет");
            }
            try
            {
                if (number > 0 && number < 100)
                {
                    teamPlayer.Number = number;
                    teamPlayerStorage.UpdatePlayer(playerId, teamPlayer);
                }
                else
                {
                    throw new Exception("Некорректные данные");
                }
            }
            catch (Exception exception)
            {
                throw new Exception("Некорректные данные");
            }
        }
Esempio n. 25
0
        public IHttpActionResult CreateTeam(NewTeam newTeam)
        {
            var customer = _context.Customers.Single(c => c.Id == newTeam.CustomerId);

            var players = newTeam.PlayerIds;

            var team = new Team
            {
                name       = newTeam.name,
                CustomerId = newTeam.CustomerId,
                League     = _context.Leagues.Where(x => x.Id == newTeam.League).FirstOrDefault()
            };

            _context.Teams.Add(team);
            _context.SaveChanges();

            foreach (var item in newTeam.PlayerIds)
            {
                var player = new TeamPlayer()
                {
                    ExternalId = item,
                    TeamId     = team.Id
                };
                _context.TeamPlayers.Add(player);
            }


            _context.SaveChanges();
            return(Created(new Uri(Request.RequestUri + "/" + team.Id), team));
        }
Esempio n. 26
0
        public async Task <CreateTeamModel> CreateTeam(string fullName, string shortName, string inviteEmail)
        {
            User currentUser = new User();

            try
            {
                CreateTeamModel model          = new CreateTeamModel();
                Team            teamToRetruned = new Team();
                TeamPlayer      tmPlayer       = new TeamPlayer();
                currentUser = App.Current.Properties["loggedUser"] as User;
                int userId = currentUser.Id;
                //mainCity = currentUser.City;
                var input = $"https://www.harbisaha.com/api/OpponentAdvert/CreateNewTeam?userId=" + userId + "&fullName=" + fullName + "&shortName=" + shortName + "&inviteEmail=" + inviteEmail;
                //var client = await GetClient();
                var client = await GetClient();

                var result = await client.GetStringAsync(input);

                model = JsonConvert.DeserializeObject <CreateTeamModel>((result));
                if (tmPlayer.Team != null)
                {
                    App.Current.Properties["loggedUserTeamPlayer"] = model.TeamPlayer;
                }
                return(model);
            }
            catch (Exception EX)
            {
                //return null;
                throw;
            }
        }
        public void SetupTeam(bool WithLabels)
        {
            int FormationID = (MyTeam ? team.CurrentFormation : team.LastKnownFormation);
            Dictionary <int, TeamPlayer> picks = (MyTeam ? team.Players : team.LastKnownPick);

            FormationPaging.DisplayItem(FormationID);
            SetupFormationTemplate(FormationID);

            PlayerAdapter pa = new PlayerAdapter();

            foreach (KeyValuePair <int, TeamPlayer> p in picks)
            {
                TeamPlayer tp     = p.Value;
                Player     player = pa.GetPlayer(tp.PlayerID);

                if (WithLabels)
                {
                    StackPanel s = new StackPanel();
                    s.Orientation = Orientation.Horizontal;

                    TextBlock playerLabel = new TextBlock();
                    playerLabel.Width             = 150;
                    playerLabel.Height            = 30;
                    playerLabel.Text              = player.DisplayName(PersonNameReturnType.LastnameInitial);
                    playerLabel.MouseMove        += new MouseEventHandler(PlayerName_MouseMove);
                    playerLabel.Tag               = tp.PlayerID;
                    playerLabel.VerticalAlignment = VerticalAlignment.Center;
                    playerLabel.Cursor            = Cursors.Hand;
                    PlayerLabels.Add(playerLabel);

                    s.Children.Add(PlayerLabels[PlayerLabels.Count - 1]);

                    TextBlock playerPos = new TextBlock();
                    playerPos.Width             = 60;
                    playerPos.Height            = 30;
                    playerPos.Text              = pa.PositionAndSideText(player, true);
                    playerPos.VerticalAlignment = VerticalAlignment.Center;

                    s.Children.Add(playerPos);

                    s.Children.Add(GraphicUtils.StarRatingWithNumber(player.Stars));

                    //stkNames.Children.Add(PlayerLabels[PlayerLabels.Count - 1]);
                    stkNames.Children.Add(s);
                    playerLabel = null;
                }



                if (tp.Selected == PlayerSelectionStatus.Starting && tp.PlayerGridX > -1 && tp.PlayerGridY > -1)
                {
                    MarkerText[tp.PlayerGridX, tp.PlayerGridY].Text       = player.DisplayName(PersonNameReturnType.InitialOptionalLastname);
                    MarkerText[tp.PlayerGridX, tp.PlayerGridY].Visibility = Visibility.Visible;
                    PlayerGridPositions[tp.PlayerGridX, tp.PlayerGridY]   = tp.PlayerID;
                }
            }

            ChangesNotSaved = false;
        }
Esempio n. 28
0
 public void createTeamPlayer(TeamPlayer tp)
 {
     using (var context = new TennisContext())
     {
         context.TeamPlayers.Add(tp);
         context.SaveChanges();
     }
 }
Esempio n. 29
0
 public ActionResult <TeamPlayer> Post(TeamPlayer teamPlayer)
 {
     if (teamPlayer.PlayerId == 0 || teamPlayer.TeamId == 0)
     {
         return(NotFound());
     }
     return(_service.AddTeamPlayer(teamPlayer.TeamId, teamPlayer.PlayerId));
 }
Esempio n. 30
0
 public ActionResult <bool> Delete([FromBody] TeamPlayer teamPlayer)
 {
     if (teamPlayer.PlayerId == 0 || teamPlayer.TeamId == 0)
     {
         return(NotFound());
     }
     return(_service.DeleteTeamPlayer(teamPlayer.TeamId, teamPlayer.PlayerId));
 }
Esempio n. 31
0
        public ActionResult DeleteConfirmed(int id)
        {
            TeamPlayer teamPlayer = db.TeamPlayers.Find(id);

            db.TeamPlayers.Remove(teamPlayer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 32
0
 public virtual void handlePlayerCollision(TeamPlayer collidedPlayer)
 {
 }
Esempio n. 33
0
    public void spawnPointsText(int pointsGiven, TeamPlayer target)
    {
        TextMesh pointsText;
        GameObject pointsTextObject;
        //add to the pool if there isn't enough
        if (pointsTextPool.Count == 0) {
            //for (int i = POINTS_TEXT_POOL_AMOUNT; i > 0; i--) {
                pointsTextObject = GameObject.Instantiate(GameRules.instance.pointsTextPrefab);
                pointsTextObject.SetActive(false);
                pointsText = pointsTextObject.GetComponent<TextMesh>();
                pointsTextPool.Push(pointsText);
            //}
        }

        //get one from the pool
        pointsText = pointsTextPool.Pop();
        pointsTextObject = pointsText.gameObject;
        pointsTextObject.SetActive(true);
        activePointsTexts.Enqueue(pointsText);

        //reposition
        Vector3 newPosition = target.transform.position;
        Transform cameraTransform = mainCamera.transform;
        newPosition += cameraTransform.up * POINTS_TEXT_CAMERA_UP_SPAWN_MULTIPLIER;
        pointsText.transform.position = newPosition;
        pointsText.transform.localRotation = cameraTransform.rotation;

        //adjust display
        pointsText.text = pointsGiven >= 0 ? "+" + pointsGiven.ToString() : pointsGiven.ToString();
        Color textColor = GameRules.instance.teamTexts[target.team].color;
        textColor.r *= 0.8f;
        textColor.g *= 0.8f;
        textColor.b *= 0.8f;
        textColor.a = 1.0f;
        pointsText.color = textColor;
    }
Esempio n. 34
0
 public void DeregisterPlayer(TeamPlayer tp)
 {
     allPlayers[tp.team].Remove(tp);
 }
Esempio n. 35
0
    public void RegisterPlayer(TeamPlayer tp)
    {
        //fill unused teams in the allPlayers list with nulls as needed
        for (int i = tp.team - allPlayers.Count; i >= 1; i--)
            allPlayers.Add(null);

        //add a new list for the team if one doesn't already exist
        if (allPlayers.Count == tp.team)
            allPlayers.Add(new List<TeamPlayer>());

        allPlayers[tp.team].Add(tp);
    }
Esempio n. 36
0
    public void spawnPointsText(int pointsGiven, TeamPlayer target)
    {
        TextMesh pointsText;
        //if we have too many points texts, yank the oldest one from the queue
        if (activePointsTexts.Count >= MAX_ACTIVE_POINTS_TEXTS)
            pointsText = activePointsTexts.Dequeue();
        //we don't have too many points texts, get one from the pool if there's one available
        else if (pointsTextPool.Count > 0) {
            pointsText = pointsTextPool.Pop();
            pointsText.gameObject.SetActive(true);
        //there are no spare points text objects, make a new one
        } else
            pointsText = Instantiate(GameRules.instance.pointsTextPrefab).GetComponent<TextMesh>();

        activePointsTexts.Enqueue(pointsText);

        //reposition
        Vector3 newPosition = target.transform.position;
        Transform cameraTransform = mainCamera.transform;
        newPosition += cameraTransform.up * POINTS_TEXT_CAMERA_UP_SPAWN_MULTIPLIER;
        pointsText.transform.position = newPosition;
        pointsText.transform.localRotation = cameraTransform.rotation;

        //adjust display
        pointsText.text = pointsGiven >= 0 ? "+" + pointsGiven.ToString() : pointsGiven.ToString();
        Color textColor = GameRules.instance.teamTexts[target.team].color;
        textColor.r *= 0.8f;
        textColor.g *= 0.8f;
        textColor.b *= 0.8f;
        textColor.a = 1.0f;
        pointsText.color = textColor;
    }
        public void AddPlayerToRoster( int seasonId, int teamId, int playerId, bool? goalie )
        {
            if ( seasonId > 0 && teamId > 0 && playerId > 0 )
            {
                var player = ( from p in db.TeamPlayers
                               where p.PlayerId == playerId &&
                                     p.SeasonId == seasonId &&
                                     p.TeamId == teamId
                               select p ).SingleOrDefault<TeamPlayer>();

                if ( player == null )
                {
                    var newPlayer = new TeamPlayer();
                    newPlayer.SeasonId = seasonId;
                    newPlayer.TeamId = teamId;
                    newPlayer.PlayerId = playerId;
                    newPlayer.IsGoalie = ( goalie != null ) ? bool.Parse( goalie.ToString() ) : false;

                    rosterRepository.Add( newPlayer );
                }
            }
        }
Esempio n. 38
0
    private TeamPlayer addPlayer(string controllerAffix)
    {
        int numPlayers = AllPlayers.Count;

        // join team based on join game order. get 1st team if player is odd, get 2nd team if player is even (not tested for 3 or more teams)
        Team theirTeam = Teams[numPlayers % Teams.Count];

        numPlayers++;
        var newPlayer = new TeamPlayer(numPlayers, controllerAffix);
        theirTeam.Players.Add(newPlayer);
        AllPlayers = Teams.SelectMany(t => t.Players).ToList();
        return newPlayer;
    }
Esempio n. 39
0
 public override void handlePlayerCollision(TeamPlayer collidedPlayer)
 {
     if (gameRules == null)
         return;
     gameRules.SendEvent(new GameRuleEvent(GameRuleEventType.Bump, this, collidedPlayer));
     if (dashTimer > 0) {
         //steal the ball
         if (collidedPlayer.carriedBall != null) {
             Ball stolenBall = collidedPlayer.carriedBall;
             if (collidedPlayer.carriedBall.grabBall(this))
                 carriedBall = stolenBall;
         }
         //tackle them
         particles.Play();
         Vector3 tackleVector = transform.forward * tacklePower +
         Vector3.up * tackleLaunchPower;
         collidedPlayer.tackle(tackleVector, tackleDuration);
         gameRules.SendEvent(new GameRuleEvent(GameRuleEventType.Smack, this, collidedPlayer));
     }
     if (dashStopByPlayer) {
         dashTimer = 0;
     }
 }