private void MoveOverride(List <HexCell> moveCells) { // bool isLost = UnityEngine.Random.Range(0, 2) == 0; bool isLost = NKMRandom.Get(Name, 0, 2) == 0; if (!isLost) { ParentCharacter.DefaultBasicMove(moveCells); } else { Active.RemoveMoveCells(); int movementPoints = ParentCharacter.Speed.Value; Active.MoveCells.Add(ParentCharacter.ParentCell); HexCell lastCell = ParentCharacter.ParentCell; List <HexCell> moveTargets = ParentCharacter.GetBasicMoveCells(); while (movementPoints-- > 0 || !lastCell.IsFreeToStand) { // List<HexCell> neighborMoveCells = lastCell.GetNeighbors(1, // SearchFlags.StopAtEnemyCharacters | SearchFlags.StopAtFriendlyCharacters | SearchFlags.StopAtWalls); List <HexCell> neighborMoveCells = lastCell.GetNeighbors(1).Intersect(moveTargets).ToList(); // int r = UnityEngine.Random.Range(0, neighborMoveCells.Count); // lastCell = neighborMoveCells[r]; lastCell = neighborMoveCells.GetRandom(); Active.AddMoveCell(lastCell); } ParentCharacter.DefaultBasicMove(Active.MoveCells); Console.Log($"{ParentCharacter.FormattedFirstName()}: Cholera, znowu siÄ™ zgubili?"); // int rand = UnityEngine.Random.Range(1, 4); int soundID = NKMRandom.Get($"{Name} - ID", 1, 4); Active.PlayAudio("op wtf " + soundID); } }
public static T GetRandom <T>(this List <T> list) { if (list.Count == 0) { return(default(T)); } return(list[NKMRandom.Get("System Generic Random" + NKMID.GetNext("System Generic Random"), 0, list.Count)]); }
public void Get_SingleValueSet_ValueIsEqual() { NKMRandom.Set("test", 3); int?value = NKMRandom.Get("test"); Assert.Equal(3, value); }
public void Get_SecondTimeAfterSingleSet_ValueIsNull() { NKMRandom.Set("test", 3); NKMRandom.Get("test"); int?secondValue = NKMRandom.Get("test"); Assert.Null(secondValue); }
public HighLuck() : base(AbilityType.Passive, "High luck") { OnAwake += () => ParentCharacter.BeforeAttack += (character, damage) => { int r = NKMRandom.Get(Name, 1, 101); // if (UnityEngine.Random.Range(1, 101) <= 25) damage.Value *= 2; if (r <= 25) { damage.Value *= 2; } }; }
public Parry() : base(AbilityType.Passive, "Parry") { OnAwake += () => ParentCharacter.BeforeBeingBasicAttacked += (character, damage) => { // var r = UnityEngine.Random.Range(1, 101); int r = NKMRandom.Get(Name, 1, 101); if (r <= DodgeChancePercent) { damage.Value = 0; } }; }
public void Get_SeveralTimesAfterSeveralValueSet_ValuesGetProperly() { NKMRandom.Set("test", 3); NKMRandom.Set("other", 6); NKMRandom.Set("test", 133); int?value1 = NKMRandom.Get("test"); int?value2 = NKMRandom.Get("test"); int?value3 = NKMRandom.Get("other"); int?value4 = NKMRandom.Get("other"); Assert.Equal(133, value1); Assert.Null(value2); Assert.Equal(6, value3); Assert.Null(value4); }
public void Get_WithoutSetting_ValueIsNull() { int?value = NKMRandom.Get("test"); Assert.Null(value); }