Exemple #1
0
        public async Task <ContentResult> TeamLabel(int teamId, int labelId, bool selected)
        {
            using (var cn = _data.GetConnection())
            {
                if (selected)
                {
                    var tl = new TeamLabel()
                    {
                        TeamId = teamId, LabelId = labelId
                    };
                    await cn.MergeAsync(tl, _data.CurrentUser);
                }
                else
                {
                    var tl = await cn.FindWhereAsync <TeamLabel>(new { TeamId = teamId, LabelId = labelId });

                    if (tl != null)
                    {
                        await cn.DeleteAsync <TeamLabel>(tl.Id);
                    }
                }

                var labels = await new TeamLabelsInUseByTeam()
                {
                    OrgId = _data.CurrentOrg.Id, TeamId = teamId
                }.ExecuteAsync(cn);
                return(Content(labels.Count().ToString()));
            }
        }
Exemple #2
0
    public void StartGame(List <SeedManager.CarConfiguration> controllers)
    {
        int teamCount = controllers.Count;

        startScreenPanel.SetActive(false);
        thirdPlayerCover.SetActive(teamCount == 3);
        team = controllers;
        startScreenPanel.SetActive(false);
        teamParent.gameObject.SetActive(true);

        teamCounter.Clear();

        //Calculate screen pct
        float widtDelta     = (teamCount > 1) ? 0.5f : 1f;
        int   verticalCount = Mathf.CeilToInt(teamCount / 2f);
        float heightDelta   = 1.0f / verticalCount;


        for (int i = 0; i < teamCount; i++)
        {
            GameObject toAssingn = GameObject.Instantiate(teamPrefab);
            //Image image = toAssingn.GetComponent<Image>();
            Color teamColor = team[i].carController.currentColor;
            teamColor.a = alphaTeam;

            TeamLabel label = toAssingn.GetComponent <TeamLabel>();
            label.Reset(teamColor);
            //TMPro.TMP_Text text = toAssingn.GetComponentInChildren<TMPro.TMP_Text>();

            teamCounter.Add(i, label);
            toAssingn.SetActive(true);
            toAssingn.transform.SetParent(teamParent);

            //Position calculation
            int horizontalIndex = (i % 2);
            int verticalIndex   = Mathf.FloorToInt((teamCount - i - 1) / 2f);
            //Rect is defined by 4 points(corners) or by starting points and rect. The second one will be easier
            float startingX = horizontalIndex * widtDelta;
            float startingY = verticalIndex * heightDelta;

            RectTransform rectTransform = toAssingn.GetComponent <RectTransform>();
            rectTransform.anchorMin = new Vector2(startingX, startingY);
            rectTransform.anchorMax = new Vector2(startingX + widtDelta, startingY + heightDelta);
            rectTransform.offsetMin = Vector2.zero;
            rectTransform.offsetMax = Vector2.zero;
        }
        isGamePlaying = true;
    }