Exemple #1
0
 public void RecursiveDo(int id, EtyAvatar avatar, List <int> weaponList, Action callback)
 {
     if (id < weaponList.Count)
     {
         Equip(avatar, weaponList[id], () => { id++; RecursiveDo(id, avatar, weaponList, callback); });
     }
     else
     {
         if (callback != null)
         {
             callback();
         }
     }
 }
    public void UpdateSelectedAvatarModel()
    {
        //MogoMessageBox.ShowLoading();
        MogoGlobleUIManager.Instance.ShowWaitingTip(true);
        var avatarInfo = MogoWorld.theAccount.GetAvatarInfo(m_selectedCharacterId);

        NewLoginUIViewManager.Instance.SetCharacterGridDown(m_selectedCharacterId);
        if (avatarInfo != null && avatarInfo.Vocation != 0)
        {
            LoadChooseCharacter(avatarInfo.Vocation, (avatar) =>
            {
                //if (m_lastSelectedCharacter == avatar)
                //    return;
                if (m_lastSelectedCharacter != null)
                {
                    m_lastSelectedCharacter.Hide();
                }

                avatar.RemoveAll();

                var list = new List <int>();
                if (avatarInfo.Weapon != 0)
                {
                    list.Add(avatarInfo.Weapon);
                }
                if (avatarInfo.Cuirass != 0)
                {
                    list.Add(avatarInfo.Cuirass);
                }
                if (avatarInfo.Shoes != 0)
                {
                    list.Add(avatarInfo.Shoes);
                }
                if (avatarInfo.Armguard != 0)
                {
                    list.Add(avatarInfo.Armguard);
                }
                avatar.Equip(list, () =>
                {
                    //MogoMessageBox.HideLoading();
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                    avatar.Show();
                });

                m_lastSelectedCharacter = avatar;
            });
        }
    }
    /// <summary>
    /// 加载人物模型
    /// </summary>
    /// <param name="vocation"></param>
    /// <param name="cuirass"></param>
    /// <param name="weapon"></param>
    /// <param name="action"></param>
    private void LoadCharactor(int vocation, int cuirass, int weapon, Action<GameObject> action)
    {
        List<int> equipList = new List<int>();
        //cuirass = ItemEquipmentData.dataMap.Get(cuirass).mode;
        //weapon = ItemEquipmentData.dataMap.Get(weapon).mode;
        equipList.Add(ItemEquipmentData.dataMap.Get(weapon).mode);
        equipList.Add(ItemEquipmentData.dataMap.Get(cuirass).mode);
        var modelDAta = AvatarModelData.dataMap.GetValueOrDefault((int)vocation, new AvatarModelData());

        INSTANCE_COUNT++;
        MogoGlobleUIManager.Instance.ShowWaitingTip(true);
        //Debug.LogError("GetUIInstance:" + modelDAta.prefabName);
        AssetCacheMgr.GetUIInstance(modelDAta.prefabName, (prefab, id, go) =>
        {
            var ety = new EtyAvatar();
            ety.vocation = vocation;
            ety.equipList = equipList;
            ety.weapon = weapon;
            ety.CreatePosition = Vector3.zero;
            var avatar = (go as GameObject);
            ety.gameObject = avatar;
            avatar.name = "DragonMatchModelPool" + vocation.ToString();
            var cc = avatar.collider as CharacterController;
            cc.radius = 0.5f;
            ety.animator = avatar.GetComponent<Animator>();
            ety.animator.applyRootMotion = false;
            ety.sfxHandler = avatar.AddComponent<SfxHandler>();

            ety.actorParent = avatar.AddComponent<ActorParent>();
            ety.actorParent.InitEquipment(vocation);

            INSTANCE_COUNT--;
            if (INSTANCE_COUNT <= 0)
                MogoGlobleUIManager.Instance.ShowWaitingTip(false);
            //Debug.LogError("GetUIInstance done");

            INSTANCE_COUNT++;
            MogoGlobleUIManager.Instance.ShowWaitingTip(true);
            //Debug.LogError("Equip");
            ety.actorParent.Equip(equipList, () =>
            {
                avatar.transform.localPosition = Vector3.zero;
                avatar.transform.localScale = Vector3.one;

                //Debug.LogError("weapon:" + weapon);
                ItemEquipmentData equip = ItemEquipmentData.dataMap.Get(weapon);
                int subtype = equip.subtype;
                int type = equip.type;
                ControllerOfWeaponData controllerData = ControllerOfWeaponData.dataMap[subtype];
                RuntimeAnimatorController controller;
                Animator animator = ety.animator;

                string controllerName = controllerData.controllerInCity;
                if (animator.runtimeAnimatorController != null)
                {
                    if (animator.runtimeAnimatorController.name == controllerName)
                    {
                        action(go as GameObject);
                        Debug.LogError("animator.runtimeAnimatorController.name == controllerName");
                        return;
                    }

                    AssetCacheMgr.ReleaseResource(animator.runtimeAnimatorController);
                }

                INSTANCE_COUNT--;
                if (INSTANCE_COUNT <= 0)
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                //Debug.LogError("Equip done");

                INSTANCE_COUNT++;
                MogoGlobleUIManager.Instance.ShowWaitingTip(true);
                //Debug.LogError("GetResource:" + controllerName);
                AssetCacheMgr.GetResource(controllerName, (obj) =>
                {
                    controller = obj as RuntimeAnimatorController;
                    animator.runtimeAnimatorController = controller;

                    action(go as GameObject);
                    //(GetEntity() as EntityMyself).UpdateSkillToManager();
                    //EventDispatcher.TriggerEvent<int, int>(InventoryEvent.OnChangeEquip, type, subtype);

                    INSTANCE_COUNT--;
                    if (INSTANCE_COUNT <= 0)
                        MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                });
            });
        });
    }
    private void CreateCharacterModel(AvatarModelData ai, int vocation, CharacterInfoData ci, Action loaded)
    {
        if (m_avatarList.ContainsKey(vocation) && loaded != null)
        {
            if (m_avatarList[vocation].actorParent != null)
            {
                loaded();
                return;
            }
            if (m_avatarList[vocation].gameObject != null)
            {
                AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject);
            }
        }
        AssetCacheMgr.GetInstanceAutoRelease(ai.prefabName, (prefab, id, go) =>
        {
            var ety                      = new EtyAvatar();
            ety.vocation                 = vocation;
            ety.equipList                = ci.EquipList;
            ety.weapon                   = ci.Weapon;
            ety.CreatePosition           = ci.Location;
            var avatar                   = (go as GameObject);
            ety.gameObject               = avatar;
            avatar.name                  = vocation.ToString();
            var cc                       = avatar.GetComponent <Collider>() as CharacterController;
            cc.radius                    = 0.5f;
            ety.animator                 = avatar.GetComponent <Animator>();
            ety.animator.applyRootMotion = false;
            ety.PlayerShader             = PlayerShader;
            ety.FakeLightShader          = FakeLightShader;
            //MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1);

            if (vocation == 1)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, -0.4f, 0.01f, -0.5f);
            }
            else if (vocation == 2)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f);
            }
            else if (vocation == 3)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f);
            }
            else if (vocation == 4)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f);
            }
            else if (vocation == 3 || vocation == 4)
            {
                // �����ڴ�
                AssetCacheMgr.GetInstanceAutoRelease("fx_jqqd.prefab", (prefabb, idd, goo) =>
                {
                    GameObject goFX           = (GameObject)goo;
                    goFX.transform.parent     = avatar.transform;
                    goFX.transform.localScale = Vector3.one;

                    if (vocation == 3)
                    {
                        goFX.transform.localPosition = new Vector3(0, 2.2f, 0);
                    }
                    else
                    {
                        goFX.transform.localPosition = new Vector3(0, 2f, 0);
                    }
                });
            }

            #region ����

            if (m_Animators.ContainsKey(vocation))
            {
                m_Animators[vocation] = avatar.GetComponent <Animator>();
            }
            else
            {
                m_Animators.Add(vocation, avatar.GetComponent <Animator>());
            }

            #endregion

            avatar.transform.position   = ci.Location;
            avatar.transform.localScale = Vector3.one;

            ety.sfxHandler = avatar.AddComponent <SfxHandler>();

            #region ��Ч �� ��Чɾ��������ʱ��

            if (!m_sfxHandlers.ContainsKey(vocation))
            {
                SfxHandler handler = avatar.GetComponent <SfxHandler>();
                if (handler == null)
                {
                    handler = avatar.AddComponent <SfxHandler>();
                }
                m_sfxHandlers.Add(vocation, handler);
                uint timer = uint.MaxValue;
                m_fxTimes.Add(vocation, timer);
            }

            #endregion

            ety.actorParent = avatar.AddComponent <ActorParent>();
            ety.actorParent.SetNakedEquid(ai.nakedEquipList);
            ety.InitEquip();

            if (m_avatarList.ContainsKey(vocation))
            {
                m_avatarList[vocation].sfxHandler.RemoveAllFX();
                AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject);
            }
            ety.Hide();
            m_avatarList[vocation] = ety;
            AssetCacheMgr.GetResource(ci.controller,
                                      (obj) =>
            {
                var controller = obj as RuntimeAnimatorController;
                if (ety.animator)
                {
                    ety.animator.runtimeAnimatorController = controller;
                }
                if (loaded != null)
                {
                    loaded();
                }
            });
        });
    }
    public void LoadCreateCharacter(Action callback)
    {
        AssetCacheMgr.GetResource("PlayerShader.shader", (obj) =>
        {
            AssetCacheMgr.GetResource("MogoFakeLight.shader", (obj1) =>
            {
                FakeLightShader = (Shader)obj1;
                PlayerShader    = (Shader)obj;
                LoadCamera();
                MogoWorld.inCity        = false;
                m_lastSelectedCharacter = null;
                LoadCharacters(() =>
                {
                    foreach (var item in m_avatarList)
                    {
                        item.Value.Init();
                        item.Value.SetCreateMode();
                    }

                    var avatarList = m_avatarList.Values.ToList();
                    var counter    = 0;
                    for (int i = 0; i < avatarList.Count; i++)
                    {
                        var item = avatarList[i];
                        item.gameObject.transform.position = item.CreatePosition;
                        item.Equip(item.equipList, () =>
                        {
                            counter++;
                            if (counter == m_avatarList.Count * 2)
                            {
                                if (callback != null)
                                {
                                    callback();
                                }
                            }
                        });

                        int vocation = item.vocation;

                        item.Equip(item.weapon, () =>
                        {
                            if (vocation == (int)Vocation.Mage && m_sfxHandlers.ContainsKey(vocation))
                            {
                                m_sfxHandlers[vocation].HandleFx(10239, null, (go, fxid) =>
                                {
                                    go.transform.parent           = m_avatarList[vocation].gameObject.transform.Find("Bip_master/bip_weapon_separate/equip_mage_staff_02_p(Clone)");
                                    go.transform.localPosition    = Vector3.zero;
                                    go.transform.localEulerAngles = new Vector3(270, 0, 0);
                                    go.transform.localScale       = new Vector3(1, 1, 1);
                                });
                            }
                            counter++;
                            if (counter == m_avatarList.Count * 2)
                            {
                                if (callback != null)
                                {
                                    callback();
                                }
                            }
                        });
                    }
                });
            });
        });
    }
    /// <summary>
    /// ѡ�񴴽���ɫ
    /// </summary>
    /// <param name="go"></param>
    void OnCreateCharacterSelected(GameObject go, bool needFadeIn)
    {
        var vocation = Int32.Parse(go.name);

        #region ����

        var goAnimator = m_Animators[vocation];
        if (goAnimator != null)
        {
            goAnimator.SetInteger("Action", 35);
            actionTimer = TimerHeap.AddTimer(500, 0, () =>
            {
                if (go && goAnimator)
                {
                    goAnimator.SetInteger("Action", 34);
                }
            });
        }

        #endregion

        #region ��Ч

        switch (vocation)
        {
        case (int)Vocation.Warrior:
            if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
            {
                foreach (var item in m_sfxHandlers)
                {
                    item.Value.RemoveAllFX();
                }

                foreach (var item in m_fxTimes)
                {
                    TimerHeap.DelTimer(item.Value);
                }

                m_sfxHandlers[vocation].HandleFx(10135);
                m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                {
                    if (m_sfxHandlers.ContainsKey(vocation))
                    {
                        m_sfxHandlers[vocation].RemoveAllFX();
                    }
                });
            }
            break;

        case (int)Vocation.Archer:
            if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
            {
                foreach (var item in m_sfxHandlers)
                {
                    item.Value.RemoveAllFX();
                }

                foreach (var item in m_fxTimes)
                {
                    TimerHeap.DelTimer(item.Value);
                }

                m_sfxHandlers[vocation].HandleFx(10335);
                m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                {
                    if (m_sfxHandlers.ContainsKey(vocation))
                    {
                        m_sfxHandlers[vocation].RemoveAllFX();
                    }
                });
            }
            break;

        case (int)Vocation.Assassin:
            if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
            {
                foreach (var item in m_sfxHandlers)
                {
                    item.Value.RemoveAllFX();
                }

                foreach (var item in m_fxTimes)
                {
                    TimerHeap.DelTimer(item.Value);
                }

                m_sfxHandlers[vocation].HandleFx(10435);
                m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                {
                    if (m_sfxHandlers.ContainsKey(vocation))
                    {
                        m_sfxHandlers[vocation].RemoveAllFX();
                    }
                });
            }
            break;


        case (int)Vocation.Mage:
            if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
            {
                foreach (var item in m_sfxHandlers)
                {
                    item.Value.RemoveAllFX();
                }

                foreach (var item in m_fxTimes)
                {
                    TimerHeap.DelTimer(item.Value);
                }

                m_sfxHandlers[vocation].HandleFx(10235);
                m_sfxHandlers[vocation].HandleFx(10239, null, (fxgo, fxid) =>
                {
                    fxgo.transform.parent           = m_avatarList[vocation].gameObject.transform.Find("Bip_master/bip_weapon_separate/equip_mage_staff_02_p(Clone)");
                    fxgo.transform.localPosition    = Vector3.zero;
                    fxgo.transform.localEulerAngles = new Vector3(270, 0, 0);
                    fxgo.transform.localScale       = new Vector3(1, 1, 1);
                });

                m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                {
                    if (m_sfxHandlers.ContainsKey(vocation))
                    {
                        m_sfxHandlers[vocation].RemoveFXs(10235);
                    }
                });
            }
            break;

        default:
            break;
        }

        #endregion

        var cameraSlot = m_cameraSlots.GetValueOrDefault(vocation, null);
        m_loginCamera.SetTarget(cameraSlot);
        var avatar = m_avatarList.GetValueOrDefault(vocation, null);
        if (avatar == null)
        {
            return;
        }

        if (m_lastSelectedCharacter != null)
        {
            m_lastSelectedCharacter.Unfocus();
        }
        avatar.Focus();
        if (needFadeIn)
        {
            m_lastSelectedCharacter.FadeOut();
            avatar.FadeIn();
        }
        else
        {
            foreach (var item in m_avatarList)
            {
                if (item.Value != avatar)
                {
                    item.Value.FadeOut();
                }
            }
        }
        m_lastSelectedCharacter = avatar;
        NewLoginUIViewManager.Instance.ShowCreateCharacterDetailUI();
        var chrInfo = CharacterInfoData.dataMap.GetValueOrDefault(int.Parse(go.name), null);
        if (chrInfo != null)
        {
            NewLoginUIViewManager.Instance.SetCreateCharacterJobDetailName(LanguageData.dataMap[chrInfo.vocation].content);
            NewLoginUIViewManager.Instance.SetCreateCharacterJobDetailInfo(LanguageData.dataMap[chrInfo.discription].content);
            List <JobAttrGridData> listd = new List <JobAttrGridData>()
            {
                new JobAttrGridData()
                {
                    attrName = LanguageData.GetContent(46802), level = chrInfo.attack
                },
                new JobAttrGridData()
                {
                    attrName = LanguageData.GetContent(46803), level = chrInfo.defence
                },
                new JobAttrGridData()
                {
                    attrName = LanguageData.GetContent(46804), level = chrInfo.range
                },
            };

            NewLoginUIViewManager.Instance.FillJobAttrGridData(listd);
        }

        #region ��Ч

        SoundManager.PlaySoundByID(19);

        #endregion

        #region ���ƴ���

        switch (vocation)
        {
        case 1:
        case 2:
        case 4:
        case 3:
            NewLoginUIViewManager.Instance.SetEnterButtonLabel(LanguageData.GetContent(46800), true);
            NewLoginUIViewManager.Instance.ShowDiceAndName(true);
            NewLoginUIViewManager.Instance.SetCharacterNameInputText("");
            EventDispatcher.TriggerEvent <byte>(Events.UIAccountEvent.OnGetRandomName, (byte)avatar.vocation);
            break;


            //NewLoginUIViewManager.Instance.SetEnterButtonLabel(LanguageData.GetContent(46801), false);
            //NewLoginUIViewManager.Instance.ShowDiceAndName(false);
            // TO DO
            //NewLoginUIViewManager.Instance.SetCharacterNameInputText("");
            //EventDispatcher.TriggerEvent<byte>(Events.UIAccountEvent.OnGetRandomName, (byte)avatar.vocation);
            //break;
        }

        switch (vocation)
        {
        case 1:
            m_currentPos = 3;
            NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(3);
            break;

        case 2:
            m_currentPos = 4;
            NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(4);
            break;

        case 3:
            m_currentPos = 1;
            NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(1);
            break;

        case 4:
            m_currentPos = 2;
            NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(2);
            break;
        }

        #endregion
        GameProcManager.SetGameProgress(ProcType.CreateCharacter, "SelectCharacter");
    }
