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
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
// 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
// Псевдорандомно перебирает все числа (кроме 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); |
NewerOlder