private void RemoveFromEntityEffectTable(LightingEffectBehavior instance)
    {
        if (!isValid)
        {
            return;
        }
        if (ClosedOptimiezed)
        {
            return;
        }
        if (null == instance)
        {
            return;
        }
        if (null == instance.EffectConfig || null == instance.EffectParam)
        {
            return;
        }

        int effectID = instance.getID();

        if (effectID <= 0)
        {
            return;
        }
        LightEffectParam param = instance.EffectParam;

        //是single类型的,梁成说必须要创建
        if (instance.EffectConfig.bSingle)
        {
            return;
        }
        //只对绑定光效作这个效果
        if (instance.EffectConfig.GetEffectType() != LightingEffectConfigType.Bind)
        {
            return;
        }

        int entityID = param.nSrcEntityID;
        Dictionary <int, List <LightingEffectBehavior> > tables = null;
        List <LightingEffectBehavior> list = null;

        //已经有这个ID了
        if (m_EntityBindEffectHostID.TryGetValue(entityID, out tables))
        {
            if (tables.TryGetValue(effectID, out list))
            {
                list.Remove(instance);
                if (list.Count <= 0)
                {
                    tables.Remove(effectID);
                }
            }

            if (tables.Count <= 0)
            {
                m_EntityBindEffectHostID.Remove(entityID);
            }
        }
    }
    /// <summary>
    /// 这个光效是否可以创建
    /// </summary>
    /// <param name="effect"></param>
    /// <param name="param"></param>
    private bool isCanCreateEffect(LightingEffect effect, LightEffectParam param)
    {
        if (!isValid)
        {
            return(false);
        }
        if (ClosedOptimiezed)
        {
            return(true);
        }
        //是single类型的,梁成说必须要创建
        if (effect.bSingle)
        {
            return(true);
        }
        //只对绑定光效作这个效果
        if (effect.GetEffectType() != LightingEffectConfigType.Bind)
        {
            return(true);
        }

        LightingEffect_Bind bindeffect = effect as LightingEffect_Bind;

        bool Reslut = isCanCreateEffect_Single(effect.nID, param.nSrcEntityID, bindeffect.bIgnoreSingleEffectOptimtized, param) /*&&
                                                                                                                                 * isCanCreateEffect_OnView(param.nSrcEntityID)*/;

        return(Reslut);
    }
 public LightingEffectBehavior AddLighting(int nID, LightEffectParam param)
 {
     //打开开关,并且有预制体的,并且不是主角的,我们才存起来
     if (!param.bIsHero)
     {
         //如果需要创建的数量比每帧需要创建的要多,一次性最多只能创建MaxCreateOnPreFrame
         if (WillCreateList.Count > MaxCreateOnPreFrame && CurrentCreateCount < MaxCreateOnPreFrame)
         {
             EffectCreateInfo info = GetInvaildInfo();
             info.nID          = nID;
             info.param        = param;
             info.hostInstance = this;
             WillCreateList.Enqueue(info);
             return(null);
         }
         else
         {
             CurrentCreateCount++;
             return(AddLightingImpl(nID, param));
         }
     }
     else
     {
         return(AddLightingImpl(nID, param));
     }
 }
Пример #4
0
    //动作触发,添加绑定光效
    public void BindLighting(int LightingID)
    {
        if (showLog)
        {
            Trace.Log("Animation Add Bind Light" + LightingID);
        }
        if (!lightingEffectEnable) //挂动作上的光效,如果物体已经被隐藏,那直接不挂了
        {
            return;
        }
        LightEffectParam param = new LightEffectParam();

        param.srcObject = gameObject;
        param.sourcePos = gameObject.transform.position;
        param.targetPos = gameObject.transform.position;
        if (stateMachine == null)
        {
            stateMachine = GetComponent <BaseStateMachine>();
        }
        if (stateMachine)
        {
            param.nSrcEntityID = stateMachine.entityID;
        }

        AddLighting(LightingID, param);
    }
