Beispiel #1
0
 public static bool AskForMapGridDeep(int SceneID,
                                      MapStations m,
                                      int StaionsDeep,
                                      LifeMCamp Camp,
                                      DIR dir,
                                      SEARCHAGT ST,
                                      ref Int2 Pos,
                                      ref int Deep)
 {
     if (ST == SEARCHAGT.SAGTY_HD)
     {
         return(AskForMapGridDeepHD(SceneID, m, StaionsDeep, Camp, dir, ref Pos, ref Deep));
     }
     else if (ST == SEARCHAGT.SAGTY_THDA)
     {
         return(AskForMapGridDeepAttack(SceneID, m, StaionsDeep, Camp, dir, ref Pos, ref Deep));
     }
     else if (ST == SEARCHAGT.SAGTY_POLL)
     {
         return(AskForMapGridDeepPoll(SceneID, m, StaionsDeep, Camp, dir, ref Pos, ref Deep));
     }
     else
     {
         return(false);
     }
 }
Beispiel #2
0
    //申请格子,防止表现途中跟墙穿帮。
    //如诺都不满足,则使用2墙中间的格子。
    public static bool AskForMapGrid(ref MapStations m, DIR dir)
    {
        if (m == null || m is MapStair)
        {
            Debug.Log("MapStations is 非法");
            return(false);
        }

        MapGrid n = m as MapGrid;

        if (n.PropStations == StationsProp.ATTACK)
        {
            return(true);
        }
        else
        {
            m = n.GetNextAttackStation(dir);
            if (m != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }
Beispiel #3
0
 public static void EmptyRoleStations(int SceneID, LifeMType Type)
 {
     if (Type == LifeMType.SOLDIER)
     {
         if (m_RoleStation.ContainsKey(SceneID) == true)
         {
             MapStations m = m_RoleStation[SceneID];
             if (m != null)
             {
                 if (m.EmptyStations(SceneID) == true)
                 {
                     AddUpRoleStation(m);
                 }
             }
             m_RoleStation.Remove(SceneID);
         }
     }
     else if (Type == LifeMType.BUILD)
     {
         foreach (MapGrid m in m_lGrid)
         {
             m.RemoveBuild(SceneID);
         }
     }
     else if (Type == LifeMType.WALL)
     {
         foreach (MapGrid m in m_lGrid)
         {
             m.RemoveWall(SceneID);
         }
     }
 }
Beispiel #4
0
 //加入角色变更列表
 public static void AddUpRoleStation(MapStations m)
 {
     if (m == null)
     {
         return;
     }
     if (m_lUpRoleStation.Contains(m) == false)
     {
         m_lUpRoleStation.Add(m);
     }
 }
Beispiel #5
0
    public static bool AskForMapGridDeepPoll(int SceneID,
                                             MapStations m,
                                             int StaionsDeep,
                                             LifeMCamp Camp,
                                             DIR dir,
                                             ref Int2 Pos,
                                             ref int Deep)
    {
        MapGrid l   = null;
        MapGrid r   = null;
        MapGrid c   = null;
        MapGrid n   = null;       //最近的同一阵营格子
        DIR     Dir = DIR.LEFT;
        int     ret = 0;

        if (GetNAS(ref l, ref r, ref c, ref Dir, m, dir) == false)
        {
            return(false);
        }

        if (AskForMapGridDeep(SceneID, c, StaionsDeep, Camp, ref Pos, ref Deep, ref ret, ref n) == true)
        {
            return(true);
        }


        int total = 0;

        while (total < 8)
        {
            GetNASPoll(ref l, ref r, ref Dir, ref c);
            if (AskForMapGridDeep(SceneID, c, StaionsDeep, Camp, ref Pos, ref Deep, ref ret, ref n) == true)
            {
                return(true);
            }
            total++;
        }

        Deep = 2;         //使用最里面的通道
        if (n != null)
        {
            Pos = n.GetStationsPos();
        }
        else
        {
            Debug.Log("获取不到附近格子" + m.GetStationsPos());
            Pos = m.GetStationsPos();
        }
        return(true);
    }
Beispiel #6
0
    //需调整,获取不到。不改变原有的深度
    public static int GetRankDeep(int SceneID)
    {
        int deep = -1;

        if (m_RoleStation.ContainsKey(SceneID))
        {
            MapStations m = m_RoleStation[SceneID];
            if (m != null)
            {
                return(m.GetRankDeep(SceneID));
            }
        }
        return(-1);
    }
Beispiel #7
0
 public static void ChangeRoleStation(int SceneID, MapStations m)
 {
     if (m == null)
     {
         return;
     }
     if (m_RoleStation.ContainsKey(SceneID))
     {
         m_RoleStation[SceneID] = m;
     }
     else
     {
         m_RoleStation.Add(SceneID, m);
     }
 }
Beispiel #8
0
    //占领一个攻击位,在updata 调用
    public static void RoleStation(int SceneID, MapStations station, StationsInfo info)
    {
        //拆解机器人不需要占攻击位
        Life l = CM.GetAllLifeM(SceneID, LifeMType.SOLDIER | LifeMType.SUMMONPET);

        if (l.m_Attr.AttrType == 3000)
        {
            return;
        }
        if (station == null)
        {
            Debug.LogError("station is null 请调查原因");
            return;
        }
        station.InputStations(SceneID, info);
    }
Beispiel #9
0
    //格子注册,用来预测用
    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;
    }
Beispiel #10
0
    private static bool GetNAS(ref MapGrid l, ref MapGrid r, ref MapGrid m, ref DIR Dir, MapStations s, DIR dd)
    {
        if (s == null ||
            (s is MapGrid) == false)
        {
            Debug.Log("MapStations 非法");
            return(false);
        }

        if (dd != DIR.LEFT && dd != DIR.RIGHT)
        {
            Debug.Log("方向非法");
            return(false);
        }

        Dir = dd;
        m   = s as MapGrid;
        l   = m;
        r   = m;
        return(true);
    }