Esempio n. 1
0
    public void LoadModul()//非编辑器加载一次.
    {
        Release();
        role.gameobject = loader.LoadModul(-1, roleData.mod_name, roleData.mod);
        for (int i = 0, c = skillData.objs.Length; i < c; i++)
        {
            if (objs[i] == null)
            {
                objs[i] = new ObjectContain();
            }
            var o2 = objs[i];
            var o  = skillData.objs[i];


            string name = o.propertys.GetValue <string>("bind_name", "");
            var    o1   = objs[i];
            if (o.type == 3)
            {
                o1.objId = o.id;
                o1.type  = o.type;

                o1.gameobject = FindColliderInChild(role.gameobject, name);
            }
            else
            {
                o2.gameobject = loader.LoadModul(o.type, o.propertys.GetValue <string>("mod_name", ""), o.propertys.GetValue <string>("mod", ""));
                o2.objId      = o.id;
                o2.type       = o.type;
                o2.mod        = o.propertys.GetValue <string>("mod", "");
                o2.mod_name   = o.propertys.GetValue <string>("mod_name", "");
            }
        }
    }
Esempio n. 2
0
 public static void SetObjectPos(float curTime, ObjectContain contain, Dictionary <int, ObjectContain> objs, LChatacterInterface character, LChatacterInformationInterface information,
                                 Vector3 beginPositon,
                                 Vector3 beginLocalScale,
                                 Quaternion beginLocalRot)
 {
     //beginPositon
     if (contain.type == 1 || contain.type == 2 || contain.type == 4)
     {
         ObjectContain role = objs[-1];
         if (contain.bind == 1 && contain.gameobject != null && contain.gameobject.transform.parent == null && role.gameobject != null)
         {
             contain.gameobject.transform.parent = role.gameobject.transform;
         }
         else if (contain.bind == 2 && contain.gameobject != null && contain.gameobject.transform.parent == null && role.gameobject != null)
         {
             contain.gameobject.transform.parent = FindInChildrenIncludingInactive(role.gameobject.transform, contain.bindName);
         }
         else if (contain.bind == 0 && contain.gameobject != null)
         {
             contain.gameobject.transform.parent        = null;
             contain.gameobject.transform.position      = beginPositon;
             contain.gameobject.transform.localRotation = beginLocalRot;
             contain.gameobject.transform.localScale    = Vector3.one;
         }
         if (contain.bind == 0)
         {
             contain.gameobject.transform.position       = contain.gameobject.transform.localToWorldMatrix.MultiplyPoint(contain.pos);
             contain.gameobject.transform.localRotation *= contain.rot;
         }
         else
         {
             contain.gameobject.transform.localPosition = contain.pos;
             contain.gameobject.transform.localRotation = contain.rot;
             contain.gameobject.transform.localScale    = contain.scale;
         }
         contain.gameobject.transform.localScale = contain.scale;
     }
     //type3 不改位移
     else if (contain.type == 3)
     {
         if (contain.gameobject == null)
         {
             if (contain.bind == 2)
             {
                 ObjectContain c1 = objs[-1];
                 if (null != c1)
                 {
                     var t = FindInChildrenIncludingInactive(c1.gameobject.transform, contain.bindName);
                     contain.gameobject = t.gameObject;
                 }
             }
             else if (contain.bind == 1)
             {
                 ObjectContain c1 = objs[contain.bindObjId];
                 contain.gameobject = c1.gameobject;
             }
         }
     }
 }
