private bool Update(Entity old, EntityProto val) {

			if (old.Val == val.Val.ToString())
				return false;

			old.Val = val.Val.ToString();
			return true;

		}
		private CollectionDiffWithValue<Entity, Entity> TestSyncWithValue(Entity[] oldItems, EntityProto[] newItems, 
			int addedCount = 0, int removedCount = 0, int editedCount = 0, int unchangedCount = 0) {
			
			var list = oldItems.ToList();
			var result = CollectionHelper.SyncWithContent(list, newItems, EqualityEntity, FacEntity, Update, null);

			Assert.IsNotNull(result, "result is not null");
			Assert.AreEqual(addedCount > 0 || removedCount > 0 || editedCount > 0, result.Changed, "is changed");
			Assert.AreEqual(addedCount, result.Added.Length, "Aadded");
			Assert.AreEqual(editedCount, result.Edited.Length, "Edited");
			Assert.AreEqual(removedCount, result.Removed.Length, "Removed");
			Assert.AreEqual(unchangedCount, result.Unchanged.Length, "Unchanged");
			return result;

		}
		private bool EqualityEntity(Entity old, EntityProto val) {
			return old.Id == val.Id;
		}
		private Entity FacEntity(EntityProto val) {
			return new Entity { Val = val.Val.ToString() };
		}
Example #5
0
        public virtual void Deserialize(BinaryReader r)
        {
            if (!m_Init)
            {
                InitSkEntity();
            }
            int readVersion = r.ReadInt32();

            if (readVersion == 2)
            {
                _attribs.DisableNumAttribsEvent();
                for (int i = 0; i < (int)AttribType.HPRecover; i++)
                {
                    _attribs.sums[i] = _attribs.raws[i] = r.ReadSingle();
                }
                _attribs.EnableNumAttribsEvent();

                SetAttribute(AttribType.HPRecover, 0.01f);
            }
            else
            {
                _attribs.Deserialize(r);
            }

            if (1 == readVersion)
            {
                int buffLength = r.ReadInt32();
                m_InitBuffList = new int[buffLength];
                for (int i = 0; i < buffLength; i++)
                {
                    m_InitBuffList[i] = r.ReadInt32();
                }
            }

            EntityProto entityProto = Entity.entityProto;

            if (null != entityProto)
            {
                switch (entityProto.proto)
                {
                case EEntityProto.Monster:
                    MonsterProtoDb.Item monsterPDB = MonsterProtoDb.Get(entityProto.protoId);
                    if (null != monsterPDB)
                    {
                        m_InitBuffList = monsterPDB.initBuff;
                    }
                    break;

                case EEntityProto.Npc:
                    NpcProtoDb.Item npcPDB = NpcProtoDb.Get(entityProto.protoId);
                    if (null != npcPDB)
                    {
                        m_InitBuffList = npcPDB.InFeildBuff;
                    }
                    break;

                case EEntityProto.Player:
                    PlayerProtoDb.Item playerPDB = PlayerProtoDb.Get();
                    if (null != playerPDB)
                    {
                        m_InitBuffList = playerPDB.initBuff;
                    }
                    break;

                case EEntityProto.RandomNpc:
                    PlayerProtoDb.Item RnpcPDB = PlayerProtoDb.GetRandomNpc();
                    if (null != RnpcPDB)
                    {
                        m_InitBuffList = RnpcPDB.InFeildBuff;
                    }
                    break;
                }
            }
        }