Exemple #7
0
    private void LoadCharacter(int vocation, Action loaded)
    {
        var ci = CharacterInfoData.dataMap.GetValueOrDefault(vocation, new CharacterInfoData());
        var ai = AvatarModelData.dataMap.GetValueOrDefault(vocation, new AvatarModelData());

        if (ModelShowCaseLogicManager.Instance.AvatarList.ContainsKey(vocation) &&
            ModelShowCaseLogicManager.Instance.AvatarList[vocation].gameObject != null)
        {
            if (loaded != null)
            {
                loaded();
            }

            ResetViewPort(vocation);
            return;
        }

        AssetCacheMgr.GetInstance(ai.prefabName, (prefab, id, go) =>
        {
            var ety            = new EtyAvatar();
            ety.vocation       = vocation;
            ety.equipList      = ci.EquipList;
            ety.weapon         = ci.Weapon;
            ety.CreatePosition = Vector3.zero;
            var avatar         = (go as GameObject);
            ety.gameObject     = avatar;
            MogoFXManager.Instance.AddShadow(ety.gameObject, (uint)ety.gameObject.GetHashCode(), 1, 1, 1, 8);
            avatar.name  = "ModelPool" + vocation.ToString();
            var cc       = avatar.GetComponent <Collider>() as CharacterController;
            cc.radius    = 0.5f;
            ety.animator = avatar.GetComponent <Animator>();
            ety.animator.applyRootMotion = false;


            ety.sfxHandler = avatar.AddComponent <SfxHandler>();

            ety.actorParent = avatar.AddComponent <ActorParent>();
            ety.actorParent.InitEquipment(vocation);
            //ety.actorParent.SetNakedEquid(ai.nakedEquipList);
            //ety.InitEquip();
            ety.gameObject.SetActive(false);
            if (ModelShowCaseLogicManager.Instance.AvatarList.ContainsKey(vocation))
            {
                ModelShowCaseLogicManager.Instance.AvatarList[vocation].sfxHandler.RemoveAllFX();
                AssetCacheMgr.ReleaseInstance(ModelShowCaseLogicManager.Instance.AvatarList[vocation].gameObject);
            }
            //ety.Hide();

            ModelShowCaseLogicManager.Instance.AvatarList[vocation] = ety;
            //avatar.transform.parent = transform;
            avatar.transform.localPosition = new Vector3(-1000, -1000, -1000);
            avatar.transform.localScale    = Vector3.one;
            var ObjCamera = new GameObject();
            ObjCamera.transform.parent           = avatar.transform.Find("slot_camera");
            ObjCamera.name                       = "Camera";
            ObjCamera.transform.localScale       = new Vector3(1, 1, 1);
            ObjCamera.transform.localEulerAngles = new Vector3(270, 180, 0);
            switch (vocation)
            {
            case 1:
                ObjCamera.transform.localPosition = new Vector3(0, -3.33f, 0);
                break;

            case 2:
                ObjCamera.transform.localPosition = new Vector3(0, -2.77f, 0);
                break;

            case 3:
                ObjCamera.transform.localPosition = new Vector3(0, -3f, 0);
                break;

            case 4:
                ObjCamera.transform.localPosition = new Vector3(0, -2.7f, 0);
                break;

            default:
                break;
            }

            var m_camera           = ObjCamera.AddComponent <Camera>();
            m_camera.clearFlags    = CameraClearFlags.Depth;
            m_camera.cullingMask   = 1 << 8;
            m_camera.nearClipPlane = 0.01f;
            m_camera.farClipPlane  = 5;
            m_camera.depth         = 10;
            m_camera.fieldOfView   = 40;
            var m_viewport         = ObjCamera.AddComponent <UIViewport>();
            ModelShowCaseLogicManager.Instance.ViewportList[vocation] = m_viewport;
            m_viewport.sourceCamera = GameObject.Find("Camera").GetComponentInChildren <Camera>();//Camera.mainCamera;
            m_viewport.topLeft      = left;
            m_viewport.bottomRight  = right;
            if (loaded != null)
            {
                loaded();
            }
            // AssetCacheMgr.GetResource(ci.controller,
            //(obj) =>
            //{
            //    var controller = obj as RuntimeAnimatorController;
            //    if (ety.animator)
            //        ety.animator.runtimeAnimatorController = controller;
            //    if (loaded != null)
            //        loaded();
            //});
        });
    }