Esempio n. 3
0
    public static void SetRolePos(float curTime, ObjectContain contain, LCharacterInterface character, LChatacterInformationInterface information,
                                  ref Vector3 beginGroundLinePos,
                                  Vector3 beginLocalScale,
                                  Quaternion beginLocalRot,
                                  bool fixBeginPos = true)
    {
        if (null != contain.gameobject)
        {
            //初始位置
            var oldPos = contain.gameobject.transform.position;
            contain.gameobject.transform.position      = beginGroundLinePos;
            contain.gameobject.transform.localScale    = beginLocalScale;
            contain.gameobject.transform.localRotation = beginLocalRot;

            //位置转向缩放
            contain.gameobject.transform.position       = contain.gameobject.transform.localToWorldMatrix.MultiplyPoint(contain.pos);
            contain.gameobject.transform.localRotation *= contain.rot;
            contain.gameobject.transform.localScale     = MathfHelper.Vector3Mul(beginLocalScale, contain.scale);


            //旧技能位置在水平线上的位置.
            var old_h_pos = oldPos;
            old_h_pos.y = beginGroundLinePos.y;

            //新技能位置在水平线上的位置
            var new_h_pos = contain.gameobject.transform.position;
            new_h_pos.y = beginGroundLinePos.y;
            var _dir = new_h_pos - old_h_pos;

            if (fixBeginPos)
            {
                //技能贴地运动
                var new_h_pos1 = information.tryMove(old_h_pos, _dir, true);
                var _delta     = new_h_pos1 - new_h_pos;

                beginGroundLinePos = new Vector3(beginGroundLinePos.x + _delta.x, new_h_pos1.y, beginGroundLinePos.z + _delta.y);//修正技能水平线高度

                contain.gameobject.transform.position = new Vector3(new_h_pos1.x, contain.gameobject.transform.position.y, new_h_pos1.z);
            }
            else
            {
                //技能贴地运动
                new_h_pos          = information.tryMove(old_h_pos, _dir, true);
                beginGroundLinePos = new Vector3(beginGroundLinePos.x, new_h_pos.y, beginGroundLinePos.z);//修正技能水平线高度

                contain.gameobject.transform.position = new Vector3(new_h_pos.x, contain.gameobject.transform.position.y, new_h_pos.z);
            }
        }
    }
Esempio n. 4
0
    public void CheckModulUpdate(ObjectContain o, int id, int type, string mod_name, string mod, string name)
    {
        bool reload = false;

        if (o == null)
        {
            o      = new ObjectContain();
            reload = true;
        }
        else if (o.gameobject == null)
        {
            reload = true;
        }
        else
        {
            if (o.mod != mod)
            {
                loader.ReleaseModel(-1, mod_name, mod, o.gameobject);
                reload = true;
            }
        }
        if (reload)
        {
            o.objId      = id;
            o.type       = type;
            o.mod        = mod;
            o.mod_name   = mod_name;
            o.gameobject = loader.LoadModul(type, mod_name, mod);
            if (null != o.gameobject)
            {
                if (null != name)
                {
                    o.gameobject.name = name;
                }
            }
        }
    }