Пример #5
0
    public static bool Play(ref U3D_Render.EntityView ev, int effectID, cmd_creature_skillview cmdInfo)
    {
        //光效开关
        if (!Initialize.Instance || !OptimitzedControlPlane.Instance.EnabledLightingEffect)
        {
            return(true);
        }

        LightEffectParam param = new LightEffectParam();

        param.nFeedbackID     = cmdInfo.nFeedBackID;
        param.bIsHero         = ev.IsHero;
        param.nSrcEntityID    = ev.ID;
        param.nTargetEntityID = cmdInfo.nTargetEntityID;
        param.srcObject       = ev.gameObject;
        param.nCreatorSide    = cmdInfo.nCreatorSide;
        if (cmdInfo.nSrcEntityID > 0)
        {
            param.nSrcEntityID = cmdInfo.nSrcEntityID;
            param.srcObject    = EntityFactory.getEntityGameObjectByID(cmdInfo.nSrcEntityID);
        }
        param.fDistance    = cmdInfo.fDistance;
        param.fAttackRange = cmdInfo.fAttackRange;
        param.speed        = cmdInfo.fPASD;
        if (cmdInfo.nTargetEntityID != 0)
        {
            param.targetObject = EntityFactory.getEntityGameObjectByID(cmdInfo.nTargetEntityID);
        }
        param.targetPos = new Vector3(cmdInfo.fTargetPos_x, cmdInfo.fTargetPos_y, cmdInfo.fTargetPos_z);
        if (cmdInfo.bFlyToTargetPos != 0)
        {
            param.nEffectFlag |= (int)LightEffectParam.EFFECT_FLAG.FlyToTargetPos;
        }

        param.sourcePos = new Vector3(cmdInfo.fSrcPos_x, cmdInfo.fSrcPos_y, cmdInfo.fSrcPos_z);
        if (cmdInfo.bFromSrcPos != 0)
        {
            param.nEffectFlag |= (int)LightEffectParam.EFFECT_FLAG.CustomSourcePos;
        }

        LightingEffectManager manager = ev.LightingEffectManager;

        if (manager == null)
        {
            return(false);
        }

        // 开始光效
        manager.AddLighting(effectID, param);

        // 输出光效信息
        if (manager.showLog)
        {
            Trace.Log("Add Lighting" + effectID + ". Entity Id=" + ev.ID + " SrcID=" + param.nSrcEntityID);
            Trace.Log("TargetID=" + cmdInfo.nTargetEntityID + ". TargetPos=(" + cmdInfo.fTargetPos_x + "," + cmdInfo.fTargetPos_y + "," + cmdInfo.fTargetPos_z + ").");
        }

        return(true);
    }
Пример #6
0
 public virtual void ResetAllMembers()
 {
     needClose              = false;
     effectParam            = null;
     behaviorTransformAgent = null;
     //behaviorDestroyTimer = null;
     ResHandlePlayData.Clear();
 }
    /// <summary>
    /// 创建光效
    /// </summary>
    /// <param name="nID"></param>
    /// <param name="param"></param>
    /// <returns></returns>
    public LightingEffectBehavior CreateEffect(int nID, LightEffectParam param, bool isFromHero = false)
    {
        if (!isValid)
        {
            return(null);
        }
        if (nID <= 0)
        {
            return(null);
        }
        LightingEffectBehavior reslut = null;
        LightingEffect         config = ASpeedGame.Data.Scheme.SchemeLightingEffect.Instance.GetLightingEffect(nID);

        if (!config)
        {
            Trace.Warning("LightingEffect creates failed. Id " + nID.ToString() + "has not loaded.");
            return(reslut);
        }

        //if(!SceneManager.Instance.isMainCity())
        //{
        //    if (!FirstCachedEffectID.Contains(nID))
        //    {
        //        if (!currentCachedEffectID.Contains(nID))
        //        {
        //            FirstCachedEffectID.Add(nID);
        //            Debug.LogWarning("创建了没有缓存的光效,ID:" + nID);
        //        }
        //    }
        //}

        if (!isCanCreateEffect(config, param))
        {
            return(reslut);
        }
        RemovePreWarmEffectQueue(nID);
        Queue <LightingEffectBehavior> cacheList = null;

        if (!m_behaviorCacheTable.TryGetValue(nID, out cacheList))
        {
            cacheList = new Queue <LightingEffectBehavior>();
            m_behaviorCacheTable.Add(nID, new Queue <LightingEffectBehavior>());
        }

        if (cacheList.Count > 0)
        {
            reslut = cacheList.Dequeue();
            ResetBehavior(reslut);
        }
        else
        {
            reslut = CreateNewBehavior(nID, config.GetEffectType());
        }
        reslut.FillData(config, param, GetResourceHandleAsync(nID, reslut.OnResourcesLoadFinish), AllocBehaviorTransformAgent());
        reslut.SetValid();
        PushToEntityEffectTable(reslut);
        return(reslut);
    }
