Пример #1
0
        /// <summary>
        /// Starts the game for the DistrictManager for a given amount of teams.
        /// </summary>
        public void StartGame(int amountOfTeams)
        {
            m_DistrictColliders = new PolygonCollider2D[gameObject.transform.childCount];
            for (int i = 0; i < gameObject.transform.childCount; i++)
            {
                m_DistrictColliders[i] = gameObject.transform.GetChild(i).gameObject.GetComponent <PolygonCollider2D>();
            }

            // Loops trough all district groups and allocates the teams and types.
            for (int i = 0; i < transform.childCount; i++)
            {
                Transform          child = transform.GetChild(i);
                CapturableDistrict cd    = child.GetComponent <CapturableDistrict>();
                if (cd != null)
                {
                    int  teamIndex    = CurrentGame.Instance.GetTeamIndex(transform.GetChild(i).gameObject.name);
                    bool mainDistrict = CurrentGame.Instance.isHeadDistrict(transform.GetChild(i).gameObject.name);

                    if (transform.GetChild(i).gameObject.name.Equals("4a", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Debug.Log("DSITRICT FOUND");
                    }

                    //find team if any
                    ServerTeam team = null;
                    if (teamIndex >= 0)
                    {
                        team = CurrentGame.Instance.gameDetail.GetTeamByIndex(teamIndex);
                    }

                    //check for main district and assign
                    if (mainDistrict)
                    {
                        HeadDistrict district = transform.GetChild(i).gameObject.GetComponent <HeadDistrict>();
                        district.Team    = team;
                        district.enabled = true;
                        m_HeadDistricts.Add(district);
                        Destroy(district.GetComponent <CapturableDistrict>());
                        Treasure square = district.transform.GetChild(0).gameObject.GetComponent <Treasure>();
                        square.Team    = team;
                        square.enabled = true;
                        Destroy(district.transform.GetChild(0).GetComponent <CapturePoint>());
                    }
                    else
                    {
                        CapturableDistrict district = transform.GetChild(i).gameObject.GetComponent <CapturableDistrict>();
                        district.Team    = team;
                        district.enabled = true;
                        Destroy(district.GetComponent <HeadDistrict>());
                        CapturePoint square = district.transform.GetChild(0).gameObject.GetComponent <CapturePoint>();
                        square.Team    = team;
                        square.enabled = true;
                        Destroy(district.transform.GetChild(0).GetComponent <Treasure>());
                        district.OnTeamChanged();
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Handles the transitioning between the districts.
        /// </summary>
        private void HandleDistrictChange(GameObject oldDistrict, GameObject newDistrict)
        {
            m_CurrentCapturePoint = null;
            if (oldDistrict)
            {
                CapturePoint capturePointOld = oldDistrict.GetComponent <CapturePoint>();
                if (capturePointOld)
                {
                    capturePointOld.photonView.RPC("RemovePlayerOnPoint", PhotonTargets.All, m_PlayerTrans.GetComponent <Person>().Team);
                }
            }

            CapturePoint capturePointNew = newDistrict.GetComponent <CapturePoint>();

            if (capturePointNew)
            {
                m_CurrentCapturePoint = capturePointNew;
                capturePointNew.photonView.RPC("AddPlayerOnPoint", PhotonTargets.All, m_PlayerTrans.GetComponent <Person>().Team);
            }
        }
Пример #3
0
        /// <summary>
        /// Handles the transitioning between the districts.
        /// </summary>
        private void HandleDistrictChange(GameObject oldDistrict, GameObject newDistrict)
        {
            m_CurrentCapturePoint = null;
            if (oldDistrict)
            {
                CapturePoint capturePointOld = oldDistrict.GetComponent <CapturePoint>();
                if (capturePointOld)
                {
                    capturePointOld.RemovePlayerOnPoint(m_PlayerTrans.GetComponent <Person>().Team.teamName);
                }
            }

            CapturePoint capturePointNew = newDistrict.GetComponent <CapturePoint>();

            if (capturePointNew)
            {
                m_CurrentCapturePoint = capturePointNew;
                capturePointNew.AddPlayerOnPoint(m_PlayerTrans.GetComponent <Person>().Team.teamName);
            }
        }
Пример #4
0
        /// <summary>
        /// Starts the game for the DistrictManager for a given amount of teams.
        /// </summary>
        public void StartGame(int amountOfTeams)
        {
            m_DistrictColliders = new PolygonCollider2D[gameObject.transform.childCount];
            for (int i = 0; i < gameObject.transform.childCount; i++)
            {
                m_DistrictColliders[i] = gameObject.transform.GetChild(i).gameObject.GetComponent <PolygonCollider2D>();
            }

            // Loops trough all district groups and allocates the teams and types.
            for (int i = 1; i <= 6; i++)
            {
                if (amountOfTeams >= i)
                {
                    HeadDistrict district = transform.GetChild(i).gameObject.GetComponent <HeadDistrict>();
                    district.Team    = (TeamID)(i);
                    district.enabled = true;
                    m_HeadDistricts.Add(district);
                    Destroy(district.GetComponent <CapturableDistrict>());
                    Treasure square = district.transform.GetChild(0).gameObject.GetComponent <Treasure>();
                    square.Team    = (TeamID)(i);
                    square.enabled = true;
                    Destroy(district.transform.GetChild(0).GetComponent <CapturePoint>());
                }
                else
                {
                    CapturableDistrict district = transform.GetChild(i).gameObject.GetComponent <CapturableDistrict>();
                    district.Team    = TeamID.NoTeam;
                    district.enabled = true;
                    Destroy(district.GetComponent <HeadDistrict>());
                    CapturePoint square = district.transform.GetChild(0).gameObject.GetComponent <CapturePoint>();
                    square.Team    = TeamID.NoTeam;
                    square.enabled = true;
                    Destroy(district.transform.GetChild(0).GetComponent <Treasure>());
                }
            }
        }