Exemplo n.º 1
0
 //如果是空,标志着,锁定目标已经被消灭
 public void ChangeLockedTarget(MeteorUnit unit)
 {
     if (unit == null)
     {
         if (lockedEffect != null)
         {
             lockedEffect.OnPlayAbort();
             lockedEffect = null;
         }
         lockedTarget = null;
         bLocked      = false;
     }
     else
     {
         if (autoEffect != null)
         {
             autoEffect.OnPlayAbort();
             autoEffect = null;
         }
         autoTarget   = null;
         lockedTarget = unit;
         lockedEffect = SFXLoader.Instance.PlayEffect("lock.ef", lockedTarget.gameObject);
         bLocked      = true;
     }
     if (FightWnd.Exist)
     {
         FightWnd.Instance.OnChangeLock(bLocked);
     }
 }
Exemplo n.º 2
0
    public SFXEffectPlay Play(CharacterLoader character, float timePlayed = 0.0f)
    {
        if (effectList.Count == 0)
        {
            return(null);
        }
        SFXEffectPlay effectContainer = character.gameObject.AddComponent <SFXEffectPlay>();

        effectContainer.Load(this, timePlayed);
        return(effectContainer);
    }
Exemplo n.º 3
0
    public SFXEffectPlay Play(GameObject obj, bool once)
    {
        if (effectList.Count == 0)
        {
            return(null);
        }
        SFXEffectPlay effectContainer = obj.AddComponent <SFXEffectPlay>();

        effectContainer.Load(this, once);
        return(effectContainer);
    }
Exemplo n.º 4
0
    public SFXEffectPlay Play(MonoBehaviour behaviour, float timePlayed)
    {
        if (effectList.Count == 0)
        {
            return(null);
        }
        SFXEffectPlay effectContainer = behaviour.gameObject.AddComponent <SFXEffectPlay>();

        effectContainer.Load(this, timePlayed);
        return(effectContainer);
    }
    }                                           //当前动作特效,用于飞镖/飞轮的挂点查询
    void PlayEffect()
    {
        float timePlayed = 0;

        //锤绝-匕首A+上上A,音效有点问题 剑 前前A2
        //if (po.Idx == 325 || po.Idx == 253 || po.Idx == 276 || po.Idx == 560 || po.Idx == 471)
        //if (po.Idx != 325)
        timePlayed = GetTimePlayed(curIndex);
        if (!string.IsNullOrEmpty(po.EffectID) && po.EffectID != "0")
        {
            sfxEffect = SFXLoader.Instance.PlayEffect(po.EffectID + ".ef", this, timePlayed);
        }
        effectPlayed = true;
    }
Exemplo n.º 6
0
    public void PlayEffect()
    {
        if (sfxDebugTarget != null)
        {
            sfxDebugTarget.OnPlayAbort();
            sfxDebugTarget = null;
        }

        int sfx = (ScrollView.CurrentData as SfxCellData).Sfx;

        sfxDebugTarget = Main.Ins.SFXLoader.PlayEffect(sfx, Player.charLoader);
        if (sfxDebugTarget != null)
        {
            sfxDebugTarget.setAsDebug();
        }
    }
    }                                           //当前动作特效,用于飞镖/飞轮的挂点查询
    void PlayEffect()
    {
        float timePlayed = 0;

        //锤绝-匕首A+上上A,音效有点问题 剑 前前A2
        //if (po.Idx == 325 || po.Idx == 253 || po.Idx == 276 || po.Idx == 560 || po.Idx == 471)
        //if (po.Idx != 325)
        timePlayed = GetTimePlayed(curIndex);
        if (!string.IsNullOrEmpty(po.EffectID) && !string.Equals(po.EffectID, "0"))
        {
            sfxEffect = Main.Ins.SFXLoader.PlayEffect(string.Format("{0}.ef", po.EffectID), this, timePlayed);

            //表明特效是由动作触发的,不在该动作中关闭特效的攻击盒时,特效攻击盒仍存在
            //这种一般是特效出来后,在角色受到攻击前打开了特效的攻击盒,但角色受到攻击打断了动作,会立刻关闭攻击特效的攻击属性,这种应该是不对的.
            //类似雷电斩,特效出来后只要攻击盒被打开过,一旦动作被打断,那么攻击特效会一直到特效完毕.
        }
        effectPlayed = true;
    }
Exemplo n.º 8
0
    public void Unlock()
    {
        if (lockedEffect != null)
        {
            lockedEffect.OnPlayAbort();
            lockedEffect = null;
        }
        lockedTarget = null;

        if (autoEffect != null)
        {
            autoEffect.OnPlayAbort();
            autoEffect = null;
        }
        autoTarget = null;
        MeteorManager.Instance.LocalPlayer.SetLockedTarget(null);
        CameraFollow.Ins.OnUnlockTarget();
        bLocked = false;
        if (FightWnd.Exist)
        {
            FightWnd.Instance.OnChangeLock(bLocked);
        }
    }