Пример #8
0
 public virtual void FillData(LightingEffect effectConfig, LightEffectParam param, LightingEffectResHandleInstance instance, Transform transformAgent)
 {
     this.effectConfig           = effectConfig;
     effectID                    = effectConfig.nID;
     this.effectParam            = param;
     this.ResHandleInstance      = instance;
     this.behaviorTransformAgent = transformAgent;
     ResHandlePlayData.Clear();
 }
Пример #9
0
 public override void FillData(LightingEffect effectConfig, LightEffectParam param, LightingEffectResHandleInstance instance, Transform transformAgent)
 {
     base.FillData(effectConfig, param, instance, transformAgent);
     this.wardConfig = effectConfig as LightingEffect_Ward;
     if (!wardConfig && effectConfig)
     {
         Debug.LogWarning(effectConfig.nID + "配置不匹配,创建光效失败---" + GetType().ToString());
     }
 }
    private bool isCanCreateEffect_Single(int effectID, int entityID, bool bIgnore, LightEffectParam param)
    {
        if (!isValid)
        {
            return(false);
        }
        /*主要是看同一个物体上是不是会有同一个光效,如果有同一个光效,就重新播放一次*/
        Dictionary <int, List <LightingEffectBehavior> > tables = null;

        //已经有这个ID了
        if (m_EntityBindEffectHostID.TryGetValue(entityID, out tables))
        {
            List <LightingEffectBehavior> effect = null;
            //这个光效已经有了
            if (tables.TryGetValue(effectID, out effect))
            {
                //如果这个配置,忽略这个单一光效优化
                if (bIgnore)
                {
                    U3D_Render.EntityView ev = EntityFactory.getEntityViewByID(entityID);
                    if (null != ev)
                    {
                        //如果是玩家,则优化有效,如果是怪物,则继续跳过
                        if (ev.Type == ENTITY_TYPE.TYPE_PLAYER_ROLE)
                        {
                            return(true);
                        }
                    }
                }

                if (effect != null)
                {
                    while (true)
                    {
                        if (effect.Count <= 0)
                        {
                            break;
                        }

                        if (effect[0] != null)
                        {
                            if (effect[0].RePlay(param))
                            {
                                return(false);
                            }
                        }
                        effect.RemoveAt(0);
                    }
                }
                return(true);
            }
            return(true);
        }
        return(true);
    }
Пример #11
0
    public float speed = 1.0f; //播放速度倍率

    public void ColoneTo(ref LightEffectParam targetParam)
    {
        targetParam.srcObject       = srcObject;
        targetParam.nSrcEntityID    = nSrcEntityID;
        targetParam.nTargetEntityID = nTargetEntityID;
        targetParam.targetObject    = targetObject;
        targetParam.targetPos       = targetPos;
        targetParam.nFeedbackID     = nFeedbackID;
        targetParam.bIsHero         = bIsHero;
        targetParam.fDistance       = fDistance;
        targetParam.fAttackRange    = fAttackRange;
        targetParam.nEffectFlag     = nEffectFlag;
        targetParam.speed           = speed;
    }
Пример #12
0
    /// <summary>
    /// 播放开头动画(最快下一帧开始播放)
    /// </summary>
    private void PlayBattleMovie()
    {
        LightingEffectManager lem = EntityFactory.EffectGroup.GetComponent <LightingEffectManager>();

        if (lem != null)
        {
            LightEffectParam param = new LightEffectParam();
            param.srcObject = MainHerpObj;
            param.sourcePos = MainHerpObj.transform.position;
            param.targetPos = MainHerpObj.transform.position;

            lem.AddLighting(343, param);
            //lem.RegisterEffectComplete(343, OnMovieFinished);
        }
        LightingEffectManager lem2 = EntityFactory.GloabaleManager;

        if (lem2 != null)
        {
            EffectHelper.Play(ref MainHerpEv, 333, MainHerpEv.ID, 0, MainHerpObj.transform.position);
            lem2.RegisterEffectStart(333, OnMovieStart);
            lem2.RegisterEffectComplete(333, OnMovieFinished);
        }
    }
Пример #13
0
 public override void recoverEffectLift(LightEffectParam newParam)
 {
     effectParam = newParam;
     behaviorTransformAgent.SetPosition(effectParam.targetPos);
 }
 public override void recoverEffectLift(LightEffectParam newParam)
 {
     effectParam = newParam;
 }
