This repository has been archived by the owner on Nov 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganizing the palette classes into a new folder Fixed some potential issues with nullable enum fields in xmls
- Loading branch information
Showing
15 changed files
with
411 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Klyte.Commons.Utils; | ||
using UnityEngine; | ||
|
||
namespace Klyte.TransportLinesManager | ||
{ | ||
public class RandomPastelColorGenerator | ||
{ | ||
private readonly System.Random _random; | ||
|
||
public RandomPastelColorGenerator() | ||
{ | ||
// seed the generator with 2 because | ||
// this gives a good sequence of colors | ||
const int RandomSeed = 2; | ||
_random = new System.Random(RandomSeed); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Returns a random pastel color | ||
/// </summary> | ||
/// <returns></returns> | ||
public Color32 GetNext() | ||
{ | ||
// to create lighter colours: | ||
// take a random integer between 0 & 128 (rather than between 0 and 255) | ||
// and then add 64 to make the colour lighter | ||
byte[] colorBytes = new byte[3]; | ||
colorBytes[0] = (byte)(_random.Next(128) + 64); | ||
colorBytes[1] = (byte)(_random.Next(128) + 64); | ||
colorBytes[2] = (byte)(_random.Next(128) + 64); | ||
Color32 color = new Color32 | ||
{ | ||
|
||
// make the color fully opaque | ||
a = 255, | ||
r = colorBytes[0], | ||
g = colorBytes[1], | ||
b = colorBytes[2] | ||
}; | ||
LogUtils.DoLog(color.ToString()); | ||
|
||
return color; | ||
} | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.