private void OnRankRefreshModelView(IEvent ievent) { var e = ievent as RankRefreshModelView; var info = e.Info; ModelRoot.DestroyFakeCharacter(); ItemBaseData elfData = null; var elfId = -1; if (info.Equips.ItemsChange.TryGetValue((int)eBagType.Elf, out elfData)) { elfId = elfData.ItemId; } if (AnimModelRoot) { AnimModelRoot.DestroyModel(); } if (e.Iselfrank) { var tbElf = Table.GetElf(elfId); if (tbElf == null) { return; } var dataId = tbElf.ElfModel; if (dataId == -1) { return; } var tableNpc = Table.GetCharacterBase(dataId); if (null == tableNpc) { Logger.Error("In CreateFormationElfModel(), null == tableNpc!!!!!!!"); return; } var offset = tableNpc.CameraHeight / 10000.0f; var colorId = -1; if (elfData.Exdata.Count > (int)ElfExdataDefine.StarLevel) { colorId = GameUtils.GetElfStarColorId(tbElf.ElfModel, elfData.Exdata[(int)ElfExdataDefine.StarLevel]); } ModelRoot.CreateWithColor(dataId, colorId, null, character => { character.SetScale(tableNpc.CameraMult / 10000.0f); character.ObjTransform.localPosition = new Vector3(0, offset - 0.48f, 0); }); } else if (e.IsMountRank) { CreateMountModel(info.MountId); } else { ModelRoot.Create(info.TypeId, info.EquipsModel, character => { ModelDrag.Target = character.transform; }, elfId, true); } }
//�ӳ���ObjCharacter private void CreateChar(int dataId, bool bsync, Dictionary <int, int> dictEquip = null, Action <ObjFakeCharacter> callback = null, int elfId = -1, int layer = 5, int charColorId = -1, int elfColorId = -1) { if (null != BackgroundWidget) { if (null != BackgroundWidget.drawCall) { CustomRenderQueue = BackgroundWidget.drawCall.renderQueue + +1; CustomRenderQueue += BackgroundWidget.SkippedRenderQueue / 2; } } Character = ObjFakeCharacter.Create(dataId, dictEquip, character => { if (Character.GetObjId() != character.GetObjId()) { character.Destroy(); return; } if (!gameObject) { character.Destroy(); return; } var xform = Character.gameObject.transform; //Character.gameObject.SetLayerRecursive(LayerMask.NameToLayer(GAMELAYER.UI)); xform.parent = gameObject.transform; xform.localPosition = Vector3.zero; xform.localScale = Vector3.one; xform.forward = Vector3.back; if (null != callback) { callback(Character); if (-1 != elfId) { if (null == ElfCreator) { ElfCreator = gameObject.AddComponent <CreateFakeCharacter>(); ElfCreator.CustomRenderQueue = CustomRenderQueue; } ElfCreator.DestroyFakeCharacter(); var tbElf = Table.GetElf(elfId); if (tbElf == null) { return; } var elfDataId = tbElf.ElfModel; var tableCharacter = Table.GetCharacterBase(elfDataId); if (null == tableCharacter) { return; } var tempUniqueId = UniqueId; ElfCreator.CreateWithColor(elfDataId, elfColorId, null, elf => { if (character.State == ObjState.Deleted) { elf.Destroy(); return; } if (!gameObject.active) { ElfCreator.Character = null; elf.Destroy(); return; } if (null == Character) { ElfCreator.Character = null; elf.Destroy(); return; } // if (tempUniqueId != UniqueId) // { // ElfCreator.Character = null; // elf.Destroy(); // return; // } var t = elf.gameObject.transform; t.parent = Character.gameObject.transform.parent; t.forward = Vector3.back; //var angle = Character.gameObject.transform.localRotation.eulerAngles.y - 90.0f; var scale = tbElf.CameraZoom * 0.0001f; if (scale <= 0) { Logger.Debug("!!!tbElf.CameraZoom<=0"); scale = 1; } var heightOffset = tbElf.Offset * 0.0001f; var temp = ElfOffset + new Vector3(0, heightOffset, 0f); t.localPosition = temp; t.localScale = Vector3.one * scale; t.parent = Character.gameObject.transform.parent; }, -1, false, layer); } } }, layer, bsync, CustomRenderQueue, UniqueId++, charColorId); }