Пример #15
0
    private void OnAICommand()
    {
        int targetID = 0;

        if (raycast.targetID > 0)
        {
            EntityView evTarget       = EntityFactory.getEntityViewByID(raycast.targetID);
            EntityView evMainHeroView = EntityFactory.MainHeroView;
            if (evTarget != null && evTarget.IsValid)
            {
                if (evTarget.CampFlag == CampFlag.CampFlag_Friend && evTarget.Type == ENTITY_TYPE.TYPE_PLAYER_ROLE)
                {
                    // 1.发送服务器要(1)控制或(2)解除或   暂时没有该功能//(3)移交targetID的友方英雄单位
                    if (evTarget.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_AI_SCHEME_ID) > 0)
                    {
                        targetID = raycast.targetID;
                        if (!LogicDataCenter.teamRightWndDataManager.MyTeamUIDTable.ContainsKey(targetID))
                        {
                            return;
                        }
                        TeamRightInfo teamRightInfo = LogicDataCenter.teamRightWndDataManager.MyTeamUIDTable[targetID] as TeamRightInfo;

                        int       groundLightEffectID     = 0;
                        const int helpmeSignLightEffectID = 13;
                        const int dangerSignLightEffectID = 12;
                        if (LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[teamRightInfo.nSlotId])
                        {
                            cmd_war_ai_command_break_follow data = new cmd_war_ai_command_break_follow();
                            data.uidTarget = targetID;
                            EntityEventHelper.Instance.SendCommand <cmd_war_ai_command_break_follow>(EntityFactory.MainHeroID, EntityLogicDef.ENTITY_CMD_AI_COMMAND_BREAK_FOLLOW, ref data);

                            groundLightEffectID = dangerSignLightEffectID;
                        }
                        else
                        {
                            cmd_war_ai_command_follow data = new cmd_war_ai_command_follow();
                            data.uidTarget = targetID;
                            EntityEventHelper.Instance.SendCommand <cmd_war_ai_command_follow>(EntityFactory.MainHeroID, EntityLogicDef.ENTITY_CMD_AI_COMMAND_FOLLOW, ref data);

                            groundLightEffectID = helpmeSignLightEffectID;
                        }
                        LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[teamRightInfo.nSlotId] = !LogicDataCenter.teamRightWndDataManager.BIsJoinFollow[teamRightInfo.nSlotId];

                        // 添加地面光效
                        Vector3 pos = new Vector3();
                        if (MouseRaycastToGround(ref pos))
                        {
                            int        LayerMaskOnPos   = (1 << LayerMask.NameToLayer(Config.LayerDefault) | 1 << LayerMask.NameToLayer(Config.LayerBuilding));
                            Ray        PointToGroundRay = new Ray(pos + new Vector3(0, 0.5f, 0), new Vector3(0, -1, 0));
                            RaycastHit projectInfo;
                            Physics.Raycast(PointToGroundRay, out projectInfo, 100, LayerMaskOnPos);
                            pos = projectInfo.point;

                            LightEffectParam param = new LightEffectParam();
                            param.nSrcEntityID = evMainHeroView.ID;
                            param.sourcePos    = pos;
                            param.targetPos    = pos;
                            LightingEffectManager lem = evMainHeroView.LightingEffectManager;
                            if (lem != null && lem)
                            {
                                lem.AddLighting(groundLightEffectID, param);
                            }
                        }
                    }
                }
            }
        }
    }
