public override bool OnTrigger(LCharacterColliderData cdata, Collider other, LChatacterInterface character, LChatacterInformationInterface information) { if (cdata.type == "hit") { LCharacterHitData data = cdata.getData <LCharacterHitData>(); ActionType status = (ActionType)data.value.GetValueInt("status", 0); if (GetActionType() == status) { if (!data.hittedObject.Contains(character.GetId()) && null != data.value) { data.hittedObject.Add(character.GetId()); if (character.IsAI()) { character.AddHaterd(data.characterId, 1); } float slow_motion = data.value.GetValueFloat("slow_motion", 0f); if (data.firstHit) { if (data.cdState == CdState.HIT) { LChatacterInterface chr = information.GetCharacter(data.characterId); chr.updateCDState(data.cdName, data.skillState); } if (slow_motion > 0.0001f) { information.slowly(0.01f, slow_motion); data.firstHit = true; } } Vector3 dir = other.transform.forward; dir.y = 0; dir.Normalize(); SetHitData(data, dir); return(true); } } } return(false); }
public void AddCharacter(LChatacterInterface character) { characters.Add(character); charactersMap[character.GetId()] = character; }
public void RemoveCharacter(LChatacterInterface character) { charactersMap.Remove(character.GetId()); characters.Remove(character); }
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); } } } }