Exemple #8
0
    public void Equip(EtyAvatar avatar, int _equipId, Action callback)
    {
        //Debug.Log("_equipId:" + _equipId);
        if (avatar.gameObject == null)
        {
            Debug.Log("Transform == null");
            //Debug.LogError("Transform == null");
            return;
        }
        System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
        stopWatch.Start();

        if (!ItemEquipmentData.dataMap.ContainsKey(_equipId))
        {
            Debug.LogError("can not find equip:" + _equipId);
            return;
        }
        ItemEquipmentData equip = ItemEquipmentData.dataMap[_equipId];

        if (equip.mode > 0)
        {
            if (avatar.actorParent == null)
            {
                Debug.Log("the actor is null!!!!");
                //Debug.LogError("the actor is null!!!!");
                return;
            }
            avatar.actorParent.m_isChangingWeapon = true;
            avatar.actorParent.Equip(equip.mode, () =>
            {
                if (equip.type == (int)EquipType.Weapon)
                {
                    //Debug.Log("ControllerOfWeaponData:" + equip.id);
                    //Debug.Log("ControllerOfWeaponData:" + equip.subtype);
                    //Debug.Log("ControllerOfWeaponData:" + (int)vocation);
                    ControllerOfWeaponData controllerData = ControllerOfWeaponData.dataMap[equip.subtype];
                    RuntimeAnimatorController controller;
                    AssetCacheMgr.GetResource(controllerData.controller,
                                              (obj) =>
                    {
                        controller = obj as RuntimeAnimatorController;
                        if (avatar.animator == null)
                        {
                            return;
                        }
                        avatar.animator.runtimeAnimatorController = controller;


                        if (MogoWorld.inCity)
                        {
                            avatar.animator.SetInteger("Action", -1);
                        }
                        else
                        {
                            avatar.animator.SetInteger("Action", 0);
                        }
                        callback();
                    });
                }
                else
                {
                    callback();
                }
            });

            stopWatch.Stop();
        }
        else
        {
            callback();
        }
    }
    public void LoadCreateCharacter(Action callback)
    {
        AssetCacheMgr.GetResource("PlayerShader.shader", (obj) =>
        {
            AssetCacheMgr.GetResource("MogoFakeLight.shader", (obj1) =>
            {
                FakeLightShader = (Shader)obj1;
                PlayerShader = (Shader)obj;
                LoadCamera();
                MogoWorld.inCity = false;
                m_lastSelectedCharacter = null;
                LoadCharacters(() =>
                {
                    foreach (var item in m_avatarList)
                    {
                        item.Value.Init();
                        item.Value.SetCreateMode();
                    }

                    var avatarList = m_avatarList.Values.ToList();
                    var counter = 0;
                    for (int i = 0; i < avatarList.Count; i++)
                    {
                        var item = avatarList[i];
                        item.gameObject.transform.position = item.CreatePosition;
                        item.Equip(item.equipList, () =>
                        {
                            counter++;
                            if (counter == m_avatarList.Count * 2)
                                if (callback != null)
                                    callback();
                        });

                        int vocation = item.vocation;

                        item.Equip(item.weapon, () =>
                        {
                            if (vocation == (int)Vocation.Mage && m_sfxHandlers.ContainsKey(vocation))
                                m_sfxHandlers[vocation].HandleFx(10239, null, (go, fxid) =>
                                {
                                    go.transform.parent = m_avatarList[vocation].gameObject.transform.Find("Bip_master/bip_weapon_separate/equip_mage_staff_02_p(Clone)");
                                    go.transform.localPosition = Vector3.zero;
                                    go.transform.localEulerAngles = new Vector3(270, 0, 0);
                                    go.transform.localScale = new Vector3(1, 1, 1);
                                });
                            counter++;
                            if (counter == m_avatarList.Count * 2)
                                if (callback != null)
                                    callback();
                        });
                    }
                });
            });
        });
    }
    private void CreateCharacterModel(AvatarModelData ai, int vocation, CharacterInfoData ci, Action loaded)
    {
        if (m_avatarList.ContainsKey(vocation) && loaded != null)
        {
            if (m_avatarList[vocation].actorParent != null)
            {
                loaded();
                return;
            }
            if (m_avatarList[vocation].gameObject != null)
            {
                AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject);
            }
        }
        AssetCacheMgr.GetInstanceAutoRelease(ai.prefabName, (prefab, id, go) =>
        {
            var ety = new EtyAvatar();
            ety.vocation = vocation;
            ety.equipList = ci.EquipList;
            ety.weapon = ci.Weapon;
            ety.CreatePosition = ci.Location;
            var avatar = (go as GameObject);
            ety.gameObject = avatar;
            avatar.name = vocation.ToString();
            var cc = avatar.collider as CharacterController;
            cc.radius = 0.5f;
            ety.animator = avatar.GetComponent<Animator>();
            ety.animator.applyRootMotion = false;
            ety.PlayerShader = PlayerShader;
            ety.FakeLightShader = FakeLightShader;
            //MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1);

            if (vocation == 1)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, -0.4f, 0.01f, -0.5f);
            }
            else if (vocation == 2)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f);
            }
            else if(vocation == 3)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f);
            }
            else if (vocation == 4)
            {
                MogoFXManager.Instance.AttachShadow(avatar, string.Concat(avatar.name, "_Shadow"), 0, 0, 0, 1.5f, 1.5f, 1, 0, 0.01f, 0.2f);
            }
            else if (vocation == 3 || vocation == 4)
            {
                // 敬请期待
                AssetCacheMgr.GetInstanceAutoRelease("fx_jqqd.prefab", (prefabb, idd, goo) =>
                    {
                        GameObject goFX = (GameObject)goo;
                        goFX.transform.parent = avatar.transform;
                        goFX.transform.localScale = Vector3.one;

                        if (vocation == 3)
                        {
                            goFX.transform.localPosition = new Vector3(0, 2.2f, 0);
                        }
                        else
                        {
                            goFX.transform.localPosition = new Vector3(0, 2f, 0);
                        }
                    });
            }

            #region 动作

            if (m_Animators.ContainsKey(vocation))
                m_Animators[vocation] = avatar.GetComponent<Animator>();
            else
                m_Animators.Add(vocation, avatar.GetComponent<Animator>());

            #endregion

            avatar.transform.position = ci.Location;
            avatar.transform.localScale = Vector3.one;

            ety.sfxHandler = avatar.AddComponent<SfxHandler>();

            #region 特效 和 特效删除函数定时器

            if (!m_sfxHandlers.ContainsKey(vocation))
            {
                SfxHandler handler = avatar.GetComponent<SfxHandler>();
                if (handler == null)
                    handler = avatar.AddComponent<SfxHandler>();
                m_sfxHandlers.Add(vocation, handler);
                uint timer = uint.MaxValue;
                m_fxTimes.Add(vocation, timer);
            }

            #endregion

            ety.actorParent = avatar.AddComponent<ActorParent>();
            ety.actorParent.SetNakedEquid(ai.nakedEquipList);
            ety.InitEquip();

            if (m_avatarList.ContainsKey(vocation))
            {
                m_avatarList[vocation].sfxHandler.RemoveAllFX();
                AssetCacheMgr.ReleaseInstance(m_avatarList[vocation].gameObject);
            }
            ety.Hide();
            m_avatarList[vocation] = ety;
            AssetCacheMgr.GetResource(ci.controller,
           (obj) =>
           {
               var controller = obj as RuntimeAnimatorController;
               if (ety.animator)
                   ety.animator.runtimeAnimatorController = controller;
               if (loaded != null)
                   loaded();
           });
        });
    }
    /// <summary>
    /// 选择创建角色
    /// </summary>
    /// <param name="go"></param>
    void OnCreateCharacterSelected(GameObject go, bool needFadeIn)
    {
        var vocation = Int32.Parse(go.name);

        #region 动作

        var goAnimator = m_Animators[vocation];
        if (goAnimator != null)
        {
            goAnimator.SetInteger("Action", 35);
            actionTimer = TimerHeap.AddTimer(500, 0, () =>
            {
                if (go && goAnimator)
                    goAnimator.SetInteger("Action", 34);
            });
        }

        #endregion

        #region 特效

        switch (vocation)
        {
            case (int)Vocation.Warrior:
                if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
                {
                    foreach (var item in m_sfxHandlers)
                        item.Value.RemoveAllFX();

                    foreach (var item in m_fxTimes)
                        TimerHeap.DelTimer(item.Value);

                    m_sfxHandlers[vocation].HandleFx(10135);
                    m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                    {
                        if (m_sfxHandlers.ContainsKey(vocation))
                            m_sfxHandlers[vocation].RemoveAllFX();
                    });
                }
                break;

            case (int)Vocation.Archer:
                if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
                {
                    foreach (var item in m_sfxHandlers)
                        item.Value.RemoveAllFX();

                    foreach (var item in m_fxTimes)
                        TimerHeap.DelTimer(item.Value);

                    m_sfxHandlers[vocation].HandleFx(10335);
                    m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                    {
                        if (m_sfxHandlers.ContainsKey(vocation))
                            m_sfxHandlers[vocation].RemoveAllFX();
                    });
                }
                break;

            case (int)Vocation.Assassin:
                if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
                {
                    foreach (var item in m_sfxHandlers)
                        item.Value.RemoveAllFX();

                    foreach (var item in m_fxTimes)
                        TimerHeap.DelTimer(item.Value);

                    m_sfxHandlers[vocation].HandleFx(10435);
                    m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                    {
                        if (m_sfxHandlers.ContainsKey(vocation))
                            m_sfxHandlers[vocation].RemoveAllFX();
                    });
                }
                break;


            case (int)Vocation.Mage:
                if (m_sfxHandlers.ContainsKey(vocation) && m_fxTimes.ContainsKey(vocation))
                {
                    foreach (var item in m_sfxHandlers)
                        item.Value.RemoveAllFX();

                    foreach (var item in m_fxTimes)
                        TimerHeap.DelTimer(item.Value);

                    m_sfxHandlers[vocation].HandleFx(10235);
                    m_sfxHandlers[vocation].HandleFx(10239, null, (fxgo, fxid) =>
                    {
                        fxgo.transform.parent = m_avatarList[vocation].gameObject.transform.Find("Bip_master/bip_weapon_separate/equip_mage_staff_02_p(Clone)");
                        fxgo.transform.localPosition = Vector3.zero;
                        fxgo.transform.localEulerAngles = new Vector3(270, 0, 0);
                        fxgo.transform.localScale = new Vector3(1, 1, 1);
                    });

                    m_fxTimes[vocation] = TimerHeap.AddTimer(3000, 0, () =>
                    {
                        if (m_sfxHandlers.ContainsKey(vocation))
                            m_sfxHandlers[vocation].RemoveFXs(10235);
                    });
                }
                break;

            default:
                break;
        }

        #endregion

        var cameraSlot = m_cameraSlots.GetValueOrDefault(vocation, null);
        m_loginCamera.SetTarget(cameraSlot);
        var avatar = m_avatarList.GetValueOrDefault(vocation, null);
        if (avatar == null)
            return;

        if (m_lastSelectedCharacter != null)
            m_lastSelectedCharacter.Unfocus();
        avatar.Focus();
        if (needFadeIn)
        {
            m_lastSelectedCharacter.FadeOut();
            avatar.FadeIn();
        }
        else
        {
            foreach (var item in m_avatarList)
            {
                if (item.Value != avatar)
                    item.Value.FadeOut();
            }
        }
        m_lastSelectedCharacter = avatar;
        NewLoginUIViewManager.Instance.ShowCreateCharacterDetailUI();
        var chrInfo = CharacterInfoData.dataMap.GetValueOrDefault(int.Parse(go.name), null);
        if (chrInfo != null)
        {
            NewLoginUIViewManager.Instance.SetCreateCharacterJobDetailName(LanguageData.dataMap[chrInfo.vocation].content);
            NewLoginUIViewManager.Instance.SetCreateCharacterJobDetailInfo(LanguageData.dataMap[chrInfo.discription].content);
            List<JobAttrGridData> listd = new List<JobAttrGridData>() { 
                new JobAttrGridData(){attrName = LanguageData.GetContent(46802), level = chrInfo.attack},
                new JobAttrGridData(){attrName = LanguageData.GetContent(46803), level = chrInfo.defence},
                new JobAttrGridData(){attrName = LanguageData.GetContent(46804), level = chrInfo.range},
            };

            NewLoginUIViewManager.Instance.FillJobAttrGridData(listd);
        }

        #region 音效

        SoundManager.PlaySoundByID(19);

        #endregion

        #region 限制创建

        switch (vocation)
        {
            case 1:
            case 2:
            case 4:
            case 3:
                NewLoginUIViewManager.Instance.SetEnterButtonLabel(LanguageData.GetContent(46800), true);
                NewLoginUIViewManager.Instance.ShowDiceAndName(true);
                NewLoginUIViewManager.Instance.SetCharacterNameInputText("");
                EventDispatcher.TriggerEvent<byte>(Events.UIAccountEvent.OnGetRandomName, (byte)avatar.vocation);
                break;

       
                //NewLoginUIViewManager.Instance.SetEnterButtonLabel(LanguageData.GetContent(46801), false);
                //NewLoginUIViewManager.Instance.ShowDiceAndName(false);
                // TO DO
                //NewLoginUIViewManager.Instance.SetCharacterNameInputText("");
                //EventDispatcher.TriggerEvent<byte>(Events.UIAccountEvent.OnGetRandomName, (byte)avatar.vocation);
                //break;
        }

        switch (vocation)
        {
            case 1:
                m_currentPos = 3;
                NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(3);
                break;
            case 2:
                m_currentPos = 4;
                NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(4);
                break;
            case 3:
                m_currentPos = 1;
                NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(1);
                break;
            case 4:
                m_currentPos = 2;
                NewLoginUIViewManager.Instance.SelectCreateCharacterDetailUIJobIcon(2);
                break;
        }

        #endregion
        GameProcManager.SetGameProgress(ProcType.CreateCharacter, "SelectCharacter");
    }
    public void UpdateSelectedAvatarModel()
    {
        //MogoMessageBox.ShowLoading();
        MogoGlobleUIManager.Instance.ShowWaitingTip(true);
        var avatarInfo = MogoWorld.theAccount.GetAvatarInfo(m_selectedCharacterId);
        NewLoginUIViewManager.Instance.SetCharacterGridDown(m_selectedCharacterId);
        if (avatarInfo != null && avatarInfo.Vocation != 0)
        {
            LoadChooseCharacter(avatarInfo.Vocation, (avatar) =>
            {
                //if (m_lastSelectedCharacter == avatar)
                //    return;
                if (m_lastSelectedCharacter != null)
                    m_lastSelectedCharacter.Hide();

                avatar.RemoveAll();

                var list = new List<int>();
                if (avatarInfo.Weapon != 0)
                    list.Add(avatarInfo.Weapon);
                if (avatarInfo.Cuirass != 0)
                    list.Add(avatarInfo.Cuirass);
                if (avatarInfo.Shoes != 0)
                    list.Add(avatarInfo.Shoes);
                if (avatarInfo.Armguard != 0)
                    list.Add(avatarInfo.Armguard);
                avatar.Equip(list, () =>
                {
                    //MogoMessageBox.HideLoading();
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                    avatar.Show();
                });

                m_lastSelectedCharacter = avatar;
            });
        }
    }