Пример #16
0
    ////-----------------------------------------------------------------------------------------------------
    ////以下部分主要处理光效跟动作配合的时候,需要检查状态机切换再开始光效的功能
    ////-----------------------------------------------------------------------------------------------------
    //private List<LightingEffect> mDelayEffectList; //延迟挂接的光效,等到状态切换后再开始挂接
    //private int lastestStateNameHash = 0;
    //private void dealWithStateEffect()
    //{
    //    if (animator == null)
    //    {
    //        animator = transform.GetComponent<Animator>();
    //    }

    //    if (animator == null)
    //    {
    //        return;
    //    }
    //    if (animator.layerCount < 2)
    //    {
    //        return;
    //    }
    //    AnimatorStateInfo sta = animator.GetCurrentAnimatorStateInfo(1);
    //    int currentStateNameHash = sta.nameHash;
    //    if (currentStateNameHash == lastestStateNameHash)
    //    {
    //        return;
    //    }

    //    //切换动作了!这里nameHash只做切换时间点的判断,用nameHash和effect.waitState对比老是失败
    //    lastestStateNameHash=currentStateNameHash;
    //    foreach (LightingEffect effect in mDelayEffectList)
    //    {
    //        if (sta.IsName(effect.getWaitState()))
    //        {
    //            if (effect.Begin())
    //            {
    //                mEffectList.Add(effect);
    //            }
    //        }
    //    }

    //    //目前暂定切一次动作就清空一次延迟光效的记录,也就是说光效只能延迟一个动作挂接
    //    mDelayEffectList.Clear();
    //}



    // 添加一个光效
    // @param nID : 光效ID
    // @param nSrcEntityID : 光效源对象ID
    // @param targetObject : 目标对象,可以为空
    // @param targetPos : 目标位置,可以为空
    // @param isHero : 是否是游戏玩家控制的主角
    // @param nFeedbackID : 逻辑层传的ID标识,用于标记、删除和碰撞是返回标识。

    public LightingEffectBehavior AddLightingImpl(int nID, LightEffectParam param)
    {
        //远距离不创建分情况考虑,具体在LightingEffect实现
        //if (LightingEffectFactory.Instance.IsEnabledOptimize())
        //{
        //    //距离超过创建距离,不创建光效了。
        //    Vector3 dis = Initialize.mainCam.transform.position - param.srcObject.transform.position;
        //    if (dis.sqrMagnitude > LightingEffectFactory.CreateDistance * LightingEffectFactory.CreateDistance)
        //    {
        //        return null;
        //    }
        //}

        //处理单一实例的光效
        if (LightingEffectFactory.Instance.IsSingleEffect(nID))
        {
            foreach (LightingEffectBehavior effect in mEffectList)
            {
                if (effect.getID() == nID && effect.EffectConfig.bSingle)
                {
                    if (effect.EffectConfig.bRecoverSingleEffect)
                    {
                        effect.recoverEffectLift(param);
                        return(effect);
                    }
                    else if (effect.EffectParam.nTargetEntityID == param.nTargetEntityID)
                    {
                        effect.extendEffectLift();
                        return(effect);
                    }
                }
            }
        }

        if (LightingEffectFactory.Instance.CheckGolbalEffect(nID) && isGlobal == false)
        {
            LightingEffectManager leManager = EntityFactory.GloabaleManager;
            if (leManager != null && leManager.isGlobal == true)
            {
                leManager.AddLighting(nID, param);
            }
            return(null);
        }

        LightingEffectBehavior newEffect = LightingEffectFactory.Instance.CreateEffect(nID, param);

        if (newEffect == null)
        {
            return(null);
        }

        newEffect.showLog = showLog;
        //string needStateName = newEffect.getWaitState();

        //if (needStateName.Length != 0)
        //{
        //    AnimatorStateInfo sta = animator.GetCurrentAnimatorStateInfo(1);
        //    if (!sta.IsName(needStateName))
        //    {
        //        //等下一个切换状态时再检测
        //        mDelayEffectList.Add(newEffect);
        //        return newEffect;
        //    }
        //}

        //开始失败了,返回null
        if (newEffect.Begin())
        {
            mEffectList.Add(newEffect);

            return(newEffect);
        }
        return(null);
    }
Пример #17
0
 public override void recoverEffectLift(LightEffectParam newParam)
 {
     effectParam = newParam;
     initTransform();
 }
