Ejemplo n.º 1
0
        private void UpdateServerStartButton()
        {
            int[] teams = TeamTracker.GetInstance().GetTeams();
            if (teams[0] == 0 || teams[1] == 0)
            {
                startGameButtonText.text = "Waiting for teams";
                allowServerStart         = false;
                return;
            }

            bool allReady = true;

            foreach (GameObject player in PlayerTracker.GetInstance().GetPlayers())
            {
                if (!player)
                {
                    continue;
                }
                PlayerDataForClients settings = player.GetComponent <PlayerDataForClients>();
                if (!settings.GetIsReadyFlag() && !settings.GetIsServerFlag())
                {
                    allReady = false;
                }
            }

            startGameButtonText.text = allReady ? "Start game" : "Waiting on ready";
            allowServerStart         = allReady;
        }
Ejemplo n.º 2
0
 private void Awake()
 {
     teamTracker      = GetComponent <TeamTracker>();
     playerMovement   = GetComponent <PlayerMovement>();
     weaponController = GetComponentInChildren <WeaponController>();
     health           = GetComponent <Health>();
     health.OnDeathSubscribe(OnDead);
     burstOffset = Random.Range(0.0f, 100f);
 }
Ejemplo n.º 3
0
        // on start instead of awake to make sure it happens afterwards (check if better way)
        public void Start()
        {
            foreach (GameObject player in PlayerTracker.GetInstance().GetPlayers())
            {
                NewLobbyPlayerAdded(player);
            }
            PlayerTracker.GetInstance().OnPlayerAdded   += NewLobbyPlayerAdded;
            PlayerTracker.GetInstance().OnPlayerRemoved += OldLobbyPlayerRemoved;

            TeamTracker.GetInstance().OnTeamChanged += UpdateVersusText;
            TeamTracker.GetInstance().ForceRecount();
        }
Ejemplo n.º 4
0
    void DetectNearTarget()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, viewRadius);

        foreach (Collider c in colliders)
        {
            TeamTracker tt = c.GetComponent <TeamTracker>();

            if (tt != null && c.transform != transform && !teamTracker.CompareTeam(tt))
            {
                if (target == null || Vector3.Distance(target.transform.position, transform.position) > Vector3.Distance(c.transform.position, transform.position))
                {
                    target = c.gameObject;
                }
            }
        }
    }
Ejemplo n.º 5
0
 // Returns true if friendly, false if enemy
 public bool CompareTeam(TeamTracker tt)
 {
     return(CompareTeam(tt.teamID));
 }