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(); }; }
/// 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++; } }
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; } }
void Reinit() { var spawnedByPlayer = ClientScene.FindLocalObject(spawnedBy).GetComponent <Player>(); if (spawnedByPlayer.eTeam != -1) { GetComponent <SpriteOverlay>().SetColor(TeamColor.FromIndex(spawnedByPlayer.eTeam, true)); } StartCoroutine(BurnUp()); }
/// 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); }