示例#1
0
 /// <summary>
 /// Adjust wait time until next movement allowed and check if can move currently.
 /// </summary>
 /// <returns><c>true</c>, if can move, <c>false</c> otherwise.</returns>
 /// <param name="dLoc">Attempted change in location.</param>
 private bool updateWaitTime(Loc dLoc)
 {
     if (dLoc.Equals (Loc.zero)) {
         cooldown = 0;
         return false;
     }
     if (cooldown > 0) {
         cooldown -= Time.deltaTime;
         return false;
     }
     cooldown = waitTime;
     return true;
 }
示例#2
0
        public void TestLoc()
        {
            PlainCellCache cache = new PlainCellCache();

            for (int bookIndex = 0; bookIndex < 0x1000; bookIndex += 0x100)
            {
                for (int sheetIndex = 0; sheetIndex < 0x1000; sheetIndex += 0x100)
                {
                    for (int rowIndex = 0; rowIndex < 0x100000; rowIndex += 0x1000)
                    {
                        for (int columnIndex = 0; columnIndex < 0x4000; columnIndex += 0x100)
                        {
                            Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
                            Assert.AreEqual(bookIndex, loc.BookIndex);
                            Assert.AreEqual(sheetIndex, loc.SheetIndex);
                            Assert.AreEqual(rowIndex, loc.RowIndex);
                            Assert.AreEqual(columnIndex, loc.ColumnIndex);

                            Loc sameLoc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
                            Assert.AreEqual(loc.GetHashCode(), sameLoc.GetHashCode());
                            Assert.IsTrue(loc.Equals(sameLoc));

                            Assert.IsNull(cache.Get(loc));
                            PlainValueCellCacheEntry entry = new PlainValueCellCacheEntry(new NumberEval(0));
                            cache.Put(loc, entry);

                            Assert.AreSame(entry, cache.Get(loc));
                            cache.Remove(loc);
                            Assert.IsNull(cache.Get(loc));

                            cache.Put(loc, entry);
                        }
                        cache.Clear();
                    }
                }
            }
        }
示例#3
0
 private bool isKo(Loc proposedLoc, List<Chain> killed)
 {
     return proposedLoc.Equals(Game.PossibleKoLoc)
         && killed.Count == 1
         && killed[0].Stones.Count == 1;
 }
示例#4
0
        private static bool isConflictHelper(List<Chain> chainsOfLikeColor, Loc proposedLoc)
        {
            foreach (Chain chain in chainsOfLikeColor)
                foreach (Stone stone in chain.Stones)
                    if (proposedLoc.Equals(stone.Loc))
                        return true;

            return false;
        }