Exemple #13
0
    private void LoadCharacter(int vocation, Action loaded)
    {
        var ci = CharacterInfoData.dataMap.GetValueOrDefault(vocation, new CharacterInfoData());
        var ai = AvatarModelData.dataMap.GetValueOrDefault(vocation, new AvatarModelData());

        if (ModelShowCaseLogicManager.Instance.AvatarList.ContainsKey(vocation) &&
            ModelShowCaseLogicManager.Instance.AvatarList[vocation].gameObject != null)
        {
            if (loaded != null)
            {
                loaded();
            }

            ResetViewPort(vocation);
            return;
        }

        AssetCacheMgr.GetInstance(ai.prefabName, (prefab, id, go) =>
        {
            var ety = new EtyAvatar();
            ety.vocation = vocation;
            ety.equipList = ci.EquipList;
            ety.weapon = ci.Weapon;
            ety.CreatePosition = Vector3.zero;
            var avatar = (go as GameObject);
            ety.gameObject = avatar;
            MogoFXManager.Instance.AddShadow(ety.gameObject, (uint)ety.gameObject.GetHashCode(), 1, 1, 1, 8);
            avatar.name = "ModelPool" + vocation.ToString();
            var cc = avatar.collider as CharacterController;
            cc.radius = 0.5f;
            ety.animator = avatar.GetComponent<Animator>();
            ety.animator.applyRootMotion = false;


            ety.sfxHandler = avatar.AddComponent<SfxHandler>();

            ety.actorParent = avatar.AddComponent<ActorParent>();
            ety.actorParent.InitEquipment(vocation);
            //ety.actorParent.SetNakedEquid(ai.nakedEquipList);
            //ety.InitEquip();
            ety.gameObject.SetActive(false);
            if (ModelShowCaseLogicManager.Instance.AvatarList.ContainsKey(vocation))
            {
                ModelShowCaseLogicManager.Instance.AvatarList[vocation].sfxHandler.RemoveAllFX();
                AssetCacheMgr.ReleaseInstance(ModelShowCaseLogicManager.Instance.AvatarList[vocation].gameObject);
            }
            //ety.Hide();

            ModelShowCaseLogicManager.Instance.AvatarList[vocation] = ety;
            //avatar.transform.parent = transform;
            avatar.transform.localPosition = new Vector3(-1000, -1000, -1000);
            avatar.transform.localScale = Vector3.one;
            var ObjCamera = new GameObject();
            ObjCamera.transform.parent = avatar.transform.FindChild("slot_camera");
            ObjCamera.name = "Camera";
            ObjCamera.transform.localScale = new Vector3(1, 1, 1);
            ObjCamera.transform.localEulerAngles = new Vector3(270, 180, 0);
            switch (vocation)
            {
                case 1:
                    ObjCamera.transform.localPosition = new Vector3(0, -3.33f, 0);
                    break;
                case 2:
                    ObjCamera.transform.localPosition = new Vector3(0, -2.77f, 0);
                    break;
                case 3:
                    ObjCamera.transform.localPosition = new Vector3(0, -3f, 0);
                    break;
                case 4:
                    ObjCamera.transform.localPosition = new Vector3(0, -2.7f, 0);
                    break;
                default:
                    break;
            }

            var m_camera = ObjCamera.AddComponent<Camera>();
            m_camera.clearFlags = CameraClearFlags.Depth;
            m_camera.cullingMask = 1 << 8;
            m_camera.nearClipPlane = 0.01f;
            m_camera.farClipPlane = 5;
            m_camera.depth = 10;
            m_camera.fieldOfView = 40;
            var m_viewport = ObjCamera.AddComponent<UIViewport>();
            ModelShowCaseLogicManager.Instance.ViewportList[vocation] = m_viewport;
            m_viewport.sourceCamera = GameObject.Find("Camera").GetComponentInChildren<Camera>();//Camera.mainCamera;
            m_viewport.topLeft = left;
            m_viewport.bottomRight = right;
            if (loaded != null)
                loaded();
            // AssetCacheMgr.GetResource(ci.controller,
            //(obj) =>
            //{
            //    var controller = obj as RuntimeAnimatorController;
            //    if (ety.animator)
            //        ety.animator.runtimeAnimatorController = controller;
            //    if (loaded != null)
            //        loaded();
            //});
        });
    }
