Пример #1
0
 public void TownUserEnterAsync(PMsgMapRoleInfoS anotherUserInfo)
 {
     StartCoroutine(TownUserEnter(anotherUserInfo));
 }
Пример #2
0
    public IEnumerator TownUserEnter(PMsgMapRoleInfoS anotherUserInfo)
    {
        //이미 있는경우는 추가하지 않는다.
        TownUnit unit = null;

        if (townUnitList.TryGetValue(anotherUserInfo.UllRoleId, out unit))
        {
            uint head = 0, cloth = 0, weapon = 0;
            int  equipCount = anotherUserInfo.UnEquipmentId.Count;
            for (int i = 0; i < equipCount; i++)
            {
                int equipId = anotherUserInfo.UnEquipmentId[i];
                if (equipId <= 0)
                {
                    continue;
                }

                Item.EquipmentInfo equipInfo = _LowDataMgr.instance.GetLowDataEquipItemInfo((uint)equipId);
                if (equipInfo == null)
                {
                    Debug.LogError(string.Format("friend equip item not found lowdataID={0} error", equipId));
                    continue;
                }

                if (equipInfo.UseParts == (byte)ePartType.CLOTH)
                {
                    cloth = (uint)equipId;
                }
                //else if (equipInfo.UseParts == (byte)ePartType.HELMET)
                //head = (uint)equipId;
                else if (equipInfo.UseParts == (byte)ePartType.WEAPON)
                {
                    weapon = (uint)equipId;
                }
            }

            unit.ChangeSkin(anotherUserInfo.UnCostumeShowFlag == (int)COSTUME_FLAG_TYPE.COSTUME_FLAG_HIDE, (uint)anotherUserInfo.UnCostumeId, head, cloth, weapon);
            unit.ChangeTitle(anotherUserInfo.UnTitlePrefix, anotherUserInfo.UnTitleSuffix);

            /*
             * UIBasePanel readyPopup = UIMgr.GetUIBasePanel("UIPopup/ReadyPopup");
             * if (readyPopup != null)
             * {
             *  if ((readyPopup as ReadyPopup).IsRoom)
             *  {
             *      (readyPopup as ReadyPopup).OnChangeUserInfo(anotherUserInfo.UllRoleId);
             *  }
             * }
             */
            yield break;
        }

        if (NetData.instance.GetUserInfo().GetCharUUID() == (ulong)anotherUserInfo.UllRoleId)
        {
            yield break;
        }

        NetData.RecommandFriendData friend = new NetData.RecommandFriendData();

        friend.c_usn         = (ulong)anotherUserInfo.UllRoleId;
        friend.character_id  = (uint)anotherUserInfo.UnType;
        friend.nickname      = anotherUserInfo.SzName;
        friend.level         = (uint)anotherUserInfo.UnLevel;
        friend.costume_id    = (uint)anotherUserInfo.UnCostumeId;
        friend.isHideCostume = (int)COSTUME_FLAG_TYPE.COSTUME_FLAG_HIDE == anotherUserInfo.UnCostumeShowFlag;
        friend.Prefix        = anotherUserInfo.UnTitlePrefix;
        friend.Sufffix       = anotherUserInfo.UnTitleSuffix;

        if (friend.character_id < 10000)
        {
            friend.character_id = 12000;
        }

        if (friend.costume_id <= 0)
        {
            Debug.LogError(string.Format("RoleID: {0}, costume idx = {1} error charIdx={2}", anotherUserInfo.UllRoleId, friend.costume_id, friend.character_id));

            if (friend.character_id == 11000)
            {
                friend.costume_id = 100;
            }
            else if (friend.character_id == 12000)
            {
                friend.costume_id = 110;
            }
            else if (friend.character_id == 13000)
            {
                friend.costume_id = 120;
            }
        }

        int count = anotherUserInfo.UnEquipmentId.Count;

        for (int i = 0; i < count; i++)
        {
            int equipId = anotherUserInfo.UnEquipmentId[i];
            if (equipId <= 0)
            {
                continue;
            }

            Item.EquipmentInfo equipInfo = _LowDataMgr.instance.GetLowDataEquipItemInfo((uint)equipId);
            if (equipInfo == null)
            {
                Debug.LogError(string.Format("friend equip item not found lowdataID={0} error", equipId));
                continue;
            }

            if (equipInfo.UseParts == (byte)ePartType.CLOTH)
            {
                friend.EquipClothItemIdx = (uint)equipId;
            }
            //else if (equipInfo.UseParts == (byte)ePartType.HELMET)
            //friend.EquipHeadItemIdx = (uint)equipId;
            else if (equipInfo.UseParts == (byte)ePartType.WEAPON)
            {
                friend.EquipWeaponItemIdx = (uint)equipId;
            }
        }

        /*
         * if (friend.character_id == 11000)
         * {
         *  friend.costume_id = (uint)100;
         * }
         * else if (friend.character_id == 12000)
         * {
         *  friend.costume_id = (uint)110;
         * }
         * else if (friend.character_id == 13000)
         * {
         *  friend.costume_id = (uint)120;
         * }
         * else
         * {
         *  Debug.LogError(string.Format("error not found character id {0}, is setting default id:{1}", friend.character_id, 11000));
         *  friend.character_id = 11000;
         *  friend.costume_id = (uint)100;
         * }
         */

        object[] initialData = new object[4] {
            0, 0, (int)UnitType.TownNpc, friend
        };

        //TownUnit tu = TownUnit.CreateTownUnit(anotherUserInfo.UnPosX, anotherUserInfo.UnPosY, initialData);
        TownUnit tu = null;

        yield return(StartCoroutine(TownUnit.CreateTownUnitAsync(anotherUserInfo.UnPosX, anotherUserInfo.UnPosY, (retval) => { tu = retval; }, initialData)));

        tu.ChangeState(UnitState.Idle);

        if (!townUnitList.ContainsKey(anotherUserInfo.UllRoleId))
        {
            townUnitList.Add(anotherUserInfo.UllRoleId, tu);
        }
        else
        {
            Debug.LogError(string.Format("is already key error key={0}, name={1}, isMyChar={2}"
                                         , anotherUserInfo.UllRoleId, anotherUserInfo.SzName, ((ulong)anotherUserInfo.UllRoleId) == NetData.instance.GetUserInfo()._charUUID));
        }

        UIBasePanel basePanel = UIMgr.GetTownBasePanel();

        if (basePanel != null)
        {
            (basePanel as TownPanel).CreateHeadObjet(tu.gameObject, friend.nickname, friend.Prefix, friend.Sufffix, false);

            //string path = string.Format("Effect/_UI/_INGAME/{0}", name);
            CreateAccessEff(tu.gameObject);
        }
        else
        {
            TownNickList.Add(new TownNickData(tu.gameObject, friend.nickname, friend.Prefix, friend.Sufffix));
        }
    }