Ejemplo n.º 1
0
 public override IEnumerator onInit(LChatacterRecourceInterface loader, LChatacterInterface character, AddCoroutineFun fun)
 {
     yield return(null);
 }
Ejemplo n.º 2
0
 public override bool isFinish(LChatacterInterface character, LChatacterInformationInterface information)
 {
     return(false);
 }
Ejemplo n.º 3
0
 public override bool isQualified(LChatacterAction curAction, LChatacterInterface character, LChatacterInformationInterface information)
 {
     return(true);
 }
Ejemplo n.º 4
0
 public override void beginAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
     initJump(character, information);
     isJumpping = true;
 }
Ejemplo n.º 5
0
 public override void beginAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
     jumpCount = 0;
     firFrame  = true;
     initJump(character, information);
 }
Ejemplo n.º 6
0
 public abstract IEnumerator onInit(LChatacterRecourceInterface loader, LChatacterInterface character, AddCoroutineFun fun);
Ejemplo n.º 7
0
 public abstract void doAction(LChatacterInterface character, LChatacterInformationInterface information);
Ejemplo n.º 8
0
 public void AddCharacter(LChatacterInterface character)
 {
     characters.Add(character);
     charactersMap[character.GetId()] = character;
 }
Ejemplo n.º 9
0
 public void RemoveCharacter(LChatacterInterface character)
 {
     charactersMap.Remove(character.GetId());
     characters.Remove(character);
 }
Ejemplo n.º 10
0
    public override void doAction(LChatacterInterface character, LChatacterInformationInterface information)
    {
        if (!hasLoaded)
        {
            return;
        }

        role.ResetTransformData();
        for (int i = 0, c0 = objList.Length; i < c0; i++)
        {
            var o0 = objList[i];
            o0.ResetTransformData();
        }

        CmpAnimationPos(curTime, role, character, information);
        SetRolePos(curTime, role, character, information, ref baseGroundPos, beginLocalScale, beginLocalRot, true);
        for (int i1 = 0, c1 = objList.Length; i1 < c1; i1++)
        {
            var contain = objList[i1];
            CmpAnimationPos(curTime, contain, character, information);
        }
        //因为模型不是技能系统负责加载,所以最后一刻才负责绑定。
        if (null == role.gameobject)
        {
            role.gameobject  = character.GetRoleAnimation().gameObject;
            role.roleRenders = character.GetRoleRender();
        }


        //避免调用字典foreach导致每帧产生 GC Allow
        for (int i = 0, c0 = objList.Length; i < c0; i++)
        {
            var contain = objList[i];
            SetObjectPos(curTime, contain, objs, character, information,
                         beginPositon,
                         beginLocalScale,
                         beginLocalRot);
        }

        {
            var contain = role;
            for (int i = 0, c0 = contain.events.Count; i < c0; i++)
            {
                var _e = contain.events[i];
                CmpObjectEvent(curTime, lastTime, _e, contain, character, information, objs, cdState, cdName, skillState);
            }
        }
        for (int ii = 0, c1 = objList.Length; ii < c1; ii++)
        {
            var contain = objList[ii];
            for (int i = 0, c0 = contain.events.Count; i < c0; i++)
            {
                var _e = contain.events[i];
                CmpObjectEvent(curTime, lastTime, _e, contain, character, information, objs, cdState, cdName, skillState);
            }
        }
        //计算物体事件,比如播放动作,声音等。
        for (int i = 0, c0 = skillData.events.Count; i < c0; i++)
        {
            var _e      = skillData.events[i];
            var contain = objs[_e.objId];
        }
        lastTime = curTime;
    }
Ejemplo n.º 11
0
    public override IEnumerator onInit(LChatacterRecourceInterface loader, LChatacterInterface character, AddCoroutineFun fun)
    {
        Debug.Log("skill on init " + SkillId);
        hasLoaded = false;
        CharactorLoadHandle handle0 = loader.LoadSkillDataFile(SkillId, fun);

        while (!handle0.isFinish)
        {
            yield return(null);
        }
        skillData = (LCHSkillData)handle0.asset;
        //Debug.LogError("LoadSkillDataFile");
        role.type        = 1;
        role.objId       = -1;
        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;
        Debug.Log("skill on init finish " + SkillId);
    }
Ejemplo n.º 12
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);
                }
            }
        }
    }
Ejemplo n.º 13
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;
             }
         }
     }
 }
Ejemplo n.º 14
0
    public static void CmpAnimationPos(float curTime, ObjectContain contain, LChatacterInterface character, LChatacterInformationInterface information)
    {
        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;
            }
            }
        }
    }
Ejemplo n.º 15
0
 public override void endAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
 }
Ejemplo n.º 16
0
 public override void beginAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
     //Debug.LogError("begin fall");
     character.CrossFade(animName);
 }
Ejemplo n.º 17
0
 public override void beginAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
     character.CrossFade(animName);
 }
Ejemplo n.º 18
0
 public override bool isFinish(LChatacterInterface character, LChatacterInformationInterface information)
 {
     return(!VirtualInput.isDirectKeyDown);
 }
Ejemplo n.º 19
0
 public abstract bool isQualified(LChatacterAction curAction, LChatacterInterface character, LChatacterInformationInterface information);
Ejemplo n.º 20
0
 public override bool isQualified(LChatacterAction curAction, LChatacterInterface character, LChatacterInformationInterface information)
 {
     return(VirtualInput.isDirectKeyDown);
 }
Ejemplo n.º 21
0
 public abstract bool isFinish(LChatacterInterface character, LChatacterInformationInterface information);
Ejemplo n.º 22
0
 public override void endAction(LChatacterInterface character, LChatacterInformationInterface information)
 {
     isJumpping = false;
     character.SetCurPosition(information.getGroundHight(endPositoin + Vector3.up));
 }