コード例 #1
0
    /// <summary>
    /// 判断HeroInfo.szClientWeaponCID与WeaponCID是否相同
    /// </summary>
    /// <param name="heroCID"></param>
    /// <param name="weaponCID"></param>
    /// <returns></returns>
    public bool NeedChangeWeapon(byte[] heroCID, byte[] weaponCID)
    {
        var heroInfo = PlayerDataMgr.instance.GetHeroInfoByCID(heroCID);

        if (heroInfo == null || weaponCID == null || PortalMgr.CompareCID(weaponCID, emptyCID))
        {
            return(false);
        }
        else
        {
            return(!PortalMgr.CompareCID(heroInfo.szClientWeaponCID, weaponCID));
        }
    }
コード例 #2
0
    /// <summary>
    /// 更新虚拟底座需要显示的已拥有、尚未拥有、死亡的非实体英雄列表
    /// </summary>
    public void UpdateVirtualHero()
    {
        //实体模式下不需要更新
        if (CoreEntry.toyMgr.GameMode == GameMode.TOY)
        {
            return;
        }

        //更新虚拟英雄VirtualHero
        //更新时机:添加新英雄\有虚拟英雄死亡\退出关卡
        if (listVirtualHeroInfo == null)
        {
            return;
        }
        listVirtualHero.Clear();
        List <VirtualHero> ownedHeroList    = new List <VirtualHero>();
        List <VirtualHero> notOwnedHeroList = new List <VirtualHero>();
        List <VirtualHero> deadHeroList     = new List <VirtualHero>();
        VirtualHero        currentHero      = null;

        //区分还需购买哪些虚拟英雄
        List <int> listResIds = GlobalFunctions.GetHeroResIds((sbyte)HERO_KIND_GROUP.HERO_KIND_ADVANCED);

        for (int i = 0; i < listResIds.Count; i++)
        {
            HeroInfo info = PlayerDataMgr.instance.GetHeroInfoByResId(listResIds[i]);
            if (info == null)
            {
                //尚未拥有该类型虚拟英雄
                var data = BuildVirtualHero(listResIds[i], null, VirtualHeroStatus.NOT_OWNED);
                if (!notOwnedHeroList.Contains(data))
                {
                    notOwnedHeroList.Add(data);
                }
            }
        }

        //区分虚拟英雄是否死亡
        foreach (HeroInfo hero in listVirtualHeroInfo)
        {
            //如果英雄数据是当前英雄数据,不加入list
            var  currentCID    = CoreEntry.portalMgr.GetCurrentHeroInstanceId();
            bool isCurrentHero = PortalMgr.CompareCID(currentCID, hero.szCID);

            var heroData = PlayerDataMgr.instance.GetHeroDataByInstanceId(hero.szCID);
            if (heroData != null)
            {
                if (heroData.currentHp > 0)
                {
                    var data = BuildVirtualHero(hero.nResID, hero, VirtualHeroStatus.OWNED);
                    if (!isCurrentHero)
                    {
                        ownedHeroList.Add(data);
                    }
                    else
                    {
                        currentHero = data;
                    }
                }
                else
                {
                    var data = BuildVirtualHero(hero.nResID, hero, VirtualHeroStatus.DEAD);
                    if (!isCurrentHero)
                    {
                        deadHeroList.Add(data);
                    }
                    else
                    {
                        currentHero = data;
                    }
                }
            }
        }
        //listVirtualHeroInfo分为三部分
        //1、已经拥有且未死亡的英雄
        //2、尚未拥有的英雄
        //3、已经拥有且死亡的英雄
        //排序按照resId,相同resId按照英雄等级排序
        if (currentHero != null)                //理论上虚拟模式下当前底座CID不会为空,因此currentHero数据不会为空。不过为了未考虑到的异常,增加判空
        {
            listVirtualHero.Add(currentHero);
        }
        listVirtualHero.AddRange(ownedHeroList);
        listVirtualHero.AddRange(notOwnedHeroList);
        listVirtualHero.AddRange(deadHeroList);
    }
