示例#1
0
        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);
            }
        }
示例#2
0
 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)]);
 }
示例#3
0
        public void Get_SingleValueSet_ValueIsEqual()
        {
            NKMRandom.Set("test", 3);

            int?value = NKMRandom.Get("test");

            Assert.Equal(3, value);
        }
示例#4
0
        public void Get_SecondTimeAfterSingleSet_ValueIsNull()
        {
            NKMRandom.Set("test", 3);
            NKMRandom.Get("test");

            int?secondValue = NKMRandom.Get("test");

            Assert.Null(secondValue);
        }
示例#5
0
文件: HighLuck.cs 项目: tojatos/NKM
        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;
                }
            };
        }
示例#6
0
文件: Parry.cs 项目: tojatos/NKM
        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;
                }
            };
        }
示例#7
0
    public void MakeAction(string[] action)
    {
        switch (action[0])
        {
        //TODO: Remove that all and work with clicks maybe, or not
        case "CHARACTER PLACED":
            string[]  data      = action[1].SplitData();
            Character character = Characters.First(c => c.ToString() == data[0]);
            HexCell   cell      = HexMapDrawer.Cells.First(c => c.ToString() == data[1]);
            PlaceCharacter(character, cell);
            break;

        case "TURN FINISHED": Active.Turn.Finish(); break;

        case "ACTION TAKEN": Characters.First(c => c.ToString() == action[1]).TryToInvokeJustBeforeFirstAction(); break;

        case "MOVE":
            List <HexCell> moveCells = action[1].SplitData().ConvertToHexCellList();
            Active.Turn.CharacterThatTookActionInTurn.MakeActionBasicMove(moveCells);
            break;

        case "BASIC ATTACK":
            Character targetCharacter = Characters.First(c => c.ToString() == action[1]);
            Active.Turn.CharacterThatTookActionInTurn.MakeActionBasicAttack(targetCharacter);
            break;

        case "ABILITY CLICK":
            ((IClickable)Abilities.First(a => a is IClickable && a.ID == int.Parse(action[1]))).Click();
            break;

        case "ABILITY USE":
            List <HexCell> targetCells = action[1].SplitData().ConvertToHexCellList();
//	                ((IUseable) Abilities.First(a => a is IUseable && a.ID == abilityID)).Use(targetCells);
            Active.AbilityToUse.Use(targetCells);
            break;

        case "ABILITY CANCEL":
            ((Ability)Active.AbilityToUse).Cancel();
            break;

        case "RNG":
            string[] rngData = action[1].SplitData();
            NKMRandom.Set(rngData[0], int.Parse(rngData[1]));
            break;

        default:
            Console.Instance.DebugLog("Unknown action in GameLog!");
            break;
        }
    }
示例#8
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);
        }
示例#9
0
        public void Get_WithoutSetting_ValueIsNull()
        {
            int?value = NKMRandom.Get("test");

            Assert.Null(value);
        }