Exemplo n.º 9
0
    public void OnUnitDead(MeteorUnit unit, MeteorUnit killer = null)
    {
        //无阵营的角色,杀死人,不统计信息
        if (killer != null && (killer.Camp == EUnitCamp.EUC_ENEMY || killer.Camp == EUnitCamp.EUC_FRIEND))
        {
            //统计杀人计数
            if (!battleResult.ContainsKey(killer.name))
            {
                BattleResultItem it = new BattleResultItem();
                it.camp      = (int)killer.Camp;
                it.id        = killer.InstanceId;
                it.deadCount = 0;
                it.killCount = 1;
                battleResult.Add(killer.name, it);
            }
            else
            {
                battleResult[killer.name].killCount += 1;
            }
        }

        if (unit != null && (unit.Camp == EUnitCamp.EUC_ENEMY || unit.Camp == EUnitCamp.EUC_FRIEND))
        {
            //统计被杀次数
            if (!battleResult.ContainsKey(unit.name))
            {
                BattleResultItem it = new BattleResultItem();
                it.camp      = (int)unit.Camp;
                it.id        = unit.InstanceId;
                it.deadCount = 1;
                it.killCount = 0;
                battleResult.Add(unit.name, it);
            }
            else
            {
                battleResult[unit.name].deadCount += 1;
            }
        }

        if (unit == MeteorManager.Instance.LocalPlayer)
        {
            GameBattleEx.Instance.GameOver(0);
            DropMng.Instance.Drop(unit);
            Unlock();
        }
        else
        {
            //无论谁杀死,都要爆东西
            DropMng.Instance.Drop(unit);
            //如果是被任意流星角色的伤害,特效,技能,等那么主角得到经验,如果是被场景环境杀死,
            //爆钱和东西
            //检查剧情
            //检查任务
            //检查过场对白,是否包含角色对话
            if (unit == autoTarget)
            {
                if (autoEffect != null)
                {
                    autoEffect.OnPlayAbort();
                    autoEffect = null;
                }
                autoTarget = null;
            }
            if (unit == lockedTarget)
            {
                Unlock();
            }
            //检测关卡通关或者失败条件。
            if (Global.GLevelItem.Pass == 1)//敌方阵营全死
            {
                int totalEnemy = U3D.GetEnemyCount();
                if (totalEnemy == 0)
                {
                    GameOver(1);
                }
            }
            else if (Global.GLevelItem.Pass == 2)//敌方指定脚本角色死亡
            {
                if (unit.Attr.NpcTemplate == Global.GLevelItem.Param)
                {
                    GameOver(1);
                }
            }
        }
    }