Exemple #14
0
    public void Equip(EtyAvatar avatar, int _equipId, Action callback)
    {
        //Mogo.Util.LoggerHelper.Debug("_equipId:" + _equipId);
        if (avatar.gameObject == null)
        {
            Mogo.Util.LoggerHelper.Debug("Transform == null");
            //LoggerHelper.Error("Transform == null");
            return;
        }
        System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
        stopWatch.Start();

        if (!ItemEquipmentData.dataMap.ContainsKey(_equipId))
        {
            LoggerHelper.Error("can not find equip:" + _equipId);
            return;
        }
        ItemEquipmentData equip = ItemEquipmentData.dataMap[_equipId];
        if (equip.mode > 0)
        {
            if (avatar.actorParent == null)
            {
                Mogo.Util.LoggerHelper.Debug("the actor is null!!!!");
                //LoggerHelper.Error("the actor is null!!!!");
                return;
            }
            avatar.actorParent.m_isChangingWeapon = true;
            avatar.actorParent.Equip(equip.mode, () => 
            {
                if (equip.type == (int)EquipType.Weapon)
                {
                    //Mogo.Util.LoggerHelper.Debug("ControllerOfWeaponData:" + equip.id);
                    //Mogo.Util.LoggerHelper.Debug("ControllerOfWeaponData:" + equip.subtype);
                    //Mogo.Util.LoggerHelper.Debug("ControllerOfWeaponData:" + (int)vocation);
                    ControllerOfWeaponData controllerData = ControllerOfWeaponData.dataMap[equip.subtype];
                    RuntimeAnimatorController controller;
                    AssetCacheMgr.GetResource(controllerData.controller,
                    (obj) =>
                    {
                        controller = obj as RuntimeAnimatorController;
                        if (avatar.animator == null) return;
                        avatar.animator.runtimeAnimatorController = controller;


                        if (MogoWorld.inCity)
                        {
                            avatar.animator.SetInteger("Action", -1);
                        }
                        else
                        {
                            avatar.animator.SetInteger("Action", 0);
                        }
                        callback();
                    });
                }
                else
                {
                    callback();
                }
            });

            stopWatch.Stop();
        }
        else
        {
            callback();
        }
    }
Exemple #15
0
 public void RecursiveDo(int id, EtyAvatar avatar, List<int> weaponList, Action callback)
 {
     if (id < weaponList.Count)
     {
         Equip(avatar, weaponList[id], () => { id++; RecursiveDo(id, avatar, weaponList, callback); });
     }
     else
     {
         if (callback != null)
         {
             callback();
         }
     }
 }