示例#1
0
 public void MakeHole()
 {
 
     CreateHole();
     
     List<Life> RoleList = new List<Life>();
     CM.SearchLifeMListInBoat(ref RoleList, LifeMType.SOLDIER | LifeMType.SUMMONPET);
     AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_MAP), RoleList);
 }
示例#2
0
文件: Walk.cs 项目: 741645596/batgame
    public void Teleport(MapGrid g, bool ischange = true)
    {
#if UNITY_EDITOR_LOG
        FileLog.write(m_Owner.SceneID, "Teleport " + g.GridPos + "," + m_Owner.m_thisT.localPosition);
#endif
        LifeMCamp   Camp     = (m_Owner.m_Core.m_Camp == LifeMCamp.ATTACK) ? LifeMCamp.DEFENSE : LifeMCamp.ATTACK;
        List <Life> RoleList = new List <Life>();
        CM.SearchLifeMListInBoat(ref RoleList, LifeMType.SOLDIER | LifeMType.SUMMONPET, Camp);
        AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_TM), RoleList);
        AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_SELFSP), m_Owner);
        if (ischange)
        {
            m_Owner.ChangeTarget(ChangeTargetReason.Teleport, null);
        }
        run.ClearPath();
        run.Teleport(g);
    }
示例#3
0
文件: Walk.cs 项目: 741645596/batgame
    public void DoPathEvent()
    {
        LifeMCamp   Camp     = (m_Owner.m_Core.m_Camp == LifeMCamp.ATTACK) ? LifeMCamp.DEFENSE : LifeMCamp.ATTACK;
        List <Life> RoleList = new List <Life>();

        CM.SearchLifeMListInBoat(ref RoleList, LifeMType.SOLDIER | LifeMType.SUMMONPET, Camp);
        if (CurrentAction is GridActionCmdStair || CurrentAction is GridActionCmdJump || CurrentAction is GridActionCmdFall)
        {
            AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_INA), RoleList);
        }
        else if ((m_ActionList.Count > 0 && (m_ActionList[m_ActionList.Count - 1] is GridActionCmdStair || m_ActionList[m_ActionList.Count - 1] is GridActionCmdJump || m_ActionList[m_ActionList.Count - 1] is GridActionCmdSpecialJump)) ||
                 CurrentAction is GridActionCmdFallDown)
        {
            AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_FMA), RoleList);
        }
        else if (CurrentAction is GridActionCmdWalk)
        {
            AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_TM), RoleList);
        }
    }
示例#4
0
 public void SetUpdataPath(AIEventData data)
 {
     m_UpdataPathFlag = true;
     if (m_AIEventData == null)
     {
         m_AIEventData = data;
         if (this is RoleGridRun)
         {
             (this as RoleGridRun).RoleParent.InterruptAction(data);
         }
     }
     else
     {
         if (AIPathConditions.ComareEvent(data, m_AIEventData))
         {
             m_AIEventData = data;
             if (this is RoleGridRun)
             {
                 (this as RoleGridRun).RoleParent.InterruptAction(data);
             }
         }
     }
 }
示例#5
0
    //取下一个动作
    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);
    }
示例#6
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;
    }
示例#7
0
    //取下一个动作
    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);
    }
示例#8
0
    //取下一个动作
    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);
    }
示例#9
0
文件: Life.cs 项目: 741645596/batgame
    public virtual void Dead()
    {
        if (m_isDead)
        {
            return;
        }
        //Debug.Log(this + " dead" + "," + SceneID);
        //炮弹兵死亡
        if (m_Core.m_type == LifeMType.SOLDIER)
        {
            CmCarbon.AddDiePlayerSoldier(m_Core, GetMapPos());
            //Debug.Log("add mana" + m_SceneID + gameObject);
            CmCarbon.AddGodSkillMana(!m_Core.m_IsPlayer, ConfigM.GetSoldierDeadMana());
            if (m_Core.m_IsPlayer == false)
            {
                GodSkillWnd gsw = WndManager.FindDialog <GodSkillWnd>();
                if (gsw != null)
                {
                    gsw.SetCurMana(CmCarbon.GetGodSkillMana(true));
                }
            }
        }
        //建筑物死亡
        if (m_Core.m_type == LifeMType.BUILD)
        {
            CmCarbon.AddDieBuild(m_Core);
            BattleEnvironmentM.ShowSmoke();
            //Debug.Log("add mana" + m_SceneID + gameObject);
            if (BattleEnvironmentM.GetBattleEnvironmentMode() == BattleEnvironmentMode.CombatPVE)
            {
                int mana = (m_Attr as BuildAttribute).DeadMana;
                CmCarbon.AddGodSkillMana(!m_Core.m_IsPlayer, mana);
            }
            else
            {
                CmCarbon.AddGodSkillMana(!m_Core.m_IsPlayer, ConfigM.GetBuildDeadMana());
            }

            if (m_Core.m_IsPlayer == false)
            {
                GodSkillWnd gsw = WndManager.FindDialog <GodSkillWnd>();
                if (gsw != null)
                {
                    gsw.SetCurMana(CmCarbon.GetGodSkillMana(true));
                }
            }
        }
        m_isDead = true;
        BeforeDead();
        //SkillEffects._instance.LoadEffect("effect/prefab/", "1052061",transform.position,1f);
        LifeMCamp   Camp     = (m_Core.m_Camp == LifeMCamp.ATTACK) ? LifeMCamp.DEFENSE :LifeMCamp.ATTACK;
        List <Life> RoleList = new List <Life>();

        CM.SearchLifeMListInBoat(ref RoleList, LifeMType.SOLDIER | LifeMType.SUMMONPET, Camp);
        AIPathConditions.AIPathEvent(new AIEventData(AIEvent.EVENT_TD), RoleList);
        MapM.EmptyRoleStations(m_SceneID, m_Core.m_type);
        CM.ExitCombat(m_Core, m_SceneID);


        DeadEffect();

        if (this is Building1300)
        {
        }
        else
        {
            Destroy();
        }
    }