protected override void TriggerSkillTime(ref List <Life> RoleList, ref float fReleaseDelay) { fReleaseDelay = 0.25f; bool IsRelease = false; if (RoleList.Count > 0) { SetAnimator(Build_AnimatorState.Trigger30000); { Life w = RoleList[0]; Vector3 posSrc = m_goPao.transform.position; Vector3 posRole = new Vector3(w.GetPos().x, w.GetPos().y, w.GetPos().z); float fgreed = NdUtil.V2toAngle(posSrc, posRole, Vector3.right); if (fgreed < 0f || fgreed > 270) { fgreed = 0f; } else if (fgreed > 180f) { fgreed = 180f; } m_vDirGreed = new Vector3(0, -fgreed, 0); } m_bAttack = true; m_fAttackTime = Time.time; m_goEffect1912011.SetActive(true); SoundPlay.Play("trap_cannon_sky", false, false); } }
/// <summary> /// 释放技能主逻辑 /// </summary> protected override bool ReleaseSkill(ref List <Life> RoleList, ref int nAttackIndex) { bool IsRelease = false; if (RoleList.Count > 0) { IsRelease = true; { Life w = RoleList[0]; Vector3 posSrc = m_goPao.transform.position; Vector3 posRole = new Vector3(w.GetPos().x, w.GetPos().y, w.GetPos().z); float fgreed = NdUtil.V2toAngle(posSrc, posRole, Vector3.right); if (fgreed < 0f || fgreed > 270) { fgreed = 0f; } else if (fgreed > 180f) { fgreed = 180f; } m_vDirGreed = new Vector3(0, -fgreed, 0); bool InterruptSkill = false; GridActionCmd action = null; if (w is Role) { action = (w as Role).CurrentAction; } SkillReleaseInfo Info = m_Skill.SkillRelease(this, w, action, m_Skill.PropSkillInfo); w.ApplyDamage(Info, m_thisT); } } return(IsRelease); }
/// <summary> /// 获取2个对象之间的夹角 /// </summary> public static float GetAngle(Life Self, Life Target) { Vector3 from = Self.GetCenterPos(); Vector3 to = Target.GetCenterPos(); return(NdUtil.V2toAngle(from, to, Vector3.right)); }
/// <summary> /// 释放技能主逻辑 /// </summary> protected override bool ReleaseSkill(ref List <Life> RoleList, ref int nAttackIndex) { bool IsRelease = false; if (RoleList.Count > 0) { IsRelease = true; SetAnimator(Build_AnimatorState.Trigger30000); //foreach(Life w in RoleList) { Life w = RoleList[0]; Vector3 posSrc = Pao.transform.position; Vector3 posRole = new Vector3(w.GetPos().x, w.GetPos().y, w.GetPos().z); float fgreed = NdUtil.V2toAngle(posSrc, posRole, Vector3.right); m_vDirGreed = new Vector3(fgreed, 90f, 0); bool InterruptSkill = false; GridActionCmd action = null; if (w is Role) { action = (w as Role).CurrentAction; } SkillReleaseInfo Info = m_Skill.SkillRelease(this, w, action, m_Skill.PropSkillInfo); w.ApplyDamage(Info, m_thisT); } m_bAttack = true; m_fAttackTime = Time.time; ActiveEffect1915011(true); } return(IsRelease); }
public override void Update() { base.Update(); if (m_TimeCount < m_fDelay) { m_LifePrent.m_thisT.transform.position = start; return; } if (m_TimeCount < (m_fDelay + 3.02f)) { if ((m_TimeCount - m_Delatime) <= m_fDelay) { SoundPlay.Play("back_ship", false, false); //SkillEffects._instance.LoadEffect("effect/prefab/", "2000201", start, 1.5f, dolphineDir); GameObjectActionExcute gae = EffectM.LoadEffect("effect/prefab/", m_effectName, start, null); if (gae != null) { GameObjectActionEffectInit effectinit = new GameObjectActionEffectInit(); //effectinit.SetEffectMirror(dolphineDir); gae.AddAction(effectinit); GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(1.5f); gae.AddAction(ndEffect); } } Vector3 pos = bezier.GetPointAtTime((m_TimeCount - m_fDelay) / 3.0f); float Angles = NdUtil.V2toAngle(pos, bezier.GetPointAtTime((m_TimeCount - m_fDelay) / 3.0f + 0.01f), Vector3.right) + 180; m_curangle = NdUtil.ClampAngle(Angles + 180, 0, 360f); //Debug.Log(m_curangle); if (m_bRotate) { if (dolphineDir == WalkDir.WALKRIGHT) { m.SetAngle(-Angles); } else { m.SetAngle(Angles); } } PlayAction(AnimatorState.Fly00000, pos, true); //NGUIUtil.DebugLog(m_TimeCount.ToString()); //if (m_TimeCount >= 0.4f && m_TimeCount < 0.4f +Time.deltaTime) //{ // m_Skin.ProPerty.EnableTrail(true); //} } else { //PlayAction(AnimatorState.Fly00000, bezier.GetPointAtTime(1), true); //MoveAction(AnimatorState.Fly00000, Vector3.down * m_LifePrent.m_Attr.Flyspeed * Time.deltaTime, ActionMode.Delta); MoveAction(AnimatorState.Fly00000, Vector3.down * 10 * Time.deltaTime, ActionMode.Delta); } }
float UpdateAimAt(bool bTriggle) { if (m_Skill.PropSkillInfo.m_LifeTarget != null && m_DurationRotate == 0) { Vector3 posSrc = new Vector3(Pao.transform.position.x, Pao.transform.position.y, -2); Vector3 vTargetPos = m_Skill.PropSkillInfo.m_vTargetPos; if (!bTriggle) { if (m_Skill.PropSkillInfo.m_LifeTarget.isDead) { vTargetPos = m_Skill.PropSkillInfo.m_vTargetPos; } else { vTargetPos = m_Skill.PropSkillInfo.m_LifeTarget.GetPos(); } } Vector3 posRole = new Vector3(vTargetPos.x, vTargetPos.y + 0.5f, -2); m_fdistance = Vector3.Distance(posSrc, posRole); float fgreed = NdUtil.V2toAngle(posSrc, posRole, Vector3.right); if (m_vCurGreed.x < 0) { m_vCurGreed.x = 360f + m_vCurGreed.x; } else if (m_vCurGreed.x > 360f) { m_vCurGreed.x = m_vCurGreed.x - 360f; } m_vStartGreed = m_vCurGreed; m_vDirGreed = new Vector3(fgreed, 90f, 0); float fGreeddistance = m_vStartGreed.x - m_vDirGreed.x; fGreeddistance = fGreeddistance > 0 ? fGreeddistance : -fGreeddistance; if (fGreeddistance > 180f) { if (m_vStartGreed.x > m_vDirGreed.x) { m_vDirGreed.x += 360f; } else if (m_vStartGreed.x < m_vDirGreed.x) { m_vDirGreed.x -= 360f; } fGreeddistance = 360f - fGreeddistance; } m_DurationRotate = fGreeddistance / m_fGunRotateSpeed; m_bTriggle = bTriggle; } return(m_DurationRotate); }
/// <summary> /// 收集飞行轨迹 /// </summary> private bool CollectFlyPath(List <Vector3> pos) { if (pos.Count < 2) { return(false); } //收集飞行数据点。 for (int i = 0; i < pos.Count; i++) { if (NdUtil.V3Equal(pos[i], Vector3.zero)) { continue; } FlyDataInfo Info = new FlyDataInfo(); Info.Pos = new Vector3(pos[i].x, pos[i].y, 0); m_lFlyData.Add(Info); } // for (int i = 0; i < m_lFlyData.Count - 1; i++) { float Angel = NdUtil.V2toAngle(m_lFlyData[i].Pos, m_lFlyData[i + 1].Pos, Vector3.right); FlyDataInfo Info = m_lFlyData[i]; Info.FlyDir = new Vector3(0, 0, Angel); float Distance = Vector3.Distance(m_lFlyData[i].Pos, m_lFlyData[i + 1].Pos); Info.FlyTime = Distance / m_fSpeed; m_Duration += Info.FlyTime; m_lFlyData[i] = Info; m_Lastdir = (m_lFlyData[i + 1].Pos - m_lFlyData[i].Pos).normalized; } // FlyDataInfo Info1 = m_lFlyData[m_lFlyData.Count - 1]; Info1.FlyDir = m_lFlyData[m_lFlyData.Count - 2].FlyDir; m_lFlyData[m_lFlyData.Count - 1] = Info1; m_Dir = (m_lFlyData[1].Pos.x - m_lFlyData[0].Pos.x > 0)? WalkDir.WALKRIGHT : WalkDir.WALKLEFT; return(true); }
// Update is called once per frame void Update() { if (m_bpause) { return; } m_TimeCount += Time.deltaTime; if (m_type == BulletType.Missile) { Missile m = GetComponent <Missile>(); Vector3 pos = transform.localPosition; if (m_TimeCount < m_outtime) { pos = Vector3.Lerp(m_Start, m_fadeoutpos, m_TimeCount / m_outtime); transform.localPosition = pos; float Angles = NdUtil.V2toAngle(m_Start, m_fadeoutpos, Vector3.right); m.SetAngle(-Angles); } else if (m_TimeCount >= m_Duration) { //effect = SkillEffects._instance.LoadEffect("effect/prefab/", "1002061",transform.position,1.5f); GameObjectActionExcute gae = EffectM.LoadEffect(EffectM.sPath, "1002061", transform.position, BattleEnvironmentM.GetLifeMBornNode(true)); GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(1.5f); gae.AddAction(ndEffect); effect = gae.gameObject; SoundPlay.Stop("missile_launch", false); SoundPlay.Play("missile_explosion", false, false); m_fun(m_skillinfo, 1); GameObject.Destroy(gameObject); } else { pos = myBezier.GetPointAtTime((m_TimeCount - m_outtime) / (m_Duration - m_outtime)); float Angles = NdUtil.V2toAngle(pos, myBezier.GetPointAtTime((m_TimeCount - m_outtime) / (m_Duration - m_outtime) + 0.01f), Vector3.right); m.SetAngle(-Angles); transform.localPosition = pos; } } else { if (m_TimeCount < m_Duration) { Vector3 pos = transform.localPosition; //pos.x = Mathf.Lerp(m_Start.x,m_Destination.x,m_TimeCount/ m_Duration); pos = myBezier.GetPointAtTime(m_TimeCount / m_Duration); transform.localPosition = pos; } else if (m_TimeCount >= m_Duration) { if (m_skillinfo.m_type == 1005) { if (m_TimeCount <= m_Duration + 0.5f) { Vector3 pos = transform.localPosition; pos = myBezier1.GetPointAtTime((m_TimeCount - m_Duration) / 0.5f); transform.localPosition = pos; } else if (m_TimeCount < m_Duration + 1f) { Vector3 pos = transform.localPosition; pos = myBezier2.GetPointAtTime((m_TimeCount - m_Duration - 0.5f) / 0.5f); transform.localPosition = pos; } } if (m_TimeCount >= m_Duration + m_skillinfo.m_intone_speed * 0.001f) { //Debug.Log(m_type +"," + transform.position); transform.localPosition = m_Destination; if (m_skillinfo.m_type != 1028) { m_fun(m_skillinfo, 1); } //SkillEffects._instance.LoadEffect("effect/prefab/", m_info.m_hiteffect.ToString(),transform.position,1.5f); if (m_info.m_hiteffect != 0) { Vector3 pos = transform.position; pos.z = -1.5f; GameObjectActionExcute gae = EffectM.LoadEffect(EffectM.sPath, m_info.m_hiteffect.ToString(), pos, BattleEnvironmentM.GetLifeMBornNode(true)); GameObjectActionEffectInit init = new GameObjectActionEffectInit(); init.SetEffectMirror(m_dir); gae.AddAction(init); GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(1.5f); gae.AddAction(ndEffect); } if (m_info.m_hitaudio != "") { SoundPlay.Play(m_info.m_hitaudio, false, false); } GameObject.Destroy(gameObject); } } } /*else if (m_type == BulletType.Bullet ) * { * Vector3 pos = transform.localPosition; * pos.x = Mathf.Lerp(m_Start.x,m_Destination.x,m_TimeCount/ m_Duration); * transform.localPosition = pos; * if (m_TimeCount>= m_Duration) * { * m_fun(m_skillinfo,1); * GameObject.Destroy(gameObject); * } * } * else if (m_type == BulletType.Grenade) * { * Vector3 pos = transform.localPosition; * //pos.x = Mathf.Lerp(m_Start.x,m_Destination.x,m_TimeCount/ m_Duration); * pos = myBezier.GetPointAtTime(m_TimeCount/m_Duration); * transform.localPosition = pos; * if (m_TimeCount>= m_Duration) * { * //Debug.Log(m_type +"," + transform.position); * transform.localPosition = m_Destination; * m_fun(m_skillinfo,1); * SkillEffects._instance.LoadEffect("effect/prefab/", "1002081",transform.position,1.5f); * SoundPlay.Play("grenade_explosion",false ,false); * GameObject.Destroy(gameObject); * } * } * else if (m_type == BulletType.Snowball) * { * Vector3 pos = transform.localPosition; * pos = myBezier.GetPointAtTime(m_TimeCount/m_Duration); * transform.localPosition = pos; * if (m_TimeCount>= m_Duration) * { * //Debug.Log(m_type +"," +transform.position); * transform.localPosition = m_Destination; * m_fun(m_skillinfo,1); * SkillEffects._instance.LoadEffect("effect/prefab/", "1002101",transform.position,1.5f); * GameObject.Destroy(gameObject); * } * } * else if (m_type == BulletType.Poison) * { * Vector3 pos = transform.localPosition; * pos = myBezier.GetPointAtTime(m_TimeCount/m_Duration); * transform.localPosition = pos; * //Debug.Log(m_Start + ", " + m_Destination + ", " + pos + ", " + m_TimeCount + "," + m_Duration); * if (m_TimeCount>= m_Duration) * { * //Debug.Log(m_type +"," +transform.position); * transform.localPosition = m_Destination; * m_fun(m_skillinfo,1); * SkillEffects._instance.LoadEffect("effect/prefab/", "1052031",transform.position,1f); * GameObject.Destroy(gameObject); * SoundPlay.Play("skill_money_dy",false ,false); * } * } * else if (m_type == BulletType.ling) * { * Vector3 pos = transform.localPosition; * pos = myBezier.GetPointAtTime(m_TimeCount/m_Duration); * transform.localPosition = pos; * //Debug.Log(m_Start + ", " + m_Destination + ", " + pos + ", " + m_TimeCount + "," + m_Duration); * if (m_TimeCount>= m_Duration) * { * //Debug.Log(m_type +"," +transform.position); * transform.localPosition = m_Destination; * m_fun(m_skillinfo,1); * //SkillEffects._instance.LoadEffect("effect/prefab/", "1052031",transform.position,1f); * GameObject.Destroy(gameObject); * } * } * else if (m_type == BulletType.bomb1028) * { * Vector3 pos = transform.localPosition; * pos.x = Mathf.Lerp(m_Start.x, m_Destination.x, m_TimeCount / m_Duration); * transform.localPosition = pos; * if (m_TimeCount >= m_Duration) * { * //m_fun(m_skillinfo, 1); * SkillEffects._instance.LoadEffect("effect/prefab/", "1003031", transform.position, 1.3f); * GameObject.Destroy(gameObject); * } * }*/ }
/// <summary> /// 释放技能主逻辑 /// </summary> protected override bool ReleaseSkill(ref List <Life> RoleList, ref int nAttackIndex) { bool IsRelease = false; m_AttackRoleList.Clear(); m_SkillReleaseInfoList.Clear(); if (RoleList.Count > 0) { if (nAttackIndex == 0) { IsRelease = true; m_fAttackTimer = Time.time; Vector3 posSrc = m_goEffectLeft1905021_03.transform.position; Vector3 posRole = new Vector3(RoleList[0].GetPos().x, RoleList[0].GetPos().y + 1.5f, RoleList[0].GetPos().z); float fRate = Vector2.Distance(posSrc, posRole) / 3.8f; m_goEffectLeft1905021_03.transform.localScale = new Vector3(fRate, 1.0f, 1.0f); float fAngle = NdUtil.V2toAngle(posSrc, posRole, Vector2.right); m_goEffectLeft1905021_03.transform.rotation = Quaternion.Euler(new Vector3(0, 180f, fAngle)); posSrc = m_goEffectRight1905021_03.transform.position; fRate = Vector2.Distance(posSrc, posRole) / 3.8f; m_goEffectRight1905021_03.transform.localScale = new Vector3(fRate, 1.0f, 1.0f); fAngle = NdUtil.V2toAngle(posSrc, posRole, Vector2.right); m_goEffectRight1905021_03.transform.rotation = Quaternion.Euler(new Vector3(0, 180f, fAngle)); foreach (Life w in RoleList) { IsRelease = true; GridActionCmd action = null; if (w is Role) { action = (w as Role).CurrentAction; } SkillReleaseInfo Info = m_Skill.SkillRelease(this, w, action, m_Skill.PropSkillInfo); m_SkillReleaseInfoList.Add(Info); m_AttackRoleList.Add(w); } m_bAttack = true; } int nRoleCount = m_AttackRoleList.Count; for (int nCnt = 0; nCnt < nRoleCount; nCnt++) { Life w = m_AttackRoleList[nCnt]; if (!w.InBoat || w.isDead) { continue; } SkillReleaseInfo info = m_SkillReleaseInfoList[nCnt]; BuildSkill rs = m_Skill as BuildSkill; float power = rs.PropSkillInfo.GetAttackPower(nAttackIndex + 1); info.m_Damage = (int)(info.m_Damage * power); info.mOwnerLevel = m_Attr.Level; w.ApplyDamage(info, m_thisT); } if (nRoleCount > 0) { SoundPlay.Play("Trap/trap_electricshock", false, false); } } return(IsRelease); }