/// <summary> /// 激活行为. /// </summary> public override void Active() { base.Active(); curPosition = beginPosition = KingSoftCommonFunction.NearPosition(hero.Position); endPosition = KingSoftCommonFunction.NearPosition(endPosition); NavMesh.CalculatePath(beginPosition, endPosition, -1, path); steps = path.corners; stepsLen = steps.Length; if (stepsLen <= 1) { endPosition = curPosition; isFinish = true; return; } curStepIndex = 1; if (stepsLen > 1) { SendNextDistance(); } isFinish = false; if (Vector3.Distance(hero.Position, endPosition) < deltaSpace) { hero.Position = KingSoftCommonFunction.GetGoundHeight(hero.Position); Vector3 forward = endPosition - hero.Position; forward = new Vector3(forward.x, 0, forward.z); hero.Forward = forward; OnDistanceChange(hero.Position); isFinish = true; } }
// Update is called once per frame void Update() { RefreadEndPosition(); Vector3 p = transform.position; if (/* null== target || */ KingSoftMath.MoveTowards(ref p, target.transform.position, speed * Time.deltaTime)) { if (displayInfor != null && displayInfor.CameraEffect.CompareTo("SHAKE_BULLET_HIT") == 0) { Shake(); } if (displayInfor.SoundType == KSkillDisplay.ACTION_AUIDO_TYPE.Hit) { if (displayInfor.Sound.Length > 0) { AudioManager.instance.PlaySound3d(displayInfor.Sound, hero.Position); } } msg_case.PopMessage(hero); gameObject.AddComponent <DestoryObject>(); } else { KingSoftCommonFunction.NearPosition(p); transform.position = p; } }
/// <summary> /// 激活行为. /// </summary> public override void Active() { //FxAsset assert = new FxAsset(); //assert.init(URLUtil.GetResourceLibPath() + buffInfor.BuffPath); base.Active(); KParams kParams = KConfigFileManager.GetInstance().GetParams(); outColor = KingSoftCommonFunction.StringToColor(kParams.MonsterOutColor); totalTime = kParams.MonsterOutTime; MonsterOutHeight = kParams.MonsterOutHeight; if (kParams.MonsterOutFx.Length > 0) { assert.init(URLUtil.GetResourceLibPath() + kParams.MonsterOutFx); GameObject fx = assert.CloneObj(); if (null != fx) { fx.transform.position = hero.Position; fx.transform.localScale = hero.transform.localScale * kParams.MonsterOutFxScale; DestoryObject d = fx.AddComponent <DestoryObject>(); d.delta = 1f; } } hero.DispatchEvent(ControllerCommand.CrossFadeAnimation, "idle1", AMIN_MODEL.ONCE, false); isFinish = false; hero.DispatchEvent(ControllerCommand.CLEAR_BUFF); beginTime = Time.realtimeSinceStartup; }
/// <summary> /// 激活行为. /// </summary> public override void Active() { base.Active(); if (hitAnim.Length > 0) { hero.DispatchEvent(ControllerCommand.CrossFadeAnimation, hitAnim); } isFinish = false; action = new ActionThrowUp(hero); action.beginPosition = hero.Position; action.endPosition = KingSoftCommonFunction.NearPosition(hero.Position); KParams kParams = KConfigFileManager.GetInstance().GetParams(); action.height = kParams.HitHeight; action.changeForward = false; action.type = ActionThrowUp.ThrowUpType.TIME; action.totalTime = time; action.Active(); if (hero.property.isMainHero) { hero.DispatchEvent(ControllerCommand.HERO_MOVE); } }
public override void Active() { base.Active(); KSkillDisplay skillDisplay = KConfigFileManager.GetInstance().GetSkillDisplay(hero.property.lastHitSkillId, hero.property.tabID); Vector3 forward = hero.Position - attacker.Position; forward.Normalize(); jump.beginPosition = hero.Position; jump.dampen = true; if (null == skillDisplay) { height = 0; distance = 0; speed = 100f; jump.endPosition = KingSoftCommonFunction.NearPosition(hero.Position); } else { height = skillDisplay.DieJump; distance = skillDisplay.DieDistance; speed = skillDisplay.DieSpeed; jump.endSpeed = skillDisplay.DieSpeed2; jump.endPosition = KingSoftCommonFunction.NearPosition(hero.Position + forward * distance); } lookForward = new Vector3(-forward.x, 0f, -lookForward.z); jump.speed = speed; attackerPosition = attacker.transform.position; jump.height = height; jump.Active(); hero.DispatchEvent(ControllerCommand.CrossFadeAnimation, "dead", AMIN_MODEL.ONCE, false); }
public override void OnAttachToEntity(SceneEntity ety) { BaseInit(ety); redTicker.Stop(); KParams kParams = KConfigFileManager.GetInstance().GetParams(); redTicker.cd = kParams.HitColorTime; hitColor = KingSoftCommonFunction.StringToColor(kParams.HitColor); // 注册事件响应函数 Regist(ControllerCommand.BE_HIT, OnBeHit); }
public static Vector3 ScreenMouseToGround(Vector3 heroPosition) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hitList = Physics.RaycastAll(ray, 200); System.Array.Sort(hitList, delegate(RaycastHit r1, RaycastHit r2) { return(r1.distance.CompareTo(r2.distance)); }); System.Nullable <RaycastHit> heroHit = null; foreach (RaycastHit hit in hitList) { if (hit.collider.gameObject.tag == TagManager.GetInstance().NavMeshTag) { //Debug.Log("get hit "+hit.collider.gameObject.name + " " + hit.distance); return(KingSoftCommonFunction.NearPosition(hit.point)); } else { //Debug.Log("hit "+hit.collider.gameObject.name + " " + hit.distance); heroHit = hit; } } if (null != heroHit) { return(NearPosition(heroHit.GetValueOrDefault().point)); } if (null == plane) { plane = new GameObject(); GameObject.DontDestroyOnLoad(plane); BoxCollider box = plane.AddComponent <BoxCollider>(); plane.tag = TagManager.GetInstance().NavMeshTag; box.center = Vector3.zero; box.size = new Vector3(1000f, 1, 1000f); } { plane.transform.position = heroPosition - Vector3.down - Vector3.down; plane.SetActive(true); ray = Camera.main.ScreenPointToRay(Input.mousePosition); hitList = Physics.RaycastAll(ray, 200); foreach (RaycastHit hit in hitList) { if (hit.collider.gameObject.tag == TagManager.GetInstance().NavMeshTag) { plane.SetActive(false); return(NearPosition(hit.point, 2f)); } } plane.SetActive(false); } return(NearPosition(Vector3.zero, 100000f)); }
/// <summary> /// Update this instance. /// </summary> public override void Update() { if (Vector3.Distance(hero.Position, endPosition) < deltaSpace) { Vector3 forward = endPosition - hero.Position; forward = new Vector3(forward.x, 0, forward.z); hero.Forward = forward; isFinish = true; return; } if (curStepIndex < stepsLen) { curPosition = new Vector3(hero.Position.x, curPosition.y, hero.Position.z); bool b = KingSoftMath.MoveTowards(ref curPosition, steps[curStepIndex], speed * Time.deltaTime); Vector3 forward = curPosition - hero.Position; forward = new Vector3(forward.x, 0, forward.z); if (forward.x != 0 || forward.z != 0) { hero.Rotation = Quaternion.RotateTowards(hero.Rotation, Quaternion.LookRotation(forward), 600f * Time.deltaTime); } hero.Position = KingSoftCommonFunction.GetGoundHeight(curPosition); if (b) { curStepIndex++; if (curStepIndex == stepsLen) { hero.Position = endPosition; isFinish = true; } else { SendNextDistance(); } } else if (curStepIndex == stepsLen - 1 && deltaSpace > 0) { if (Vector3.Distance(curPosition, steps[curStepIndex]) < deltaSpace) { hero.Position = KingSoftCommonFunction.GetGoundHeight(curPosition); hero.Forward = forward; OnDistanceChange(hero.Position); isFinish = true; } } } else { isFinish = true; } }
/// <summary> /// Update this instance. /// </summary> public override void Update() { bool b = KingSoftMath.MoveTowards(ref curPosition, endPosition, speed * Time.deltaTime); if (b) { isFinish = true; hero.Position = KingSoftCommonFunction.GetGoundHeight(curPosition); } else { hero.Position = curPosition; } }
private void LoadResource_OnLoadComplete(AssetInfo info) { if (this == null && Owner == null) { return; } try { Owner.BodyGo = GameObject.Instantiate(info.bundle.mainAsset) as GameObject; } catch (System.Exception e) { //对象月已经释放. return; } Owner.BodyGo.transform.parent = Owner.transform; Owner.BodyGo.transform.localPosition = Vector3.zero; Owner.BodyGo.transform.rotation = Quaternion.identity; Owner.BodyGo.transform.localScale = new Vector3(1, 1, 1); Owner.BodyGo.layer = CameraLayerManager.GetInstance().GetSceneObjectTag(); Owner.Anim = Owner.BodyGo.animation; BoxCollider _boxCollider = Owner.BodyGo.GetComponent <BoxCollider>(); if (null == _boxCollider) { Vector3 _size = KingSoftCommonFunction.GetGameObjectSize(Owner.BodyGo); float _h = _size.y / Owner.transform.localScale.y; float _s = Mathf.Max(_size.x, _size.z) * 0.5f / Owner.transform.localScale.y; Owner.property.characterController.size = new Vector3(_s, _h, _s); Owner.property.characterController.center = new Vector3(0, _h / 2, 0); } else { Owner.property.characterController.size = _boxCollider.size * Owner.BodyGo.transform.localScale.y; Owner.property.characterController.center = _boxCollider.center * Owner.BodyGo.transform.localScale.y; GameObject.Destroy(_boxCollider); } if (Owner.L_Anim_Name.Length > 0) { Owner.DispatchEvent(ControllerCommand.PlayAnimation, Owner.L_Anim_Name, Owner.AnimModel); } if (Owner.ActiveAction.NAME.CompareTo("ActionMousterOut") == 0) { Owner.BodyGo.transform.localPosition = Vector3.down * 3f; } Owner.DispatchEvent(ControllerCommand.UPDATE_MISSION_SIGN); }
public object OnMoveToDestination(params object[] objs) { if (objs.Length < 1) { return(null); } Vector3 _destination; _destination = (Vector3)objs[0]; bool sendMessage = false; if (objs.Length >= 2) { sendMessage = Convert.ToBoolean(objs[1]); } if (Owner.property.isMainHero) { Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(_destination); AnimationComponent.OperaWalking = true; } EventRet ret = Owner.DispatchEvent(ControllerCommand.TryFinishAction); bool bRet = (bool)ret.GetReturn <AnimationComponent>(); if (bRet) { ActionWalk walk = new ActionWalk(Owner); if (objs.Length >= 3) { walk.deltaSpace = (float)(objs[3]); } walk.speed = Owner.Speed; walk.IsPushStack = sendMessage; walk.endPosition = _destination; Owner.DispatchEvent(ControllerCommand.SetActiveAction, walk); } else { Owner.DispatchEvent(ControllerCommand.ActionMoveToDistance, _destination, Owner.Speed, sendMessage); } return(null); }
private void LoadLevelUpComplete(AssetInfo info) { try { if (null != SceneLogic.GetInstance().MainHero&& null != info.bundle.mainAsset) { GameObject fx = GameObject.Instantiate(info.bundle.mainAsset) as GameObject; fx.transform.parent = SceneLogic.GetInstance().MainHero.transform; fx.transform.localPosition = Vector3.zero; KingSoftCommonFunction.SetLayer(fx, 11); DestoryObject d = fx.AddComponent <DestoryObject>(); d.delta = 5f; } } catch (System.Exception e) { } }
public void ToDead(SceneEntity killer) { if (null != killer) { KingSoftCommonFunction.LootAt(Owner.gameObject, killer.gameObject); } Owner.property.fightHp = 0; if (Owner.HeroType == KHeroObjectType.hotMonster) { if (null != killer && killer.property.isMainHero) { HitPanelView.GetInstance().hit(); } KSkillDisplay skillDisplay = KConfigFileManager.GetInstance().GetSkillDisplay(Owner.property.lastHitSkillId, Owner.property.tabID); if (Owner.property.lastAttackEvent == (byte)KAttackEvent.aeCrit || skillDisplay.DeadType == KSkillDisplay.DEAD_TYPE.BOMB) { ActionBomb action = new ActionBomb(Owner); action.IsPushStack = false; Owner.DispatchEvent(ControllerCommand.SetActiveAction, action); } else if (skillDisplay.DeadType == KSkillDisplay.DEAD_TYPE.PHYSICS) { ActionPlysiceDie action = new ActionPlysiceDie(Owner); action.attacker = killer; action.IsPushStack = false; Owner.DispatchEvent(ControllerCommand.SetActiveAction, action); } else { ActionMonsterDie action = new ActionMonsterDie(Owner); action.attacker = killer; action.IsPushStack = false; Owner.DispatchEvent(ControllerCommand.SetActiveAction, action); } //ActionBomb } else { ActionDie action = new ActionDie(Owner); action.IsPushStack = false; Owner.DispatchEvent(ControllerCommand.SetActiveAction, action); } }
void OnHit() { if (displayInfor.CameraEffect.CompareTo("SHAKE_HIT") == 0) { Shake(); } if (displayInfor.BulletEffect.Length > 0 && target != null) { hero.property.AutoAttack = false; GameObject bulletObj = null; AssetInfo inf = AssetLoader.GetInstance().Load(URLUtil.GetResourceLibPath() + displayInfor.BulletEffect); if (inf.isDone(false)) { bulletObj = inf.CloneGameObject(); } else { bulletObj = new GameObject(); } bulletObj.transform.position = hero.transform.position; bulletObj.SetActive(true); KingSoftCommonFunction.SetLayer(bulletObj, 11); Bullet bullet = bulletObj.AddComponent <Bullet>(); bullet.msg_case = msg_case; msg_case = null; bullet.displayInfor = displayInfor; bullet.hero = hero; bullet.target = target; bullet.speed = (activeSkill.SkillFlySpeed / 100); bullet.hitFx = displayInfor.HitEffect; } else { if (displayInfor.SoundType == KSkillDisplay.ACTION_AUIDO_TYPE.Hit) { if (displayInfor.Sound.Length > 0) { AudioManager.instance.PlaySound3d(displayInfor.Sound, hero.Position); } } PopMsg(); } }
public void PlayEndFx(float second) { if (displayInfor.EndEffect.Length > 0) { AssetInfo inf = AssetLoader.GetInstance().Load(URLUtil.GetResourceLibPath() + displayInfor.EndEffect); if (inf.isDone(false)) { EndFxObj = inf.CloneGameObject(); EndFxObj.transform.parent = hero.transform; EndFxObj.transform.localPosition = Vector3.zero; ObjectUtil.SetTagWithAllChildren(EndFxObj, CameraLayerManager.GetInstance().GetMissionSignName()); if (displayInfor.EndEffectBindPoint.Length == 0 || displayInfor.BeginEffectBindPoint.CompareTo("Ground") == 0) { EndFxObj.transform.localRotation = Quaternion.identity; EndFxObj.transform.localScale = Vector3.one; } else { Transform t = hero.GetChildTransform(displayInfor.BeginEffectBindPoint); if (null != t) { EndFxObj.transform.parent = t; EndFxObj.transform.localPosition = Vector3.zero; EndFxObj.transform.localRotation = Quaternion.identity; EndFxObj.transform.localScale = Vector3.one; EndFxObj.transform.parent = hero.transform; } } if (!displayInfor.EndEffectBind) { EndFxObj.transform.parent = hero.transform.parent; } ParticleSystemScaleManager.ScaleParticle(EndFxObj); KingSoftCommonFunction.SetLayer(EndFxObj, 11); EndFxObj.SetActive(true); DestoryObject dos = EndFxObj.AddComponent <DestoryObject>(); dos.delta = second; } } if (hitTicker.isPlaying()) { OnHit(); } }
/// <summary> /// 激活行为. /// </summary> public override void Active() { base.Active(); curPosition = beginPosition = hero.Position; endPosition = KingSoftCommonFunction.GetGoundHeight(endPosition); forward = (endPosition - beginPosition).normalized; distance = Vector3.Distance(beginPosition, endPosition); float deltaY = Mathf.Abs(curPosition.y - beginPosition.y); if (type == ThrowUpType.DISTANCE) { deltaHeight = beginPosition.y - endPosition.y; //因为服务器的速度是水平的速度. curPosition = beginPosition = new Vector3(beginPosition.x, endPosition.y, beginPosition.z); //起点和终点放在一个水平面上. float v = (speed + endSpeed) / 2; totalTime = distance / v; a = (endSpeed - speed) / totalTime; } }
private void LoadSceneCompleteHandler(AssetInfo info) { DestroyOldScene(); sceneParent = new GameObject("SubScene_" + currentMapId); sceneParent.transform.parent = rootParent.transform; log.Debug("构建基础scene场景"); UObject.DontDestroyOnLoad(GameObject.Find("GameObject")); Application.LoadLevel(currentMapId.ToString()); MoveTo(Vector3.zero); KingSoftCommonFunction.ResetGoundMesh(); log.Debug("装载场景unit完成"); //Assets.Scripts.View.Npc.LoadingView.GetInstance().SetValue(0.2f); SceneView.GetInstance().BuildComplete(); /*Assets.Scripts.Manager.EventDispatcher.GameWorld.Dispath( * Assets.Scripts.Manager.ControllerCommand.CLOSE_LOADING_PANEL);*/ }
public void LoadTrail() { tuowei1_1 = Owner.property.weapon[0].transform.Find("tuowei1"); tuowei1_2 = Owner.property.weapon[0].transform.Find("tuowei2"); if (null != tuowei1_1 && null != tuowei1_2) { trail1 = tuowei1_1.gameObject.AddComponent <MyTrail>(); trail1.p1 = tuowei1_1; trail1.p2 = tuowei1_2; //trail.time = 80; trail1.mat = WeaponTrailLoader.trailMat; KHeroSetting heroSetting = KConfigFileManager.GetInstance().heroSetting.getData(Owner.TabID.ToString()); if (null != heroSetting) { trail1.time = heroSetting.WeaponTrailTime; trail1.startColor = KingSoftCommonFunction.StringToColor(heroSetting.WeaponTrailBeginColor); trail1.endColor = KingSoftCommonFunction.StringToColor(heroSetting.WeaponTrailEndColor); } } }
//播放攻击动画 public void PlayFightAnimation(SceneEntity target, uint skillId, Vector3 position) { Owner.AnimCmp.ResetFightingState(); uint jobId = Owner.TabID; KSkillDisplay skillDisplay = KConfigFileManager.GetInstance().GetSkillDisplay(skillId, jobId); KActiveSkill skillSetting = KConfigFileManager.GetInstance().GetActiveSkill(skillId, 1); AnimActionParam param = new AnimActionParam(); param.skillId = (ushort)skillId; if (null != target) { KingSoftCommonFunction.LootAt(Owner.gameObject, target.gameObject); param.targetId = target.property.Id; } param.position = position; param.target = target; if (null != Owner.property.activeAction) { Owner.property.activeAction.FinishImmediate(); } if (skillDisplay.SkillType.CompareTo("MOVINGAOE") == 0) { SkillMovingAOE(param, skillDisplay, false); } else if (skillDisplay.SkillType.CompareTo("ANIM") == 0) { SkillSelf(param, skillDisplay, false); } else if (skillDisplay.SkillType.CompareTo("RUSH") == 0) { SkillRush(param, skillDisplay, false); } else if (skillDisplay.SkillType.CompareTo("SHOT") == 0) { } }
bool Bind() { float _meshScale = 3; float _scale = hero.heroSetting.Scale; Transform _root = FindObject <Transform> (hero.gameObject, rootName); if (_root == null) { UnBind(); return(false); } BoxCollider _rootBC = _root.gameObject.AddComponent <BoxCollider>(); _rootBC.size = new Vector3(0.2f, 0.2f, 0.2f) * _scale; _rootBC.center = new Vector3(0, 0.8f, 1f) * _scale; _rootRB = _root.gameObject.AddComponent <Rigidbody>(); _rootRB.mass = 200f * _meshScale; _rootRB.angularDrag = 0.05f; componentList.Add(_bodyRB); componentList.Add(_rootBC); Transform _body = FindObject <Transform> (hero.gameObject, bodyName); if (_body == null) { UnBind(); return(false); } BoxCollider _bodyBC = _body.gameObject.AddComponent <BoxCollider>(); _bodyBC.size = new Vector3(0.4f, 0.2f, 0.2f) * _scale; _bodyBC.center = new Vector3(-0.4f, 0f, 0f) * _scale; _bodyRB = _body.gameObject.AddComponent <Rigidbody>(); _bodyRB.mass = 10f * _meshScale; _bodyRB.angularDrag = 0.05f; FixedJoint _bodyCJ = _body.gameObject.AddComponent <FixedJoint>(); _bodyCJ.connectedBody = _rootRB; componentList.Add(_bodyCJ); componentList.Add(_bodyBC); componentList.Add(_bodyRB); Transform _head = FindObject <Transform> (_body.gameObject, Head); if (_head == null) { UnBind(); return(false); } BoxCollider _headBC = _head.gameObject.AddComponent <BoxCollider>(); _headBC.size = new Vector3(0.2f, 0.2f, 0.2f) * _scale; Rigidbody _headRB = _head.gameObject.AddComponent <Rigidbody>(); _headRB.mass = 10f * _meshScale; _headRB.angularDrag = 0.05f; FixedJoint _headCJ = _head.gameObject.AddComponent <FixedJoint>(); _headCJ.connectedBody = _bodyRB; componentList.Add(_headCJ); componentList.Add(_headBC); componentList.Add(_headRB); Transform _LeftHips = FindObject <Transform> (_body.gameObject, LeftHips); if (_LeftHips == null) { UnBind(); return(false); } BoxCollider _LHBC = _LeftHips.gameObject.AddComponent <BoxCollider>(); _LHBC.size = new Vector3(0.2f, 0.2f, 0.2f) * _scale; Rigidbody _LHRB = _LeftHips.gameObject.AddComponent <Rigidbody>(); _LHRB.mass = 10f * _meshScale; _LHRB.angularDrag = 0.5f; CharacterJoint _LHCJ = _LeftHips.gameObject.AddComponent <CharacterJoint>(); _LHCJ.connectedBody = _rootRB; _LHCJ.swingAxis = new Vector3(0, 0, -1); _LHCJ.axis = new Vector3(0, 1, 0); componentList.Add(_LHCJ); componentList.Add(_LHBC); componentList.Add(_LHRB); Transform _LeftCalf = FindObject <Transform> (_body.gameObject, LeftCalf); if (_LeftCalf == null) { UnBind(); return(false); } BoxCollider _LCBC = _LeftCalf.gameObject.AddComponent <BoxCollider>(); _LCBC.size = new Vector3(0.2f, 0.2f, 0.2f) * _scale; Rigidbody _LCRB = _LeftCalf.gameObject.AddComponent <Rigidbody>(); _LCRB.mass = 10f * _meshScale; _LCRB.angularDrag = 0.5f; CharacterJoint _LCCJ = _LeftCalf.gameObject.AddComponent <CharacterJoint>(); _LCCJ.connectedBody = _LHRB; _LCCJ.swingAxis = new Vector3(0, 0, -1); componentList.Add(_LCBC); componentList.Add(_LCRB); componentList.Add(_LHRB); /*Transform _LeftFoot = FindObject<Transform> (_body.gameObject,LeftFoot); * if (_LeftFoot == null ) * { * UnBind(); * return false; * } * BoxCollider _LFBC = _LeftFoot.gameObject.AddComponent<BoxCollider>(); * _LFBC.size = new Vector3(0.2f,0.2f,0.2f)*_scale; * Rigidbody _LFRB = _LeftFoot.gameObject.AddComponent<Rigidbody>(); * _LFRB.mass = 1f; * _LFRB.angularDrag = 0.5f; * CharacterJoint _LFCJ = _LeftFoot.gameObject.AddComponent<CharacterJoint>(); * _LFCJ.connectedBody = _LCRB; * _LFCJ.swingAxis = new Vector3(0,0,-1); * * * componentList.Add(_LFBC); * componentList.Add(_LFRB); * componentList.Add(_LCRB);*/ Transform _RightHips = FindObject <Transform> (_body.gameObject, RightHips); if (_RightHips == null) { UnBind(); return(false); } BoxCollider _RHBC = _RightHips.gameObject.AddComponent <BoxCollider>(); _RHBC.size = new Vector3(0.2f, 0.2f, 0.2f) * _scale; Rigidbody _RHRB = _RightHips.gameObject.AddComponent <Rigidbody>(); _RHRB.mass = 10f * _meshScale; _RHRB.angularDrag = 0.5f; CharacterJoint _RHCJ = _RightHips.gameObject.AddComponent <CharacterJoint>(); _RHCJ.connectedBody = _rootRB; _RHCJ.swingAxis = new Vector3(0, 0, -1); _RHCJ.axis = new Vector3(0, 1, 0); componentList.Add(_RHBC); componentList.Add(_RHRB); componentList.Add(_RHCJ); Transform _RightCalf = FindObject <Transform> (_body.gameObject, RightCalf); if (_RightCalf == null) { UnBind(); return(false); } BoxCollider _RCBC = _RightCalf.gameObject.AddComponent <BoxCollider>(); _RCBC.size = new Vector3(0.2f, 0.2f, 0.2f) * _scale; Rigidbody _RCRB = _RightCalf.gameObject.AddComponent <Rigidbody>(); _RCRB.mass = 10f * _meshScale; _RCRB.angularDrag = 0.5f; CharacterJoint _RCCJ = _RightCalf.gameObject.AddComponent <CharacterJoint>(); _RCCJ.connectedBody = _RHRB; _RCCJ.swingAxis = new Vector3(0, 0, -1); componentList.Add(_RCBC); componentList.Add(_RCRB); componentList.Add(_RCCJ); /*Transform _RightFoot = FindObject<Transform> (_body.gameObject,RightFoot); * if (_RightFoot == null ) * { * UnBind(); * return false; * } * BoxCollider _RFBC = _RightFoot.gameObject.AddComponent<BoxCollider>(); * _RFBC.size = new Vector3(0.2f,0.2f,0.2f)*_scale; * Rigidbody _RFRB = _RightFoot.gameObject.AddComponent<Rigidbody>(); * _RFRB.mass = 1f; * _RFRB.angularDrag = 0.5f; * CharacterJoint _RFCJ = _RightFoot.gameObject.AddComponent<CharacterJoint>(); * _RFCJ.connectedBody = _RCRB; * _RFCJ.swingAxis = new Vector3(0,0,-1); * * componentList.Add(_RFBC); * componentList.Add(_RFRB); * componentList.Add(_RFCJ);*/ Transform _RightArm = FindObject <Transform> (_body.gameObject, RightArm); if (_RightArm == null) { UnBind(); return(false); } BoxCollider _RABC = _RightArm.gameObject.AddComponent <BoxCollider>(); _RABC.size = new Vector3(0.1f, 0.1f, 0.1f) * _scale; _rightHandRB = _RightArm.gameObject.AddComponent <Rigidbody>(); _rightHandRB.mass = 10f * _meshScale; _rightHandRB.angularDrag = 0.5f; CharacterJoint _RACJ = _RightArm.gameObject.AddComponent <CharacterJoint>(); _RACJ.connectedBody = _bodyRB; componentList.Add(_RABC); componentList.Add(_rightHandRB); componentList.Add(_RACJ); /*Transform _RightHand = FindObject<Transform> (_body.gameObject,RightHand); * if (_RightHand == null ) * { * UnBind(); * return false; * } * BoxCollider _RHDBC = _RightHand.gameObject.AddComponent<BoxCollider>(); * _RHDBC.size = new Vector3(0.1f,0.1f,0.1f)*_scale; * Rigidbody _RHDRB = _RightHand.gameObject.AddComponent<Rigidbody>(); * _RHDRB.mass = 1; * _RHDRB.angularDrag = 0.5f; * CharacterJoint _RHDCJ = _RightHand.gameObject.AddComponent<CharacterJoint>(); * _RHDCJ.connectedBody = _rightHandRB; * * componentList.Add(_RHDBC); * componentList.Add(_RHDRB); * componentList.Add(_RHDRB);*/ Transform _LeftArm = FindObject <Transform> (_body.gameObject, LeftArm); if (_LeftArm == null) { UnBind(); return(false); } BoxCollider _LABC = _LeftArm.gameObject.AddComponent <BoxCollider>(); _LABC.size = new Vector3(0.1f, 0.1f, 0.1f) * _scale; Rigidbody _LARB = _LeftArm.gameObject.AddComponent <Rigidbody>(); _LARB.mass = 10f * _meshScale; _LARB.angularDrag = 0.5f; CharacterJoint _LACJ = _LeftArm.gameObject.AddComponent <CharacterJoint>(); _LACJ.connectedBody = _bodyRB; componentList.Add(_LABC); componentList.Add(_LARB); componentList.Add(_LACJ); Transform _LeftHand = FindObject <Transform> (_body.gameObject, LeftHand); if (_LeftHand == null) { UnBind(); return(false); } BoxCollider _LHDBC = _LeftHand.gameObject.AddComponent <BoxCollider>(); _LHDBC.size = new Vector3(0.1f, 0.1f, 0.1f) * _scale; Rigidbody _LHDRB = _LeftHand.gameObject.AddComponent <Rigidbody>(); _LHDRB.mass = 10f * _meshScale; _LHDRB.angularDrag = 0.5f; CharacterJoint _LHDCJ = _LeftHand.gameObject.AddComponent <CharacterJoint>(); _LHDCJ.connectedBody = _LARB; _LHDCJ.axis = new Vector3(0, 0, 1); componentList.Add(_LHDBC); componentList.Add(_LHDRB); componentList.Add(_LHDCJ); KingSoftCommonFunction.SetLayer(hero.gameObject, 10); Physics.IgnoreLayerCollision(10, 10, true); Physics.gravity = new Vector3(0f, -20f, 0f); return(true); }
//鼠标在屏幕中移动 private void MouseSceneHandler() { if (null == scene || scene.IsLock) { return; } if (SceneLogic.GetInstance().MainHero.property.lockOpera) { return; } //这里是为做点击做的。 if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hitList = Physics.RaycastAll(ray, 200); foreach (RaycastHit hit in hitList) { if (hit.collider.gameObject.tag == TagManager.GetInstance().NavMeshTag) { MouseClickHandler(hit.point, true); } } } if (Input.GetMouseButtonDown(0)) { SceneLogic.GetInstance().MainHero.property.CmdAutoAttack = false; } GameObject go = KingSoftCommonFunction.ScreenMouseGetObject(); if (null != go) { SceneEntity so = go.GetComponent <SceneEntity>() as SceneEntity; if (so.property.isInteractive == false) { return; } SetMoveSceneObject(so); if (Input.GetMouseButtonDown(0)) { SceneLogic.GetInstance().MainHero.property.AutoAttack = false; SetClickSceneObject(so); if (so.property.sceneObjType == KSceneObjectType.sotDoodad) { Debug.LogWarning("PickUpDrop"); SceneLogic.GetInstance().PickUpDrop(so); return; //so.property.dropValue; } else if (so.property.sceneObjType == KSceneObjectType.sotHero) { AnimationComponent.OperaWalking = false; if (so.HeroType == KHeroObjectType.hotNpc) { SceneLogic.GetInstance().MainHero.Action.MoveToNPC(so, OnCatchNPC); } else if (so.HeroType == KHeroObjectType.hotPlayer) { bool canPk = true; if (canPk == true) { SceneEntity player = so; player.property.isCanAttack = true; SceneLogic.GetInstance().MainHero.property.AutoAttack = true; SceneLogic.GetInstance().MainHero.Action.CommonAttack(so); } } else if (so.HeroType == KHeroObjectType.hotMonster) { SceneLogic.GetInstance().MainHero.property.AutoAttack = true; SceneLogic.GetInstance().MainHero.Action.CommonAttack(so); } } } else if (Input.GetMouseButtonDown(1)) { SceneLogic.GetInstance().MainHero.property.AutoAttack = false; if (so.property.sceneObjType == KSceneObjectType.sotHero) { if (so.HeroType == KHeroObjectType.hotPlayer) { bool canPk = true; if (canPk == true) { SceneEntity h = so as SceneEntity; h.property.isCanAttack = true; SetClickSceneObject(so); SceneLogic.GetInstance().MainHero.property.AutoAttack = false; SceneLogic.GetInstance().MainHero.DispatchEvent(ControllerCommand.Idle, true); SceneLogic.GetInstance().MainHero.DispatchEvent(ControllerCommand.LookAtPos, h.Position); } } else if (so.HeroType == KHeroObjectType.hotMonster) { SceneEntity h = so as SceneEntity; h.property.isCanAttack = true; SetClickSceneObject(so); SceneLogic.GetInstance().MainHero.property.AutoAttack = false; SceneLogic.GetInstance().MainHero.DispatchEvent(ControllerCommand.Idle, true); SceneLogic.GetInstance().MainHero.DispatchEvent(ControllerCommand.LookAtPos, h.Position); } } } } else { SetMoveSceneObject(null); if (Input.GetMouseButtonDown(0)) { //寻路. SceneLogic.GetInstance().MainHero.property.AutoAttack = false; Vector3 pos = KingSoftCommonFunction.ScreenMouseToGround(SceneLogic.GetInstance().MainHero.Position); SceneLogic.GetInstance().ClearAutoMoveAcrossMap(); SceneLogic.GetInstance().MainHero.DispatchEvent(ControllerCommand.MOVE_TO_DES, pos, true); } } }
public void OnSkill(ushort skillId) { AnimationComponent.OperaWalking = false; if (SkillLogic.GetInstance().RequestSkill(skillId)) { KSkillDisplay skillDisplay = KConfigFileManager.GetInstance().GetSkillDisplay(skillId, (uint)SceneLogic.GetInstance().MainHero.Job); if (skillDisplay.Opera.CompareTo("NONE") == 0) { SceneLogic.GetInstance().MainHero.Action.SendSkill(skillId); } else if (skillDisplay.Opera.CompareTo("TARGET") == 0) { if (SceneLogic.GetInstance().MainHero.property.target != null && SceneLogic.GetInstance().MainHero.property.target.property.isCanAttack&& !SceneLogic.GetInstance().MainHero.property.target.property.isDeaded) { SceneLogic.GetInstance().MainHero.Action.MoveAndSkill(skillId, SceneLogic.GetInstance().MainHero.property.target); } } else if (skillDisplay.Opera.CompareTo("DIR_RAND") == 0) { EventRet ret = SceneLogic.GetInstance().MainHero.DispatchEvent(ControllerCommand.TryFinishAction); bool bRet = (bool)ret.GetReturn <AnimationComponent>(); if (!bRet) { return; } ActiveSkillData skillVO = SkillLogic.GetInstance().GetActiveSkillVOByID(skillId); KActiveSkill skill = KConfigFileManager.GetInstance().GetActiveSkill((uint)skillId, skillVO.Level); if (null == skill) { return; } float CastMinRange = ((float)skill.CastMinRange) / 100f; float CastRange = ((float)skill.CastRange) / 100f; Vector3 currMousePoint = KingSoftCommonFunction.ScreenMouseToGround(SceneLogic.GetInstance().MainHero.Position); currMousePoint = new Vector3(currMousePoint.x, SceneLogic.GetInstance().MainHero.Position.y, currMousePoint.z); Vector3 dir = currMousePoint - SceneLogic.GetInstance().MainHero.Position; dir = new Vector3(dir.x, 0, dir.z); float f = Vector3.Distance(Vector3.zero, dir); if (f < CastMinRange) { Vector3 dir2 = dir.normalized * CastMinRange; currMousePoint = SceneLogic.GetInstance().MainHero.Position + dir2; } else if (f > CastRange) { Vector3 dir2 = dir.normalized * CastRange; currMousePoint = SceneLogic.GetInstance().MainHero.Position + dir2; } Vector3 p = KingSoftCommonFunction.NearPosition(currMousePoint); Vector3 midPoint = SceneLogic.GetInstance().MainHero.Position + (p - SceneLogic.GetInstance().MainHero.Position) * 0.5f; if (KingSoftCommonFunction.IsPointCanWalk(midPoint)) { SceneLogic.GetInstance().MainHero.Action.SendSkill(skillId, p); } } else if (skillDisplay.Opera.CompareTo("TARGET_DIR") == 0) { EventRet ret = SceneLogic.GetInstance().MainHero.DispatchEvent(ControllerCommand.TryFinishAction); bool bRet = (bool)ret.GetReturn <AnimationComponent>(); if (!bRet) { return; } ActiveSkillData skillVO = SkillLogic.GetInstance().GetActiveSkillVOByID(skillId); KActiveSkill skill = KConfigFileManager.GetInstance().GetActiveSkill((uint)skillId, skillVO.Level); if (null == skill) { return; } float CastRange = 2f; Vector3 currMousePoint; if (SceneLogic.GetInstance().MainHero.property.target != null && SceneLogic.GetInstance().MainHero.property.target.property.isCanAttack&& !SceneLogic.GetInstance().MainHero.property.target.property.isDeaded) { currMousePoint = SceneLogic.GetInstance().MainHero.property.target.Position; } else { currMousePoint = KingSoftCommonFunction.ScreenMouseToGround(SceneLogic.GetInstance().MainHero.Position); } Vector3 dir = currMousePoint - SceneLogic.GetInstance().MainHero.Position; dir = new Vector3(dir.x, 0, dir.z); if (dir.x == 0 && dir.z == 0) { dir = new Vector3(0f, 1f, 0f); } float f = Vector3.Distance(Vector3.zero, dir); SceneLogic.GetInstance().MainHero.Forward = dir; Vector3 dir2 = dir.normalized * CastRange; currMousePoint = SceneLogic.GetInstance().MainHero.Position + dir2; Vector3 p = KingSoftCommonFunction.NearPosition(currMousePoint); SceneLogic.GetInstance().MainHero.Action.SendSkill(skillId, p); } } }
public object OnDestinationChange(params object[] objs) { Vector3 destination = (Vector3)objs[0]; destination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination)); int moveType = (int)objs[1]; Owner.property.destination = destination; if (!Owner.property.isMainHero) { Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination)); } if (Owner.Position == Owner.property.destination) { return(null); } if (moveType == (int)KForceMoveType.fmtJump) { Owner.DispatchEvent(ControllerCommand.Jump, destination); return(null); } else if (moveType == (int)KForceMoveType.fmtRush) { Owner.DispatchEvent(ControllerCommand.Drag, destination); return(null); } else if (moveType == (byte)KForceMoveType.fmtPull) { Owner.DispatchEvent(ControllerCommand.Drag, destination); return(null); } else if (moveType == (byte)KForceMoveType.fmtBack) { Owner.DispatchEvent(ControllerCommand.Back, destination); return(null); } else if (moveType == (byte)KForceMoveType.fmtPlayerFuKong) { Owner.DispatchEvent(ControllerCommand.FuKong, destination); return(null); } else //if (moveType == (byte)KForceMoveType.fmtInvalid) { bool bRet = Owner.ActiveAction.TryFinish(); if (!bRet) { bool bRet2 = Owner.ActiveAction.MoveToDistance(destination, Owner.Speed); if (bRet2) { if (Owner.property.isMainHero) { Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination)); } return(null); } } if (Owner.Position.x == destination.x && Owner.Position.z == destination.z) { Owner.Position = destination; return(null); } ActionWalk walk = new ActionWalk(Owner); walk.speed = Owner.Speed; walk.IsPushStack = false; walk.endPosition = destination; Owner.DispatchEvent(ControllerCommand.SetActiveAction, walk); } return(null); }
//播放战斗效果 public void PlayFightEffect(ushort wSkillID, int damage, byte byAttackEvent, SceneEntity killerHero) { if (byAttackEvent == (byte)KAttackEvent.aeMiss) { if (Owner.property.isMainHero) { Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "2", "FightFont", "effect_ui_shuzitanchu_putong.res"); } else { Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "1", "FightFont", "effect_ui_shuzitanchu_putong.res"); } return; } else if (byAttackEvent == (byte)KAttackEvent.aeCrit) { Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "+" + damage, "CritFont", "effect_ui_shuzitanchu_baoji2.res"); } else if (Owner.property.isMainHero) { Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "+" + damage, "HurtFont", "effect_ui_shuzitanchu_putong.res", NumTip.OFFSET_TYPE.LEFT); } else { Owner.TipsCmp.CreateTip(new Vector3(0, Owner.heroSetting.TipPos0, 0), "+" + damage, "AttackFont", "effect_ui_shuzitanchu_putong.res"); } KSkillDisplay skillDisplay = KConfigFileManager.GetInstance().GetSkillDisplay(wSkillID, Owner.TabID); if (skillDisplay.OnHitAction.CompareTo("JUMP") == 0) { ActionBeAttactedAndThrowUp action = new ActionBeAttactedAndThrowUp(Owner); action.hitAnim = skillDisplay.OnHitAnim; action.time = skillDisplay.OnHitEffecTime; action.height = skillDisplay.OnHitHeight; Owner.ActiveAction = action; //action } else if (Owner.property.heroObjType == KHeroObjectType.hotMonster && Owner.heroSetting.MonsterGrade == KMonsterGrade.mgQuestBoss) { if (Owner.property.activeAction.TryFinish()) { ActiionBeAttack beAttack = new ActiionBeAttack(Owner); Owner.DispatchEvent(ControllerCommand.SetActiveAction, beAttack); } } else { Owner.DispatchEvent(ControllerCommand.BE_HIT); } Vector3 forward = Vector3.forward; if (null != killerHero) { forward = killerHero.transform.position - Owner.transform.position; forward = new Vector3(forward.x, 0, forward.z); forward.Normalize(); } if (skillDisplay.HitShakeTime > 0 && skillDisplay.HitShakeDelta > 0) { Owner.DispatchEvent(ControllerCommand.HIT_SLOW, skillDisplay.HitShakeTime, skillDisplay.HitShakeDelta); } if (null != skillDisplay && skillDisplay.HitEffect.Length > 0 /*&& skillDisplay.BulletEffect.Length == 0*/) { AssetInfo inf = AssetLoader.GetInstance().Load(URLUtil.GetResourceLibPath() + skillDisplay.HitEffect); if (inf.isDone(false)) { if (skillDisplay.SingleHitFx) { GameObject _hit = null; if (hitFxs.TryGetValue(skillDisplay.HitEffect, out _hit)) { GameObject.Destroy(_hit); } } GameObject hitObject = inf.CloneGameObject(); ObjectUtil.SetTagWithAllChildren(hitObject, CameraLayerManager.GetInstance().GetMissionSignName()); hitObject.transform.parent = Owner.transform.parent; hitObject.transform.position = Owner.transform.position; hitObject.transform.forward = forward; if (skillDisplay.SingleHitFx) { hitFxs[skillDisplay.HitEffect] = hitObject; } KingSoftCommonFunction.SetLayer(hitObject, 11); DestoryObject dos = hitObject.AddComponent <DestoryObject>(); dos.delta = 5; if (skillDisplay.HitBindPoint.Length > 0) { if (skillDisplay.HitBindPoint.CompareTo("Ground") != 0) { Transform t = Owner.GetChildTransform(skillDisplay.HitBindPoint); if (null != t) { hitObject.transform.parent = t; hitObject.transform.localPosition = Vector3.zero; hitObject.transform.localScale = Vector3.one; } } } hitObject.SetActive(true); } } }
public virtual void InitParam(AnimActionParam param, KSkillDisplay skillDisplay) { displayInfor = skillDisplay; WeaponPosition = displayInfor.WeaponPosition; skillId = param.skillId; targetId = param.targetId; level = param.level; target = param.target; endPosition = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(param.position)); activeSkill = KConfigFileManager.GetInstance().GetActiveSkill(skillId, level); FirstAttackTime = 0; animArys = displayInfor.Anim.Split('|'); int [] ids = KingSoftCommonFunction.RandomAry(animArys.Length); beginFxs = displayInfor.BeginEffect.Split('|'); beginFxs = KingSoftCommonFunction.GrowArrays(beginFxs, animArys.Length); if (isRandomAnim) { animArys = KingSoftCommonFunction.RandomAryByList(animArys, ids); beginFxs = KingSoftCommonFunction.RandomAryByList(beginFxs, ids); } if (beginFxs[0].Length > 0) { AssetLoader.GetInstance().PreLoad(URLUtil.GetResourceLibPath() + beginFxs[0]); } if (displayInfor.EndEffect.Length > 0) { AssetLoader.GetInstance().PreLoad(URLUtil.GetResourceLibPath() + displayInfor.EndEffect); } if (displayInfor.BulletEffect.Length > 0) { AssetLoader.GetInstance().PreLoad(URLUtil.GetResourceLibPath() + displayInfor.BulletEffect); } try { string [] AttackTimes = activeSkill.AttackTimeList.Split(';'); if (displayInfor.CameraEffect.CompareTo("SHAKE_ALL") == 0) { foreach (string _t in AttackTimes) { try { shakeTimes.Add((float)System.Convert.ToDouble(_t)); } catch (System.Exception e) { } } if (shakeTimes.Count > 0) { FirstAttackTime = (float)shakeTimes[0]; } } else { if (AttackTimes.Length > 0) { try { FirstAttackTime = (float)System.Convert.ToDouble(AttackTimes[0]); } catch (System.Exception e) { } } } if (activeSkill.ClientCache) { KAminEvent _event = KConfigFileManager.GetInstance().GetAnimEvent(hero.property.tabID, animArys[0]); if (null == _event) { FirstAttackTime = hero.AnimCmp.GetAnimLong(animArys[0]) - 0.3f; } else { FirstAttackTime = _event.time; } } } catch (System.Exception e) { } hitTicker.SetCD(FirstAttackTime); finishTicker.SetCD(FirstAttackTime + displayInfor.hitDelay); }