예제 #1
0
    Button.ButtonClickedEvent CreateOnButtonPressed(Button b, ContestantData cd)
    {
        Button.ButtonClickedEvent bcevent = new Button.ButtonClickedEvent();

        bcevent.AddListener(() => {
            b.interactable = false;

            Team t = holder.Keys.ToList()[currentTeamIndex];
            t.AddContestant(cd);

            b.transform.SetParent(holder[t], worldPositionStays: true);
            b.transform.localPosition = new Vector3(0f, -t.Contestants.Count * (b.GetComponent <RectTransform>().rect.height * 0.25f));

            b.GetComponent <TeamSelectorButton>().originalChildPosition = b.transform.GetSiblingIndex();
            b.GetComponent <TeamSelectorButton>().active = true;

            ColorBlock cb    = b.colors;
            cb.disabledColor = t.Color;
            b.colors         = cb;

            CheckEndOfList();
        });

        return(bcevent);
    }
예제 #2
0
    void Start()
    {
        if (instance != null)
        {
            Debug.LogError("There should not be more than one team manager");
        }

        instance = this;

        teamsInMatch = new Dictionary <Team, int> ();


        GameObject teamSelectionData = GameObject.Find("Team Selection Data");

        if (teamSelectionData != null)
        {
            List <Team> createdTeams = teamSelectionData.GetComponent <TeamTransfer>().Teams;

            foreach (Team t in createdTeams)
            {
                teamsInMatch [t] = 0;
            }
        }
        else
        {
            //this is the testing case for when there was no selection
            Debug.Log("testing case");

            Team one = new Team("Team 1", Color.red, new Sprite());
            Team two = new Team("Team 2", Color.blue, new Sprite());

            one.AddContestant(new ContestantData("R", 8f, 1f, 1f, 1));
            one.AddContestant(new ContestantData("R", 8f, 1f, 1f, 1));
            one.AddContestant(new ContestantData("R", 8f, 1f, 1f, 1));
            two.AddContestant(new ContestantData("R", 8f, 1f, 1f, 1));
            two.AddContestant(new ContestantData("R", 8f, 1f, 1f, 1));
            two.AddContestant(new ContestantData("R", 8f, 1f, 1f, 1));

            teamsInMatch [one] = 0;
            teamsInMatch [two] = 0;
        }
    }