Пример #18
0
        private void LoadPrizeResultEffectAndSetUIData()
        {
            //获取当前开启的宝箱配置
            prizeChestConfig = ActorPrizeConfig.Instance.GetPrizeChestConfig(m_nResultPageChestType);
            if (prizeChestConfig == null)
            {
                return;
            }

            //创建临时模型
            tempModelID = Mathf.Clamp(prizeChestConfig.nChestModelID - 1, 0, 2);
            if (prizeChestResNodeList[tempModelID] != null)
            {
                GameObject prizeChestObj = prizeChestResNodeList[tempModelID].InstanceMainRes();
                if (prizeChestObj != null)
                {
                    prizeChestObj.transform.SetParent(prizeResultObjContainer);
                    prizeChestObj.transform.localPosition = Vector3.zero;

                    tempPriezeChestModel = prizeChestObj;
                }
            }
            else
            {
                Debug.LogError(String.Format("not find model ID in prizeChestResNodeList[{0}]", tempModelID));
                return;
            }

            //播放模型打开动画的光效
            SceneEffectParamBase openEffectParam = new SceneEffectParamBase(prizeChestConfig.nOpenEffect, tempPriezeChestModel.transform);

            SceneEffectManager.Instance.CreateSceneEffect(ref openEffectParam);

            Data.UISoundConfig.SSchemeUSoundData soundData = new Data.UISoundConfig.SSchemeUSoundData();
            if (Data.UISoundConfig.UISoundConfig.Instance.GetData(SoundFilter_AnimStart, SoundKey_AnimStart, ref soundData))
            {
                SoundManager.CreateUISound(soundData.USoundID);
            }

            Transform[] tempChestModelChilds = tempPriezeChestModel.transform.GetComponentsInChildren <Transform>();

            //挂载摄像机动画
            Transform cmdTr = prizeResultObjContainer.parent.FindChild("CamTarget");

            if (cmdTr != null)
            {
                DestroyObject(cmdTr.gameObject);
            }
            GameObject camTarget = new GameObject();

            camTarget.name = "CamTarget";
            camTarget.transform.SetParent(prizeResultObjContainer.parent);
            camTarget.transform.localPosition    = prizeResultObjContainer.localPosition;
            camTarget.transform.localEulerAngles = Vector3.zero;

            LightingEffectManager lem = EntityFactory.EffectGroup.GetComponent <LightingEffectManager>();

            if (lem != null)
            {
                LightEffectParam param = new LightEffectParam();
                param.srcObject = camTarget;
                param.sourcePos = camTarget.transform.position;
                param.targetPos = camTarget.transform.position;

                m_camEffectID = prizeChestConfig.nCamEffectID;

                lem.AddLighting(prizeChestConfig.nCamEffectID, param);
            }


            List <int> prizeIdList = LogicDataCenter.prizeChestDataManager.PrizeIdList;

            openPrizeCount = 0;
            prizeCount     = Mathf.Clamp(prizeIdList.Count, 0, 7);

            //增加Tooltip
            if (continueOpenBtn != null)
            {
                continueOpenBtn.interactable = prizeCount > 0 ? false : true;
                if (!continueOpenBtn.interactable)
                {
                    UTooltipTrigger tooltip = continueOpenBtn.gameObject.GetComponent <UTooltipTrigger>();
                    if (tooltip == null)
                    {
                        tooltip = continueOpenBtn.gameObject.AddComponent <UTooltipTrigger>(ETooltipStyle.ETS_Default);
                    }
                    tooltip.SetText(UTooltipParamName.BodyText, openTips);
                }
            }

            foreach (PrizeResultItem item in prizeResultList)
            {
                UTooltipTrigger trigger = item.transform.GetComponent <UTooltipTrigger>();
                if (trigger != null)
                {
                    trigger.enabled = false;
                }
            }

            //奖励宝箱模型上挂载光效
            for (int i = 0; i < prizeIdList.Count; ++i)
            {
                //PrizeID必须大于0,界面大小,图标最多放12个
                if (prizeIdList[i] <= 0 || i >= 7)
                {
                    break;
                }

                int nPrizeID = prizeIdList[i];
                SSchemeActorPrizeConfig config = null;

                if (nPrizeID >= RAND_CARD_FIRST_INDEX && nPrizeID < LogicDataCenter.prizeChestDataManager.RandCardIndex)
                {
                    config = LogicDataCenter.prizeChestDataManager.RandCardResult[nPrizeID];
                }
                else
                {
                    config = ActorPrizeConfig.Instance.GetActorPrizeConfig(nPrizeID);
                }

                if (config == null)
                {
                    return;
                }

                //骨骼上挂载奖励光效
                foreach (Transform tr in tempChestModelChilds)
                {
                    if (tr != null && tr.name.Equals(bonesName[i]))
                    {
                        SceneEffectParamBase effectParam = new SceneEffectParamBase(config.nCakeTrailEffectID, tr, null, true, 2700);
                        SceneEffectManager.Instance.CreateSceneEffect(ref effectParam);

                        CakeTrailEffectParamList.Add(effectParam);
                    }
                }
                //奖励UI数据填充
                prizeResultList[i].SetData(this, i, prizeIdList[i], config);
            }
            //开启动画定时器
            TimerManager.SetTimer(this, chestAnimTimer, 4.2f);
        }
