public static void AddStair(MapStair stair) { if (m_Stair == null) { m_Stair = new List <MapStair>(); } m_Stair.Add(stair); }
public static void ClearMap() { m_RoleStation.Clear(); m_lUpRoleStation.Clear(); m_lGrid.Clear(); m_lStair.Clear(); MapSize.ClearMapSize(); MapGrid.ClearMapGrid(); MapStair.ClearStair(); }
public void SetMapGrid(int cx, int cy) { m_MapPos = new Int2(cx, cy); MapStair stair = MapStair.GetStair(m_MapPos, false); if (stair != null) { stair.JoinStairLife(this); } }
public static void CreateStair(StairInfo Stair) { MapGrid UpStair = GetMG(Stair.Up); MapGrid DownStair = GetMG(Stair.Down); if (UpStair != null && DownStair != null) { MapStair stair = new MapStair(); stair.Init(); stair.SetStair(Stair.Up, Stair.Down); if (UpStair.Type == GridType.GRID_HOLE) { UpStair.Type = GridType.GRID_HOLESTAIR; } else { UpStair.Type = GridType.GRID_STAIR; } if (DownStair.Type == GridType.GRID_HOLE) { DownStair.Type = GridType.GRID_HOLESTAIR; } else { DownStair.Type = GridType.GRID_STAIR; } UpStair.Down = DownStair; DownStair.Up = UpStair; MapStair.AddStair(stair); SetNNearestUpPort(DownStair, UpStair); SetNNearestDownPort(UpStair, DownStair, false); //这个需要调整。 //MapGrid m = GetMG(Stair.Down.Layer,Stair.Up.Unit); //if(m != null) //{ // DownStair.UpHaveHole = true; //} //foreach(Int2 HolePos in Stair.m_NearHole ) //{ // CreateHole(HolePos); //} } }
//取下一个动作 public GridActionCmd GetNextAction() { Vector3 pos = RoleParent.m_thisT.localPosition; float cdtime = RoleParent.CDTime; //int bodyradius = RoleParent.m_Attr.Radius; RoleSkill roleskill = RoleParent.m_Skill as RoleSkill; GridActionCmd action = null; m_IndexAdd = false; if (RoleParent.isDead) { action = new GridActionCmdDie(pos, 3 * 60 * 60f, WalkDIR, RankDeep); action.SetTarget(RoleParent); m_Reject = false; return(action); } if (RoleParent == null || RoleParent.m_Attr == null) { action = new GridActionCmdStand(); action.SetData(pos, pos, RoleState.STAND, Time.deltaTime, -1, WalkDIR, RankDeep); action.SetTarget(RoleParent); return(action); } if (m_bForce == 0) { action = new GridActionCmdSpecialJump(0.5f, MapGrid.GetMG(MapPos).pos, MapGrid.GetMG(m_ForceGrid).pos, m_ForceDir, RankDeep); action.SetTarget(RoleParent); m_bForce = -1; SetUpdataPath(new AIEventData(AIEvent.EVENT_MAP)); m_NGrid = m_ForceGrid; if (MapGrid.GetMG(MapPos).PropStations == StationsProp.ATTACK) { m_AttackStation = MapPos; m_NAttackStation = MapPos; } MapPos = m_NGrid; WalkDIR = m_ForceDir; m_Reject = true; m_DoUpatePath = false; return(action); } if (m_bForce > 0) { m_bForce--; } m_PreGrid = MapPos; m_PreAttackStation = m_AttackStation; MapGrid attackstation = MapGrid.GetMG(m_AttackStation); PathData CurRoad = Path.GetPathData(PathAccess.Cur); if (m_Attack && RoleParent.m_Skill.CanAttack() && CheckAttackPos() // && (!(RoleParent.m_Skill.m_AttackTarget is Role) || RoleParent.m_Skill.CheckCanAttack((RoleParent.m_Skill.m_AttackTarget as Role).CurrentAction)) && (RoleParent.m_Skill.m_AttackTarget is IggWall || RoleParent.m_Skill.m_AttackTarget is IggFloor || (NdUtil.IsSameMapPos(MapPos, m_AttackStation) && attackstation.IsAttackStations()) &&//&& attackstation.GetRoleStateInStation(m_SceneID) == RoleStationState.HoldStation) !(CurRoad != null && (CurRoad.state == RoleState.FALL || CurRoad.state == RoleState.JUMP)))) { if (cdtime > 0) { if (cdtime > 0.5 && RoleParent.m_Hit) { action = new GridActionCmdHit(0.5f, pos, RankDeep, WalkDIR); action.SetTarget(RoleParent); RoleParent.m_Hit = false; } else { action = new GridActionCmdCDStand(cdtime, pos, RankDeep, WalkDIR); action.SetTarget(RoleParent); action.SetSpeed(RoleParent.m_Attr.SpeedPercent); } } m_Reject = true; m_DoUpatePath = false; if (action != null) { return(action); } } else if (m_Attack) { } if (!m_Reject && RoleParent.m_Attr.CanMove && m_Pass) { PathData NextRoad = Path.GetPathData(PathAccess.Next); if (NextRoad != null && CurRoad != null) { if (MapGrid.GetMG(MapPos).PropStations == StationsProp.ATTACK) { m_AttackStation = m_NAttackStation; //获取下一个攻击位,不包含当前节点 ErrorInfo Error = new ErrorInfo(); PathData AttackStation = Path.GetNextAttackPosNoCurInPath(ref Error); if (AttackStation != null) { m_AttackStation = AttackStation.Road.GridPos; m_NAttackStation = m_AttackStation; } } RoleState roleState = CurRoad.state; Vector3 vStart = pos;//CurRoad.Road.pos; Vector3 vEnd = Vector3.zero; CurrentGS = CurRoad.gs; vEnd = NextRoad.Road.pos; if (roleState == RoleState.FALL) { vStart = pos; if (Path.CheckRunFirstRoad() == true) { action = new GridActionCmdFall(vStart, vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else { Vector3 mid = Vector3.zero; if (CurRoad.dir == WalkDir.WALKLEFT) { if (CurRoad.Road.Left.Down != null) { NextRoad.Road = CurRoad.Road.Left.Down;//MapGrid.GetMG() mid = CurRoad.Road.Left.pos; } } else { if (CurRoad.Road.Right.Down != null) { NextRoad.Road = CurRoad.Road.Right.Down; mid = CurRoad.Road.Right.pos; } } while (NextRoad.Road.Down != null) { NextRoad.Road = NextRoad.Road.Down; } vEnd = NextRoad.Road.pos; action = new GridActionCmdJumpHoleDown(vStart, mid, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } } else if (roleState == RoleState.JUMP) { action = new GridActionCmdJump(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep, 0.2f, 0.2f, 0f, null, null, null); } else if (roleState == RoleState.STAIR) { MapStair s1 = MapStair.GetStair(CurRoad.Road.GridPos, CurRoad.Road.GridPos.Layer > NextRoad.Road.GridPos.Layer); Vector3 inpos = Vector3.zero; Vector3 outpos = Vector3.zero; if (s1 != null) { if (CurRoad.Road.GridPos.Layer > NextRoad.Road.GridPos.Layer) { inpos = MapGrid.GetMG(s1.GetStairUp()).pos; outpos = MapGrid.GetMG(s1.GetStairDown()).pos; outpos.y -= 0.5f; } else { outpos = MapGrid.GetMG(s1.GetStairUp()).pos; inpos = MapGrid.GetMG(s1.GetStairDown()).pos; inpos.y -= 0.5f; } Building1201 b = s1.GetStairLife(); b.ShowUpEffect(CurRoad.deltaTime); } else { Debug.Log("找不到楼梯"); } WalkDIR = (CurRoad.Road.GridPos.Unit < NextRoad.Road.GridPos.Unit) ? WalkDir.WALKRIGHT : WalkDir.WALKLEFT; action = new GridActionCmdStair(vStart, vEnd, 0.5f /*CurRoad.deltaTime*/, WalkDIR, RankDeep, 0.2f, 0.2f, inpos, outpos); } else if (roleState == RoleState.WALK) { float time = 1f / RoleParent.m_Attr.Speed; if (CurRoad.gs == GridSpace.Space_UP) { vStart = CurRoad.Road.Uppos; vEnd = NextRoad.Road.Uppos; action = new GridActionCmdUnderWalk(vStart, vEnd, time, CurRoad.dir, RankDeep); } else { action = new GridActionCmdWalk(vStart, vEnd, time, CurRoad.dir, RankDeep); } } else if (roleState == RoleState.FALLDOWN) { action = new GridActionCmdFallDown(Time.deltaTime, RankDeep, vStart); m_Reject = true; m_DoUpatePath = false; AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_SELFSP), RoleParent); action.SetTarget(RoleParent); return(action); } else if (roleState == RoleState.JUMPDOWN) { vStart = CurRoad.Road.Uppos; action = new GridActionCmdJumpDown(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else if (roleState == RoleState.JUMPUP) { vEnd = NextRoad.Road.Uppos; action = new GridActionCmdJumpUp(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else if (roleState == RoleState.REVERSEJUMP) { vStart = CurRoad.Road.Uppos; vEnd = NextRoad.Road.Uppos; action = new GridActionCmdReverseJump(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep, 0.2f, 0.2f, 0f, null, null, null); } else if (roleState == RoleState.HITFLY) { } if (action != null) { MapPos = NextRoad.Road.GridPos; m_NGrid = MapPos; WalkDIR = CurRoad.dir; action.SetTarget(RoleParent); action.SetSpeed(RoleParent.m_Attr.SpeedPercent); } //运行到下一个路径节点 Path.RunNextPath(); m_IndexAdd = true; } else if (CurrentGS == GridSpace.Space_UP) { action = new GridActionCmdJumpDown(MapGrid.GetMG(MapPos).Uppos, MapGrid.GetMG(MapPos).pos, 1f, m_AttackDir, RankDeep); action.SetTarget(RoleParent); CurrentGS = GridSpace.Space_DOWN; } else { //if (!( NdUtil.IsSameMapPos(MapPos,m_AttackStation) && attackstation.GetRoleStateInStation(m_SceneID) == RoleStationState.HoldStation)) AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_SELFSP), RoleParent); } } if (action == null) { action = new GridActionCmdStand(); action.SetData(pos, pos, RoleState.STAND, Time.deltaTime, -1, WalkDIR, RankDeep); action.SetTarget(RoleParent); } m_Reject = true; m_DoUpatePath = false; return(action); }
//格子注册,用来预测用 public void RegisterNextAction(bool IsMove = true) { //如果需要强制跳跃,就不做预测 if (m_bForce > -1 || !m_Reject) { return; } RoleState CurState = RoleState.WALK; PathData PrevRoad = Path.GetPathData(PathAccess.Prev); PathData CurRoad = Path.GetPathData(PathAccess.Cur); PathData NextRoad = Path.GetPathData(PathAccess.Next); if (PrevRoad != null) { CurState = PrevRoad.state; } m_DoUpatePath = true; if (CurState == RoleState.STAIR || CurState == RoleState.JUMP || CurState == RoleState.FALL) { if (CurState == RoleState.JUMP && CurRoad.state == RoleState.FALL) { m_Reject = false; return; } AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_SELFSP), RoleParent); } //获取下一个Action if (CurRoad == null) { return; } if (CurRoad.state != RoleState.FALLDOWN && IsMove && NextRoad != null) { m_NGrid = NextRoad.Road.GridPos; WalkDIR = CurRoad.dir; } #if UNITY_EDITOR_LOG FileLog.write(m_SceneID, "DORegisterNextAction" + Path.Indext + "," + m_ForceGrid + "," + m_NGrid + "," + MapPos + "," + m_AttackStation + "," + m_NAttackStation + "," + m_Attack + "," + RoleParent.m_Skill.CanAttack() + "," + Time.realtimeSinceStartup); #endif MapStations cur = CurRoad.Road; MapStations next = CurRoad.Road; if (NextRoad != null) { next = NextRoad.Road; } RoleState NextState = CurRoad.state; // if (MapPos != PreGrid) { (m_parent as Role).m_ajustcount += (m_parent as Role).m_ajustduration; } if (MapPos == m_AttackStation) { cur = MapGrid.GetMG(m_AttackStation) as MapStations; DIR dir = WalkDIR == WalkDir.WALKLEFT ? DIR.LEFT : DIR.RIGHT; MapCheckStations.RoleStation(m_SceneID, cur, new StationsInfo(RoleParent.m_Attr as RoleAttribute, RankDeep, RoleParent.m_Core.m_Camp, dir, GridSpace.Space_DOWN)); bool isEnd = true; ErrorInfo Error = new ErrorInfo(); PathData AttackStation = Path.GetNextAttackPosNoCurInPath(ref Error); if (AttackStation != null) { isEnd = false; } else if (Error.Err == ErrReason.NoAttackPos) { isEnd = true; } else if (Error.Err == ErrReason.RePathPoint) { isEnd = false; if (Error.state == RoleState.STAIR) { if (m_Pass) { bool IsUP = (Error.dir == DIR.DOWN) ? true : false; next = MapStair.GetStair(Error.GridPos, IsUP); #if UNITY_EDITOR_LOG if (next == null) { Debug.LogError("楼梯为空" + Error.GridPos + "," + Error.dir); } FileLog.write(m_SceneID, "DORegisterNextActionSTAIRin" + Path.Indext + "," + MapPos + "," + m_NGrid + "," + RankDeep + "," + next.GetStationsPos() + "," + cur.GetStationsPos() + "," + Time.realtimeSinceStartup); #endif MapCheckStations.RoleStation(m_SceneID, next, new StationsInfo(RoleParent.m_Attr as RoleAttribute, RankDeep, RoleParent.m_Core.m_Camp, Error.dir, GridSpace.Space_DOWN)); } } } if (isEnd) { ClearPath(); } } else { DIR dir = WalkDIR == WalkDir.WALKLEFT ? DIR.LEFT : DIR.RIGHT; MapCheckStations.RoleStation(m_SceneID, cur, new StationsInfo(RoleParent.m_Attr as RoleAttribute, RankDeep, RoleParent.m_Core.m_Camp, dir, GridSpace.Space_DOWN)); } m_Reject = false; }
//取下一个动作 public GridActionCmd GetNextAction() { Vector3 pos = PetParent.m_thisT.localPosition; GridActionCmd action = null; if (Path.CheckRunFinishRoad()) { return(null); } if (PetParent == null || PetParent.m_Attr == null) { action = new GridActionCmdStand(); action.SetData(pos, pos, RoleState.STAND, Time.deltaTime, -1, WalkDIR, RankDeep); action.SetTarget(PetParent); return(action); } m_PreGrid = MapPos; m_PreAttackStation = m_AttackStation; MapGrid attackstation = MapGrid.GetMG(m_AttackStation); PathData CurRoad = Path.GetPathData(PathAccess.Cur); if (PetParent.m_Attr.CanMove) { PathData NextRoad = Path.GetPathData(PathAccess.Next); if (NextRoad != null && CurRoad != null) { if (MapGrid.GetMG(MapPos).PropStations == StationsProp.ATTACK) { m_AttackStation = m_NAttackStation; //获取下一个攻击位,不包含当前节点 ErrorInfo Error = new ErrorInfo(); PathData AttackStation = Path.GetNextAttackPosNoCurInPath(ref Error); if (AttackStation != null) { m_AttackStation = AttackStation.Road.GridPos; } } RoleState roleState = CurRoad.state; Vector3 vStart = CurRoad.Road.pos; Vector3 vEnd = Vector3.zero; CurrentGS = CurRoad.gs; vEnd = NextRoad.Road.pos; if (roleState == RoleState.FALL) { vStart = pos; if (Path.CheckRunFirstRoad() == true) { action = new GridActionCmdFall(vStart, vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else { Vector3 mid = Vector3.zero; if (CurRoad.dir == WalkDir.WALKLEFT) { if (CurRoad.Road.Left.Down != null) { NextRoad.Road = CurRoad.Road.Left.Down; //MapGrid.GetMG() mid = CurRoad.Road.Left.pos; } } else { if (CurRoad.Road.Right.Down != null) { NextRoad.Road = CurRoad.Road.Right.Down; mid = CurRoad.Road.Right.pos; } } while (NextRoad.Road.Down != null) { NextRoad.Road = NextRoad.Road.Down; } vEnd = NextRoad.Road.pos; action = new GridActionCmdJumpHoleDown(vStart, mid, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } } else if (roleState == RoleState.JUMP) { action = new GridActionCmdJump(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep, 0.2f, 0.2f, 0f, null, null, null); } else if (roleState == RoleState.STAIR) { MapStair s1 = MapStair.GetStair(CurRoad.Road.GridPos, CurRoad.Road.GridPos.Layer > NextRoad.Road.GridPos.Layer); Vector3 inpos = Vector3.zero; Vector3 outpos = Vector3.zero; if (s1 != null) { if (CurRoad.Road.GridPos.Layer > NextRoad.Road.GridPos.Layer) { inpos = MapGrid.GetMG(s1.GetStairUp()).pos; outpos = MapGrid.GetMG(s1.GetStairDown()).pos; outpos.y -= 0.5f; } else { outpos = MapGrid.GetMG(s1.GetStairUp()).pos; inpos = MapGrid.GetMG(s1.GetStairDown()).pos; inpos.y -= 0.5f; } } else { Debug.Log("找不到楼梯"); } WalkDIR = (CurRoad.Road.GridPos.Unit < NextRoad.Road.GridPos.Unit)? WalkDir.WALKRIGHT:WalkDir.WALKLEFT; action = new GridActionCmdStair(vStart, vEnd, CurRoad.deltaTime, WalkDIR, RankDeep, 0.2f, 0.2f, inpos, outpos); } else if (roleState == RoleState.WALK) { float time = 1f / (PetParent.m_Attr.Speed); if (CurRoad.gs == GridSpace.Space_UP) { vStart = CurRoad.Road.Uppos; vEnd = NextRoad.Road.Uppos; action = new GridActionCmdUnderWalk(vStart, vEnd, time, CurRoad.dir, RankDeep); } else { action = new GridActionCmdWalk(vStart, vEnd, time, CurRoad.dir, RankDeep); } } else if (roleState == RoleState.FALLDOWN) { action = new GridActionCmdFallDown(Time.deltaTime, RankDeep, vStart); m_Reject = true; AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_SELFSP), PetParent); action.SetTarget(PetParent); return(action); } else if (roleState == RoleState.JUMPDOWN) { vStart = CurRoad.Road.Uppos; action = new GridActionCmdJumpDown(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else if (roleState == RoleState.JUMPUP) { vEnd = NextRoad.Road.Uppos; action = new GridActionCmdJumpUp(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else if (roleState == RoleState.REVERSEJUMP) { vStart = CurRoad.Road.Uppos; vEnd = NextRoad.Road.Uppos; action = new GridActionCmdReverseJump(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep, 0.2f, 0.2f, 0f, null, null, null); } else if (roleState == RoleState.HITFLY) { } if (action != null) { MapPos = NextRoad.Road.GridPos; m_NGrid = MapPos; WalkDIR = CurRoad.dir; action.SetTarget(PetParent); action.SetSpeed(PetParent.m_Attr.SpeedPercent); } //运行到下一个路径节点 Path.RunNextPath(); } else if (CurrentGS == GridSpace.Space_UP) { action = new GridActionCmdJumpDown(MapGrid.GetMG(MapPos).Uppos, MapGrid.GetMG(MapPos).pos, 1f, m_AttackDir, RankDeep); action.SetTarget(PetParent); CurrentGS = GridSpace.Space_DOWN; } } if (action == null) { action = new GridActionCmdStand(); action.SetData(pos, pos, RoleState.STAND, Time.deltaTime, -1, WalkDIR, RankDeep); action.SetTarget(PetParent); } m_Reject = true; return(action); }
private static void GetStairsList() { m_lStair.Clear(); MapStair.GetStairsList(ref m_lStair); }
//取下一个动作 public GridActionCmd GetNextAction() { Vector3 pos = RoleParent.m_thisT.localPosition; float cdtime = RoleParent.CDTime; //int bodyradius = RoleParent.m_Attr.Radius; RoleSkill roleskill = RoleParent.m_Skill as RoleSkill; GridActionCmd action = null; m_IndexAdd = false; if (RoleParent.isDead) { action = new GridActionCmdDie(pos, 3 * 60 * 60f, WalkDIR, RankDeep); action.SetTarget(RoleParent); Reject = false; return(action); } if (RoleParent == null || RoleParent.m_Attr == null) { action = new GridActionCmdStand(); action.SetData(pos, pos, RoleState.STAND, Time.deltaTime, -1, WalkDIR, RankDeep); action.SetTarget(RoleParent); return(action); } if (m_bForce == 0) { action = new GridActionCmdSpecialJump(0.5f, MapGrid.GetMG(MapPos).pos, MapGrid.GetMG(m_ForceGrid).pos, m_ForceDir, RankDeep); action.SetTarget(RoleParent); m_bForce = -1; SetUpdataPath(new AIEventData(AIEvent.EVENT_MAP)); m_NGrid = m_ForceGrid; if (MapGrid.GetMG(MapPos).PropStations == StationsProp.ATTACK) { m_AttackStation = MapPos; m_NAttackStation = MapPos; } MapPos = m_NGrid; WalkDIR = m_ForceDir; Reject = true; m_DoUpatePath = false; return(action); } if (m_bForce > 0) { m_bForce--; } m_PreGrid = MapPos; m_PreAttackStation = m_AttackStation; MapGrid attackstation = MapGrid.GetMG(m_AttackStation); PathData CurRoad = Path.GetPathData(PathAccess.Cur); if (m_Attack && RoleParent.m_Skill.CanAttack() && CheckAttackPos() // && (!(RoleParent.m_Skill.m_AttackTarget is Role) || RoleParent.m_Skill.CheckCanAttack((RoleParent.m_Skill.m_AttackTarget as Role).CurrentAction)) && (RoleParent.m_Skill.m_AttackTarget is IggWall || RoleParent.m_Skill.m_AttackTarget is IggFloor || (NdUtil.IsSameMapPos(MapPos, m_AttackStation) && attackstation.IsAttackStations()) &&//&& attackstation.GetRoleStateInStation(m_SceneID) == RoleStationState.HoldStation) !(CurRoad != null && (CurRoad.state == RoleState.FALL || CurRoad.state == RoleState.JUMP)))) { if (cdtime > 0) { if (cdtime > 0.5 && RoleParent.m_Hit) { action = new GridActionCmdHit(0.5f, pos, RankDeep, WalkDIR); action.SetTarget(RoleParent); RoleParent.m_Hit = false; } else { action = new GridActionCmdCDStand(cdtime, pos, RankDeep, WalkDIR); action.SetTarget(RoleParent); action.SetSpeed(RoleParent.m_Attr.SpeedPercent); } } Reject = true; m_DoUpatePath = false; if (action != null) { return(action); } } else if (m_Attack) { } if (!m_Reject && RoleParent.m_Attr.CanMove && m_Pass) { PathData NextRoad = Path.GetPathData(PathAccess.Next); if (NextRoad != null && CurRoad != null) { if (MapGrid.GetMG(MapPos).PropStations == StationsProp.ATTACK) { m_AttackStation = m_NAttackStation; //获取下一个攻击位,不包含当前节点 ErrorInfo Error = new ErrorInfo(); PathData AttackStation = Path.GetNextAttackPosNoCurInPath(ref Error); if (AttackStation != null) { m_AttackStation = AttackStation.Road.GridPos; m_NAttackStation = m_AttackStation; } } RoleState roleState = CurRoad.state; Vector3 vStart = pos;//CurRoad.Road.pos; Vector3 vEnd = Vector3.zero; CurrentGS = CurRoad.gs; vEnd = NextRoad.Road.pos; if (roleState == RoleState.FALL) { vStart = pos; if (Path.CheckRunFirstRoad() == true) { action = new GridActionCmdFall(vStart, vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else { Vector3 mid = Vector3.zero; if (CurRoad.dir == WalkDir.WALKLEFT) { if (CurRoad.Road.Left.Down != null) { NextRoad.Road = CurRoad.Road.Left.Down;//MapGrid.GetMG() mid = CurRoad.Road.Left.pos; } } else { if (CurRoad.Road.Right.Down != null) { NextRoad.Road = CurRoad.Road.Right.Down; mid = CurRoad.Road.Right.pos; } } while (NextRoad.Road.Down != null) { NextRoad.Road = NextRoad.Road.Down; } vEnd = NextRoad.Road.pos; action = new GridActionCmdJumpHoleDown(vStart, mid, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } } else if (roleState == RoleState.JUMP) { /*if ( NextRoad.Road.Type == GridType.GRID_WALL && RoleParent.m_Core.m_Camp == LifeMCamp.ATTACK) * { * Life w = NextRoad.Road.GetWall(); * int width = Mathf.Abs(NextRoad.Road.GridPos.Unit - CurRoad.Road.GridPos.Unit); * float t = CurRoad.deltaTime * (width - bodyradius) / (float)width; * int flag = NextRoad.Road.GridPos.Unit > CurRoad.Road.GridPos.Unit ? -1 : 1; * MapGrid m = MapGrid.GetMG(new Int2(NextRoad.Road.GridPos.Unit+ flag * bodyradius,NextRoad.Road.GridPos.Layer)); * action = new GridActionCmdJump(vStart,vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep,0.2f,0.2f,t,RoleParent.JumpAttack,w,m); * } * else*/ action = new GridActionCmdJump(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep, 0.2f, 0.2f, 0f, null, null, null); } else if (roleState == RoleState.STAIR) { MapStair s1 = MapStair.GetStair(CurRoad.Road.GridPos, CurRoad.Road.GridPos.Layer > NextRoad.Road.GridPos.Layer); Vector3 inpos = Vector3.zero; Vector3 outpos = Vector3.zero; bool bOccupy = false; if (NextRoad.Road.Left != null && NextRoad.Road.Left.Type != GridType.GRID_HOLE) { List <int> rolelist = new List <int>(); MapGrid g = NextRoad.Road.Left; g.GetRoleList(ref rolelist); if (rolelist.Count > 0) { for (int i = 0; i < rolelist.Count; i++) { Role l = CM.GetAllLifeM(rolelist[i], LifeMType.SOLDIER | LifeMType.SUMMONPET) as Role; if (l.m_Core.m_Camp != m_parent.m_Core.m_Camp) { bOccupy = true; break; } } } if (!bOccupy) { NextRoad.Road = NextRoad.Road.Left; } } if (bOccupy && NextRoad.Road.Right != null && NextRoad.Road.Right.Type != GridType.GRID_HOLE) { bOccupy = false; List <int> rolelist = new List <int>(); MapGrid g = NextRoad.Road.Right; g.GetRoleList(ref rolelist); if (rolelist.Count > 0) { for (int i = 0; i < rolelist.Count; i++) { Role l = CM.GetAllLifeM(rolelist[i], LifeMType.SOLDIER | LifeMType.SUMMONPET) as Role; if (l.m_Core.m_Camp != m_parent.m_Core.m_Camp) { bOccupy = true; break; } } } if (!bOccupy) { NextRoad.Road = NextRoad.Road.Right; } } if (bOccupy && NextRoad.Road.Left.Type != GridType.GRID_HOLE) { NextRoad.Road = NextRoad.Road.Left; } vEnd = NextRoad.Road.pos; if (s1 != null) { if (CurRoad.Road.GridPos.Layer > NextRoad.Road.GridPos.Layer) { inpos = CurRoad.Road.pos; //MapGrid.GetMG(s1.GetStairUp()).pos; outpos = NextRoad.Road.pos; //MapGrid.GetMG(s1.GetStairDown()).pos; outpos.y -= 0.5f; } else { outpos = NextRoad.Road.pos; //MapGrid.GetMG(s1.GetStairUp()).pos; inpos = CurRoad.Road.pos; //MapGrid.GetMG(s1.GetStairDown()).pos; inpos.y -= 0.5f; } Building1201 b = s1.GetStairLife(); b.ShowUpEffect(CurRoad.deltaTime); SetPet1002StairState(true); } else { Debug.Log("找不到楼梯"); } WalkDIR = (CurRoad.Road.GridPos.Unit < NextRoad.Road.GridPos.Unit) ? WalkDir.WALKRIGHT : WalkDir.WALKLEFT; action = new GridActionCmdStair(vStart, vEnd, 0.5f /*CurRoad.deltaTime*/, WalkDIR, RankDeep, 0.2f, 0.2f, inpos, outpos); } else if (roleState == RoleState.WALK) { float time = 1f / RoleParent.m_Attr.Speed; if (CurRoad.gs == GridSpace.Space_UP) { vStart = CurRoad.Road.Uppos; vEnd = NextRoad.Road.Uppos; action = new GridActionCmdUnderWalk(vStart, vEnd, time, CurRoad.dir, RankDeep); } else { action = new GridActionCmdWalk(vStart, vEnd, time, CurRoad.dir, RankDeep); } SetPet1002WalkState(); } else if (roleState == RoleState.FALLDOWN) { action = new GridActionCmdFallDown(Time.deltaTime, RankDeep, vStart); Reject = true; m_DoUpatePath = false; AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_SELFSP), RoleParent); action.SetTarget(RoleParent); return(action); } else if (roleState == RoleState.JUMPDOWN) { vStart = CurRoad.Road.Uppos; action = new GridActionCmdJumpDown(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else if (roleState == RoleState.JUMPUP) { vEnd = NextRoad.Road.Uppos; action = new GridActionCmdJumpUp(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep); } else if (roleState == RoleState.REVERSEJUMP) { vStart = CurRoad.Road.Uppos; vEnd = NextRoad.Road.Uppos; action = new GridActionCmdReverseJump(vStart, vEnd, CurRoad.deltaTime, CurRoad.dir, RankDeep, 0.2f, 0.2f, 0f, null, null, null); } else if (roleState == RoleState.HITFLY) { } if (action != null) { MapPos = NextRoad.Road.GridPos; m_NGrid = MapPos; WalkDIR = CurRoad.dir; action.SetTarget(RoleParent); action.SetSpeed(RoleParent.m_Attr.SpeedPercent); } //运行到下一个路径节点 Path.RunNextPath(); m_IndexAdd = true; } else if (CurrentGS == GridSpace.Space_UP) { action = new GridActionCmdJumpDown(MapGrid.GetMG(MapPos).Uppos, MapGrid.GetMG(MapPos).pos, 1f, m_AttackDir, RankDeep); action.SetTarget(RoleParent); CurrentGS = GridSpace.Space_DOWN; } else { //if (!( NdUtil.IsSameMapPos(MapPos,m_AttackStation) && attackstation.GetRoleStateInStation(m_SceneID) == RoleStationState.HoldStation)) AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_SELFSP), RoleParent); } } if (action == null) { action = new GridActionCmdStand(); action.SetData(pos, pos, RoleState.STAND, Time.deltaTime, -1, WalkDIR, RankDeep); action.SetTarget(RoleParent); } Reject = true; m_DoUpatePath = false; return(action); }