コード例 #3
0
    public void FinishEffect(string actionName, System.Action cb)
    {
        float finishTime = EFFECT_FINISH;

        //是否需要展示进化相关特效
        if (evolutionCID != null && PortalMgr.CompareCID(usingHeroCID, evolutionCID))
        {
            finishTime = EFFECT_FINISH_EVOLUTION;
            Scheduler.Create(this, (sche, t, s) =>
            {
                evolutionObj = CoreEntry.resourceMgr.InstantiateObject("Prefabs/Effect/common/" + evolutionBase, SceneMgr.FarAway, Quaternion.identity);
                if (heroObj != null && evolutionObj != null)
                {
                    GlobalFunctions.MountTransform(evolutionObj.transform, heroObj.transform);
                    GlobalFunctions.ChangeLayer(evolutionObj, LayerMask.NameToLayer("ChangePlayer"), "Untagged");
                }
            }, 0, 0, EFFECT_PRE_FINISH, ActionMgr.Priority.Normal, true);
            Scheduler.Create(this, (sche, t, s) =>
            {
                wingObj = CoreEntry.resourceMgr.InstantiateObject("Prefabs/Character/Hero/Wings/" + wing, SceneMgr.FarAway, Quaternion.identity);
                var evolutionWingObj = CoreEntry.resourceMgr.InstantiateObject("Prefabs/Effect/common/" + evolutionWing, SceneMgr.FarAway, Quaternion.identity);

                if (heroObj != null)
                {
                    var wingPoint = GlobalFunctions.GetTransform(heroObj.transform, "FloatingItem");
                    if (wingPoint != null && wingObj != null && evolutionWingObj != null)
                    {
                        GlobalFunctions.MountTransform(wingObj.transform, wingPoint);
                        GlobalFunctions.MountTransform(evolutionWingObj.transform, wingPoint);
                        GlobalFunctions.ChangeLayer(wingObj, LayerMask.NameToLayer("ChangePlayer"), "Untagged");
                        GlobalFunctions.ChangeLayer(evolutionWingObj, LayerMask.NameToLayer("ChangePlayer"), "Untagged");
                    }
                }
            }, 0, 0, EFFECT_PRE_FINISH + 0.5f, ActionMgr.Priority.Normal, true);
            Scheduler.Create(this, (sche, t, s) =>
            {
                //TODO:先看效果,英雄进化资源到位后替换
                var namePoint = GlobalFunctions.GetTransform(switchEffect.transform, "NamePoint");
                if (playerData != null && namePoint != null)                    //进化特效不展示英雄名字
                {
                    var name = CoreEntry.resourceMgr.InstantiateObject("Prefabs/Effect/ui/zi/p_ui_jinhuachenggong", SceneMgr.FarAway, Quaternion.identity);
                    if (name != null)
                    {
                        name.transform.parent        = namePoint;
                        name.transform.localPosition = Vector3.zero;
                        name.transform.localRotation = Quaternion.identity;
                    }
                }
            }, 0, 0, EFFECT_PRE_FINISH + 1.0f, ActionMgr.Priority.Normal, true);
        }

        Scheduler.Create(this, (sche, t, s) =>
        {
            if (switchEffect != null)
            {
                GameObject.Destroy(switchEffect);
            }
            if (evolutionObj != null)
            {
                GameObject.Destroy(evolutionObj);
            }
            if (wingObj != null)
            {
                GameObject.Destroy(wingObj);
            }
            if (cb != null)
            {
                cb();
            }
        }, 0, 0, finishTime, ActionMgr.Priority.Normal, true);
    }