Пример #19
0
    private bool createEffect()
    {
        LightEffectParam newParam = new LightEffectParam();

        EffectParam.ColoneTo(ref newParam);

        float maxDistance = EffectParam.fDistance;
        float effectRad   = EffectParam.fAttackRange;

        Vector3 newSourcePos = newParam.srcObject.transform.position;

        if (sourceTransform != null)
        {
            newSourcePos = sourceTransform.position;
        }


        Vector3 areaTargetPos = EffectParam.targetPos;
        Vector3 newTargetPos  = areaTargetPos;

        //构造一个范围内的随机目标位置
        if (areaConfig.projectOnGround == true)
        {  //构造一个投影到地面的圆形
            int     angle  = Random.Range(0, 360);
            float   _rad   = angle * Mathf.PI / 180.0f;
            Vector3 offset = new Vector3(Mathf.Sin(_rad), 0, Mathf.Cos(_rad));
            float   dis    = Random.Range(0.0f, effectRad);
            offset       *= dis;
            newTargetPos += offset;

            RaycastHit _ClosestHitInfo_Down;
            RaycastHit _ClosestHitInfo_Up;
            float      rayDistance          = maxDistance;
            Ray        PointToGroundRayDown = new Ray(newTargetPos, new Vector3(0, -1, 0));
            Ray        PointToGroundRayUp   = new Ray(newTargetPos, new Vector3(0, 1, 0));
            bool       DownHit     = Physics.Raycast(PointToGroundRayDown, out _ClosestHitInfo_Down, rayDistance, -1);
            bool       UpHit       = Physics.Raycast(PointToGroundRayUp, out _ClosestHitInfo_Up, rayDistance, -1);
            Vector3    recordPos   = newTargetPos;
            float      hitDistance = maxDistance;
            if (DownHit)
            {
                hitDistance  = (_ClosestHitInfo_Down.point - recordPos).magnitude;
                newTargetPos = _ClosestHitInfo_Down.point;
            }

            if (UpHit)
            {
                if ((_ClosestHitInfo_Up.point - recordPos).magnitude < hitDistance)
                {
                    hitDistance  = (_ClosestHitInfo_Up.point - recordPos).magnitude;
                    newTargetPos = _ClosestHitInfo_Up.point;
                }
            }

            newParam.targetPos = newTargetPos;
        }
        else if (effectRad > 0.01f)
        { //构造一个圆锥
            Vector3 normal  = EffectParam.targetPos - newSourcePos;
            Vector3 tangent = new Vector3(0, 0, 1);
            Vector3.OrthoNormalize(ref normal, ref tangent);
            int        angle    = Random.Range(0, 360);
            Quaternion rotation = Quaternion.AngleAxis((float)angle, normal);
            tangent = rotation * tangent;
            float dis = Random.Range(0.0f, effectRad);
            tangent      *= dis;
            newTargetPos += tangent;
            if (areaConfig.extentToMaxDistance)
            {//将目标点拉远,延长用更容易造成与地面的碰撞
                Vector3 dir = newTargetPos - newSourcePos;
                dir.Normalize();
                newTargetPos = newSourcePos + dir * maxDistance;
            }
            newParam.targetPos = newTargetPos;
        }
        else
        {
            if (areaConfig.extentToMaxDistance)
            {//将目标点拉远,延长用更容易造成与地面的碰撞
                Vector3 dir = newTargetPos - newSourcePos;
                dir.Normalize();
                newTargetPos = newSourcePos + dir * maxDistance;
            }
            newParam.targetObject = EffectParam.targetObject;
            newParam.targetPos    = EffectParam.targetPos;
        }

        if (areaConfig.customOffset.sqrMagnitude > 0.001f)
        {
            //有此设置时,变更起始点,变为相对于newParam.targetPos,偏移customOffet
            Vector3 offsetNormal = EffectParam.targetPos - newSourcePos;
            offsetNormal.y = 0;
            offsetNormal.Normalize();
            Vector3 offsetTangent  = new Vector3(0, 1, 0);
            Vector3 offsetBinormal = Vector3.Cross(offsetTangent, offsetNormal);
            //Vector3.OrthoNormalize(ref offsetNormal, ref offsetTangent,ref offsetBinormal);
            Vector3 offSet = newParam.targetPos;
            offSet               += offsetNormal * areaConfig.customOffset.z;
            offSet               += offsetTangent * areaConfig.customOffset.y;
            offSet               += offsetBinormal * areaConfig.customOffset.x;
            newParam.sourcePos    = offSet;
            newParam.nEffectFlag |= (int)LightEffectParam.EFFECT_FLAG.CustomSourcePos;
        }

        LightingEffectManager leManager = EffectParam.srcObject.GetComponent <LightingEffectManager>();

        if (leManager != null)
        {
            ////测试用代码,用来标记检测发射区域是否正确
            //GameObject checkPoint = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            //checkPoint.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
            //checkPoint.transform.SetPosition( newParam.targetPos;
            //checkPoint.collider.enabled = false;
            //checkPoint.name = "Point" + mEffectLeftCount.ToString();

            leManager.AddLighting(areaConfig.subEffectID, newParam);
        }

        return(true);
    }
