/// <summary> /// Initialises the result display with all required data /// </summary> /// <param name="points">List of items the player picked up</param> /// <param name="playerName">Name of the player</param> /// <param name="playerIndex">Index of the player</param> /// <param name="died">Whether the player died</param> /// <param name="characterindex">Index of the character being used</param> internal void Initialise(List <int> points, string playerName, int playerIndex, bool died, int characterindex, Action <int> addPointsCallback) { Rocket.color = ColourFetcher.GetColour(playerIndex); _values = points; TxtPlayerName.text = playerName; Player.sprite = CharacterImages[characterindex]; _pointsCallback = addPointsCallback; _playerIndex = playerIndex; // if the player died, disable the rocket if (died) { _moveSpeed = 0; Rocket.transform.eulerAngles = Vector3.zero; // hide it Rocket.gameObject.SetActive(false); TxtPlayerName.text = ""; TxtScore.text = ""; _complete = true; } if (points.Count == 0) { _moveSpeed = 0; _complete = true; } }
void SpawnPlayers_() { // loop through all players float left = START_LEFT; int index = 0; foreach (var player in PlayerManagerScript.Instance.GetPlayers()) { // switch to use an input handler suitable for this scene player.SetActiveScript(typeof(GameCentralInputHandler)); // create the "visual" player var spawned = player.Spawn(PlayerPrefab, new Vector2(left, -5.5f)); // move to next position left += POSITION_GAP; // get the latest points player.UpdatePoints(); // display player info NameTexts[player.PlayerInput.playerIndex].text = player.GetPlayerName(); ScoreTexts[player.PlayerInput.playerIndex].text = player.GetPoints().ToString(); Plinths[index].GetComponentsInChildren <SpriteRenderer>()[1].color = ColourFetcher.GetColour(index); Plinths[index++].SetActive(true); } }
/// <summary> /// Displays the round data for the player /// </summary> /// <param name="player"></param> public void SetDisplay(MineGamesInputHandler player) { // display values TxtPlayerName.text = player.GetPlayerName(); TxtTotalPoints.text = player.GetRoundPoints().ToString(); ColouredImage.color = ColourFetcher.GetColour(player.GetPlayerIndex()); ImgProfile.sprite = MineGamesController.Instance.PlayerIcons[player.GetCharacterIndex()]; // group items by type var grouped = player.GetResultList().GroupBy(p => p).ToList(); for (int i = 0; i < grouped.Count(); i++) { var data = grouped[i].Key; var split = data.Split('@'); var value = int.Parse(split[0]); var totalValue = value * grouped[i].Count(); // display summaries BreakdownPoints[i].text = totalValue.ToString(); BreakdownPointsDescriptions[i].text = split[1]; } // hide unused controls for (int i = grouped.Count(); i < BreakdownPointsDescriptions.Count(); i++) { BreakdownPoints[i].text = ""; BreakdownPointsDescriptions[i].text = ""; } }
/// <summary> /// Sets the values to display /// </summary> /// <param name="pl">The player info to display</param> internal void Initialise(FollowBackInputHandler pl) { TxtNumFollowers.text = pl.GetFollowerCount().ToString(); TxtPlayerName.text = "@" + pl.GetPlayerName(); PlayerSprite.sprite = FollowBackController.Instance.CharacterSprites[pl.GetCharacterIndex()]; PlayerSpriteBg.color = ColourFetcher.GetColour(pl.GetPlayerIndex()); PlayerSpriteBgRing.color = ColourFetcher.GetColour(pl.GetPlayerIndex()); }
public void SetColour(string name, int playerIndex) { TxtPlayerName.text = name; foreach (var img in ColourImages) { img.color = ColourFetcher.GetColour(playerIndex); } }
/// <summary> /// Player is deselected /// </summary> public void Deselected() { SelectionBackground.SetActive(false); var colour = PlayerIndex < 4 ? ColourFetcher.GetColour(PlayerIndex) : new Color(0.392f, 0.067f, 0.745f); GuidText.color = colour; PlayerCircle.color = colour; }
/// <summary> /// Delay the UI loading for player preview until the swoosh has cleared /// </summary> /// <returns></returns> IEnumerator DelayedUiShow_() { yield return(new WaitForSeconds(0.9f)); PlayerUi.SetActive(true); PlayerUiPlayerColour.color = ColourFetcher.GetColour(_activePlayerIndex); PlayerUiPlayerName.text = _players[_activePlayerIndex].GetPlayerName(); PlayerUiBehindLeader.text = "First shot"; }
/// <summary> /// Randomly selects an influencer from list of players who are yet to have all their turns /// </summary> private IEnumerator SelectInfluencer_() { // briefly wait yield return(new WaitForSeconds(3)); // clear round counts foreach (var pl in _players) { pl.NewRound(); } ResetSpriteImage_(); // show trending panel TrendingPanel.SetActive(true); // flick through each player for (int i = 0; i < 50; i++) { TxtTrendingMessage.text = "@" + _players[i % _players.Count].GetPlayerName(); ImgInfluencer.sprite = CharacterSprites[_players[i % _players.Count].GetCharacterIndex()]; ImgInfluencerBG.color = ColourFetcher.GetColour(i % _players.Count); yield return(new WaitForSeconds(0.1f)); } // ensure the list is empty _playersInZone.Clear(); // pick a random player var r = UnityEngine.Random.Range(0, _remainingTurns.Count); _currentInfluencer = _players[_remainingTurns[r]]; _remainingTurns.RemoveAt(r); // display selection TxtTrendingMessage.text = "@" + _currentInfluencer.GetPlayerName(); ImgInfluencer.sprite = CharacterSprites[_currentInfluencer.GetCharacterIndex()]; ImgInfluencerBG.color = ColourFetcher.GetColour(_currentInfluencer.GetPlayerIndex()); // show zone InfluencerZone.gameObject.SetActive(true); InfluencerZone.SetParent(_currentInfluencer.MovementObject()); InfluencerZone.localPosition = new Vector3(0, 0, 2f); // increase size StartCoroutine(GrowZone_()); // start timer _turnLimit.StartTimer(); _turnRunning = true; StartCoroutine(CheckZone_()); }
/// <summary> /// Sets the colour of the display /// </summary> /// <param name="playerIndex">Index of the player</param> /// <param name="plName">Name of the player</param> public void SetColour(int playerIndex, string plName) { _normalColour = ColourFetcher.GetColour(playerIndex); ColourPanel.color = _normalColour; TxtName.text = plName; // selfie noise setup _splashNoise = (AudioSource)gameObject.AddComponent(typeof(AudioSource)); _splashNoise.clip = MarshLandController.Instance.SplashSound; _splashNoise.volume = 1f; }
IEnumerator DisplayMessage_(string message, int playerColour) { _particleModule.startColor = ColourFetcher.GetColour(playerColour); BvSignText.text = message; BvSignImage.color = ColourFetcher.GetColour(playerColour); yield return(new WaitForSeconds(2f)); BvSignImage.color = _particleColour; BvSignText.text = "BILL VALIDATOR"; _particleModule.startColor = _particleColour; }
/// <summary> /// Set the rock to be specific to one player /// </summary> /// <param name="playerIndex">THe index of the player</param> public void SetPlayerIndex(int playerIndex) { // sets the colour ColourRenderer.gameObject.SetActive(true); var col = ColourFetcher.GetColour(playerIndex); ColourRenderer.color = new Color(col.r, col.g, col.b, .8f); // esnure this player cannot be hit gameObject.name = "Rock" + playerIndex; }
/// <summary> /// Initialises the pause popups /// </summary> /// <param name="players">The list of players involved in the game</param> public void Initialise(List <GenericInputHandler> players, Action quitCallback) { _quitCallback = quitCallback; // loop through the players and configure the pause request messages for (int i = 1; i < players.Count; i++) { // update the colour and the name on the popup PausePopups[i - 1].GetComponentsInChildren <Image>()[1].color = ColourFetcher.GetColour(i); PausePopups[i - 1].GetComponentInChildren <Text>().text = players[i].GetPlayerName() + " requested a pause"; } }
/// <summary> /// Shows the details of the current player /// </summary> private void DisplayActivePlayer_() { // display image TxtActivePlayer.text = _players[_activePlayerIndex].GetPlayerName(); ImgCharacterImage.sprite = PlayerIcons[_players[_activePlayerIndex].GetCharacterIndex()]; // set colour of images foreach (var img in ColouredImages) { img.color = ColourFetcher.GetColour(_activePlayerIndex); } }
/// <summary> /// Sets the display /// </summary> /// <param name="player">The player to display</param> internal void SetValues(GenericInputHandler player) { TxtOverallScore.text = player.GetPoints().ToString(); TxtBonusScore.text = "+" + player.GetBonusPoints().ToString(); TxtOriginalScore.text = (player.GetPoints() - player.GetBonusPoints()).ToString(); TxtName.text = player.GetPlayerName(); ImgPlayerImage.sprite = PlayerIcons[player.GetCharacterIndex()]; ImgBackground.color = ColourFetcher.GetColour(player.GetPlayerIndex()); if (player.GetBonusPoints() == 0) { TxtBonusScore.text = ""; } }
/// <summary> /// Links a player to this segment /// </summary> /// <param name="playerIndex">The index of the player that the segment belongs to</param> /// <param name="playerName">The name of the player that the segment belongs to</param> internal void Initialise(int playerIndex, string playerName) { // set index _playerIndex = playerIndex; // display name on segment GetComponentInChildren <TextMesh>().text = playerName; // get the colour for this player _colour = ColourFetcher.GetColour(playerIndex); // set the colour of the segment _spriteRenderer = GetComponent <SpriteRenderer>(); _spriteRenderer.color = _colour; }
// TODO: code for swapping positions /// <summary> /// Initialises the player display with the correct data /// </summary> /// <param id="playerName">The name of the player</param> /// <param id="playerIndex">The index of the player</param> public void Initialise(string playerName, int playerIndex) { // display player info TxtPlayerName.text = playerName.Substring(0, 3); PlayerColourImage.color = ColourFetcher.GetColour(playerIndex); // no laps at start TxtLaps.text = "0"; // these are not seen at the start BestLap.SetActive(false); PowerUpIconBackground.SetActive(false); TxtBestLap.text = "00:00.000"; }
/// <summary> /// Drops a pin /// </summary> IEnumerator DropPin_() { // briefly delay yield return(new WaitForSeconds(0.25f)); // drop pin at current point var created = Instantiate(PinPrefab, transform.position, Quaternion.identity); created.GetComponentsInChildren <SpriteRenderer>()[1].color = ColourFetcher.GetColour(_playerIndex); // can pass through briefly (gives time for car to drive away) created.GetComponent <Collider2D>().isTrigger = true; yield return(new WaitForSeconds(0.1f)); created.GetComponent <Collider2D>().isTrigger = false; }
/// <summary> /// Shows the UI on the player preview /// </summary> private IEnumerator ShowPlayerUi_() { // wait for the swoosh to finish yield return(new WaitForSeconds(0.9f)); var activeScore = 0; var highScore = 0; var index = 0; // loop through all players foreach (var player in PlayerScores) { // add up all points var score = 0; foreach (var control in player.RoundTotalScores) { score += control.GetValue(); } // display points player.TxtTotalScore.text = score.ToString(); // if this is the current player, store their score if (index == _activePlayerIndex) { activeScore = score; } // keep a record of the highest score if (score > highScore) { highScore = score; } index++; } // display player info var leaderText = (highScore - activeScore) <= 0 ? "Current Leader" : (highScore - activeScore) + " points behind leader"; PlayerUi.SetActive(true); PlayerUiPlayerColour.color = ColourFetcher.GetColour(_activePlayerIndex); PlayerUiPlayerName.text = _players[_activePlayerIndex].GetPlayerName(); PlayerUiBehindLeader.text = leaderText; _showingCharacter = true; }
/// <summary> /// Initialises the display /// </summary> /// <param name="player">The player that this relates to</param> /// <param name="message">The message to show</param> public void Initialise(FollowBackInputHandler player, string message) { TxtDescription.text = message; if (player != null) { ImgPlayerImageBG.gameObject.SetActive(true); ImgPlayerImage.sprite = FollowBackController.Instance.CharacterSprites[player.GetCharacterIndex()]; ImgPlayerImageBG.color = ColourFetcher.GetColour(player.GetPlayerIndex()); } else { ImgPlayerImageBG.gameObject.SetActive(false); } gameObject.SetActive(true); Initialised = true; }
/// <summary> /// Called when the object is created /// </summary> void Start() { DontDestroyOnLoad(this); // get the necessary components _device = PlayerInput.devices.FirstOrDefault(); _activeHandler = GetComponent <LobbyInputHandler>(); // work out which colour to assign to this player _colour = ColourFetcher.GetColour(PlayerInput.playerIndex); // display the player on UI UpdateMenu(); // sets the colour on dualshock controls SetLightbarColour_(); }
/// <summary> /// Finds the paddles assigned to this player /// </summary> public void AssignPaddles(int playerIndex) { // fetch paddles associated with the player _paddles = FindObjectsOfType <PaddleScript>().Where(t => t.gameObject.name == "PADDLE_" + playerIndex).ToArray(); // link to trolley, and show it _trolley = ShopDropController.Instance.Trolleys[playerIndex]; _trolley.gameObject.SetActive(true); var imgs = _trolley.GetComponentsInChildren <SpriteRenderer>(); // set the colour of the trolley for (int i = 1; i < imgs.Count(); i++) { if (!imgs[i].gameObject.name.ToLower().Contains("shadow")) { imgs[i].color = ColourFetcher.GetColour(GetPlayerIndex()); } } }
/// <summary> /// Called when object is created /// </summary> private void Start() { // we want this to stay DontDestroyOnLoad(this); // easy access to this item Instance = this; // loop through the players and configure the pause request messages for (int i = 0; i < PausePopups.Length; i++) { // update the colour and the name on the popup PausePopups[i].GetComponentsInChildren <Image>()[1].color = ColourFetcher.GetColour(i); } EndFader.StartFade(1, 0, null); // load values _profileHandler.Initialise(); }
/// <summary> /// Displays the name and colour of active player /// </summary> private void DisplayActivePlayer_() { var colour = ColourFetcher.GetColour(_players[_activePlayerIndex].GetPlayerIndex()); TxtActivePlayerName.text = _players[_activePlayerIndex].GetPlayerName(); ActivePlayerColour.color = colour; Arrow.GetComponentInChildren <SpriteRenderer>().color = colour; // display the player PlayerAnimator.runtimeAnimatorController = PlayerAnimatorControllers[_players[_activePlayerIndex].GetCharacterIndex()]; PlayerShadowAnimator.runtimeAnimatorController = PlayerAnimatorControllers[_players[_activePlayerIndex].GetCharacterIndex()]; // display other players in the background var currentIndex = _activePlayerIndex + 1; if (currentIndex >= _players.Count) { currentIndex = 0; } for (int i = 0; i < PlayerBGAnimator.Length; i++) { PlayerBGAnimator[i].runtimeAnimatorController = PlayerAnimatorControllers[_players[currentIndex].GetCharacterIndex()]; PlayerBGShadowAnimator[i].runtimeAnimatorController = PlayerAnimatorControllers[_players[currentIndex].GetCharacterIndex()]; currentIndex++; if (currentIndex >= _players.Count) { currentIndex = 0; } } SetAnimators_("Idle"); // display player active colour for (int i = 0; i < PlayerScores.Count(); i++) { PlayerScores[i].ImgActiveOverlay.SetActive(i == _activePlayerIndex); } }
/// <summary> /// Called once on startup /// </summary> private void Start() { // get the Chef corresponding to this player Chef = LicenseToGrillController.Instance.Chefs[GetPlayerIndex()]; Chef.gameObject.SetActive(true); // set appearance of items which change colour based on player Chef.ChoppingBoardColour.color = ColourFetcher.GetColour(GetPlayerIndex()); Chef.SelectionHandColour.color = ColourFetcher.GetColour(GetPlayerIndex()); // create order list _customerHandler = new CustomerHandler(); Chef.DisplayOrders(_customerHandler.GetNextOrders(5)); // assign callbacks for when the selection hand enters a trigger, and when an action is complete Chef.AddItemSelectionCallbacks(TriggerEntered_, TriggerExited_); Chef.AssignActionCallback(UpdateAction_); // store position of the sauce bottles _saucesYPosition = Chef.SauceBottles[0].localPosition.y; _saucePlatformSize = Chef.SaucePlatform.transform.localScale; }
/// <summary> /// Assigns players to each paddle /// </summary> void SetZones_() { int playerIndex = 0; // find all paddles GameObject[] zones = GameObject.FindGameObjectsWithTag("AreaTrigger"); zones = zones.OrderBy(p => UnityEngine.Random.Range(0, 10)).ToArray(); // loop through each paddle for (int i = 0; i < zones.Length; i++) { // assign to current player, and set colour accordingly zones[i].name = "AREA_" + playerIndex; zones[i].GetComponentInChildren <SpriteRenderer>().color = ColourFetcher.GetColour(playerIndex); // move to the next player, and loop around if at end playerIndex++; if (playerIndex >= PlayerManagerScript.Instance.GetPlayers().Count) { playerIndex = 0; } } }
/// <summary> /// Spawn players in menu /// </summary> private void SpawnPlayers_() { int index = 0; // don't show wins stats if there is only one player var showWins = PlayerManagerScript.Instance.GetPlayerCount() > 1; // loop through all players foreach (var player in PlayerManagerScript.Instance.GetPlayers()) { // add a win to the player if the previous handler was marked as a win var win = player.GetComponent <GenericInputHandler>()?.IsWinner(); if (win == true) { player.AddWin(); } // switch to use an input handler suitable for this scene player.SetActiveScript(typeof(QuickPlayInputHandler)); // needed to set up player index player.Spawn(null, Vector3.zero); // create display var display = Instantiate(PlayerDetailPrefab, PlayerDetailHolder); // update UI var script = display.GetComponent <QPPlayerDisplayScript>(); script.ImgBackground.color = ColourFetcher.GetColour(index); script.ImgPlayer.sprite = PlayerIcons[player.GetCharacterIndex()]; script.TxtPlayerName.text = player.GetPlayerName(); script.TxtPlayerWins.text = player.GetWinCount() + " win" + (player.GetWinCount() == 1 ? "" : "s"); // "win" for 1 win, "wins" for the rest script.TxtPlayerWins.gameObject.SetActive(showWins); index++; } }
internal void SetColour(int playerIndex) { ColouredPart.color = ColourFetcher.GetColour(playerIndex); name = "PADDLE_" + playerIndex; }
/// <summary> /// Sets the values of the burger /// </summary> /// <param name="customer">The complaints</param> /// <param name="tip">How much top was given</param> /// <param name="totalScore">Score achieved for this burger</param> /// <param name="playerIndex">Index of the player who made the burger</param> internal void Initialise(List <BurgerComplaint> complaints, int tip, int totalScore, int playerIndex, string customerName) { Sprite bread = null; _complaints = complaints; // display tip for (int i = 0; i < TipsRenderers.Length; i++) { TipsRenderers[i].gameObject.SetActive((tip) >= ((i + 1) * 10)); } StarImage.sprite = LicenseToGrillController.Instance.StarImages[((totalScore + 19) / 20)]; ColourBar.color = ColourFetcher.GetColour(playerIndex); TxtCustomerName.text = customerName; // display burger var index = 0; var message = ""; foreach (var item in complaints) { // add to the message if (message.Length > 0) { message += ", "; } message += (message.Length > 0) ? item.ErrorMessage().ToLower() : item.ErrorMessage(); if (item.GetSprite() != null) { // if bread, add both parts if (item.ErrorMessage().ToLower().Contains("bread")) { bread = LicenseToGrillController.Instance.BreadTop[item.GetSpriteIndex()]; } // show the image ElementRenderers[index].sprite = item.GetSprite(); ElementRenderers[index].color = item.GetColour(); ElementRenderers[index].gameObject.SetActive(true); index++; } } // update message if flawless if (complaints.Count == 0) { message = MessageFetcher.GetPerfectBurgerMessage(); } // format message TxtDescription.text = TextFormatter.GetBurgerReviewString(message); // show heading based on score TxtTitle.text = GetHeading_(totalScore); // add second part of bread if (bread) { // show the image ElementRenderers[index].sprite = bread; ElementRenderers[index].color = Color.white; ElementRenderers[index].gameObject.SetActive(true); index++; } // hide unused elements for (; index < ElementRenderers.Length; index++) { ElementRenderers[index].gameObject.SetActive(false); } }
/// <summary> /// Sets the colour of the suit details to match the players colour /// </summary> /// <param name="playerIndex"></param> /// <param name="characterIndex"></param> internal void SetPlayerColour(int playerIndex, int characterIndex) { _playerIndex = playerIndex; _colourDetails.color = ColourFetcher.GetColour(playerIndex); _playerSprite.sprite = IdleImages[characterIndex]; }
// Start is called before the first frame update void Start() { Instance = this; // fade in EndFader.GetComponentInChildren <Image>().sprite = PlayerManagerScript.Instance.GetFaderImage(); EndFader.StartFade(1, 0, FadeInComplete); // load all jokes - must be done in Start, not constructor (as Resources must be loaded after script starts) _jokeManager = new JokeManager(); // create players SpawnPlayers_(); // find components _cards = FindObjectsOfType <CardScript>(); _players = FindObjectsOfType <PunchlineBlingInputHandler>().OrderBy(p => p.GetPlayerIndex()).ToArray(); // set all players as not active for (int i = 0; i < _players.Length; i++) { _players[i].ActivePlayer(false, 0); } // initialise the notepad texts for (var i = 0; i < NoteBookTexts.Length; i++) { NoteBookTexts[i].text = ""; } // hide end UI PnlTotalPoints.SetActive(false); // configure the points display controls for (int i = 0; i < _players.Length; i++) { var images = PlayerDisplays[i].GetComponentsInChildren <Image>(); images[0].color = ColourFetcher.GetColour(i); images[1].sprite = CharacterIcons[_players[i].GetCharacterIndex()]; // set player name on display var txts = PlayerDisplays[i].GetComponentsInChildren <Text>(); txts[0].text = _players[i].GetPlayerName(); } // hide unused controls for (int i = _players.Length; i < PlayerDisplays.Length; i++) { PlayerDisplays[i].gameObject.SetActive(false); } CreateCards_(); // set up the timers _overallLimit = (TimeLimit)gameObject.AddComponent(typeof(TimeLimit)); _playerLimit = (TimeLimit)gameObject.AddComponent(typeof(TimeLimit)); _overallLimit.Initialise(300, OverallTickCallback, OverallTimeoutCallback); _playerLimit.Initialise(20, PlayerTickCallback, PlayerTimeoutCallback); SpinWheel.Initialise(_players.ToList()); List <GenericInputHandler> genericPlayers = _players.ToList <GenericInputHandler>(); PauseGameHandler.Instance.Initialise(genericPlayers, QuitGame_); }