コード例 #4
0
    void CreateEffect(int heroResId, string actionName, System.Action cb)
    {
        // 清除旧的特效
        CloseEmpty();
        ClearEffect();


        // 切换过程中都只认这个CID
        usingHeroCID = showingCID == null?CoreEntry.portalMgr.GetLastHeroCID() : showingCID;

        usingHeroResId     = heroResId;
        isShowingEmptyBase = false;

        // 创建特效
        float     costTime  = 0;
        Transform heroPoint = null;

        //ChardLi需求,进化后英雄第一次进入时,应播放进化之前对应的英雄动画
        if (evolutionCID != null && PortalMgr.CompareCID(usingHeroCID, evolutionCID))
        {
            var heroAttr = CoreEntry.gameDataMgr.heroAttr.GetRecord(heroResId);
            if (heroAttr != null)
            {
                heroResId = heroAttr.iInitialID;
            }
        }
        createHeroAction = () =>
        {
            //创建英雄
            if (CoreEntry.gameDataMgr.GetPlayerDataByResId(heroResId, out playerData))
            {
                if (heroObj != null)
                {
                    UnityEngine.Object.Destroy(heroObj);
                }
                heroObj = CoreEntry.resourceMgr.InstantiateObject(playerData.resPath + "_hd", Vector3.one, Quaternion.identity);
            }
            if (heroObj == null)
            {
                cb();
                return;
            }
            //加载翅膀
            CoreEntry.resourceMgr.LoadWing(heroObj, heroResId);
            // 关闭脚本
            var cs = heroObj.GetComponents <Creature>();
            for (int i = 0; i < cs.Length; ++i)
            {
                cs[i].enabled = false;
            }
            GlobalFunctions.ChangeLayer(heroObj, LayerMask.NameToLayer("ChangePlayer"), "Untagged");
            if (CoreEntry.sceneMgr.isPauseGame)
            {
                GlobalFunctions.AnimationIgnoreTime(heroObj);
            }
        };


        if (IsDeadType(changeType))
        {
            if (CoreEntry.toyMgr.GameMode == GameMode.VIRTUAL)
            {
                //如果是虚拟英雄的话走单独流程
                CoreEntry.globalObject.GetComponent <CoreEntry>().StartCoroutine(SceneMgr.DelayToInvoke(() =>
                {
                    // 关闭主摄像机,直接使用美术的
                    CoreEntry.cameraMgr.CloseMainCamera();
                    var panel = CoreEntry.uiMgr.GetPanelSimply(AIToyMgr.VIRTUAL_PANEL);
                    cb();
                }));
                return;
            }

            // 关闭主摄像机,直接使用美术的
            CoreEntry.cameraMgr.CloseMainCamera();
            //英雄死亡的逻辑走这里
            switchEffect = CoreEntry.resourceMgr.InstantiateObject("Prefabs/Effect/pet/p_pet_catch_lose", SceneMgr.FarAway, Quaternion.identity);
            costTime     = EFFECT_DIE_TIME;

            // 检查是否还有可以更换的英雄玩偶
            bool isAllDead = CoreEntry.virtualHeroMgr.ToyHeroAllDead();

            // 获取文字特效
            Transform goShowText1 = switchEffect.transform.Find("HeroPoint/p_pet_lose");
            if (null != goShowText1)
            {
                goShowText1.gameObject.SetActive(isAllDead);
            }
            Transform goShowText2 = switchEffect.transform.FindChild("HeroPoint/p_pet_lose02");
            if (null != goShowText2)
            {
                goShowText2.gameObject.SetActive(!isAllDead);
            }

            heroPoint = GlobalFunctions.GetTransform(switchEffect.transform, "HeroPoint");
            if (heroPoint != null)
            {
                //延后执行,不显示英雄生成时站立画面,直接显示失败动画
                Scheduler.Create(this, (sche, t, s) =>
                {
                    createHeroAction();
                    if (heroObj != null)
                    {
                        GlobalFunctions.MountTransform(heroObj.transform, heroPoint);
                    }
                    // 播放英雄死亡公共特效
                    CoreEntry.actionMgr.PlayAction("hero_dead", heroObj);
                    //执行回调函数
                    cb();
                }, 0, 0, costTime, ActionMgr.Priority.Normal, true);
            }
        }
        else
        {
            // 关闭主摄像机,直接使用美术的
            CoreEntry.cameraMgr.CloseMainCamera();
            //英雄正常进入走这里
            createHeroAction();
            switchEffect = CoreEntry.resourceMgr.InstantiateObject("Prefabs/Effect/scene/switchball/" + switchBg, SceneMgr.FarAway * 2, Quaternion.identity);
            costTime     = EFFECT_SHOW_TIME;

            // 使用美术坐标

            heroPoint = GlobalFunctions.GetTransform(switchEffect.transform, "NonHeroPoint");
#if true
            if (heroPoint != null && heroObj != null)
            {
                //播放切换英雄时音效
                //GlobalFunctions.ChangeLayer(heroPoint.gameObject, LayerMask.NameToLayer("ChangePlayer"));
                GlobalFunctions.MountTransform(heroObj.transform, heroPoint);
                var actor = heroObj.GetComponent <Actor>();
                if (actor != null)
                {
                    actor.ignoreTimeScale = true;
                }
                CoreEntry.actionMgr.PlayAction("switchFlyIn", heroObj);
            }
#endif

            // 创建名字特效
            Scheduler.Create(this, (sche, t, s) =>
            {
                // mount name
                if (switchEffect == null)
                {
                    cb();
                    return;
                }
                var namePoint = GlobalFunctions.GetTransform(switchEffect.transform, "NamePoint");
                if (playerData != null && namePoint != null && evolutionCID == null)                    //进化特效不展示英雄名字
                {
                    var name = CoreEntry.resourceMgr.InstantiateObject(playerData.namePath, SceneMgr.FarAway, Quaternion.identity);
                    if (name != null)
                    {
                        name.transform.parent        = namePoint;
                        name.transform.localPosition = Vector3.zero;
                        name.transform.localRotation = Quaternion.identity;
                    }
                }
                cb();
            }, 0, 0, costTime, ActionMgr.Priority.Normal, true);
        }

        // 设置场景对象,用于设置soundListener
        CoreEntry.sceneMgr.soundPlayerTransform = heroPoint.transform;
    }
