/// <summary> /// Append the colour to the appropriate group and to the main list of colours in the supplied <see cref="gamPalette" /> /// </summary> /// <param name="gamPalette">The gam palette.</param> /// <param name="colour">The colour.</param> /// <param name="gamColourGroup">The gam colour group.</param> internal static void AppendColour(GamPalette gamPalette, Color colour, ColourGroup gamColourGroup) { // Append to supplied palette. AppendToPalette(gamPalette, colour, gamColourGroup); // Add to 'All Colours' palette. AppendToPalette(colourPalettes[ColourPaletteType.AllPalette], colour, gamColourGroup); }
/// <summary> /// Gets a colour based on a zero-based index within a colour group, within a palette.<br /> /// If the index exceeds the number of elements in the colour group, then a remainder index is used instead. /// </summary> /// <param name="palette">The <see cref="ColourPaletteType" /></param> /// <param name="colourGroup">The <see cref="ColourGroup" /></param> /// <param name="index">The index used to look up a colour</param> /// <returns> /// A <see cref="Color" /> /// </returns> public static Color GetColour(ColourPaletteType palette, ColourGroup colourGroup, int index) { int remainder; var gp = colourPalettes[palette].ColourGroups; List <Color> colourGroupColours = colourPalettes[palette].ColourGroups[colourGroup]; Math.DivRem(index, colourGroupColours.Count, out remainder); return(colourGroupColours[remainder]); }
/// <summary> /// Appends to palette. /// </summary> /// <param name="gamPalette">The gam palette.</param> /// <param name="colour">The colour.</param> /// <param name="gamColourGroup">The gam colour group.</param> private static void AppendToPalette(GamPalette gamPalette, Color colour, ColourGroup gamColourGroup) { // Check if colour group exists, if not then create if (!gamPalette.ColourGroups.ContainsKey(gamColourGroup)) { gamPalette.ColourGroups.Add(gamColourGroup, new List <Color>()); } gamPalette.ColourGroups[gamColourGroup].Add(colour); // Add to full list if not already there. if (!gamPalette.ColorList.Exists(c => c.Equals(colour))) { gamPalette.ColorList.Add(colour); } else { } }
public void AddCubeToGrid(IntVector2 coords, ColourGroup CG, Color C, Vector2 diff) { int newYCoord = coords.y; int newXCoord = coords.x; if (diff.y >= 0.5f) { newYCoord = coords.y - 1; } else if (diff.x >= 0.5f) { newXCoord = coords.x - 1; } else if (diff.x <= -0.5f) { newXCoord = coords.x + 1; } Vector3 offset = new Vector3(newXCoord * GridSpacing, newYCoord * GridSpacing, 0.0f); GameObject cubeObj = (GameObject)GameObject.Instantiate(CubePrefab); cubeObj.transform.position = offset + transform.position; cubeObj.transform.parent = transform; m_Grid[newXCoord, newYCoord] = cubeObj.GetComponent <ClickableCube>(); cubeObj.GetComponent <ClickableCube>().SetCoords(new IntVector2(newXCoord, newYCoord)); cubeObj.GetComponent <ClickableCube>().SetColorStuff(CG, C); RecalcuateClusters(); if (cubeObj.GetComponent <ClickableCube>().cluster.GetListSize() > 1) { cubeObj.GetComponent <ClickableCube>().cluster.DeactivateCubes(); } DebugUtils.Assert(m_Grid[newXCoord, newYCoord] != null, "Could not find clickableCube component."); }
//A helper function to add new coordinates to check in our search. //It will first create the new coords, then double check if the coordinates are valid before adding //them to the list void AddCoordsIfNeeded(IntVector2 coords, IntVector2 checkDir, ref List <IntVector2> coordsToVisit, ColourGroup colourGroup) { IntVector2 nextCoords = coords + checkDir; if (AreCoordsValid(nextCoords)) { ClickableCube Tempcheck = m_Grid[nextCoords.x, nextCoords.y]; if (Tempcheck != null) { if (colourGroup == Tempcheck.GetColourGroup()) { coordsToVisit.Add(nextCoords); } } } }
/// <summary> /// Creates and returns a new instance of a brush based on a zero-based index within a colour group, within a palette.<br /> /// If the index exceeds the number of elements in the colour group, then a remainder index is used instead. /// </summary> /// <param name="palette">The <see cref="ColourPaletteType" /></param> /// <param name="colourGroup">The <see cref="ColourGroup" /></param> /// <param name="index">The index used to look up a colour</param> /// <returns> /// A new instance of a <see cref="SolidColorBrush" /> /// </returns> public static Brush GetNewBrush(ColourPaletteType palette, ColourGroup colourGroup, int index) { return(new SolidColorBrush(GetColour(palette, colourGroup, index))); }
public PostsViewModel() { var colour = new ColourGroup(); }
public void SetColorStuff(ColourGroup CG, Color C) { colourGroup = CG; m_Activated = true; ActivatedColor = C; }