Exemplo n.º 10
0
    //敌方角色移动时,不用整个刷新,只需要用当前的自动目标和这个对象对比下角度就OK
    public void RefreshAutoTarget()
    {
        if (MeteorManager.Instance.LocalPlayer.GetWeaponType() == (int)EquipWeaponType.Dart || MeteorManager.Instance.LocalPlayer.GetWeaponType() == (int)EquipWeaponType.Gun)
        {
            return;
        }
        if (lockedTarget != null)
        {
            Vector3 vec = lockedTarget.transform.position - MeteorManager.Instance.LocalPlayer.transform.position;
            float   v   = vec.magnitude;
            if (v > ViewLimit)
            {
                Unlock();
            }
            return;
        }
        MeteorUnit player    = MeteorManager.Instance.LocalPlayer;
        float      angleMax  = Mathf.Cos(75 * Mathf.Deg2Rad); //cos值越大,角度越小
        float      autoAngle = 0.0f;                          //自动目标与主角的夹角
        MeteorUnit want      = null;
        Vector3    vecPlayer = -player.transform.forward;

        vecPlayer.y = 0;
        for (int i = 0; i < MeteorManager.Instance.UnitInfos.Count; i++)
        {
            if (MeteorManager.Instance.UnitInfos[i] == player)
            {
                continue;
            }
            if (player.SameCamp(MeteorManager.Instance.UnitInfos[i]))
            {
                continue;
            }
            if (MeteorManager.Instance.UnitInfos[i].Dead)
            {
                continue;
            }
            Vector3 vec = MeteorManager.Instance.UnitInfos[i].transform.position - player.transform.position;
            float   v   = vec.magnitude;
            //飞轮时,无限角度距离
            if (v > ViewLimit && MeteorManager.Instance.LocalPlayer.GetWeaponType() != (int)EquipWeaponType.Guillotines)
            {
                continue;
            }
            //高度差2个角色,不要成为自动对象,否则摄像机位置有问题
            if (Mathf.Abs(vec.y) >= 75 && MeteorManager.Instance.LocalPlayer.GetWeaponType() != (int)EquipWeaponType.Guillotines)
            {
                continue;
            }
            vec.y = 0;
            vec   = Vector3.Normalize(vec);
            float angle = Vector3.Dot(vecPlayer, vec);
            //角度小于75则可以成为自动对象.
            if (angle > angleMax)
            {
                angleMax = angle;
                want     = MeteorManager.Instance.UnitInfos[i];
            }
            //保存自动对象 与主角的角度
            if (autoTarget == MeteorManager.Instance.UnitInfos[i])
            {
                autoAngle = angle;
            }
        }

        //与角色的夹角不能大于75度,否则主角脑袋骨骼可能注视不到自动目标.
        if (want != null && want != autoTarget)
        {
            if (autoEffect != null)
            {
                autoEffect.OnPlayAbort();
                autoEffect = null;
            }
            autoTarget = want;
            autoEffect = SFXLoader.Instance.PlayEffect("Track.ef", autoTarget.gameObject);
            return;
        }

        //如果当前的自动目标存在,且夹角超过75度,即在主角背后,那么自动目标清空
        if (autoTarget != null && autoAngle < Mathf.Cos(75 * Mathf.Deg2Rad) && MeteorManager.Instance.LocalPlayer.GetWeaponType() != (int)EquipWeaponType.Guillotines)
        {
            autoEffect.OnPlayAbort();
            autoTarget = null;
        }

        if (autoTarget != null && MeteorManager.Instance.LocalPlayer.GetWeaponType() != (int)EquipWeaponType.Guillotines)
        {
            Vector3 vec = autoTarget.transform.position - player.transform.position;
            float   v   = vec.magnitude;
            if (v > ViewLimit)
            {
                Unlock();
            }
        }
    }
    public void SetPosData(Pose pos, float BlendTime = 0.0f, bool singlePos = false, int targetFrame = 0)
    {
        //一些招式,动作结束会给使用者加上BUFF,另外一些招式,会让受击方得到BUFF
        int lastPosIdx = 0;

        if (po != null && po.Idx != 0)
        {
            lastPosIdx = po.Idx;
        }

        TheLastFrame  = 0;
        TheFirstFrame = 0;
        moveScale     = 1.0f;

        //重置速度
        bool isAttackPos = false;

        if (po == null)
        {
            isAttackPos = false;
        }
        else
        {
            //isAttackPos = po.Idx >= CommonAction.AttackActStart && po.Idx != CommonAction.GunIdle;
            isAttackPos = posMng.IsAttackPose(po.Idx);
        }
        single = singlePos;
        //从IDLE往IDLE是不许融合的,否则武器位置插值非常难看
        if (pos != null && po != null && pos.Idx == po.Idx && pos.Idx == 0)
        {
            BlendTime = 0.0f;
        }
        //保存当前帧的姿势,用于和下个动作融合
        //当前状态下有姿势,且帧存在状态缓存
        if (po != null)
        {
            lastPosIdx = po.Idx;
        }
        else
        {
            lastPosIdx = pos.Idx;
        }
        if (BlendTime != 0.0f)
        {
            GetCurrentSnapShot();
        }
        //动画帧率与运行帧率可能要转换一下.
        blendTime            = BlendTime;
        lastFramePlayedTimes = 0;
        po   = pos;
        loop = (pos.LoopStart != 0 && pos.LoopEnd != 0);//2帧相同不为0

        //查看第一个blend的最后一帧,如果有,切换目标帧设置为这个,若第一个是act则目标帧为起始帧
        //PosAction blend = null;
        PosAction act = null;

        if (pos.ActionList.Count != 0)
        {
            for (int i = pos.ActionList.Count - 1; i >= 0; i--)
            {
                if (pos.ActionList[i].Type == "Action")
                {
                    if (TheLastFrame == 0)
                    {
                        TheLastFrame = pos.ActionList[i].End;
                    }
                    if (TheFirstFrame == 0 || TheFirstFrame > pos.ActionList[i].Start)
                    {
                        TheFirstFrame = pos.ActionList[i].Start;
                    }
                }
            }
            if (isAttackPos)
            {
                for (int i = 0; i < pos.ActionList.Count; i++)
                {
                    //过滤掉565,刀雷电斩的头一个 第一个混合段与整个动画一致.
                    if (pos.ActionList[i].Start == pos.Start && pos.ActionList[i].End == pos.End)
                    {
                        continue;
                    }
                    act = pos.ActionList[i];
                    break;
                }
            }
            else
            {
                act = pos.ActionList[0];
            }
        }
        //算第一个融合条件很多,有切换目的帧是否设定,第一个混合帧是否存在,上一个动作是否攻击动作,锤绝325BUG,其他招式接325,还要在地面等,应该不需要在地面等
        //curIndex = targetFrame != 0 ? targetFrame : (act != null ? (act.Type == "Action" ? act.Start: (isAttackPos ? act.End : pos.Start)): pos.Start);
        curIndex = targetFrame != 0 ? targetFrame : (act != null ? (act.Type == "Action" ? (isAttackPos ? act.Start : pos.Start) : (isAttackPos ? act.End : act.Start)) : pos.Start);
        //部分动作混合帧比开始帧还靠前
        if (curIndex < pos.Start)
        {
            curIndex = pos.Start;
        }
        blendStart   = curIndex;
        effectPlayed = false;
        sfxEffect    = null;
        playedTime   = 0;
        //下一个动作的第一帧所有虚拟物体
        if (po.SourceIdx == 0)
        {
            lastDBasePos = AmbLoader.CharCommon[curIndex].DummyPos[0];
        }
        else if (po.SourceIdx == 1)
        {
            lastDBasePos = AmbLoader.FrameBoneAni[CharacterIdx][curIndex].DummyPos[0];
        }

        if (lastPosIdx != 0)
        {
            Option poseInfo = MenuResLoader.Instance.GetPoseInfo(lastPosIdx);
            if (poseInfo.first.Length != 0 && poseInfo.first[0].flag[0] == 18 && lastPosIdx != 468) //18为,使用招式后获取物品ID 468-469都会调用微尘,hack掉468pose的
            {
                owner.GetItem(poseInfo.first[0].flag[1]);                                           //忍刀小绝,同归于尽,会获得微尘物品,会即刻死亡
            }
        }
    }