Пример #20
0
    public override bool RePlay(LightEffectParam newParam)
    {
        if (!isCreated)
        {
            return(true);
        }

        //if (!behaviorDestroyTimer)
        //{
        //    return false;
        //}
        needClose   = false;
        effectParam = newParam;
        if (BindConfig.bindTargetToSource)
        {
            if (!EffectParam.targetObject)
            {
                return(true);
            }
            m_BindToTargetTransform = EffectParam.targetObject.transform;
            BaseStateMachine machine = GetStateMachine(EffectParam.nTargetEntityID);
            if (machine != null)
            {
                machine.bPauseMachineUpdate = true;
                machine.enableCollider(false);
            }

            m_BindToTargetBoneTransform = null;
            if (BindConfig.bindTargetBone != "")
            {
                m_BindToTargetBoneTransform = FindTransformRoot(m_BehaviorRootTransform, BindConfig.bindTargetBone);
            }
            m_BindToTargetOrgRotation = m_BindToTargetTransform.rotation;
            initTransform();
            return(true);
        }

        int effectNodeMask = 0;

        if (BindConfig.effectType == LightingEffect.LightingEffectType.Hit)
        {
            //受击光效,不是主角的,则低一个等级
            if (EffectParam.nSrcEntityID != EntityFactory.MainHeroID &&
                EffectParam.nTargetEntityID != EntityFactory.MainHeroID)
            {
                effectNodeMask |= (int)Effect.EffectNodeMask.Mask_DownLevelQuality;
            }
        }
        if (EffectParam.nSrcEntityID == EntityFactory.MainHeroID)
        {
            effectNodeMask |= (int)Effect.EffectNodeMask.Mask_EnableLihgt;
        }
        //uint tick = GameLogicAPI.getTickCount();
        //if (BindConfig.effectLiveTick >= 0)
        //{
        //    behaviorDestroyTimer.destroyTick = GameLogicAPI.getTickCount() + (uint)(((float)BindConfig.effectLiveTick + (float)BindConfig.effectDispearTick) / EffectParam.speed + 500.0f); //比这个类延迟500毫秒,这个类没销毁的再自我销毁。
        //}
        //else
        //{
        //    behaviorDestroyTimer.destroyTick = 0; //0的时候表示无限循环
        //}

        initTransform();

        if (BindConfig.scale != 1.0f)
        {
            ResHandlePlayData.SizeScale = BindConfig.scale;
        }

        if (BindConfig.bUseSpeedScale)
        {
            ResHandlePlayData.Speed = EffectParam.speed;
        }

        ResHandlePlayData.parent       = behaviorTransformAgent;
        ResHandlePlayData.bRePlay      = true;
        ResHandlePlayData.isEnemy      = EffectParam.nCreatorSide == 0;
        ResHandlePlayData.entityID     = EffectParam.nSrcEntityID;
        ResHandlePlayData.SrcTransform = null;
        ResHandlePlayData.DstTransform = null;
        ResHandlePlayData.playMask     = effectNodeMask;//绑定类光效,目标是自己(梁成、董哲宇、徐凡强一起决定的,2016/5/12);

        if (soundInstance && BindConfig.SoundID == soundInstance.ConfigID)
        {
            SoundManager.DeleteSound(ref soundInstance);
        }
        soundInstance = SoundManager.CreateSound(behaviorTransformAgent.gameObject, BindConfig.SoundID);
        return(true);
    }
Пример #21
0
 public virtual void recoverEffectLift(LightEffectParam newParam) //和bSingle一起使用,为光效更新参数
 {
 }
Пример #22
0
 public virtual bool RePlay(LightEffectParam newParam)
 {
     return(false);
 }