コード例 #1
0
        public void ObjectIsCached()
        {
            var cache = new CacheList <int, TestObject>();
            var obj1  = cache.Get(0, (i) => new TestObject(1));
            var obj2  = cache.Get(0, (i) => new TestObject(2));

            Assert.AreEqual(obj1, obj2);
            Assert.AreEqual(1, obj2.Index);
        }
コード例 #2
0
        public void StoreNewValueFromCallback()
        {
            var cache = new CacheList <int, TestObject>();
            var obj1  = cache.Get(0, (i) => new TestObject(i));

            Assert.IsNotNull(obj1);
        }
コード例 #3
0
 public GameEntity GetPlayerEntity(int playerId)
 {
     return(_cachedPlayerEntity.Get(playerId, (id) =>
                                    this.GetEntities(GameMatcher.Player)
                                    .Where(e => e.player.PlayerId == id)
                                    .FirstOrDefault()
                                    ));
 }
コード例 #4
0
 public void AddAbility()
 {
     _entity.AddAbility
     (
         _cacheAbility.Get
         (
             _data.AbilityClassFullName,
             (name) => (Ability)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(name)
         )
     );
 }
コード例 #5
0
    protected override void Execute(List <CardEntity> entities)
    {
        foreach (var e in entities)
        {
            var deck = _playerDeckCache.Get(e.owner.Entity, (playerEntity) =>
                                            _gameContext.GetEntities(GameMatcher.PlayerDeck)
                                            .Where(p => p == playerEntity)
                                            .First()
                                            .playerDeck.PlayerDeckObject
                                            );

            deck.AddCard(e.view.GameObject);
        }
    }