public void BuyDevelopmentCardsButtonPress() { action = ActionCode.BUY_DEVELOPMENT_CARD; // Set up the status panel. TextMeshProUGUI popupText = statusPanel.transform.GetChild(0).gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>(); popupText.text = "One development card costs 1x" + ColourUtility.GetResourceText(Inventory.UnitCode.GRAIN) + ", 1x" + ColourUtility.GetResourceText(Inventory.UnitCode.ORE) + ", and 1x" + ColourUtility.GetResourceText(Inventory.UnitCode.WOOL) + ".\n"; if (!deck.IsEmpty()) { if (inventory.CanBuyDevelopmentCard()) { popupText.text += "<color=green>You have enough resources to buy a development card.</color>"; confirmButton.interactable = true; } else { popupText.text += "<color=red>You do not have enough resources to buy a development card.</color>"; confirmButton.interactable = false; } } else { popupText.text += "<color=red>The development card deck is empty.</color>"; confirmButton.interactable = false; } // Open panel. statusPanel.SetActive(true); }
public static Color HSL2BlueGreen(double h, double sl, double l) { double new_h = (1 - h) * (ColourUtility.lowestBlue - ColourUtility.highestGreen) + highestGreen; Color rgb = ColourUtility.HSL2RGB(new_h, sl, l); return(rgb); }
public static Color HSL2PurpleRed(double h, double sl, double l) { double new_h = h * (ColourUtility.lowestPurple); Color rgb = ColourUtility.HSL2RGB(new_h, sl, l); return(rgb); }
public static Color HSL2YellowRed(double h, double sl, double l) { double new_h = (1 - h) * (ColourUtility.lowestYellow); Color rgb = ColourUtility.HSL2RGB(new_h, sl, l); return(rgb); }
private void SetHarbourText() { string harbourText = ""; switch (harbourBonus) { case HarbourBonus.THREE_TO_ONE: harbourText = "3:1"; break; case HarbourBonus.TWO_TO_ONE_BRICK: harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.BRICK); break; case HarbourBonus.TWO_TO_ONE_GRAIN: harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.GRAIN); break; case HarbourBonus.TWO_TO_ONE_LUMBER: harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.LUMBER); break; case HarbourBonus.TWO_TO_ONE_ORE: harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.ORE); break; case HarbourBonus.TWO_TO_ONE_WOOL: harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.WOOL); break; } gameObject.transform.GetChild(HARBOUR_TEXT_CHILD_ID).gameObject.SetActive(true); gameObject.transform.GetChild(HARBOUR_TEXT_CHILD_ID).GetComponent <TextMeshPro>().text = harbourText; }
public void mutateBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { Vector3 position = origin; Vector3 stackTwist = formConfig.getStackStartTwist(); float radius = formConfig.getBranchPositionDelta().x * 20; float rhumbAngle = formConfig.getStartRotation().x * 0.032f; //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } int i = offset; foreach (IStack stack in stacks) { position.x = formConfig.getStartPosition().x + (radius * (float)Math.Cos(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.y = formConfig.getStartPosition().y + (radius * (float)Math.Sin(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.z = formConfig.getStartPosition().z + (radius * (float)Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i - offset); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i - offset); } stack.mutateTo(position, stackTwist, 0.5f, stackColour); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public void SupplyTradeInit() { // Hide trade panel and show trade panel. GameObject.Find("BottomPanel").GetComponent <BottomPanel>().OpenTradeTab(); // toggles the trade tab offersPanel.SetActive(true); confirmed = false; foreach (GameObject panel in localPanels) { panel.GetComponent <Image>().color = new Color(1f, 1f, 1f); } LockRemotePanel(); clearRemoteButton.SetActive(true); trading = true; this.tradeDeclined = false; supplyTrading = true; yearOfPlenty = false; this.AvailableCards = 0; this.senderId = PhotonNetwork.LocalPlayer.ActorNumber; this.recepientId = SUPPLY_ID; // Set up player and supply name. localPlayerText.text = ColourUtility.GetPlayerDisplayNameFromId(senderId) + "'s offer"; remotePlayerText.text = "Available cards: 0"; // Set up cards. Left ones are local, right ones are remote. foreach (Card card in localCards) { card.Init(); card.SetVisible(true); card.SetInventory(inventory); card.UpdateCard(0); } foreach (Card card in remoteCards) { card.Init(); card.SetVisible(true); card.SetInventory(inventory); card.UpdateCard(0); // Specifically for supply trading. card.SetEnabled(true); } GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.TRADE_SUPPLY_INITIATED, PhotonNetwork.LocalPlayer); }
public void YearOfPlentyInit() { offersPanel.SetActive(true); confirmed = false; foreach (GameObject panel in localPanels) { panel.GetComponent <Image>().color = new Color(1f, 1f, 1f); } LockRemotePanel(); clearRemoteButton.SetActive(true); trading = true; this.tradeDeclined = false; this.supplyTrading = false; this.yearOfPlenty = true; // Set available cards instantly. this.AvailableCards = 2; this.senderId = PhotonNetwork.LocalPlayer.ActorNumber; this.recepientId = SUPPLY_ID; // Set up player and supply name. localPlayerText.text = ColourUtility.GetPlayerDisplayNameFromId(senderId) + "'s offer"; remotePlayerText.text = "Available cards: 2"; // Set up cards. Left ones are local, right ones are remote. foreach (Card card in localCards) { card.Init(); card.SetVisible(false); // Local cards here cannot be clicked. card.SetInventory(inventory); card.UpdateCard(0); } foreach (Card card in remoteCards) { card.Init(); card.SetVisible(true); card.SetInventory(inventory); card.UpdateCard(0); // Specifically for year of plenty and supply trading. card.SetEnabled(true); } GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.YEAR_OF_PLENTY_INITIATED, PhotonNetwork.LocalPlayer); }
// Should be run only from the Tick functions. private void InitOffersPanel() { offersPanel.SetActive(true); confirmed = false; foreach (GameObject panel in localPanels) { panel.GetComponent <Image>().color = new Color(1f, 1f, 1f); } UnlockRemotePanel(); trading = true; this.tradeDeclined = false; supplyTrading = false; yearOfPlenty = false; clearRemoteButton.SetActive(false); // Set up player names. if (amRecepient) { localPlayerText.text = ColourUtility.GetPlayerDisplayNameFromId(recepientId) + "'s offer"; remotePlayerText.text = ColourUtility.GetPlayerDisplayNameFromId(senderId) + "'s offer"; } else { localPlayerText.text = ColourUtility.GetPlayerDisplayNameFromId(senderId) + "'s offer"; remotePlayerText.text = ColourUtility.GetPlayerDisplayNameFromId(recepientId) + "'s offer"; } // Set up cards. Left ones are local, right ones are remote. foreach (Card card in localCards) { card.Init(); card.SetVisible(true); card.SetInventory(inventory); card.UpdateCard(0); } foreach (Card card in remoteCards) { card.Init(); card.SetVisible(true); card.SetInventory(inventory); card.UpdateCard(0); } }
// This is run on the sender of the trade request. private IEnumerator TradeSenderTick() { recepientResponded = false; TextMeshProUGUI panelText = tradeRequestStatusPanel.transform.GetChild(0).GetComponent <TextMeshProUGUI>(); string recepientName = ColourUtility.GetPlayerDisplayNameFromId(recepientId); for (int i = 10; i > 0; i--) { if (recepientResponded) { break; } panelText.text = "Waiting for " + recepientName + " to accept your trade request... (" + i + ")"; yield return(new WaitForSeconds(1f)); } if (recepientResponded) { if (tradeDeclined) { panelText.text = ColourUtility.GetPlayerDisplayNameFromId(recepientId) + " has declined your trade request."; yield return(new WaitForSeconds(3)); tradeRequestStatusPanel.SetActive(false); yield break; } else { // Trade accepted. // Do not delay the initialisation on the sender as compensation for the message sending. tradeRequestStatusPanel.SetActive(false); GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.TRADE_PLAYERS_INITIATED, PhotonNetwork.LocalPlayer, recepientId); InitOffersPanel(); yield break; } } else { panelText.text = "The trade request timed out."; yield return(new WaitForSeconds(3)); tradeRequestStatusPanel.SetActive(false); yield break; } }
// This is run on the recepient of the trade request. private IEnumerator ReceiverOfferTick() { recepientResponded = false; tradeRequestPopupPanel.SetActive(true); TextMeshProUGUI popupText = tradeRequestPopupPanel.transform.GetChild(0).gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>(); for (int i = 10; i > 0; i--) { if (recepientResponded) { break; } popupText.text = ColourUtility.GetPlayerDisplayNameFromId(senderId) + " sent you a trade request (" + i + ")."; yield return(new WaitForSeconds(1)); } if (recepientResponded) { // Close trade request popup panel. if (tradeDeclined) { tradeRequestPopupPanel.SetActive(false); yield break; } else { //yield return new WaitForSeconds(1); tradeRequestPopupPanel.SetActive(false); InitOffersPanel(); yield break; } } else { tradeRequestPopupPanel.SetActive(false); yield break; } }
/* Internal methods */ private void renderTexture(ColourUtility.RGBColour[,] rgbPixelMap) { int width = rgbPixelMap.GetLength (0); int height = rgbPixelMap.GetLength (1); Texture2D texture = new Texture2D (width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { ColourUtility.RGBColour pixelColour = rgbPixelMap[x, y]; texture.SetPixel(x, y, new Color(pixelColour.red, pixelColour.green, pixelColour.blue, 1)); } } Rect backgroundSize = backgroundImage.pixelInset; backgroundSize.width = width; backgroundSize.height = height; backgroundImage.pixelInset = backgroundSize; //apply the texture to the background texture.Apply(); backgroundImage.texture = texture; }
private void RPCSetCurrentPlayer(int playerId) { currentPlayerText.text = ColourUtility.GetPlayerDisplayNameFromId(playerId); }
private string GetMessage(EventCode code, int actorNumber, params object[] additionalParams) { switch (code) { case EventCode.FIRST_TURN_PHASE_ONE: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their first settlement."); case EventCode.FIRST_TURN_PHASE_TWO: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their first road."); case EventCode.SECOND_TURN_PHASE_ONE: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their second settlement."); case EventCode.SECOND_TURN_PHASE_TWO: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their second road."); case EventCode.ROAD_CONSTRUCTED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has constructed a road."); case EventCode.SETTLEMENT_CONSTRUCTED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has constructed a settlement."); case EventCode.CITY_CONSTRUCTED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has upgraded a settlement into a city."); case EventCode.PRE_DICE_ROLL: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is rolling the dice."); case EventCode.DICE_ROLLED: int diceValue = (int)additionalParams[0]; string diceValueString = ""; if (diceValue == 7) { diceValueString = "<color=black>"; } else if (diceValue == 6 || diceValue == 8) { diceValueString = "<color=red>"; } diceValueString += diceValue; if (diceValue >= 6 && diceValue <= 8) { diceValueString += "</color>"; } return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has rolled a " + diceValueString + "."); case EventCode.PLAYER_IDLE: return("Waiting for an action from " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + "."); case EventCode.RESOURCE_EARNED: int resourceType = (int)additionalParams[0]; int amount = (int)additionalParams[1]; Debug.Log("resourceType = " + resourceType + ", amount = " + amount); return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has earned " + amount + "x" + ColourUtility.GetResourceText((Inventory.UnitCode)resourceType) + "."); case EventCode.NO_RESOURCE_EARNED: return("No player has earned any resources from this roll."); case EventCode.TRADE_SUPPLY_INITIATED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is trading with the supply."); case EventCode.TRADE_PLAYERS_INITIATED: int secondPlayerId = (int)additionalParams[0]; return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is trading with " + ColourUtility.GetPlayerDisplayNameFromId(secondPlayerId) + "."); case EventCode.TRADE_CANCELLED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has cancelled the trade."); case EventCode.TRADE_SUPPLY_COMPLETED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has finished trading with the supply."); case EventCode.TRADE_PLAYERS_COMPLETED: secondPlayerId = (int)additionalParams[0]; return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has finished trading with " + ColourUtility.GetPlayerDisplayNameFromId(secondPlayerId) + "."); case EventCode.SHOULD_DISCARD: string resultText = "Waiting for "; if (actorNumber == -1) { // Initial set. discardList = ((int[])additionalParams[0]).OfType <int>().ToList(); bool first = true; for (int i = 0; i < discardList.Count; i++) { if (first) { first = false; } else { resultText += ", "; } //discardlist[i] is null for some reason resultText += ColourUtility.GetPlayerDisplayNameFromId(discardList[i]); } resultText += " to discard half of their resource cards."; } else { // Update. Remove the player from the discard list and then repeat. if (discardList.IndexOf(actorNumber) != -1) { discardList.Remove(actorNumber); } bool first = true; for (int i = 0; i < discardList.Count; i++) { if (first) { first = false; } else { resultText += ", "; } resultText += ColourUtility.GetPlayerDisplayNameFromId(discardList[i]); } resultText += " to discard half of their resource cards."; } Debug.Log(resultText); return(resultText); case EventCode.BANDIT_MOVE: return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to move the bandit to another hex."); case EventCode.SELECTING_STEAL_VICTIM: return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to select a player to steal from."); case EventCode.STEAL_NO_ADJACENT_PLAYER: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " had nobody to steal from."); case EventCode.NO_RESOURCE_STOLEN: Player stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]); return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " had no cards to steal from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "."); case EventCode.RESOURCE_STOLEN: stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]); string resourceText = (string)additionalParams[1]; return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen 1x" + resourceText + " from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "."); case EventCode.DEVELOPMENT_CARD_PURCHASED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has purchased a development card from the supply."); case EventCode.DEVELOPMENT_CARD_PLAYED: Inventory.UnitCode cardCode = (Inventory.UnitCode)additionalParams[0]; return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has played a " + ColourUtility.GetDevelopmentText(cardCode) + " card!"); case EventCode.YEAR_OF_PLENTY_INITIATED: return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to take 2 free Resource cards."); case EventCode.YEAR_OF_PLENTY_COMPLETED: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has taken two resource cards."); case EventCode.MONOPOLY_COMPLETE: resourceText = (string)additionalParams[0]; return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen all " + resourceText + " cards from the other players!"); case EventCode.LARGEST_ARMY_TAKE_FIRST_TIME: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has received the <color=black>Largest Army</color> card!"); case EventCode.LARGEST_ARMY_STEAL: stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]); return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen the <color=black>Largest Army</color> card from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "!"); case EventCode.LONGEST_ROAD_TAKE_FIRST_TIME: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has received the <color=black>Longest Road</color> card!"); case EventCode.LONGEST_ROAD_STEAL: stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]); return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen the <color=black>Longest Road</color> card from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "!"); case EventCode.LONGEST_ROAD_RETURNED: return("The <color=black>Longest Road</color> card no longer belongs to any player!"); case EventCode.GAME_OVER: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has won the game! Press ESC to return to the main menu."); case EventCode.END_TURN: return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has ended their turn."); } return("<invalid_text_code>"); }
void ProcessData() { double[] powerSpectrum; ComplexSignal cs = Signal.FromArray(dataBuffer, SAMPLE_RATE).ToComplex(); cs.ForwardFourierTransform(); powerSpectrum = Tools.GetPowerSpectrum(cs.GetChannel(0)); //Convert to dB powerSpectrum = powerSpectrum.Select((double arg, int index) => (10 * Math.Log10(arg / baselinePowerSpectrum[index]))).ToArray(); // Normalize values double minPowerSpectrum = (powerSpectrum.Min()); double maxPowerSpectrum = (powerSpectrum.Max()); powerSpectrum = powerSpectrum.Select((double arg, int index) => (arg - minPowerSpectrum) / (maxPowerSpectrum - minPowerSpectrum)).ToArray(); //Pick the color scheme according to the peak frequency - Blue-Green if peak below alpha, //Yellow-Red otherwise int highestFrequency = Array.IndexOf(powerSpectrum, powerSpectrum.Max()); currentScheme = highestFrequency >= alphaCutoff ? (highestFrequency >= gammaCutoff ? COLOUR_SCHEME.YELLOW_RED : COLOUR_SCHEME.PURPLE_RED) : COLOUR_SCHEME.BLUE_GREEN; Color[] spectrogramColours; if (currentScheme == COLOUR_SCHEME.BLUE_GREEN) { spectrogramColours = powerSpectrum.Select(((double arg) => ColourUtility.HSL2BlueGreen(arg, 0.75, 0.5))).ToArray(); } else if (currentScheme == COLOUR_SCHEME.PURPLE_RED) { spectrogramColours = powerSpectrum.Select(((double arg) => ColourUtility.HSL2PurpleRed(arg, 0.75, 0.5))).ToArray(); } else { spectrogramColours = powerSpectrum.Select(((double arg) => ColourUtility.HSL2YellowRed(arg, 0.75, 0.5))).ToArray(); } //Set the texture for (int i = 0; i < numFreqs; i++) { texture.SetPixel(i, (currentWindow % maxTextureWidth), spectrogramColours[i]); } currentWindow++; texture.Apply(); //Set the normal map float xLeft; float xRight; float yUp; float yDown; float yDelta; float xDelta; for (int i = 0; i < numFreqs; i++) { int y = (currentWindow % maxTextureWidth); yUp = normalMap.GetPixel(y - 1, i).grayscale; yDown = normalMap.GetPixel(y + 1, i).grayscale; int tempI = (int)Mathf.Clamp(i, 1, numFreqs - 2); xLeft = (float)powerSpectrum[tempI - 1]; xRight = (float)powerSpectrum[tempI + 1]; xDelta = ((xLeft - xRight) + 1) * 0.5f; yDelta = ((yUp - yDown) + 1) * 0.5f; normalMap.SetPixel(i, y, new Color(xDelta, yDelta, 1.0f, yDelta)); } normalMap.Apply(); }
// Do threaded task. DON'T use the Unity API here protected override void ThreadFunction() { double moveX = 0; double moveY = 0; hsbPixelMap = new ColourUtility.HSBColour[width, height]; rgbPixelMap = new ColourUtility.RGBColour[width, height]; int x = 0; int y = 0; //each iteration, it calculates: new = old*old + c, where c is a constant and old starts at current pixel double cRe, cIm; //real and imaginary part of the constant c, determinate shape of the Julia Set double newRe, newIm, oldRe, oldIm; //real and imaginary parts of new and old //pick some values for the constant c, this determines the shape of the Julia Set cRe = -0.7; cIm = 0.27015; //loop through every pixel for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { //calculate the initial real and imaginary part of z, based on the pixel location and zoom and position values newRe = 1.5 * (x - width / 2) / (0.5 * zoom * width) + moveX; newIm = (y - height / 2) / (0.5 * zoom * height) + moveY; //i will represent the number of iterations int i; //start the iteration process for (i = 0; i < maxIterations; i++) { //remember value of previous iteration oldRe = newRe; oldIm = newIm; //the actual iteration, the real and imaginary part are calculated newRe = oldRe * oldRe - oldIm * oldIm + cRe; newIm = 2 * oldRe * oldIm + cIm; //if the point is outside the circle with radius 2: stop if ((newRe * newRe + newIm * newIm) > 4) { break; } } //colour black if max iterations exceeded ColourUtility.HSBColour hsbColour = new ColourUtility.HSBColour(0, 0, 0); if (i < maxIterations) { float hue = ((float)(i % 256)) / 256; hsbColour.hue = hue; hsbColour.saturation = 1; hsbColour.brightness = hue; } ColourUtility.RGBColour rgbColour = ColourUtility.rgbFromHSB(hsbColour.hue, hsbColour.saturation, hsbColour.brightness); //set pixel map for colour cycling hsbPixelMap[x, y] = hsbColour; rgbPixelMap[x, y] = rgbColour; } } }
public void mutateBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { float scale = formConfig.getStartScale(); Vector3 stackTwist = formConfig.getStackStartTwist(); Vector3 position = branchStartPosition; Vector3 twist = branchStartTwist; //rotate position araound previous branch start position position = GeometryUtility.rotateCoordinateAboutPoint(origin, position, branchStartTwist); //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } int i = 0; foreach (IStack stack in stacks) { formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.mutateTo(position, stackTwist, scale, stackColour); scale = scale * formConfig.getScaleDelta(); float positionScale = scale; if (!formConfig.getScaleBranch()) { //ignore scale positionScale = 1; } Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), positionScale); position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist); twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta()); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public void createBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { float scale = formConfig.getStartScale(); Vector3 stackTwist = formConfig.getStackStartTwist(); Vector3 position = branchStartPosition; Vector3 twist = branchStartTwist; //rotate position araound previous branch start position position = GeometryUtility.rotateCoordinateAboutPoint(origin, position, branchStartTwist); //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } for (int i = 0; i < iterations; i++) { formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, scale, stackColour); stacks.Add(stack); scale = scale * formConfig.getScaleDelta(); Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), scale); position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist); twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta()); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public void PrepareStealing(List <int> playerIdList) { // The playerIdList size can be maximum 3. stealPanel.SetActive(true); // Reset buttons. Fill with player info top down. for (int i = 0; i < stealButtons.Length; i++) { if (playerIdList.Count == 0) { stealButtons[i].interactable = false; stealButtons[i].transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = ""; playerStealIds[i] = -1; } else { int playerId = playerIdList[0]; playerIdList.RemoveAt(0); stealButtons[i].interactable = true; stealButtons[i].transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = ColourUtility.GetPlayerDisplayNameFromId(playerId); playerStealIds[i] = playerId; } } }
public void ReceiveStolenCard(int senderId, int receivedResourceId) { // If the resource id is -1, the selected player had no card to give. if (receivedResourceId == -1) { GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.NO_RESOURCE_STOLEN, PhotonNetwork.LocalPlayer, senderId); } else { UnitCode receivedResource = (UnitCode)receivedResourceId; this.GiveToPlayer(receivedResource, 1); GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.RESOURCE_STOLEN, PhotonNetwork.LocalPlayer, senderId, ColourUtility.GetResourceText(receivedResource)); } }
public void MonopolyReplyReceived(int amount) { // Give the received resources to the player. inventory.GiveToPlayer(this.monopolyResource, amount); monopolyReplies++; if (monopolyReplies == 3) { // All players have replied. The Monopoly card effect is complete. // switch to idle phase GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.MONOPOLY_COMPLETE, PhotonNetwork.LocalPlayer, ColourUtility.GetResourceText(monopolyResource)); GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.PLAYER_IDLE, PhotonNetwork.LocalPlayer); } }
public void createBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { Vector3 position = origin; Vector3 stackTwist = formConfig.getStackStartTwist(); float radius = formConfig.getBranchPositionDelta().x * 20; float rhumbAngle = formConfig.getStartRotation().x * 0.032f; //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } for (int i = offset; i < offset + iterations; i++) { position.x = formConfig.getStartPosition().x + (radius * (float)Math.Cos(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.y = formConfig.getStartPosition().y + (radius * (float)Math.Sin(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.z = formConfig.getStartPosition().z + (radius * (float)Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, 0.5f, stackColour); stacks.Add(stack); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public void mutateBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { int iterations = formConfig.getStackIterations(); float scale = formConfig.getStartScale(); for (int o = 0; o < offset; o++) { scale *= formConfig.getScaleDelta(); } //centre of ring Vector3 position = branchStartPosition; //add radius of ring float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale; //first element of ring on radius float zAngle = branchStartTwist.z * Mathf.Deg2Rad; float yAngle = branchStartTwist.y * Mathf.Deg2Rad; float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad; Vector3 stackTwist = formConfig.getStackStartTwist(); //colour stuff Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } int i = 0; foreach (IStack stack in stacks) { position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x; position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y; position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z; formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.mutateTo(position, stackTwist, 0.5f * scale, stackColour); yAngle += ringSegmentAngle; yAngle += ringSegmentAngle; stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public void createBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { int iterations = formConfig.getStackIterations(); float scale = formConfig.getStartScale(); for (int o = 0; o < offset; o++) { scale *= formConfig.getScaleDelta(); } //centre of ring Vector3 position = branchStartPosition; //add radius of ring float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale; //angle to calculate ring float zAngle = branchStartTwist.z * Mathf.Deg2Rad; float yAngle = branchStartTwist.y * Mathf.Deg2Rad; float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad; Vector3 stackTwist = formConfig.getStackStartTwist(); //colour stuff Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } for (int i = offset; i < offset + iterations; i++) { position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x; position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y; position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z; formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, 0.5f * scale, stackColour); stacks.Add(stack); yAngle += ringSegmentAngle; stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
private string GetPlayerToTradeWithDisplayName() { return(ColourUtility.GetPlayerDisplayName(playerToTradeWith)); }