Example #1
0
        /// <summary>
        /// Initialises the class.
        /// </summary>
        protected new void Start()
        {
            Team = null;
            base.Start();
            ActionRadius = 15;

            GetComponent <Renderer>().material.color = TeamData.GetColor(m_BuildingType);
        }
Example #2
0
        /// <summary>
        /// [PunBehaviour] Gets called when player properties are modified. Updates the ui corresponding to the new properties.
        /// </summary>
        public override void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps)
        {
            base.OnPhotonPlayerPropertiesChanged(playerAndUpdatedProps);
            PhotonPlayer player = playerAndUpdatedProps[0] as PhotonPlayer;

            if (player == photonView.owner)
            {
                Hashtable props = playerAndUpdatedProps[1] as Hashtable;
                if (props[RoomTeams.TeamPlayerProp] != null)
                {
                    m_TeamBtn.GetComponent <Image>().color = TeamData.GetColor((TeamID)props[RoomTeams.TeamPlayerProp]);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Gets called when the player is not a local player. Sets up the lobbyplayer behaviour.
        /// </summary>
        private void SetupOtherPlayer()
        {
            m_TeamBtn.GetComponent <Image>().color = TeamData.GetColor(photonView.owner.GetTeam());
            m_NameInp.text = photonView.owner.NickName;
            SetReadyButton(m_IsReady);

            if (PhotonNetwork.player.IsMasterClient)
            {
                m_KickPlayerBtn.gameObject.SetActive(true);
                m_KickPlayerBtn.onClick.AddListener(() => {
                    PhotonNetwork.CloseConnection(photonView.owner);
                });
            }
        }
Example #4
0
        /// <summary>
        /// Initialises the class.
        /// </summary>
        protected new void Start()
        {
            GetComponent <MeshRenderer>().material.color = TeamData.GetColor(m_Team);
            transform.SetParent(GameManager.s_Singleton.Teams[(byte)m_Team - 1].transform, false);
            transform.GetChild(0).GetComponent <TextMesh>().text = photonView.owner.NickName;
            ActionRadius = 40;

            //instantiate list with 3 numbers for each list.

            for (int i = 0; i < 3; i++)
            {
                m_LegalItems.Add(0);
                m_IllegalItems.Add(0);
            }
        }
Example #5
0
    /// <summary>
    /// Gets called when the GameObject becomes active. Creates the scoreboard and calls sorting of teams.
    /// </summary>
    private void OnEnable()
    {
        SortTeams();

        for (int i = 0; i < m_TeamOrder.Count; i++)
        {
            GameObject scoreEntryInstance = Instantiate(m_ScoreEntryPrefab);
            scoreEntryInstance.transform.SetParent(m_Content, false);
            scoreEntryInstance.transform.FindChild("Place").GetComponent <Text>().text  = (i + 1).ToString();
            scoreEntryInstance.transform.FindChild("Team").GetComponent <Image>().color = TeamData.GetColor(m_TeamOrder[i].TeamID);
            scoreEntryInstance.transform.FindChild("Money").GetComponent <Text>().text  = m_TeamOrder[i].TotalMoney.ToString();
        }
    }
Example #6
0
 /// <summary>
 /// Initialises the class before Start.
 /// </summary>
 protected void Awake()
 {
     gameObject.GetComponent <Renderer>().material.color = TeamData.GetColor(m_DistrictType);
 }
Example #7
0
        /// <summary>
        /// Gets called every frame. Handles the capturing of the square.
        /// </summary>
        private void Update()
        {
            int    totalPlayers    = 0;
            int    mostPlayers     = 0;
            TeamID mostPlayersTeam = TeamID.NotSet;

            // Check which team has the most players
            for (int i = 0; i < m_PlayersOnPoint.Length; i++)
            {
                totalPlayers += m_PlayersOnPoint[i];
                if (m_PlayersOnPoint[i] > mostPlayers)
                {
                    mostPlayers     = m_PlayersOnPoint[i];
                    mostPlayersTeam = (TeamID)i + 1;
                }
            }

            // If there are players calculate the difference between the next team with the most players.
            if (mostPlayers > 0)
            {
                int competingPlayers    = totalPlayers - mostPlayers;
                int mostPlayersTeamDiff = mostPlayers - competingPlayers;

                // If the capturing team has a majority capturing begins
                if (mostPlayersTeamDiff > 0)
                {
                    // Reverse capturing progress competing team
                    if (mostPlayersTeam != m_CapturingTeam)
                    {
                        m_CapturingAmount -= Time.deltaTime * mostPlayersTeamDiff * m_CaptureMultiplier;
                        if (m_CapturingAmount <= 0)
                        {
                            m_CapturingTeam = mostPlayersTeam;
                        }
                    }
                    // Progress capturing of capturing team
                    else if (Team != mostPlayersTeam)
                    {
                        m_CapturingAmount += Time.deltaTime * mostPlayersTeamDiff * m_CaptureMultiplier;
                        m_CapturingTeam    = mostPlayersTeam;
                    }

                    // If fully captured update team, team data and show notification.
                    if (m_CapturingAmount >= 100)
                    {
                        if (Team != TeamID.NoTeam)
                        {
                            GameManager.s_Singleton.Teams[(int)Team - 1].AddOrRemoveDistrict(-1);
                        }
                        Team = m_CapturingTeam;
                        transform.parent.GetComponent <CapturableDistrict>().Team = m_CapturingTeam;
                        GameManager.s_Singleton.DistrictManager.DestroyCapturingNotification();
                        InGameUIManager.s_Singleton.LogUI.AddToLog(LogUI.m_WasCaptured, new object[] { this.name, Team });
                        m_CapturingAmount = 0;
                        GameManager.s_Singleton.Teams[(int)Team - 1].AddOrRemoveDistrict(1);
                    }
                }

                // Update the capturing notification progress.
                if (GameManager.s_Singleton.DistrictManager.CurrentCapturePoint == this && (int)Mathf.Round(m_CapturingAmount) != 0)
                {
                    GameManager.s_Singleton.DistrictManager.GenerateCapturingNotification();
                    GameManager.s_Singleton.DistrictManager.CapturingNotification.SetColor(TeamData.GetColor(Team), TeamData.GetColor(m_CapturingTeam));
                    GameManager.s_Singleton.DistrictManager.CapturingNotification.SetProgress(m_CapturingAmount / 100);
                }
            }

            // Destroy the capturing notification when no longer on capture point.
            if (GameManager.s_Singleton.DistrictManager.CurrentCapturePoint == null)
            {
                GameManager.s_Singleton.DistrictManager.DestroyCapturingNotification();
            }
        }
Example #8
0
 /// <summary>
 /// Initialises the class.
 /// </summary>
 private void Start()
 {
     m_TeamColor.color = TeamData.GetColor(Stadsspel.Networking.TeamExtensions.GetTeam(PhotonNetwork.player));
 }
Example #9
0
        /// <summary>
        /// Handles the change of team.
        /// </summary>
        protected virtual void OnTeamChanged()
        {
            Color newColor = TeamData.GetColor(m_Team);

            gameObject.GetComponent <Renderer>().material.color = newColor;
        }