Ejemplo n.º 1
0
    public void OnSocket(int key, ByteBuffer byteBuffer)
    {
        UnityTools.Log(key);
        if (key == 11)
        {
            loadData();
        }
        else if (key == 133)
        {
            byteBuffer.ReadShort();
            BattleStartResponse battleStartResponse = new BattleStartResponse();
            battleStartResponse.MergeFrom(byteBuffer.ReadBytes());
            foreach (var hero in battleStartResponse.Heros)
            {
                UnityTools.Log(hero.ToString());
            }
            GameData.g_battleView.InitHeros(battleStartResponse.Heros.ToArrayList());
        }
        else if (key == 135)
        {
            byteBuffer.ReadShort();
            BattleResultResponse battleResultResponse = new BattleResultResponse();
            battleResultResponse.MergeFrom(byteBuffer.ReadBytes());
            UnityTools.Log(battleResultResponse.Earn);

            GameData.g_battleView.ShowResult(GameData.g_battleResult, battleResultResponse.Earn, battleResultResponse.Level, battleResultResponse.Exp, battleResultResponse.LevelUpExp);
        }
        else if (key == 111)
        {
            byteBuffer.ReadShort();
            SkillResponse skillResponse = new SkillResponse();
            skillResponse.MergeFrom(byteBuffer.ReadBytes());
            foreach (var skill in skillResponse.Skills)
            {
                UnityTools.Log(skill.ToString());
            }
            GameData.g_battleView.InitSkills(skillResponse.Skills.ToArrayList());
        }
        else if (key == 113)
        {
            byteBuffer.ReadShort();
            EquipResponse itemResponse = new EquipResponse();
            itemResponse.MergeFrom(byteBuffer.ReadBytes());
            foreach (var item in itemResponse.Equips)
            {
                UnityTools.Log(item.ToString());
            }
            GameData.g_battleView.InitItems(itemResponse.Equips.ToArrayList());
        }
    }
Ejemplo n.º 2
0
        public void TestItemsEquipXmlGetAttributes()
        {
            string xml =
                @"<roar tick=""128779477951"">
				<items>
					<equip status=""ok""/>
				</items>
				<!--The server flags that the user inventory status has changed-->
				<server>
					<inventory_changed/>
				</server>
			</roar>"            ;

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.Items.Equip equip_parser = new Roar.DataConversion.Responses.Items.Equip();
            EquipResponse response = equip_parser.Build(nn);

            Assert.IsNotNull(response);
        }