/// <summary> /// 根据移动方向获取最远格子 /// </summary> private MapGrid GetFastestGrid(int layer, WalkDir walkDir) { MapGrid result = null; MapGrid minGrid = null; MapGrid maxGrid = null; Int2 posStart = new Int2(MapSize.GetGridStart(layer), layer); minGrid = MapGrid.GetMG(posStart); Int2 posEnd = new Int2(MapSize.GetLayerMaxGrid(layer), layer); maxGrid = MapGrid.GetMG(posEnd); if (walkDir == WalkDir.WALKLEFT) { result = minGrid; } else { result = maxGrid; } return(result); }
public override void ActiiveStart() { Life w = m_LifePrent.m_Skill.m_SkillTarget; if (w is Role) { //Transform EffectPos = (w as Role).m_Skin.ProPerty.m_EffectPos; GameObject posgo = (w as Role).m_Skin.ProPerty.HelpPoint.GetVauleByKey(HelpPointName.EffectPos); if (posgo != null) { Vector3 pos = posgo.transform.position; pos.z = -1.5f; //SkillEffects._instance.LoadEffect("effect/prefab/", "1002051",pos,1f); GameObjectActionExcute gae1 = EffectM.LoadEffect(EffectM.sPath, "1002051", pos, BattleEnvironmentM.GetLifeMBornNode(true)); GameObjectActionDelayDestory ndEffect1 = new GameObjectActionDelayDestory(1f); gae1.AddAction(ndEffect1); } } SoundPlay.Play("skill_voice_yidao", false, false); SoundPlay.Play("skill_yidao_sstx", false, false); Life emeny = CM.GetAllLifeM(m_AttackSceneID, LifeMType.ALL); GameObjectActionExcute gae = EffectM.LoadEffect(EffectM.sPath, "1051041", BattleEnvironmentM.Local2WorldPos(m_TargetPos), BattleEnvironmentM.GetLifeMBornNode(true)); GameObjectActionDelayDestory ndEffect = new GameObjectActionDelayDestory(m_action3); gae.AddAction(ndEffect); GameObject go = gae.gameObject; go.transform.parent = m_Skin.tRoot; go.transform.localPosition = Vector3.zero; //m_LifePrent.InBoat =false; MapGrid gfrom = m_LifePrent.GetMapGrid(); m_TelePortGrid = gfrom; MapGrid gstart = gfrom; //m_Dir = WalkDir.WALKRIGHT; MapGrid gto = emeny.GetTargetMapGrid(); int startunit = MapSize.GetGridStart(gto.GridPos.Layer); int endtunit = startunit + MapSize.GetLayerSize(gto.GridPos.Layer) - 1; //if (gto.GridPos.Layer > 0) MapGrid start = MapGrid.GetMG(gto.GridPos.Layer, startunit); MapGrid end = MapGrid.GetMG(gto.GridPos.Layer, endtunit); MapGrid gl = gto.GetNextAttackStation(DIR.LEFT, false); MapGrid gr = gto.GetNextAttackStation(DIR.RIGHT, false); if (gl == null && gr == null) { Debug.LogError("xxxxxxxxxxxxxxxxXXXXXXXXXXXXXX " + gto.GridPos); } if (emeny is Role) { m_TargetPos = emeny.m_thisT.localPosition; } else { m_TargetPos = gto.pos; } if (gfrom.GridPos.Unit < startunit) { gstart = start; } else if (gfrom.GridPos.Unit > endtunit) { gstart = end; } if (gto.GridPos.Layer > 0) { int upstartunit = MapSize.GetGridStart(gto.GridPos.Layer - 1); int upendtunit = upstartunit + MapSize.GetLayerSize(gto.GridPos.Layer - 1) - 1; MapGrid upstart = MapGrid.GetMG(gto.GridPos.Layer - 1, upstartunit); MapGrid upend = MapGrid.GetMG(gto.GridPos.Layer - 1, upendtunit); if (gfrom.GridPos.Unit < upstartunit) { gstart = upstart; } else if (gfrom.GridPos.Unit > upendtunit) { gstart = upend; } } m_gs = (m_LifePrent as Role).CurrentGS; if (m_gs == GridSpace.Space_UP) { m_LifePrent.m_thisT.localScale = new Vector3(m_LifePrent.m_thisT.localScale.x, -m_LifePrent.m_thisT.localScale.y, m_LifePrent.m_thisT.localScale.z); } if (gr != null && gstart.GridPos.Unit > gr.GridPos.Unit) { m_Dir = WalkDir.WALKLEFT; m_PreTelePortGrid = gr; if (gl != null) { /*MapGrid temp = gl.GetNextAttackStation(DIR.LEFT,false); * if ( temp!= null) * gl = temp;*/ //w.Teleport(gl); m_TelePortGrid = gl; m_End = gl.pos; //m_Dir = WalkDir.WALKLEFT; } else { m_TelePortGrid = gr; //w.Teleport(gr); m_End = gr.pos; } MapGrid oldgrid = null; if (gstart.GridPos.Unit - gr.GridPos.Unit <= 3) { oldgrid = MapGrid.GetMG(gr.GridPos.Layer, gstart.GridPos.Unit); if (m_gs == GridSpace.Space_DOWN) { lpos.Add(gfrom.pos); Vector3 upos = gr.Uppos; upos.x += (oldgrid.Uppos.x - gr.Uppos.x) / 2; lpos.Add(upos); lpos.Add(gr.pos); } else { lpos.Add(gfrom.Uppos); lpos.Add(gr.pos); } } else { oldgrid = MapGrid.GetMG(gr.GridPos.Layer, gstart.GridPos.Unit); if (m_gs == GridSpace.Space_DOWN) { lpos.Add(gfrom.pos); Vector3 upos = gr.Uppos; upos.x += (oldgrid.Uppos.x - gr.Uppos.x) * 3 / 4; lpos.Add(upos); lpos.Add(gr.pos + new Vector3((oldgrid.pos.x - gr.pos.x) / 2, 0, 0)); lpos.Add(gr.Uppos + new Vector3((oldgrid.Uppos.x - gr.Uppos.x) / 4, 0, 0)); lpos.Add(gr.pos); } else { lpos.Add(gfrom.Uppos); lpos.Add(gr.pos); } } } else if (gl != null && gstart.GridPos.Unit < gl.GridPos.Unit) { m_Dir = WalkDir.WALKRIGHT; m_PreTelePortGrid = gl; if (gr != null) { /*MapGrid temp = gr.GetNextAttackStation(DIR.RIGHT,false); * if ( temp!= null) * gr = temp;*/ //w.Teleport(gr); m_TelePortGrid = gr; m_End = gr.pos; } else { //w.Teleport(gl); m_TelePortGrid = gl; m_End = gl.pos; } MapGrid oldgrid = null; if (gl.GridPos.Unit - gstart.GridPos.Unit <= 3) { oldgrid = MapGrid.GetMG(gl.GridPos.Layer, gstart.GridPos.Unit); if (m_gs == GridSpace.Space_DOWN) { lpos.Add(gfrom.pos); Vector3 upos = gl.Uppos; upos.x += (oldgrid.Uppos.x - gl.Uppos.x) / 2; lpos.Add(upos); lpos.Add(gl.pos); } else { lpos.Add(gfrom.Uppos); lpos.Add(gl.pos); } } else { oldgrid = MapGrid.GetMG(gl.GridPos.Layer, gstart.GridPos.Unit); if (m_gs == GridSpace.Space_DOWN) { lpos.Add(gfrom.pos); Vector3 upos = oldgrid.Uppos; upos.x += (gl.Uppos.x - oldgrid.Uppos.x) / 4; lpos.Add(upos); lpos.Add(oldgrid.pos + new Vector3((gl.pos.x - oldgrid.pos.x) / 2, 0, 0)); lpos.Add(oldgrid.Uppos + new Vector3((gl.Uppos.x - oldgrid.pos.x) * 3 / 4, 0, 0)); lpos.Add(gl.pos); } else { lpos.Add(gfrom.Uppos); lpos.Add(gl.pos); } } } else { if (gl != null && gfrom.GridPos.Unit < gto.GridPos.Unit) { m_Dir = WalkDir.WALKRIGHT; m_Start = gl.pos; m_End = gl.pos; m_PreTelePortGrid = gl; if (gr != null) { lpos.Add(gfrom.pos); Vector3 upos = gl.Uppos; upos.x += (gr.Uppos.x - gl.Uppos.x) / 2; lpos.Add(upos); lpos.Add(gr.pos); lpos.Add(upos); lpos.Add(gl.pos); //w.Teleport(gr); m_TelePortGrid = gr; m_End = gr.pos; } else { m_TelePortGrid = gl; lpos.Add(gfrom.pos); Vector3 upos = gl.Uppos; lpos.Add(upos); lpos.Add(gl.pos); lpos.Add(upos); lpos.Add(gl.pos); } } else if (gr != null && gfrom.GridPos.Unit > gto.GridPos.Unit) { m_PreTelePortGrid = gr; m_Dir = WalkDir.WALKLEFT; m_Start = gr.pos; m_End = gr.pos; if (gl != null) { lpos.Add(gfrom.pos); Vector3 upos = gl.Uppos; upos.x += (gr.Uppos.x - gl.Uppos.x) / 2; lpos.Add(upos); lpos.Add(gl.pos); lpos.Add(upos); lpos.Add(gr.pos); //w.Teleport(gl); m_TelePortGrid = gl; m_End = gl.pos; } else { m_TelePortGrid = gr; lpos.Add(gfrom.pos); Vector3 upos = gr.Uppos; lpos.Add(upos); lpos.Add(gr.pos); lpos.Add(upos); lpos.Add(gr.pos); } } else { m_PreTelePortGrid = gto; m_Start = gto.pos; m_End = gto.pos; //Debug.Log("左右都没有攻击位" + gl.GridPos + "," + gr.GridPos + "," +gfrom.GridPos + "," + gto.GridPos.Unit); } } //PlayAction(AnimatorState.Skill01,m_Start,true); #if UNITY_EDITOR_LOG string str = "lujin:"; for (int i = 0; i < lpos.Count; i++) { str += lpos[i] + ", "; } //Debug.Log(str + ", mend " +m_End); #endif if (lpos.Count > 0) { m_Start = lpos[lpos.Count - 1]; m_oncejumptime = m_JumpTime / (lpos.Count - 1); m_AniSpeed = 0.8f / m_oncejumptime; m_gs = (m_LifePrent as Role).CurrentGS; m_JumpCount = 0; } #if UNITY_EDITOR_LOG FileLog.write(m_LifePrent.SceneID, "能量燃烧 " + m_Start + "," + m_End + "," + m_TelePortGrid.GridPos + "," + m_Dir + "," + gfrom.GridPos + "," + gto.GridPos); #endif }