Exemple #1
0
        public void Enable()
        {
            text = GetComponent <Text>();
            GameController.Instance.EventLifeChanged   += PlayerLifeChanged;
            GameController.Instance.EventDamageChanged += PlayerDamageChanged;

            GameController.Instance.PlayersInitialized += players => {
                if (player >= players.Length)
                {
                    return;
                }
                var p = players[player];
                if (p.eTeam == -1)
                {
                    text.color = Color.white;
                }
                else
                {
                    text.color = TeamColor.FromIndex(p.eTeam, false);
                }
                lives  = p.eLives;
                damage = p.eDamage;
                UpdateInfo();
            };
        }
Exemple #2
0
        /// Callback when the game is started and player display names are set.
        void Init(Player[] players)
        {
            this.players = players;
            var i = 0;

            while (i < players.Length)
            {
                if (players[i].eTeam == -1)
                {
                    panels[i].GetComponent <Image>().color = Color.black.WithAlpha(0.4f);
                }
                else
                {
                    panels[i].GetComponent <Image>().color = TeamColor.FromIndex(players[i].eTeam, true).WithAlpha(0.4f);
                }
                labels[i].text = players[i].eDisplayName;
                i++;
            }
            while (i < panels.Length)
            {
                Destroy(panels[i].gameObject);
                Destroy(labels[i].gameObject);
                i++;
            }
        }
Exemple #3
0
        public void GameControllerReady(GameController gameController, IInputManager inputManager)
        {
            // This is called twice on a host - once when the client game
            // starts and once when the server game starts.
            if (pInputManager != null)
            {
                return;
            }

            if (eTeam != -1)
            {
                GetComponent <SpriteOverlay>().SetColor(TeamColor.FromIndex(eTeam));
            }

            pInputManager = inputManager;
            pJoystick     = new JoystickControl(inputManager);

            if (isLocalPlayer)
            {
                var leftButton = GameObject.Find("LeftButton");
                if (leftButton != null)
                {
                    pTouchButtons = leftButton.GetComponent <TouchButtons>();
                }
            }

            if (lRb != null)
            {
                Initialize();
                lInitialized = true;
            }
        }
Exemple #4
0
        void Reinit()
        {
            var spawnedByPlayer = ClientScene.FindLocalObject(spawnedBy).GetComponent <Player>();

            if (spawnedByPlayer.eTeam != -1)
            {
                GetComponent <SpriteOverlay>().SetColor(TeamColor.FromIndex(spawnedByPlayer.eTeam, true));
            }

            StartCoroutine(BurnUp());
        }
Exemple #5
0
        /// Set the team, or if this team is already selected,
        /// unset it.
        void SetTeam(int team)
        {
            if (TransitionParams.team == team)
            {
                TransitionParams.team = -1;
                selected.GetComponent <SpriteOverlay>().SetColorWithAlpha(Color.clear);
                return;
            }

            TransitionParams.team = team;
            selectedColor         = TeamColor.FromIndex(team);
            selected.GetComponent <SpriteOverlay>().SetColor(selectedColor);
        }