Esempio n. 5
0
    public void CmpObjectEvent(float curTime, float lastTime, LCHEventChannelData _e, ObjectContain contain, LCharacterInterface character, LChatacterInformationInterface information,
                               Dictionary <int, ObjectContain> objs
                               , CdState cdState
                               , string cdName
                               , int skillState
                               , Vector3 baseGroundPos
                               , ref float beginToTarget
                               , ref float endToTarget
                               , ref Vector3 beginTargetPoint
                               )
    {
        if (contain.isFlyTool)
        {
            if (null != contain.gameobject)
            {
                contain.gameobject.SetActive(false);
            }
            return;
        }
        LCHChannelType t = (LCHChannelType)_e.type;
        ObjDictionary  value;
        float          _time;
        float          _keyFrameTime;

        if (t == LCHChannelType.Object)
        {
            int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time, out _keyFrameTime);
            if (res == 1)
            {
                if (null != contain.gameobject)
                {
                    bool enable = value.GetValue <bool>("enable", true);
                    if (_e.objId == -1)
                    {
                        //因為主對象直接設置 gameObject的Enable,所有腳本都不工作了.
                        if (null != contain.roleRenders)
                        {
                            for (int n = 0; n < contain.roleRenders.Length; n++)
                            {
                                contain.roleRenders[n].enabled = enable;
                            }
                        }
                    }
                    else
                    {
                        if (enable)
                        {
                            contain.gameobject.SetActive(false);
                            contain.gameobject.SetActive(true);
                        }
                        else
                        {
                            contain.gameobject.SetActive(enable);
                        }
                    }
                    if (enable)
                    {
                        if (contain.type == 1)
                        {
                            string anim_name = value.GetValue <string>("anim", "");
                            if (anim_name.Length > 0)
                            {
                                if (null == contain.animaction)
                                {
                                    contain.animaction = contain.gameobject.GetComponent <Animation>();
                                }
                                if (null != contain.animaction)
                                {
                                    bool cf = value.GetValue <bool>("crossFade", true);
                                    //crossFade
                                    contain.animaction[anim_name].time = _time;
                                    if (cf)
                                    {
                                        contain.animaction.CrossFade(anim_name, 0.05f);
                                    }
                                    else
                                    {
                                        contain.animaction[anim_name].time = 0f;//特么不这么干不重置。。。
                                        contain.animaction.Play(anim_name);
                                    }
                                }
                            }
                            int ex_action = value.GetValueInt("ex_action", 0);
                            if (ex_action == 1)
                            {
                                //主模型.
                                if (_e.objId == -1)
                                {
                                    float ToTargetTime = value.GetValueFloat("ex_action", -1f);
                                    if (ToTargetTime > 0f)
                                    {
                                        beginToTarget    = _keyFrameTime;
                                        endToTarget      = _keyFrameTime + ToTargetTime;
                                        beginTargetPoint = baseGroundPos;
                                    }
                                }
                            }

                            //
                            else if (ex_action == 2)
                            {
                                contain.stopUpatePos = true;
                            }
                        }
                    }
                }
            }
            else if (res == 0)
            {
                if (_e.objId != -1)//非主模型,一开始隐藏
                {
                    if (null != contain.gameobject)
                    {
                        if (contain.objId != -1)
                        {
                            contain.gameobject.SetActive(false);
                        }
                    }
                }
            }
        }
        if (t == LCHChannelType.Event)
        {
            int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time, out _keyFrameTime);
            if (res == 1)
            {
                if (contain.type == 2 || contain.type == 3)
                {
                    if (null == contain.collider)
                    {
                        if (null != contain.gameobject)
                        {
                            contain.collider         = contain.gameobject.GetComponent <Collider>();
                            contain.gameobject.layer = character.GetAttackLayer();
                            if (null != contain.collider)
                            {
                                contain.collider.isTrigger = true;
                            }
                        }
                    }
                }
                if (null != contain.gameobject)
                {
                    bool enable = value.GetValue <bool>("enable", true);
                    contain.gameobject.SetActive(enable);
                    if (contain.collider)
                    {
                        contain.collider.enabled = enable;
                        if (enable)
                        {
                            if (null == contain.hitData)
                            {
                                LCharacterHitDataCmp hdc = contain.gameobject.GetComponent <LCharacterHitDataCmp>();
                                if (null == hdc)
                                {
                                    hdc = contain.gameobject.AddComponent <LCharacterHitDataCmp>();
                                }
                                contain.hitData = hdc.data;
                            }

                            contain.hitData.type = "hit";
                            LCharacterHitData hitData = new LCharacterHitData();

                            hitData.hittedObject.Clear();
                            hitData.value       = value;
                            hitData.characterId = character.GetId();
                            hitData.firstHit    = true;

                            hitData.cdName     = cdName;
                            hitData.skillState = skillState;
                            hitData.cdState    = cdState;

                            int effectId = value.GetValueInt("hit_effect", -2);
                            if (effectId != -2 && objs.ContainsKey(effectId))
                            {
                                var ct = objs[effectId];
                                hitData.effect     = ct.mod;
                                hitData.effect_obj = ct.baseGameObject;
                            }
                            else
                            {
                                hitData.effect     = null;
                                hitData.effect_obj = null;
                            }
                            contain.hitData.data = hitData;
                            int IsFlyTool = value.GetValueInt("IsFlyTool", 0);
                            if (IsFlyTool == 1)
                            {
                                if (contain.type == 3)
                                {
                                    float FlyToolTime  = value.GetValueFloat("FlyToolTime", 20f);
                                    float FlyToolSpeed = value.GetValueFloat("FlyToolSpeed", 2f);
                                    if (null != contain.gameobject)
                                    {
                                        var g = GameObject.Instantiate(contain.gameobject);
                                        LCharacterHitDataCmp hdc0 = g.GetComponent <LCharacterHitDataCmp>();
                                        g.name = "bullet";
                                        LCHBullet bullet = g.AddComponent <LCHBullet>();
                                        hdc0.data.data    = hitData;
                                        hdc0.data.type    = "hit";
                                        contain.isFlyTool = true;
                                        bullet.type       = LCHBullet.TYPE.NORMAL;
                                        bullet.speed      = FlyToolSpeed;
                                        bullet.maxTime    = FlyToolTime;

                                        g.SetActive(true);
                                        contain.gameobject.SetActive(false);
                                    }
                                }
                            }
                            else if (IsFlyTool == 2)
                            {
                                if (contain.type == 3)
                                {
                                    //float FlyToolTime = value.GetValueFloat("FlyToolTime", 20f);
                                    float FlyToolSpeed = value.GetValueFloat("FlyToolSpeed", 2f);
                                    if (null != contain.gameobject)
                                    {
                                        var g = GameObject.Instantiate(contain.gameobject);
                                        LCharacterHitDataCmp hdc0 = g.GetComponent <LCharacterHitDataCmp>();
                                        g.name = "bullet";
                                        LCHBullet bullet = g.AddComponent <LCHBullet>();
                                        hdc0.data.data     = hitData;
                                        hdc0.data.type     = "hit";
                                        contain.isFlyTool  = true;
                                        bullet.type        = LCHBullet.TYPE.FELLOW;
                                        bullet.speed       = FlyToolSpeed;
                                        bullet.curTargetId = curTargetId;

                                        bullet.maxTime = 60f;
                                        g.SetActive(true);
                                        contain.gameobject.SetActive(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (res == 0)
            {
                if (null != contain.gameobject)
                {
                    contain.gameobject.SetActive(false);
                }
            }
        }
    }
Esempio n. 6
0
    public static void CmpAnimationPos(float curTime, ObjectContain contain, LCharacterInterface character, LChatacterInformationInterface information)
    {
        if (contain.isFlyTool)
        {
            return;
        }
        contain.ResetTransformData();

        for (int i = 0, c0 = contain.channels.Count; i < c0; i++)
        {
            var channel = contain.channels[i];

            LCHChannelType t = (LCHChannelType)channel.type;
            switch (t)
            {
            case LCHChannelType.PosX:
            {
                float v = channel.GetLerpValue(curTime);
                contain.pos += new Vector3(v, 0f, 0f);
                break;
            }

            case LCHChannelType.PosY:
            {
                float v = channel.GetLerpValue(curTime);
                contain.pos += new Vector3(0f, v, 0f);
                break;
            }

            case LCHChannelType.PosZ:
            {
                LCHChannelData.debug = true;
                float v = channel.GetLerpValue(curTime);
                LCHChannelData.debug = false;
                contain.pos         += new Vector3(0f, 0f, v);
                break;
            }

            case LCHChannelType.RotY:
            {
                contain.rot = channel.GetSlerpYValue(curTime);
                break;
            }

            case LCHChannelType.ScaleX:
            {
                float v = channel.GetLerpValue(curTime);
                contain.scale = new Vector3(v, contain.scale.y, contain.scale.z);
                break;
            }

            case LCHChannelType.ScaleY:
            {
                float v = channel.GetLerpValue(curTime);
                contain.scale = new Vector3(contain.scale.x, v, contain.scale.z);
                break;
            }

            case LCHChannelType.ScaleZ:
            {
                float v = channel.GetLerpValue(curTime);
                contain.scale = new Vector3(contain.scale.x, contain.scale.y, v);
                break;
            }
            }
        }
    }
Esempio n. 7
0
    public override IEnumerator onInit(LChatacterRecourceInterface loader, LCharacterInterface character, AddCoroutineFun fun)
    {
        hasLoaded = false;
        CharactorLoadHandle handle0 = loader.LoadSkillDataFile(SkillId, fun);

        while (!handle0.isFinish)
        {
            yield return(null);
        }
        skillData = (LCHSkillData)handle0.asset;

        role.type  = 1;
        role.objId = -1;

        character.UpdateSkillRange(cdName, skillData.skillRange, skillData.skillWidth);
        //
        objs[role.objId] = role;
        objList          = new ObjectContain[skillData.objs.Length];
        for (int i = 0, l = skillData.objs.Length; i < l; i++)
        {
            var           o  = skillData.objs[i];
            ObjectContain oc = new ObjectContain();
            oc.SetInformation(o);
            objs[o.id] = oc;
            objList[i] = oc;
            if (o.id == -1)//不加载主模型。
            {
                continue;
            }
            else if (o.type == 1)//对象(特效,模型...)。
            {
                //Debug.LogError("load " + oc.mod);
                var handle = loader.loadResource(oc.mod_name, oc.mod, fun);
                while (!handle.isFinish)
                {
                    yield return(1);
                }
                if (null != handle.asset)
                {
                    if (handle.asset == null)
                    {
                        Debug.LogError("找不到资源,是否没打包 ? " + oc.mod);
                    }
                    else
                    {
                        oc.baseGameObject = (GameObject)handle.asset;
                        if (null != oc.baseGameObject)
                        {
                            oc.gameobject = GameObject.Instantiate(oc.baseGameObject);
                            oc.gameobject.SetActive(false);
                            oc.gameobject.name      = o.name;
                            oc.gameobject.hideFlags = HideFlags.None;
                            oc.systems = oc.gameobject.GetComponentsInChildren <ParticleSystem>();
                        }
                    }
                }
            }
            else if (o.type == 2)//(碰撞体)。
            {
                GameObject g = new GameObject();
                g.layer = character.GetAttackLayer();
                g.SetActive(false);
                g.AddComponent <BoxCollider>();
                g.hideFlags   = HideFlags.DontSave;
                oc.gameobject = g;
                g.name        = o.name;
            }
            else if (o.type == 3)//模型本身碰撞体。暂不连接。
            {
                continue;
            }
            else if (o.type == 4)//加载声音
            {
                GameObject g = new GameObject();
                g.name        = o.name;
                oc.gameobject = g;
                loader.loadResource(oc.mod_name, oc.mod, fun);
            }
        }
        for (int i = 0, c0 = skillData.events.Count; i < c0; i++)
        {
            var _e      = skillData.events[i];
            var contain = objs[_e.objId];
            contain.events.Add(_e);
        }

        for (int i = 0, c0 = skillData.channels.Count; i < c0; i++)
        {
            var _c      = skillData.channels[i];
            var contain = objs[_c.objId];
            contain.channels.Add(_c);
        }

        hasLoaded = true;
    }
Esempio n. 8
0
    public static void CmpObjectEvent(float curTime, float lastTime, LCHEventChannelData _e, ObjectContain contain, LChatacterInterface character, LChatacterInformationInterface information,
                                      Dictionary <int, ObjectContain> objs
                                      , CdState cdState
                                      , string cdName
                                      , int skillState

                                      )
    {
        LCHChannelType t = (LCHChannelType)_e.type;
        ObjDictionary  value;
        float          _time;

        if (t == LCHChannelType.Object)
        {
            int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time);
            if (res == 1)
            {
                if (null != contain.gameobject)
                {
                    bool enable = value.GetValue <bool>("enable", true);
                    if (_e.objId == -1)
                    {
                        //因為主對象直接設置 gameObject的Enable,所有腳本都不工作了.
                        if (null != contain.roleRenders)
                        {
                            for (int n = 0; n < contain.roleRenders.Length; n++)
                            {
                                contain.roleRenders[n].enabled = enable;
                            }
                        }
                    }
                    else
                    {
                        if (enable)
                        {
                            contain.gameobject.SetActive(false);
                            contain.gameobject.SetActive(true);

                            /*contain.gameobject.SetActive(enable);
                             * for (int i = 0, l = contain.systems.Length; i < l; i++)
                             * {
                             *  //Debug.Log(contain.systems[i].isStopped);
                             *  contain.systems[i].gameObject.SetActive(false);
                             *  contain.systems[i].gameObject.SetActive(true);
                             *  contain.systems[i].Play(true);
                             * }*/
                        }
                        else
                        {
                            contain.gameobject.SetActive(enable);
                        }

                        //Debug.LogError("_e.objId  " + _e.objId + " " + enable);
                        //contain.gameobject.SetActive(enable);
                    }

                    if (enable)
                    {
                        if (contain.type == 1)
                        {
                            string anim_name = value.GetValue <string>("anim", "");
                            if (anim_name.Length > 0)
                            {
                                if (null == contain.animaction)
                                {
                                    contain.animaction = contain.gameobject.GetComponent <Animation>();
                                }
                                if (null != contain.animaction)
                                {
                                    bool cf = value.GetValue <bool>("crossFade", true);
                                    //crossFade
                                    contain.animaction[anim_name].time = _time;
                                    if (cf)
                                    {
                                        contain.animaction.CrossFade(anim_name, 0.05f);
                                    }
                                    else
                                    {
                                        contain.animaction[anim_name].time = 0f;//特么受击不这么干不重置。。。
                                        contain.animaction.Play(anim_name);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (res == 0)
            {
                if (_e.objId != -1)//非主模型,一开始隐藏
                {
                    if (null != contain.gameobject)
                    {
                        if (contain.objId != -1)
                        {
                            contain.gameobject.SetActive(false);
                        }
                    }
                }
            }
        }
        if (t == LCHChannelType.Event)
        {
            int res = _e.TryGetKeyFrameRunTime(curTime, lastTime, out value, out _time);
            if (res == 1)
            {
                if (contain.type == 2 || contain.type == 3)
                {
                    if (null == contain.collider)
                    {
                        if (null != contain.gameobject)
                        {
                            contain.collider         = contain.gameobject.GetComponent <Collider>();
                            contain.gameobject.layer = character.GetAttackLayer();
                            if (null != contain.collider)
                            {
                                contain.collider.isTrigger = true;
                            }
                        }
                    }
                }
                if (null != contain.gameobject)
                {
                    bool enable = value.GetValue <bool>("enable", true);
                    contain.gameobject.SetActive(enable);
                    if (contain.collider)
                    {
                        contain.collider.enabled = enable;
                        if (enable)
                        {
                            if (null == contain.hitData)
                            {
                                LCharacterHitDataCmp hdc = contain.gameobject.GetComponent <LCharacterHitDataCmp>();
                                if (null == hdc)
                                {
                                    hdc = contain.gameobject.AddComponent <LCharacterHitDataCmp>();
                                }
                                contain.hitData = hdc.data;
                            }

                            contain.hitData.type = "hit";
                            LCharacterHitData hitData = new LCharacterHitData();

                            hitData.hittedObject.Clear();
                            hitData.value       = value;
                            hitData.characterId = character.GetId();
                            hitData.firstHit    = true;

                            hitData.cdName     = cdName;
                            hitData.skillState = skillState;
                            hitData.cdState    = cdState;

                            int effectId = value.GetValueInt("hit_effect", -2);
                            if (effectId != -2 && objs.ContainsKey(effectId))
                            {
                                var ct = objs[effectId];
                                hitData.effect     = ct.mod;
                                hitData.effect_obj = ct.baseGameObject;
                            }
                            else
                            {
                                hitData.effect     = null;
                                hitData.effect_obj = null;
                            }
                            contain.hitData.data = hitData;
                        }
                    }
                }
            }
            else if (res == 0)
            {
                if (null != contain.gameobject)
                {
                    contain.gameobject.SetActive(false);
                }
            }
        }
    }