This file contains hidden or 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
// Псевдорандомно перебирает все числа (кроме 0) без повторов | |
// https://ru.wikipedia.org/wiki/Регистр_сдвига_с_линейной_обратной_связью | |
uint feed = 0x12; // для результата в 5 бит | |
uint i = 1; | |
do { | |
if ((i & 1) != 0) | |
i = (i >> 1) ^ feed; | |
else | |
i = (i >> 1); |
This file contains hidden or 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
// 20 разных цветов для всяких графиков | |
// https://fly2sky.ru/ChartColors.png | |
#0000FF | |
#FF0000 | |
#820080 | |
#FFFF00 | |
#00FF00 | |
#0080FF | |
#5F5F5F | |
#F9A753 |
This file contains hidden or 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
using UnityEngine; | |
namespace Common { | |
/// <summary> | |
/// Перебор координат по спирали против часовой стрелки: | |
/// (0:0), | |
/// (1:0), (1:1), (0:1), (-1:1), (-1:0), (-1:-1), (0:-1), (1:-1), | |
/// (2:-1), (2:0), (2:1), (2:2), (1:2), (0:2), (-1:2), (-2:2), (-2:1), (-2:0), (-2:-1), (-2:-2), (-1:-2), (0:-2), (1:-2), (2:-2), | |
/// (3:-2), ... |
This file contains hidden or 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
current_chance = (max — goods) / (length — tries) | |
max=сколько нужно выдать игроку предметов | |
length=на количество попыток (max=1, length=10: на 10 попыток один предмет, т.е. шанс 10%) | |
goods=сколько уже выпало предметов | |
tries=номер попытки (как только tries становится равным length, всё начинается заново) |
This file contains hidden or 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
Если при компиляции под Android получается ошибка: Too many field references | |
По совету: http://answers.unity3d.com/questions/970713/too-many-method-references-max-is-65536.html | |
Надо объединить какие-нибудь модули в одном package | |
1. Выбрать жертву (например, модули от firebase) | |
2. Раскрыть все .aar архивы, после компиляции (даже неудачной) взять | |
раскрытые из .\Temp\StagingArea\android-libraries\ и положить их вместо .aar | |
3. Заменить в каждом из раскрытых AndroidManifest.xml тег "package" на "com.google.unity" | |
чтобы объединились вместе с модулями Google play (games или ads) |
This file contains hidden or 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
using System; | |
public static class AppInfo { | |
//--- AutoGenerated.begin | |
public const string Version = "1.0.3"; | |
public static readonly DateTime Date = new DateTime(2018, 04, 29, 13, 41, 08, 331, DateTimeKind.Utc); | |
//--- AutoGenerated.end | |
} | |
This file contains hidden or 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
using System.IO; | |
public static class ProcessExecute { | |
public static int Execute(string command, string arguments, out string output, out string error, string input = null) { | |
var proc = new System.Diagnostics.Process(); | |
proc.StartInfo.UseShellExecute = false; | |
if (!string.IsNullOrEmpty(input)) | |
proc.StartInfo.RedirectStandardInput = true; | |
proc.StartInfo.RedirectStandardError = true; |
This file contains hidden or 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
/// <summary> | |
/// Number of changes needed to turn one string into another. | |
/// Taken from https://www.dotnetperls.com/levenshtein | |
/// </summary> | |
public static int LevenshteinDistanceTo(string s, string t) | |
{ | |
int n = s.Length; | |
int m = t.Length; | |
if (n == 0) return m; | |
if (m == 0) return n; |
This file contains hidden or 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
public static string ReplaceQuotes(string s) { | |
var quotes = new[] { "«", "»" }; | |
int n = 0; | |
while (true) { | |
int i = s.IndexOf("\"", StringComparison.Ordinal); | |
if (i < 0) break; | |
s = s.Substring(0, i) + quotes[n++%quotes.Length] + s.Substring(i + 1); | |
} | |
return s; | |
} |
This file contains hidden or 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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Reflection; | |
using System.Text; | |
using UnityEngine; | |
/// <summary> | |
/// Dump configuration |
OlderNewer