コード例 #5
0
    void ShowHeroDeadAnim(ChangeType changeType)
    {
        switch (changeType)
        {
        case ChangeType.HERO_DEAD:
        {
            // play dead and wait for hero
            int hero = CoreEntry.portalMgr.GetLastHeroResId();
            this.changeType = ChangeType.HERO_DEAD;

            //正在播放本英雄死亡动画时,不再切换
            if (isPlayingHeroDead == true &&
                PortalMgr.CompareCID(UsingHeroCID, CoreEntry.portalMgr.GetCurrentHeroInstanceId()) == true)
            {
                return;
            }

            isPlayingHeroDead = true;
            //回调函数
            System.Action cb = () =>
            {
                CoreEntry.eventMgr.TriggerEvent <bool>("showHeroSwitch", true);
                DeadPanel deadPanel = null;
                VirtualHeroSwitchPanel virtualPanel = null;

                if (CoreEntry.toyMgr.GameMode == GameMode.TOY)
                {
                    deadPanel = CoreEntry.uiMgr.GetPanelSimply("DeadPanel") as DeadPanel;

                    soundId = CoreEntry.soundMgr.PlaySound("MainUIsfx", "Play_Hero_Change_Before", deadPanel.gameObject);
                }
                else
                {
                    virtualPanel = CoreEntry.uiMgr.GetPanelSimply(AIToyMgr.VIRTUAL_PANEL) as VirtualHeroSwitchPanel;

                    soundId = CoreEntry.soundMgr.PlaySound("MainUIsfx", "Play_Hero_Change_Before", virtualPanel.gameObject);
                }

                deadAction = () =>
                {
                    isAllDead = true;
                    CoreEntry.eventMgr.TriggerEvent("HeroDeadShowEnd");
                    EndSwitch();
                    CoreEntry.eventMgr.TriggerEvent(EventDefine.EVENT_LOSE_BATTLE);
                };
                if (deadPanel != null)
                {
                    deadPanel.onRestart = deadAction;
                }
                else
                {
                    virtualPanel.onRestart = deadAction;
                }
            };
            //播放特效
            CreateEffect(hero, "hero_dead", cb);
        }
        break;

        case ChangeType.PVE_HERO_DEAD:
        {
            AiToyDebug.Log("pve英雄死亡, 检查英雄是否已死亡完");

            if (CoreEntry.uiMgr.GetPanel(PvePanelMgr.PveResultPanel) != null)
            {
                isChanging = false;
                return;
            }

            if (CoreEntry.areaMgr.IsDoublePveScene() && PveMgr.instance.heroMgr.IsAllDie())
            {
                isChanging = false;
                return;
            }
            // play dead and wait for hero
            int hero = CoreEntry.portalMgr.GetLastHeroResId();
            this.changeType   = ChangeType.PVE_HERO_DEAD;
            isPlayingHeroDead = true;

            CreateEffect(hero, "hero_dead", () =>
                {
                    pveDeadAction = () =>
                    {
                        isAllDead         = true;
                        isChanging        = false;
                        isPlayingHeroDead = false;
                        CoreEntry.uiMgr.DestroyPanel("DeadPanel");
                        CoreEntry.eventMgr.TriggerEvent("CancelPauseChallengeScene");
                    };
                    CoreEntry.eventMgr.TriggerEvent <bool>("showHeroSwitch", true);
                    DeadPanel deadPanel = null;
                    VirtualHeroSwitchPanel virtualPanel = null;
                    if (CoreEntry.toyMgr.GameMode == GameMode.TOY)
                    {
                        deadPanel = CoreEntry.uiMgr.GetPanelSimply("DeadPanel") as DeadPanel;
                    }
                    else
                    {
                        virtualPanel = CoreEntry.uiMgr.GetPanelSimply(AIToyMgr.VIRTUAL_PANEL) as VirtualHeroSwitchPanel;
                    }

                    if (deadPanel != null)
                    {
                        deadPanel.onRestart = pveDeadAction;
                    }
                    else
                    {
                        virtualPanel.onRestart = pveDeadAction;
                    }
                });
        }
        break;
        }
    }