コード例 #1
0
        /// <summary>
        /// 处理和显示总结算信息
        /// </summary>
        /// <param name="dataArray"></param>
        public void InitAccount(ISFSArray dataArray)
        {
            //用于记录有多少个玩家,同时作为数组索引使用
            int count    = 0;
            int maxPoint = 0;           //本局最高分点数

            //对小结窗口玩家信息进行初始化
            foreach (ISFSObject data in dataArray)
            {
                if (data.ContainsKey("seat"))
                {
                    AccItem acc = _accItems[count++].GetComponent <AccItem>();
                    acc.InitAccItem(data);
                    int point = data.GetInt("gold");        //当前玩家的得分数
                    if (point > maxPoint)
                    {
                        maxPoint = point;
                    }
                }
            }

            //显示大赢家标记
            for (int i = 0; i < _accItems.Length; i++)
            {
                _accItems[i].SetBigWinnerMark(_accItems[i].PlayerScore >= maxPoint);
                _accItems[i].gameObject.SetActive(i < count);       //有数据的显示,没有数据的隐藏
            }
            _accountGrid.Reposition();
        }
コード例 #2
0
        public void CanRetrieveFacetCounts()
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    var item1 = new AccItem {
                        Lat = 52.156161, Lon = 1.602483, Name = "House one", Bedrooms = 2
                    };
                    item1.Attributes.Add(Tag.HasGarden);
                    item1.Attributes.Add(Tag.HasPool);
                    var item2 = new AccItem {
                        Lat = 52.156161, Lon = 1.602483, Name = "House two", Bedrooms = 2
                    };
                    item2.Attributes.Add(Tag.HasGarden);
                    var item3 = new AccItem {
                        Lat = 52.156161, Lon = 1.602483, Name = "Bungalow three", Bedrooms = 3
                    };
                    item3.Attributes.Add(Tag.HasGarden);
                    item3.Attributes.Add(Tag.HasPool);
                    item3.Attributes.Add(Tag.HasTennis);
                    session.Store(item1);
                    session.Store(item2);
                    session.Store(item3);
                    var _facets = new List <Facet>
                    {
                        new Facet
                        {
                            Name = "Attributes"
                        }
                    };
                    session.Store(new FacetSetup {
                        Id = "facets/AttributeFacets", Facets = _facets
                    });
                    session.SaveChanges();
                    session.SaveChanges();
                }

                new AccItems_Spatial().Execute(store);
                new AccItems_Attributes().Execute(store);

                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var query = session.Query <AccItem, AccItems_Spatial>()
                                .Customize(customization => customization.WaitForNonStaleResults())
                                .Customize(x => x.WithinRadiusOf(radius: 10, latitude: 52.156161, longitude: 1.602483))
                                .Where(x => x.Bedrooms == 2);
                    var partialFacetResults = query
                                              .ToFacets("facets/AttributeFacets");
                    var fullFacetResults = session.Query <AccItem, AccItems_Attributes>()
                                           .ToFacets("facets/AttributeFacets");

                    TestHelper.AssertNoIndexErrors(store);

                    var partialGardenFacet =
                        partialFacetResults.Results["Attributes"].Values.First(
                            x => x.Range.Contains("hasgarden"));
                    Assert.Equal(2, partialGardenFacet.Hits);

                    var fullGardenFacet =
                        fullFacetResults.Results["Attributes"].Values.First(
                            x => x.Range.Contains("hasgarden"));
                    Assert.Equal(3, fullGardenFacet.Hits);

                    TestHelper.AssertNoIndexErrors(store);
                }
            }
        }