Exemplo n.º 12
0
    //public void SaveParticle(string file)
    //{
    //    if (source != null && source.particle != null)
    //    {
    //        System.IO.FileStream fs = System.IO.File.OpenWrite(file);
    //        System.IO.BinaryWriter w = new System.IO.BinaryWriter(fs);
    //        w.Write(source.particle);
    //        w.Flush();
    //        w.Close();
    //        fs.Close();
    //    }
    //}

    //原粒子系统是右手坐标系的,转移到左手坐标系后非常多问题,特别是父子关系以及,跟随和子物体旋转叠加
    public void Init(SfxEffect effect, SFXEffectPlay parent, int index, float timePlayed = 0.0f, bool preLoad = false)
    {
        playedTime         = timePlayed;
        PlayDone           = false;
        transform.rotation = Quaternion.identity;
        effectIndex        = index;
        parentSfx          = parent;//当找不到跟随者的时候,向父询问其他特效是否包含此名称.
        name       = effect.EffectName;
        EffectType = effect.EffectType;
        //一个是跟随移动,一个是跟随旋转
        mOwner = parent.GetComponent <MeteorUnit>();
        source = effect;
        if (effect.EffectType.Equals("PARTICLE"))
        {
            particle = Instantiate(Resources.Load <GameObject>("SFXParticles"), Vector3.zero, Quaternion.identity, transform).GetComponent <ParticleSystem>();
            ParticleSystem.MainModule     mainModule     = particle.main;
            ParticleSystem.EmissionModule emissionModule = particle.emission;
            ParticleSystem.ShapeModule    shapeModule    = particle.shape;

            emissionModule.rateOverTime = new ParticleSystem.MinMaxCurve(effect.MaxParticles, effect.MaxParticles);
            mainModule.startLifetime    = effect.StartLifetime;
            mainModule.maxParticles     = effect.MaxParticles;
            mainModule.startSize3D      = false;
            mainModule.startSize        = new ParticleSystem.MinMaxCurve(effect.startSizeMin, effect.startSizeMax);
            mainModule.startSpeed       = new ParticleSystem.MinMaxCurve(effect.startSpeedMin, effect.startSpeedMax);
            mainModule.loop             = true;
            mainModule.duration         = 1.0f;

            //124字节的,烟雾特效,旋转角度 0-360,shape使用box, render使用billboard
            if (effect.version == 1)
            {
                mainModule.startRotation = new ParticleSystem.MinMaxCurve(0, 360);
                shapeModule.shapeType    = ParticleSystemShapeType.Box;
                shapeModule.box          = new Vector3(effect.startSizeMin, 0, effect.startSizeMax);
                ParticleSystemRenderer r = particle.GetComponent <ParticleSystemRenderer>();
                r.renderMode      = ParticleSystemRenderMode.Billboard;
                r.minParticleSize = 0.1f;
                r.maxParticleSize = 0.1f;
            }
        }

        if (string.IsNullOrEmpty(effect.Bone0))
        {
            PositionFollow = mOwner == null ? parentSfx.transform : mOwner.transform;
        }
        else
        if (effect.Bone0.Equals("ROOT"))
        {
            PositionFollow = mOwner == null ? parent.transform : mOwner.ROOTNull;
        }
        else if (effect.Bone0.Equals("Character"))//根骨骼上一级,角色,就是不随着b骨骼走,但是随着d_base走
        {
            PositionFollow = mOwner == null ? parent.transform: mOwner.RootdBase;
        }
        else
        {
            PositionFollow = FindFollowed(effect.Bone0);
        }

        if (string.IsNullOrEmpty(effect.Bone1))
        {
            RotateFollow = mOwner == null ? parent.transform : mOwner.transform;
        }
        else
        if (effect.Bone1.Equals("ROOT"))
        {
            RotateFollow = mOwner == null ? parent.transform : mOwner.ROOTNull;
        }
        else if (effect.Bone1.Equals("Character"))
        {
            RotateFollow = mOwner == null ? parent.transform : mOwner.RootdBase;
        }
        else
        {
            RotateFollow = FindFollowed(effect.Bone1);
        }

        if (PositionFollow != null)
        {
            transform.position = PositionFollow.transform.position;
        }

        mRender = gameObject.GetComponent <MeshRenderer>();
        mFilter = gameObject.GetComponent <MeshFilter>();
        int meshIndex = -1;

        if (effect.EffectType.Equals("DONUT"))
        {
            //Debug.LogError("find Donut Effect");
        }
        //部分模型是要绕X旋转270的,这样他的缩放,和移动,都只能靠自己
        if (effect.EffectType.Equals("PLANE"))
        {
            meshIndex = 0;
        }
        else if (effect.EffectType.Equals("BOX"))
        {
            meshIndex = 1;
        }
        else if (effect.EffectType.Equals("DONUT"))
        {
            transform.localScale = effect.frames[0].scale;
            meshIndex            = 2;
        }
        else if (effect.EffectType.Equals("MODEL"))//自行加载模型
        {
            transform.localScale = effect.frames[0].scale;
            transform.rotation   = RotateFollow.rotation * effect.frames[0].quat;
            transform.position   = PositionFollow.position + effect.frames[0].pos;
            if (!string.IsNullOrEmpty(effect.Tails[0]))
            {
                string[] des = effect.Tails[0].Split(new char[] { '\\' }, System.StringSplitOptions.RemoveEmptyEntries);
                if (des.Length != 0)
                {
                    WsGlobal.ShowMeteorObject(des[des.Length - 1], transform);
                }
            }
            //这个时候,不要用自带的meshfilter了,让他自己处理显示问题,只要告诉他在哪个地方显示
            meshIndex = 100;
        }
        else if (effect.EffectType.Equals("SPHERE"))
        {
            meshIndex = 3;
        }
        else if (effect.EffectType.Equals("PARTICLE"))
        {
            if (!string.IsNullOrEmpty(effect.Tails[0]))
            {
                PositionFollow = FindFollowed(effect.Tails[0]);
            }
            if (!string.IsNullOrEmpty(effect.Tails[1]))
            {
                RotateFollow = FindFollowed(effect.Tails[1]);
            }
            if (PositionFollow != null)
            {
                transform.position = PositionFollow.transform.position;
            }
            meshIndex = 101;
        }
        else if (effect.EffectType.Equals("CYLINDER"))
        {
            meshIndex = 4;
        }
        else if (effect.EffectType.Equals("BILLBOARD"))
        {
            LookAtC   = true;
            meshIndex = 5;
        }
        else if (effect.EffectType.Equals("DRAG"))
        {
            meshIndex = 6;
        }
        //决定模型
        if (meshIndex != -1 && meshIndex < GamePool.Instance.MeshMng.Meshes.Length)
        {
            if (meshIndex == 4)
            {
                mFilter.mesh = Main.Ins.SfxMeshGenerator.CreateCylinder(source.origAtt.y, source.origAtt.x, source.origScale.x);
            }
            else if (meshIndex == 3)
            {
                mFilter.mesh = Main.Ins.SfxMeshGenerator.CreateSphere(source.SphereRadius);
            }
            else if (meshIndex == 0)
            {
                mFilter.mesh = Main.Ins.SfxMeshGenerator.CreatePlane(source.origScale.x, source.origScale.y);
            }
            else
            {
                mFilter.mesh = GamePool.Instance.MeshMng.Meshes[meshIndex];
            }
        }
        if (effect.Texture.ToLower().EndsWith(".bmp") || effect.Texture.ToLower().EndsWith(".jpg") || effect.Texture.ToLower().EndsWith(".tga"))
        {
            texture = effect.Texture.Substring(0, effect.Texture.Length - 4);
            tex     = Resources.Load <Texture>(texture);
        }
        else if (effect.Texture.ToLower().EndsWith(".ifl"))
        {
            iflTexture         = gameObject.AddComponent <IFLLoader>();
            iflTexture.IFLFile = Resources.Load <TextAsset>(effect.Texture);
            if (effect.EffectType.Equals("PARTICLE"))
            {
                iflTexture.SetTargetMeshRenderer(particle.GetComponent <ParticleSystemRenderer>());
            }
            iflTexture.LoadIFL();//传递false表示由特效控制每一帧的切换时间.
            tex = iflTexture.GetTexture(0);
        }
        //else
        //    print("effect contains other prefix:" + effect.Texture == null ? " texture is null" : effect.Texture);
        if (tex != null)
        {
            if (effect.EffectType.Equals("PARTICLE"))
            {
                ParticleSystemRenderer render = particle.GetComponent <ParticleSystemRenderer>();
                if (effect.BlendType == 0)
                {
                    render.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                else
                if (effect.BlendType == 1)
                {
                    render.material.shader = Shader.Find("UnlitAdditive");//滤色 加亮 不透明
                }
                else
                if (effect.BlendType == 2)
                {
                    render.material.shader = Shader.Find("UnlitAdditive");//反色+透明度
                }
                else if (effect.BlendType == 3)
                {
                    render.material.shader = Shader.Find("Mobile/Particles/Alpha Blended");//不滤色,支持透明
                }
                else if (effect.BlendType == 4)
                {
                    render.material.shader = Shader.Find("Custom/MeteorBlend4");//滤色,透明
                }
                else
                {
                    render.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                if (texture.Equals("AItem09"))
                {
                    render.enabled = false;
                    particle.Stop();

                    /* 应该是有一个地裂的粒子特效,但是这个特效参数没分析出来.
                     *  tex = Resources.Load<Texture>("AItemParticle");
                     *  render.material.SetTexture("_MainTex", tex);
                     */
                }
                else
                {
                    render.material.SetTexture("_MainTex", tex);
                }
                render.material.SetColor("_Color", effect.frames[0].colorRGB);
                render.material.SetColor("_TintColor", effect.frames[0].colorRGB);
                render.material.SetFloat("_Intensity", effect.frames[0].TailFlags[9]);
                if (Main.Ins.GameStateMgr.gameStatus != null && !Main.Ins.GameStateMgr.gameStatus.DisableParticle)
                {
                    particle.Play();
                }
            }
            else
            {
                if (effect.BlendType == 0)
                {
                    mRender.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                else
                if (effect.BlendType == 1)
                {
                    mRender.material.shader = Shader.Find("UnlitAdditive");//滤色 加亮 不透明
                }
                else
                if (effect.BlendType == 2)
                {
                    mRender.material.shader = Shader.Find("UnlitAdditive");//反色+透明度
                }
                else if (effect.BlendType == 3)
                {
                    mRender.material.shader = Shader.Find("Mobile/Particles/Alpha Blended");//不滤色,支持透明
                }
                else if (effect.BlendType == 4)
                {
                    mRender.material.shader = Shader.Find("Custom/MeteorBlend4");//滤色,透明
                }
                else
                {
                    mRender.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                if (effect.BlendType == 2)
                {
                    mRender.material.SetColor("_InvColor", effect.frames[0].colorRGB);
                }
                else
                {
                    mRender.material.SetColor("_Color", effect.frames[0].colorRGB);
                    mRender.material.SetColor("_TintColor", effect.frames[0].colorRGB);
                }
                mRender.material.SetFloat("_Intensity", effect.frames[0].TailFlags[9]);
                mRender.material.SetTexture("_MainTex", tex);
                if (effect.uSpeed != 0.0f || effect.vSpeed != 0.0f)
                {
                    tex.wrapMode = TextureWrapMode.Repeat;
                }
                else
                {
                    tex.wrapMode = TextureWrapMode.Clamp;
                }
                mRender.material.SetFloat("_u", effect.uSpeed);
                mRender.material.SetFloat("_v", effect.vSpeed);
            }
        }
        else
        {
            mRender.enabled = false;
        }
        //drag不知道有什么作用,可能只是定位用的挂载点
        if (effect.Hidden == 1 || meshIndex == 6)
        {
            if (particle != null)
            {
                ParticleSystemRenderer render = particle.GetComponent <ParticleSystemRenderer>();
                if (render != null)
                {
                    render.enabled = false;
                }
            }
            mRender.enabled = false;
        }
        if (effect.EffectName.StartsWith("Attack"))
        {
            if (effect.EffectType.ToUpper() == "BOX")
            {
                BoxCollider bo = gameObject.AddComponent <BoxCollider>();
                bo.center = Vector3.zero;
                bo.size   = Vector3.one;
                damageBox = bo;
            }
            else
            {
                //SphereCollider sph = gameObject.AddComponent<SphereCollider>();
                //damageBox = sph;
                //sph.radius = 1.0f;
                //sph.center = Vector3.zero;
                MeshCollider co = gameObject.AddComponent <MeshCollider>();
                co.convex    = true;
                co.isTrigger = true;
                damageBox    = co;
            }
            damageBox.enabled = false;
        }

        if (preLoad)
        {
            PlayDone = true;
            if (parentSfx != null)
            {
                parentSfx.OnPlayDone(this);
            }
            else
            {
                Destroy(gameObject);
            }
            return;
        }
    }
    public void SetPosData(Pose pos, float BlendTime = 0.0f)
    {
        //一些招式,需要把尾部事件执行完才能切换武器.
        LoopCount        = 0;
        LockCurrentFrame = false;
        if (TheLastFrame != -1 && po != null)
        {
            ActionEvent.HandlerFinalActionFrame(mOwner, po.Idx);
            TheLastFrame = -1;
        }
        else
        {
            if (po != null && po.Link != 0)
            {
                //一些动作,默认连接其他动作,类似,486第一帧会收刀,收刀会切换武器为2
                ActionEvent.HandlerPoseAction(mOwner, po.Link);
            }
        }
        //一些招式,动作结束会给使用者加上BUFF,另外一些招式,会让受击方得到BUFF
        int lastPosIdx = 0;

        if (po != null && po.Idx != 0)
        {
            lastPosIdx = po.Idx;
        }

        moveScale    = 1.0f;
        attackTarget = Vector3.zero;
        //重置速度
        bool isAttackPos = false;

        if (po == null)
        {
            isAttackPos = false;
        }
        else
        {
            //isAttackPos = po.Idx >= CommonAction.AttackActStart && po.Idx != CommonAction.GunIdle;
            isAttackPos = posMng.IsAttackPose(po.Idx);
        }
        //从IDLE往IDLE是不许融合的,否则武器位置插值非常难看
        if (pos != null && po != null && pos.Idx == po.Idx && pos.Idx == 0)
        {
            BlendTime = 0.0f;
        }
        //保存当前帧的姿势,用于和下个动作融合
        //当前状态下有姿势,且帧存在状态缓存
        if (po != null)
        {
            lastPosIdx = po.Idx;
        }
        else
        {
            lastPosIdx = pos.Idx;
        }
        if (BlendTime != 0.0f)
        {
            GetCurrentSnapShot();
            //如果有混合,重置混合位置.
            nextDBasePos = lastFrameStatus.DummyPos[0];
        }
        //动画帧率与运行帧率可能要转换一下.
        blendTime            = BlendTime;
        lastFramePlayedTimes = 0;
        po   = pos;
        loop = (pos.LoopStart != 0 && pos.LoopEnd != 0);//2帧相同不为0

        //查看第一个blend的最后一帧,如果有,切换目标帧设置为这个,若第一个是act则目标帧为起始帧
        //PosAction blend = null;
        PosAction act = null;

        if (pos.ActionList.Count != 0)
        {
            if (isAttackPos)
            {
                for (int i = 0; i < pos.ActionList.Count; i++)
                {
                    //过滤掉565,刀雷电斩的头一个 第一个混合段与整个动画一致.
                    if (pos.ActionList[i].Start == pos.Start && pos.ActionList[i].End == pos.End)
                    {
                        continue;
                    }
                    act = pos.ActionList[i];
                    break;
                }
            }
            else
            {
                act = pos.ActionList[0];
            }
        }

        TheLastFrame  = pos.End - 1;
        TheFirstFrame = pos.Start;

        //算第一个过渡帧条件很多,有切换目的帧是否设定,第一个过渡帧是否存在,上一个动作是否攻击动作,锤绝325BUG,其他招式接325,还要在地面等,应该不需要在地面等
        //curIndex = targetFrame != 0 ? targetFrame : (act != null ? (act.Type == "Action" ? act.Start: (isAttackPos ? act.End : pos.Start)): pos.Start);
        curIndex = act != null ? (act.Type == "Action" ? (isAttackPos ? act.Start : pos.Start) : (isAttackPos ? act.End : act.Start)) : pos.Start;
        //部分动作混合帧比开始帧还靠前
        if (curIndex < pos.Start)
        {
            curIndex = pos.Start;
        }
        blendStart = curIndex;
        //if (blendTime != 0.0f && (pos.Idx == CommonAction.JumpFall || pos.Idx == CommonAction.Jump || pos.Idx == CommonAction.JumpFallOnGround))
        //    Debug.Log("过渡帧为" + blendStart + " 转换到动作:" + pos.Idx);
        effectPlayed = false;
        sfxEffect    = null;
        playedTime   = 0;

        //下一个动作的第一帧所有虚拟物体
        if (po.SourceIdx == 0)
        {
            lastDBasePos = AmbLoader.CharCommon[curIndex].DummyPos[0];
        }
        else if (po.SourceIdx == 1)
        {
            lastDBasePos = AmbLoader.PlayerAnimation[owner.UnitId][curIndex].DummyPos[0];
        }

        if (lastPosIdx != 0)
        {
            Option poseInfo = Main.Ins.MenuResLoader.GetPoseInfo(lastPosIdx);
            if (poseInfo.first.Length != 0 && poseInfo.first[0].flag[0] == 18 && lastPosIdx != 468) //18为,使用招式后获取物品ID 468-469都会调用微尘,hack掉468pose的
            {
                owner.GetItem(poseInfo.first[0].flag[1]);                                           //忍刀小绝,同归于尽,会获得微尘物品,会即刻死亡
            }
        }

        curPos = pos.Idx;
    }
Exemplo n.º 14
0
    //原粒子系统是右手坐标系的,转移到左手坐标系后非常多问题,特别是父子关系以及,跟随和子物体旋转叠加
    public void Init(SfxEffect effect, SFXEffectPlay parent, int index, float timePlayed = 0.0f)
    {
        playedTime         = timePlayed;
        PlayDone           = false;
        transform.rotation = Quaternion.identity;
        effectIndex        = index;
        parentSfx          = parent;//当找不到跟随者的时候,向父询问其他特效是否包含此名称.
        name       = effect.EffectName;
        EffectType = effect.EffectType;
        //一个是跟随移动,一个是跟随旋转
        mOwner = parent.GetComponent <MeteorUnit>();
        source = effect;
        if (effect.EffectType == "PARTICLE")
        {
            particle = Instantiate(Resources.Load <GameObject>("SFXParticles"), Vector3.zero, Quaternion.identity, transform).GetComponent <ParticleSystem>();
        }

        if (string.IsNullOrEmpty(effect.Bone0))
        {
            PositionFollow = mOwner == null ? parentSfx.transform : mOwner.transform;
        }
        else
        if (effect.Bone0 == "ROOT")
        {
            PositionFollow = mOwner == null ? parent.transform : mOwner.ROOTNull;
        }
        else if (effect.Bone0 == "Character")//根骨骼上一级,角色,就是不随着b骨骼走,但是随着d_base走
        {
            PositionFollow = mOwner == null ? parent.transform: mOwner.RootdBase;
        }
        else
        {
            PositionFollow = FindFollowed(effect.Bone0);
        }

        if (string.IsNullOrEmpty(effect.Bone1))
        {
            RotateFollow = mOwner == null ? parent.transform : mOwner.transform;
        }
        else
        if (effect.Bone1 == "ROOT")
        {
            RotateFollow = mOwner == null ? parent.transform : mOwner.ROOTNull;
        }
        else if (effect.Bone1 == "Character")
        {
            RotateFollow = mOwner == null ? parent.transform : mOwner.RootdBase;
        }
        else
        {
            RotateFollow = FindFollowed(effect.Bone1);
        }

        if (PositionFollow != null)
        {
            transform.position = PositionFollow.transform.position;
        }

        mRender = gameObject.GetComponent <MeshRenderer>();
        mFilter = gameObject.GetComponent <MeshFilter>();
        int meshIndex = -1;

        if (effect.EffectType == "DONUT")
        {
            //Debug.LogError("find Donut Effect");
        }
        //部分模型是要绕X旋转270的,这样他的缩放,和移动,都只能靠自己
        if (effect.EffectType == "PLANE")
        {
            meshIndex = 0;
        }
        else if (effect.EffectType == "BOX")
        {
            meshIndex = 1;
        }
        else if (effect.EffectType == "DONUT")
        {
            transform.localScale = effect.frames[0].scale;
            meshIndex            = 2;
        }
        else if (effect.EffectType == "MODEL")//自行加载模型
        {
            transform.localScale = effect.frames[0].scale;
            transform.rotation   = RotateFollow.rotation * effect.frames[0].quat;
            transform.position   = PositionFollow.position + effect.frames[0].pos;
            if (!string.IsNullOrEmpty(effect.Tails[0]))
            {
                string[] des = effect.Tails[0].Split(new char[] { '\\' }, System.StringSplitOptions.RemoveEmptyEntries);
                if (des.Length != 0)
                {
                    WsGlobal.ShowMeteorObject(des[des.Length - 1], transform);
                }
            }
            //这个时候,不要用自带的meshfilter了,让他自己处理显示问题,只要告诉他在哪个地方显示
            meshIndex = 100;
        }
        else if (effect.EffectType == "SPHERE")
        {
            meshIndex = 3;
        }
        else if (effect.EffectType == "PARTICLE")
        {
            if (!string.IsNullOrEmpty(effect.Tails[0]))
            {
                PositionFollow = FindFollowed(effect.Tails[0]);
            }
            if (!string.IsNullOrEmpty(effect.Tails[1]))
            {
                RotateFollow = FindFollowed(effect.Tails[1]);
            }
            if (PositionFollow != null)
            {
                transform.position = PositionFollow.transform.position;
            }
            meshIndex = 101;
        }
        else if (effect.EffectType == "CYLINDER")
        {
            //InitializeQuat = new Quaternion(0.7170f, 0, 0, -0.7170f);
            //InitializeQuat = Quaternion.identity;
            meshIndex = 4;
        }
        else if (effect.EffectType == "BILLBOARD")
        {
            LookAtC   = true;
            meshIndex = 5;
        }
        else if (effect.EffectType == "DRAG")
        {
            meshIndex = 6;
        }
        //决定模型
        if (meshIndex != -1 && meshIndex < mesh.Length)
        {
            if (meshIndex == 4)
            {
                mFilter.mesh = SfxMeshGenerator.Instance.CreateCylinder(source.origAtt.y, source.origAtt.x, source.origScale.x);
            }
            else if (meshIndex == 3)
            {
                mFilter.mesh = SfxMeshGenerator.Instance.CreateSphere(source.SphereScale);
            }
            else if (meshIndex == 0)
            {
                mFilter.mesh = SfxMeshGenerator.Instance.CreatePlane(source.origScale.x, source.origScale.y);
            }
            else
            {
                mFilter.mesh = mesh[meshIndex];
            }
        }
        if (effect.Texture.ToLower().EndsWith(".bmp") || effect.Texture.ToLower().EndsWith(".jpg") || effect.Texture.ToLower().EndsWith(".tga"))
        {
            texture = effect.Texture.Substring(0, effect.Texture.Length - 4);
            tex     = Resources.Load <Texture>(texture);
        }
        else if (effect.Texture.ToLower().EndsWith(".ifl"))
        {
            iflTexture         = gameObject.AddComponent <IFLLoader>();
            iflTexture.IFLFile = Resources.Load <TextAsset>(effect.Texture);
            if (effect.EffectType == "PARTICLE")
            {
                iflTexture.SetTargetMeshRenderer(particle.GetComponent <ParticleSystemRenderer>());
            }
            iflTexture.LoadIFL();//传递false表示由特效控制每一帧的切换时间.
            tex = iflTexture.GetTexture(0);
        }
        //else
        //    print("effect contains other prefix:" + effect.Texture == null ? " texture is null" : effect.Texture);
        if (tex != null)
        {
            if (effect.EffectType == "PARTICLE")
            {
                ParticleSystemRenderer render = particle.GetComponent <ParticleSystemRenderer>();
                if (effect.BlendType == 0)
                {
                    render.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                else
                if (effect.BlendType == 1)
                {
                    render.material.shader = Shader.Find("UnlitAdditive");//滤色 加亮 不透明
                }
                else
                if (effect.BlendType == 2)
                {
                    render.material.shader = Shader.Find("UnlitAdditive");//反色+透明度
                }
                else if (effect.BlendType == 3)
                {
                    render.material.shader = Shader.Find("Mobile/Particles/Alpha Blended");//不滤色,支持透明
                }
                else if (effect.BlendType == 4)
                {
                    render.material.shader = Shader.Find("Custom/MeteorBlend4");//滤色,透明
                }
                else
                {
                    render.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                render.material.SetTexture("_MainTex", tex);
                render.material.SetColor("_Color", effect.frames[0].colorRGB);
                render.material.SetColor("_TintColor", effect.frames[0].colorRGB);
                render.material.SetFloat("_Intensity", effect.frames[0].TailFlags[9]);
                //particle.Emit(1);
            }
            else
            {
                if (effect.BlendType == 0)
                {
                    mRender.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                else
                if (effect.BlendType == 1)
                {
                    mRender.material.shader = Shader.Find("UnlitAdditive");//滤色 加亮 不透明
                }
                else
                if (effect.BlendType == 2)
                {
                    mRender.material.shader = Shader.Find("UnlitAdditive");//反色+透明度
                }
                else if (effect.BlendType == 3)
                {
                    mRender.material.shader = Shader.Find("Mobile/Particles/Alpha Blended");//不滤色,支持透明
                }
                else if (effect.BlendType == 4)
                {
                    mRender.material.shader = Shader.Find("Custom/MeteorBlend4");//滤色,透明
                }
                else
                {
                    mRender.material.shader = Shader.Find("Unlit/Texture");//普通不透明无光照
                }
                if (effect.BlendType == 2)
                {
                    mRender.material.SetColor("_InvColor", effect.frames[0].colorRGB);
                }
                else
                {
                    mRender.material.SetColor("_Color", effect.frames[0].colorRGB);
                    mRender.material.SetColor("_TintColor", effect.frames[0].colorRGB);
                }
                mRender.material.SetFloat("_Intensity", effect.frames[0].TailFlags[9]);
                mRender.material.SetTexture("_MainTex", tex);
                if (effect.uSpeed != 0.0f || effect.vSpeed != 0.0f)
                {
                    tex.wrapMode = TextureWrapMode.Repeat;
                }
                else
                {
                    tex.wrapMode = TextureWrapMode.Clamp;
                }
                mRender.material.SetFloat("_u", effect.uSpeed);
                mRender.material.SetFloat("_v", effect.vSpeed);
            }
        }

        if (effect.Hidden == 1)
        {
            if (particle != null)
            {
                ParticleSystemRenderer render = particle.GetComponent <ParticleSystemRenderer>();
                if (render != null)
                {
                    render.enabled = false;
                }
            }
            mRender.enabled = false;
        }
        if (effect.EffectName.StartsWith("Attack"))
        {
            if (effect.EffectType == "SPHERE")
            {
                damageBox = gameObject.AddComponent <SphereCollider>();
            }
            else
            {
                damageBox = gameObject.AddComponent <BoxCollider>();
            }
            damageBox.enabled = false;
        }

        playCoroutine = StartCoroutine(PlayEffectFrame());
    }